4 Protocol Examples

To illustrate the working of the BackupKey Remote Protocol, this section sketches the process used in Windows for protecting user secrets with the Data Protection Application Program Interface (DPAPI). This example uses the ClientWrap subprotocol.

The complete working of DPAPI is beyond the scope of this protocol, and more information about it is available in [MSDN-DPAPI]. As described in the "Key Relationships" section of [MSDN-DPAPI] and Figure 4 therein, when DPAPI is executing on behalf of an Active Directory domain user, it creates a Backup Master Key by encrypting its Master Key to a Domain Controller Key. This step is performed using the BackupKey protocol. This example illustrates DPAPI's use of this protocol in a larger context.

Consider, for example, a Windows user who logs on to a new domain-joined computer running the Windows Vista operating system for the first time and creates a new RSA key pair for signing his email. This causes the DPAPI function CryptProtectData to be invoked to protect the private key. This, in turn, causes DPAPI to generate a new Master Key and to attempt to create a Backup Master Key as described in [MSDN-DPAPI]. DPAPI then invokes the BackupKey client, passing the Master Key as the secret and requesting a ClientWrap wrapping operation against the user's domain using the user's credentials. The BackupKey protocol client performs this operation as specified in section 3.2.4.1 and returns the result, which DPAPI stores locally.

When the user subsequently attempts to sign his email, the signing application causes the DPAPI function CryptUnprotectData to be invoked. Ordinarily, as described in [MSDN-DPAPI], this operation will not require the Backup Master Key, and therefore the BackupKey Remote Protocol will not be invoked.

Now assume that at some later date, the user forgets his password and has to ask the domain administrator to reset it for him. Now when he tries to sign his email, the signing application causes the DPAPI function CryptUnprotectData to be invoked once again. This time, DPAPI will not be able to decrypt the Encrypted Master Key ([MSDN-DPAPI] Figure 4). Therefore, DPAPI will retrieve the Backup Master Key from local storage and request the BackupKey protocol client to perform a ClientWrap unwrapping operation against the user's domain using the user's credentials. The BackupKey protocol client will execute this operation as specified in section 3.2.4 and return the result (that is, the DPAPI Master Key) to DPAPI. To execute this unwrapping operation, the client will invoke the BackuprKey method on a server with the pguidActionAgent parameter set to BACKUPKEY_RESTORE_GUID, and the server will process this request as specified in section 3.1.4.1.4. When the unwrapping operation completes successfully, DPAPI will be able to complete the CryptUnprotectData operation as described in [MSDN-DPAPI], and the signing application will be able to sign the user's email.