Platform SDK: Cryptography

CALG_SCHANNEL_MASTER_HASH

A master hash is created from the master key before deriving bulk encryption keys with a call to CPCreateHash:

CPCreateHash(
        hProv, 
        CALG_SCHANNEL_MASTER_HASH, 
        hMasterKey, 
        0, 
        &hMasterHash);

The master hash must not maintain a reference to the master key. All relevant data associated with the master key must be copied to the master hash object.

Depending on the protocol, the CSP implements the following operations within CPCreateHash.

PCT1

No key generation activities are implemented within this function. All key generation is done within CPDeriveKey.

SSL2

This function creates a key block from which the session keys are created. This key block is later used to create the respective session keys using CPDeriveKey. See the SSL 2 specification for a description of this key generation.

SSL 3.0

The key passed into this function as hMasterKey is not the master key but rather a pre-master key from which the master key is created. See the SSL 3.0 specification. This pre-master key is used to generate the master key using the following formula:

        master_key = 
           MD5(
                pre_master_key + 
                SHA(
                   'A' + 
                   pre_master_key+
                   ClientHello.random + 
                   ServerHello.random
                    )
                ) +
           MD5(
                pre_master_key + 
                SHA(
                   'BB' + 
                    pre_master_key +
                    ClientHello.random +
                    ServerHello.random
                    )
                ) +
           MD5(
                pre_master_key + 
                SHA(
                   'CCC' + 
                   pre_master_key +
                   ClientHello.random + 
                   ServerHello.random
                    )
                );

Note  The master key, not the pre-master key, is hashed using CPHashSessionKey.

This function also creates the key block from which the session keys are created. This key block is later used to create the respective session keys with the CPDeriveKey function. The key block is created using the following formula:

        key_block =
            MD5(
                master_key + 
                SHA(
                    'A' + 
                     master_key +
                     ServerHello.random +
                     ClientHello.random
                    )
                ) +
            MD5(
                master_key + 
                SHA(
                    'BB' + 
                    master_key +
                    ServerHello.random +
                    ClientHello.random
                    )
                 ) +
            MD5(
                 master_key + 
                 SHA(
                    'CCC' + 
                    master_key +
                    ServerHello.random +
                    ClientHello.random)) + [...];

TLS 1.0

The key passed into this function as hMasterKey is not the master key but rather a pre-master key from which the master key is created. See the TLS 1.0 specification. This pre-master key is used to generate the 48-byte master key using the following formula:

          master_key = 
               PRF(
                  pre_master_key, 
                  "master secret",
                  ClientHello.random + 
                  ServerHello.random) [0..47];

This function creates the key block from which the session keys are created. This key block is later used to create the respective session keys with the CPDeriveKey function. For details, see the SSL 3.0 specification. The key block is created using the following formula:

          key_block = 
               PRF(
                    SecurityParameters.master_key,
                    "key expansion",
                    SecurityParameters.server_random +
                         SecurityParameters.client_random
                   );

Note  The master key, not the pre-master key, is hashed using CPHashSessionKey.