Compartir a través de


KeyDerivationParameters.BuildForSP800108(IBuffer, IBuffer) Método

Definición

Crea un objeto KeyDerivationParameters para su uso en un modo de contador, función de derivación de claves de código de autenticación de mensajes basado en hash (HMAC).

public:
 static KeyDerivationParameters ^ BuildForSP800108(IBuffer ^ label, IBuffer ^ context);
 static KeyDerivationParameters BuildForSP800108(IBuffer const& label, IBuffer const& context);
public static KeyDerivationParameters BuildForSP800108(IBuffer label, IBuffer context);
function buildForSP800108(label, context)
Public Shared Function BuildForSP800108 (label As IBuffer, context As IBuffer) As KeyDerivationParameters

Parámetros

label
IBuffer

Búfer que especifica el propósito del material de clave derivado.

context
IBuffer

Búfer que especifica información relacionada con el material de clave derivado. Por ejemplo, el contexto puede identificar a las partes que derivan el material clave y, opcionalmente, una nonce conocida por las partes.

Devoluciones

Hace referencia a los parámetros usados durante la derivación de claves.

Ejemplos

public void SampleDeriveFromSP800108()
{
    // Create a string that contains the algorithm name.
    String strAlgName = KeyDerivationAlgorithmNames.Sp800108CtrHmacSha256;

    // Open the specified algorithm.
    KeyDerivationAlgorithmProvider objKdfProv = KeyDerivationAlgorithmProvider.OpenAlgorithm(strAlgName);

    // Specify the requested size, in bytes, of the derived key. 
    UInt32 targetSize = 32;

    // Create a buffer that contains the label value.
    String strPurpose = "Purpose";
    IBuffer buffLabel = CryptographicBuffer.ConvertStringToBinary(strPurpose, BinaryStringEncoding.Utf8);

    // Create a buffer that contains the context value.
    byte[] Nonce = { 1, 1, 0, 0, 0, 0, 0, 0};
    IBuffer buffContext = CryptographicBuffer.CreateFromByteArray(Nonce);

    // Create the derivation parameters.
    KeyDerivationParameters kdf800108Params = KeyDerivationParameters.BuildForSP800108(buffLabel, buffContext);

    // Create a secret value.
    IBuffer buffSecret = CryptographicBuffer.GenerateRandom(32);

    // Create a key from the secret value.
    CryptographicKey keyOriginal = objKdfProv.CreateKey(buffSecret);

    // Derive a key based on the original key and the derivation parameters.
    IBuffer keyDerived = CryptographicEngine.DeriveKeyMaterial(
        keyOriginal,
        kdf800108Params,
        targetSize);

    // Encode the key to a hexadecimal value (for display)
    String strKeyHex = CryptographicBuffer.EncodeToHexString(keyDerived);
}

Comentarios

Puede usar los siguientes nombres de algoritmo con la función OpenAlgorithm para abrir un proveedor de algoritmoS KDF SP800108:

Se aplica a