TASN1EncPKCS8 Class Reference

class TASN1EncPKCS8

Encodes the given private key using the pkcs#8 standard.

The returned ASN1 sequence respects the following grammar:

PrivateKeyInfo ::= SEQUENCE { version Version, privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, privateKey PrivateKey, attributes [0] IMPLICIT Attributes OPTIONAL }

Version ::= INTEGER PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier PrivateKey ::= OCTET STRING Attributes ::= SET OF Attribute

The PrivateKeyAlgorithmIdentifier format it depends on the specific algorithm it represents. For RSA is specified in the PKCS#1 document, for DSA in PKCS#11.

Or, in the case of encrypted private keys:

EncryptedPrivateKeyInfo ::= SEQUENCE { encryptionAlgorithm EncryptionAlgorithmIdentifier, encryptedData EncryptedData }

EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier EncryptedData ::= OCTET STRING

AlgorithmIdentifier is the ASN1 sequence defined in the PKCS#5 standard.

Member Functions Documentation

AddAttributesL(CASN1EncSequence &, const TDesC8 &)

void AddAttributesL ( CASN1EncSequence & aSeq,
const TDesC8 & aAttribute
) [private, static]

Adds the given DER encoded ASN1 structure to the given sequence. If the structure is KNullDesC8 nothing is added. This method is used by the encoder to add the optional pkcs8 attributes to the ASN1 pkcs8 key it generates. PKCS8 attributes are stored as uninterpreted DER encoded binary data in the keystore.

Parameters

CASN1EncSequence & aSeq The sequence to which we want to add the attributes.
const TDesC8 & aAttribute The DER encoded ASN1 structure.

CalculateRSAPrivExpL(const CRSAPrivateKeyCRT &, const CRSAPublicKey &)

const RInteger CalculateRSAPrivExpL ( const CRSAPrivateKeyCRT & aPrivateKey,
const CRSAPublicKey & aPublicKey
) [private, static]

Given a CRT RSA private key it calculates the RSA private exponent "d".

Parameters

const CRSAPrivateKeyCRT & aPrivateKey The RSA private key in CRT format we are interested in.
const CRSAPublicKey & aPublicKey The RSA public key

ElementToOctetL(CASN1EncBase &)

CASN1EncOctetString * ElementToOctetL ( CASN1EncBase & aAsnElement ) [private, static]

Converts the ASN1 element to an octet string.

Parameters

CASN1EncBase & aAsnElement The ASN1 element to be converted

EncodeEncryptedL(const CRSAPrivateKeyCRT &, const CRSAPublicKey &, CPBEncryptor &, CPBEncryptParms &, const TDesC8 &)

IMPORT_C CASN1EncSequence * EncodeEncryptedL ( const CRSAPrivateKeyCRT & aPrivateKey,
const CRSAPublicKey & aPublicKey,
CPBEncryptor & aEncryptor,
CPBEncryptParms & aData,
const TDesC8 & attributes
) [static]

Encodes an RSA key in encrypted format.

Encodes an RSA key in encrypted format.

Parameters

const CRSAPrivateKeyCRT & aPrivateKey The private key to be encoded (must be in CRT format)
const CRSAPublicKey & aPublicKey The corresponding public key.
CPBEncryptor & aEncryptor The object used to encrypt the data.
CPBEncryptParms & aData The encryption parameters of the given encryptor. These parameters are stored in the resulting sequence.
const TDesC8 & attributes A set of attributes of the extended information that is encrypted along with the private-key information.

EncodeEncryptedL(const CDSAPrivateKey &, CPBEncryptor &, CPBEncryptParms &, const TDesC8 &)

IMPORT_C CASN1EncSequence * EncodeEncryptedL ( const CDSAPrivateKey & aPrivateKey,
CPBEncryptor & aEncryptor,
CPBEncryptParms & aData,
const TDesC8 & attributes
) [static]

Encodes a DSA key in encrypted format.

Encodes a DSA key in encrypted format.

Parameters

