共用方式為


KeyDerivationParameters.BuildForSP80056a 方法

定義

建立 KeyDerivationParameters 物件,以用於 SP800-56A 金鑰衍生函式。

public:
 static KeyDerivationParameters ^ BuildForSP80056a(IBuffer ^ algorithmId, IBuffer ^ partyUInfo, IBuffer ^ partyVInfo, IBuffer ^ suppPubInfo, IBuffer ^ suppPrivInfo);
 static KeyDerivationParameters BuildForSP80056a(IBuffer const& algorithmId, IBuffer const& partyUInfo, IBuffer const& partyVInfo, IBuffer const& suppPubInfo, IBuffer const& suppPrivInfo);
public static KeyDerivationParameters BuildForSP80056a(IBuffer algorithmId, IBuffer partyUInfo, IBuffer partyVInfo, IBuffer suppPubInfo, IBuffer suppPrivInfo);
function buildForSP80056a(algorithmId, partyUInfo, partyVInfo, suppPubInfo, suppPrivInfo)
Public Shared Function BuildForSP80056a (algorithmId As IBuffer, partyUInfo As IBuffer, partyVInfo As IBuffer, suppPubInfo As IBuffer, suppPrivInfo As IBuffer) As KeyDerivationParameters

參數

algorithmId
IBuffer

指定衍生金鑰的預定用途。

partyUInfo
IBuffer

包含啟動器所提供的公用資訊。

partyVInfo
IBuffer

包含回應者所提供的公開資訊。

suppPubInfo
IBuffer

包含啟動器和回應者已知的公開資訊。

suppPrivInfo
IBuffer

包含啟動器和回應程式已知的私人資訊,例如共用秘密。

傳回

參考金鑰衍生期間所使用的參數。

範例

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

    // 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 secret to be used during derivation.
    IBuffer buffSecret = CryptographicBuffer.GenerateRandom(32);

    // Create a buffer that contains the intended purpose of the derived key.
    String strAlgId = "Purpose";
    IBuffer buffAlgId = CryptographicBuffer.ConvertStringToBinary(strAlgId, BinaryStringEncoding.Utf8);

    // Create a buffer that contains public information contributed by the initiator.
    String strPartyUInfo = "Initiator public info";
    IBuffer buffPartyUInfo = CryptographicBuffer.ConvertStringToBinary(strPartyUInfo, BinaryStringEncoding.Utf8);

    // Create a buffer that contains public information contributed by the responder.
    String strPartyVInfo = "Responder public info";
    IBuffer buffPartyVInfo = CryptographicBuffer.ConvertStringToBinary(strPartyVInfo, BinaryStringEncoding.Utf8);

    // Create a buffer that contains public information known to both parties.
    String strSuppPubInfo = "Two party public info";
    IBuffer buffSuppPubInfo = CryptographicBuffer.ConvertStringToBinary(strSuppPubInfo, BinaryStringEncoding.Utf8);

    // Create a buffer that contains a shared private secret.
    IBuffer buffSuppPrivInfo = CryptographicBuffer.GenerateRandom(32);

    // Create the derivation parameters.
    KeyDerivationParameters kdf80056AParamsEx = KeyDerivationParameters.BuildForSP80056a(
        buffAlgId,
        buffPartyUInfo,
        buffPartyVInfo,
        buffSuppPubInfo,
        buffSuppPrivInfo);

    // 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,
        kdf80056AParamsEx,
        targetSize);

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

備註

您可以使用下列演算法名稱搭配 OpenAlgorithm 函式來開啟 SP80056a KDF 演算法提供者:

適用於