Export (0) Print
Expand All

StrongNameGetPublicKey

Retrieves 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.

Syntax

HRESULT StrongNameGetPublicKey(
  LPCWSTR szKeyContainer,
  BYTE *pbKeyBlob,
  ULONG cbKeyBlob,
  BYTE **ppbPublicKeyBlob,
  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 non-null, it is assumed that the key pair is contained in the key 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 API CryptExportKey. If pbKeyBlob is null, it is assumed that the key container specified by szKeyContainer contains 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 using the StrongNameFreeBuffer method.

The blob is returned in the following structure:

Struct

{

unsigned int SigAlgID;

unsigned int HashAlgID;

ULONG cbPublicKey;

BTYE[] PublicKey;

}

PublicKeyBlob;

The fields in the structure have the following values:

SigAlgID. The algorithm used to generate the strong name signature. These values are taken from the algorithm IDs specified in the Win32 crypto APIs. Currently, the common language runtime supports only CALG_RSA_SIGN.
HashAlgID. The algorithm used to generate the strong name hash. These values are taken from the algorithm IDs specified in the Win32 crypto APIs. Currently, the runtime supports only CALG_SHA1.
cbPublicKey. The length of the public key in bytes. This value is set to 1024 in the current release of the common language runtime.
PublicKey. A variable-length byte array containing the public key.
pcbPublicKeyBlob [out]
The size of the returned public key blob.
Show:
© 2015 Microsoft