const CDSAPrivateKey & aPrivateKey The private key to be encoded.
CPBEncryptor & aEncryptor The object used to encrypt the data.
CPBEncryptParms & aData The encryption parameters of the given encryptor. These parameters are stored in the resulting sequence.
const TDesC8 & attributes

EncodeL(const CRSAPrivateKeyCRT &, const CRSAPublicKey &, const TDesC8 &)

IMPORT_C CASN1EncSequence * EncodeL ( const CRSAPrivateKeyCRT & aPrivateKey,
const CRSAPublicKey & aPublicKey,
const TDesC8 & attributes
) [static]

Returns the ASN1 PKCS#8 encoding of a RSA private key.

The private key syntax for this key type is defined in the PKCS#1 document. It follows the grammar:

RSAPrivateKey ::= SEQUENCE { version Version, modulus INTEGER, -- n publicExponent INTEGER, -- e privateExponent INTEGER, -- d prime1 INTEGER, -- p prime2 INTEGER, -- q exponent1 INTEGER, -- d mod (p-1) exponent2 INTEGER, -- d mod (q-1) coefficient INTEGER, -- (inverse of q) mod p otherPrimeInfos OtherPrimeInfos OPTIONAL }

Encodes the given private key using the pkcs#8 standard.

The returned ASN1 sequence respects the following grammar:

PrivateKeyInfo ::= SEQUENCE { version Version, privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, privateKey PrivateKey, attributes [0] IMPLICIT Attributes OPTIONAL }

Version ::= INTEGER PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier PrivateKey ::= OCTET STRING Attributes ::= SET OF Attribute

Parameters

const CRSAPrivateKeyCRT & aPrivateKey The private key to be encoded (must be in CRT format)
const CRSAPublicKey & aPublicKey The corresponding public key.
const TDesC8 & attributes A set of attributes of the extended information that is encrypted along with the private-key information.

EncodeL(const CDSAPrivateKey &, const TDesC8 &)

IMPORT_C CASN1EncSequence * EncodeL ( const CDSAPrivateKey & aPrivateKey,
const TDesC8 & attributes
) [static]

Returns the ASN1 PKCS#8 encoding of a DSA private key.

The private key syntax for this key type is defined in the PKCS#11 document.

Return the ASN1 PKCS#8 encoding of a DSA private key.

The private key syntax for this key type is defined in the PKCS#11 document.

Parameters

const CDSAPrivateKey & aPrivateKey The private key to be encoded (must be in CRT format)
const TDesC8 & attributes A set of attributes of the extended information that is encrypted along with the private-key information.

EncryptKeySequenceL(CASN1EncSequence &, CPBEncryptor &)

CASN1EncOctetString * EncryptKeySequenceL ( CASN1EncSequence & aKeySeq,
CPBEncryptor & aEncryptor
) [private, static]

Given a ASN1 sequence representing a private key and a CPBEncryptor object, it returns an ASN1 octet string containing the key sequence encrypted by the given encryptor.

Parameters

CASN1EncSequence & aKeySeq The key sequence to be encrypted.
CPBEncryptor & aEncryptor The CPBEncryptor object used to encrypt the given key.

EncryptedSequenceL(CASN1EncSequence &, CPBEncryptor &, CPBEncryptParms &)

CASN1EncSequence * EncryptedSequenceL ( CASN1EncSequence & aPrivateKeySequence,
CPBEncryptor & aEncryptor,
CPBEncryptParms & aData
) [private, static]

Given a valid key sequence and appropriate PBE encryptors it encrypts the key and creates a PKCS#8 sequence of type EncryptedPrivateKeyInfo.

Parameters

CASN1EncSequence & aPrivateKeySequence A ASN1 sequence of the private key to be encrypted. Generally the structure of the sequence will depend on the key type.
CPBEncryptor & aEncryptor The PBE encryptor to be used to encrypt the key.
CPBEncryptParms & aData The PBE encryptor parameters. This information must be included in the final ASN1 sequence.