Freigeben über


StrongNameGetPublicKey Function

Gets the public key from a private/public key pair. The key pair can be supplied either as a key container name within a cryptographic service provider (CSP) or as a raw collection of bytes.

BOOLEAN StrongNameGetPublicKey ( 
        [in]  LPCWSTR   szKeyContainer,
        [in]  BYTE      *pbKeyBlob,
        [in]  ULONG     cbKeyBlob,
        [out] BYTE      **ppbPublicKeyBlob,
        [out] ULONG     *pcbPublicKeyBlob
);

Parameters

  • szKeyContainer
    [in] The name of the key container that contains the public/private key pair. If pbKeyBlob is null, szKeyContainer must specify a valid container within the CSP. In this case, StrongNameGetPublicKey extracts the public key from the key pair stored in the container.

    If pbKeyBlob is not null, the key pair is assumed to be contained in the key binary large object (BLOB).

    The keys must be 1024-bit Rivest-Shamir-Adleman (RSA) signing keys. No other types of keys are supported at this time.

  • pbKeyBlob
    [in] A pointer to the public/private key pair. This pair is in the format created by the Win32 CryptExportKey function. If pbKeyBlob is null, the key container specified by szKeyContainer is assumed to contain the key pair.

  • cbKeyBlob
    [in] The size, in bytes, of pbKeyBlob.

  • ppbPublicKeyBlob
    [out] The returned public key BLOB. The ppbPublicKeyBlob parameter is allocated by the common language runtime and returned to the caller. The caller must free the memory by using the StrongNameFreeBuffer function.

  • pcbPublicKeyBlob
    [out] The size of the returned public key BLOB.

Return Value

true on successful completion; otherwise, false.

Remarks

The public key is contained in a PublicKeyBlob structure.

If the StrongNameGetPublicKey function does not complete successfully, call the StrongNameErrorInfo function to retrieve the last generated error.

Requirements

Platforms: Windows 2000, Windows XP, Windows Server 2003 family

Header: StrongName.h

Library: Included as a resource in MsCorEE.dll

.NET Framework Version: 2.0, 1.1, 1.0

See Also

Concepts

StrongNameTokenFromPublicKey Function

PublicKeyBlob Structure

Strong Naming Global Static Functions