Share via


KeyDerivationParameters.BuildForSP800108(IBuffer, IBuffer) Methode

Definition

Erstellt ein KeyDerivationParameters-Objekt für die Verwendung in einem Zählermodus, einer HMAC-Schlüsselableitungsfunktion (Hash-based Message Authentication Code).

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

Parameter

label
IBuffer

Puffer, der den Zweck für das abgeleitete Schlüsselmaterial angibt.

context
IBuffer

Puffer, der Informationen im Zusammenhang mit dem abgeleiteten Schlüsselmaterial angibt. Der Kontext kann beispielsweise die Parteien identifizieren, die das Schlüsselmaterial ableiten, und optional eine den Parteien bekannte Nonce.

Gibt zurück

Bezieht sich auf die Parameter, die während der Schlüsselableitung verwendet werden.

Beispiele

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);
}

Hinweise

Sie können die folgenden Algorithmusnamen mit der OpenAlgorithm-Funktion verwenden, um einen SP800108 KDF-Algorithmusanbieter zu öffnen:

Gilt für: