Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

KeyDerivationAlgorithmProvider.OpenAlgorithm | openAlgorithm method

Applies to Windows and Windows Phone

Creates an instance of the KeyDerivationAlgorithmProvider class and opens the specified algorithm for use.

Syntax


var keyDerivationAlgorithmProvider = Windows.Security.Cryptography.Core.KeyDerivationAlgorithmProvider.openAlgorithm(algorithm);

Parameters

algorithm

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

Represents a KDF algorithm provider.

Return value

Type: KeyDerivationAlgorithmProvider

The algorithm provider.

Remarks

You can retrieve the algorithm name by using the AlgorithmName property. You can specify the name of the algorithm by using the static properties in the KeyDerivationAlgorithmNames class.

Examples


public IBuffer SampleDeriveKeyMaterialPbkdf(
    String strAlgName,
    UInt32 targetKeySize,
    UInt32 iterationCount)
{

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

    // Demonstrate how to retrieve the algorithm name.
    String strAlgUsed = objKdfProv.AlgorithmName;

    // Create a buffer that contains the secret used during derivation.
    String strSecret = "MyPassword";
    IBuffer buffSecret = CryptographicBuffer.ConvertStringToBinary(strSecret, BinaryStringEncoding.Utf8);

    // Create a random salt value.
    IBuffer buffSalt = CryptographicBuffer.GenerateRandom(32);

    // Create the derivation parameters.
    KeyDerivationParameters pbkdf2Params = KeyDerivationParameters.BuildForPbkdf2(buffSalt, iterationCount);

    // 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 keyMaterial = CryptographicEngine.DeriveKeyMaterial(
        keyOriginal,
        pbkdf2Params,
        targetKeySize);

    // Demonstrate checking the iteration count.
    UInt32 iterationCountOut = pbkdf2Params.IterationCount;

    // Demonstrate returning the derivation parameters to a buffer.
    IBuffer buffParams = pbkdf2Params.KdfGenericBinary;

    // return the KDF key material.
    return keyMaterial;
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Security.Cryptography.Core
Windows::Security::Cryptography::Core [C++]

Metadata

Windows.winmd

See also

KeyDerivationAlgorithmProvider

 

 

Show:
© 2015 Microsoft