Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CryptExportKey keeps returning last error 87

145 views
Skip to first unread message

TemporalBeing

unread,
Apr 27, 2006, 2:47:39 PM4/27/06
to
I'm trying to export keys on Win2k/SP4/rollup-1 - will eventually be
testing on XP (SP1 & SP2). I'm currently using a DH Pregen key, and
having trouble with CryptExportKey returning error code 87 via
GetLastError().

The code is like the following:

HCRYPTKEY LegitKeyToExport = PreviouslyCreatedDHPregenKey;
HCRYPTKEY NullEncryptionKey = NULL;
DWORD Flags = NULL;
DWORD DataSize = 0;
DWORD Last_Error = 0;
DWORD KeyType = PUBLICKEYBLOB;
BOOL Result = FALSE;
Result =
CryptExportKey(LegitKeyToExport,NullEncryptionKey,KeyType,Flags,NULL,&DataSize);
Last_Error = GetLastError();

LegitKey is a valid key that was generated in the step prior; which I
will be needing to export for DH key exchange. However, it keeps
returning error code 87. I am looking to use the unknown buffer size
option in order to make sure I have enough space, so I am putting a
NULL buffer in and expecting ERROR_MORE_DATA (234L) back so I can then
allocate the buffer and perform the call again. Can anyone see anything
in why it won't work?

Help very much appreciated.

Ben

TemporalBeing

unread,
Apr 28, 2006, 12:00:09 PM4/28/06
to
Sorry to reply to my own, just wanted to clarify:

The "LegitKeyToExport" was created as a 512bit (512<<16), DH Pregen
(CALG_DH_EPHEM, CRYPT_PREGEN), with exportable permissions
(CRYPT_EXPORTABLE) using the MS_DEF_DSS_DH_PROV/PROV_DSS_DH provider.

TemporalBeing

unread,
Apr 28, 2006, 1:07:59 PM4/28/06
to
Ok...that issue was something stupid...I forgot to remove the 'delete
key' from the success portion of a previous test case...

also for anyone in the future reading this, the results won't quite
make sense after this point as it will return TRUE (instead of FALSE
and setting the last error to ERROR_MORE_DATA). Any how...

0 new messages