InvestorsHub Logo
Followers 38
Posts 777
Boards Moderated 0
Alias Born 11/30/2003

Re: SheldonLevine post# 112247

Sunday, 03/12/2006 11:19:47 PM

Sunday, March 12, 2006 11:19:47 PM

Post# of 249621
Platform SDK: Cryptography API: Next Generation Pt.II

>>>
NCryptExportKey

Note: This documentation is preliminary and is subject to change.

The NCryptExportKey function exports a CNG key to a memory BLOB.


SECURITY_STATUS WINAPI NCryptExportKey(
NCRYPT_KEY_HANDLE hKey,
NCRYPT_KEY_HANDLE hExportKey,
LPCWSTR pszBlobType,
NCryptBufferDesc* pParameterList,
PBYTE pbOutput,
DWORD cbOutput,
DWORD* pcbResult,
DWORD dwFlags
);


Parameters

hKey
[in] The handle of the key to export.

hExportKey
[in, optional] The handle to a cryptographic key of the destination user. The key data within the exported key BLOB is encrypted using this key. This ensures that only the destination user is able to make use of the key BLOB.

pszBlobType
[in] A null-terminated Unicode string that contains an identifier that specifies the type of BLOB to export. This can be one of the following values.

Value / Meaning

BCRYPT_DH_PRIVATE_BLOB / Export a Diffie-Hellman private and public key pair.
BCRYPT_DH_PUBLIC_BLOB / Export a Diffie-Hellman public key.
BCRYPT_DSA_PRIVATE_BLOB / Export a DSA private and public key pair.
BCRYPT_DSA_PUBLIC_BLOB / Export a DSA public key.

BCRYPT_OPAQUE_KEY_BLOB / Export a symmetric key in a format that is specific to a single cryptographic service provider (CSP). Opaque BLOBs are not transferable and must be imported by using the same CSP that generated the BLOB.

BCRYPT_RSAPRIVATE_BLOB / Export an RSA private and public key pair.
BCRYPT_RSAPUBLIC_BLOB / Export an RSA public key.
LEGACY_DH_PRIVATE_BLOB / Export a Diffie-Hellman private and public key pair in a form that can be imported by using the CryptoAPI.
LEGACY_DH_PUBLIC_BLOB / Export a Diffie-Hellman public key in a form that can be imported by using the CryptoAPI.
LEGACY_DSA_PRIVATE_BLOB / Export a DSA private and public key pair in a form that can be imported by using the CryptoAPI.
LEGACY_DSA_PUBLIC_BLOB / Export a DSA public key in a form that can be imported by using the CryptoAPI.
LEGACY_RSAPRIVATE_BLOB / Export an RSA private and public key pair in a form that can be imported by using the CryptoAPI.
LEGACY_RSAPUBLIC_BLOB / Export an RSA public key in a form that can be imported by using the CryptoAPI.

pParameterList
[in, optional] The address of an NCryptBufferDesc structure that receives parameter information for the key. This parameter can be NULL if this information is not needed.

pbOutput
[out, optional] The address of a buffer that receives the key BLOB. The cbOutput parameter contains the size of this buffer. If this parameter is NULL, this function will place the required size, in bytes, in the DWORD pointed to by the pcbResult parameter.

cbOutput
[in] The size, in bytes, of the pbOutput buffer.

pcbResult
[out] The address of a DWORD variable that receives the number of bytes copied to the pbOutput buffer. If the pbOutput parameter is NULL, this function will place the required size, in bytes, in the DWORD pointed to by this parameter.

dwFlags
[in] A set of flags that modify the behavior of this function. No flags are defined for this function.

Return Values

Returns a status code that indicates the success or failure of the function.

Possible return codes include, but are not limited to, the following.

Return code Description

ERROR_SUCCESS The function was successful.
NTE_BAD_FLAGS The dwFlags parameter contains a value that is not valid.
NTE_BAD_KEY_STATE The key specified by the hKey parameter is not valid. The most common cause of this error is that the key was not completed with the NCryptFinalizeKey function.
NTE_BAD_TYPE The key specified by the hKey parameter cannot be exported into the BLOB type specified by the pszBlobType parameter.
NTE_INVALID_HANDLE The hKey or the hExportKey parameter is not valid.
NTE_INVALID_PARAMETER One or more parameters are not valid.

Requirements

Client Requires Windows Vista.
Server Requires Windows Server "Longhorn".
Header Declared in Ncrypt.h.
Library Link to Ncrypt.lib.

<<<

http://msdn.microsoft.com/library/en-us/seccng/security/ncryptexportkey_func.asp?frame=true

Regards

SL


"RTFM"

Join InvestorsHub

Join the InvestorsHub Community

Register for free to join our community of investors and share your ideas. You will also get access to streaming quotes, interactive charts, trades, portfolio, live options flow and more tools.