Has anyone messed around with these APIs and, in particular, importing a PLAINTEXTKEYBLOB?
Announcement
Collapse
No announcement yet.
API CryptImportKey & CryptExportKey
Collapse
X
-
I don't believe this.
Code:Function PBMain Dim OurKeyBlob As KeyBlob Dim HMACInfo As HMAC_Info
This
Code:Function PBMain Dim HMACInfo As HMAC_Info Dim OurKeyBlob As KeyBlob
All I've done is change the Dims order.
Alignment? Nope - tried Dword - the obvious candidate.
Why did I change the order? After two days there wasn't much left I could do.
Now, is anyone going to put me out of my misery or do I have a PB bug on my hands?
-
And what is KeyBlob? A DWORD, a LONG a pointer? If it is dimmed in the first position maybe it becomes a register variable.
Comment
-
They are both UDTs
Code:Type PublicKeyStruc bType As Byte bVersion As Byte Reserved As Word ALG_ID As Dword End Type Type KeyBlob BlobHeader As PublicKeyStruc cbData As Dword pbData( 1 To 1024 ) As Byte End Type Type HMAC_Info HashAlgid As Dword dummy As String * 10 End Type
I must remember that one, José.
Comment
-
In other of your posts, I see that you have defined HMAC_Info as follows:
Code:Type HMAC_Info HashAlgid As Dword dummy As String * 10 End Type
Code:TYPE HMAC_INFO HashAlgid AS DWORD ' ALG_ID HashAlgid pbInnerString AS BYTE PTR ' BYTE *pbInnerString cbInnerString AS DWORD ' DWORD cbInnerString pbOuterString AS BYTE PTR ' BYTE *pbOuterString cbOuterString AS DWORD ' DWORD cbOuterString END TYPE
Code:typedef struct _HMAC_Info { ALG_ID HashAlgid; BYTE * pbInnerString; DWORD cbInnerString; BYTE * pbOuterString; DWORD cbOuterString; }HMAC_INFO, *PHMAC_INFO;
Comment
-
Wow, I'm lucky to get away with it.
I'll now use:
Code:Type HMAC_Info HashAlgid As Dword dummy As String * 16 End Type
HashAlgid
Specifies the hash algorithm to be used.
pbInnerString
Pointer to the inner string to be used in the HMAC calculation. The default inner string is defined as the byte 0x36 repeated 64 times.
cbInnerString
The count of bytes in pbInnerString. The CSP uses the default inner string if cbInnerString is equal to zero.
pbOuterString
Pointer to the outer string to be used in the HMAC calculation. The default outer string is defined as the byte 0x5C repeated 64 times.
cbOuterString
The count of bytes in pbOuterString. The CSP uses the default outer string if cbOuterString is equal to zero.
I read that rather quickly and missed the pointer reference.
Thanks, José - an incorrect structure size could do untold damage.
PS The very first code snippet no longer gives an error. Magic!Last edited by David Roberts; 16 Nov 2009, 11:15 AM.
Comment
Comment