DSS Provider Key BLOBs

BLOBs are used with the Digital Signature Standard (DSS) provider to export keys from, and import keys into, the cryptographic service provider (CSP).

Public Key BLOBs

A DSS public key is exported and imported as a BLOB, a sequence of bytes structured as follows.

PUBLICKEYSTRUC    publickeystruc;
DSSPUBKEY         dsspubkey;
BYTE              p[dsspubkey.bitlen/8];
BYTE              q[20];
BYTE              g[dsspubkey.bitlen/8];
BYTE              y[dsspubkey.bitlen/8];
DSSSEED           seedstruct;

The following table describes these components. All values are in little-endian format.

FieldDescription
dsspubkeyA DSSPUBKEY structure. The magic member must have a value of 0x31535344. This hexadecimal number is the ASCII encoding of DSS1.
gA BYTE sequence. The generator, g. Must be the same length as p. If it is not the same length as p, then it must be padded with 0x00 bytes.
pA BYTE sequence. The prime modulus, p. The most significant bit of the most significant byte must be set to one.
publickeystrucA PUBLICKEYSTRUC structure.
qA BYTE sequence. The prime, q, 20 bytes in length. The most significant bit of the most significant byte must be set to one.
seedstructA DSSSEED structure. Seed and counter values for verifying primes.
yA BYTE sequence. The public key, y. Must be same length as p. If it is not the same length as p, then it must be padded with 0x00 bytes.

 

Note  Public key BLOBs are not encrypted. They contain public keys in plaintext form.
 

Private Key BLOBs

A DSS private key is exported and imported as a sequence of bytes structured as follows.

PUBLICKEYSTRUC    publickeystruc;
DSSPUBKEY         dsspubkey;
BYTE              p[dsspubkey.bitlen/8];
BYTE              q[20];
BYTE              g[dsspubkey.bitlen/8];
BYTE              x[20];
DSSSEED           seedstruct;

The following table describes each component. All values are in little-endian format.

FieldDescription
dsspubkeyA DSSPUBKEY structure. The magic member must be set to 0x32535344. This hexadecimal number is the ASCII encoding of DSS2.
gA BYTE sequence. The generator, g. Must be the same length as p. If it is not the same length as p, then it must be padded with 0x00 bytes.
publickeystrucA PUBLICKEYSTRUC structure.
pA BYTE sequence. The prime modulus, p. The most significant bit of the most significant byte must be set to one.
qA BYTE sequence. The prime, q. q is 20 bytes in length. The most significant bit of the most significant byte must be set to one.
seedstructA DSSSEED structure. Seed and counter values for verifying primes.
xA BYTE sequence. The secret exponent, x. Must always be 20 bytes in length. If x is smaller than 20 bytes in length, then it must be padded with 0x00.

 

When calling CryptExportKey, the developer can choose whether to encrypt the key. The PRIVATEKEYBLOB is encrypted if the hExpKey parameter contains a valid handle to a session key. Everything but the PUBLICKEYSTRUC portion of the BLOB is encrypted.

Note  The encryption algorithm and encryption key parameters are not stored along with the private key BLOB. The application must manage and store this information. If zero is passed for hExpKey, the private key will be exported without encryption.
 
Caution  It is dangerous to export private keys without encryption because they are then vulnerable to interception and use by unauthorized entities.
 

 

 

Show: