michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef _LOWKEYTI_H_ michael@0: #define _LOWKEYTI_H_ 1 michael@0: michael@0: #include "blapit.h" michael@0: #include "prtypes.h" michael@0: #include "plarena.h" michael@0: #include "secitem.h" michael@0: #include "secasn1t.h" michael@0: #include "secoidt.h" michael@0: michael@0: michael@0: /* michael@0: * a key in/for the data base michael@0: */ michael@0: struct NSSLOWKEYDBKeyStr { michael@0: PLArenaPool *arena; michael@0: int version; michael@0: char *nickname; michael@0: SECItem salt; michael@0: SECItem derPK; michael@0: }; michael@0: typedef struct NSSLOWKEYDBKeyStr NSSLOWKEYDBKey; michael@0: michael@0: typedef struct NSSLOWKEYDBHandleStr NSSLOWKEYDBHandle; michael@0: michael@0: #ifdef NSS_USE_KEY4_DB michael@0: #define NSSLOWKEY_DB_FILE_VERSION 4 michael@0: #else michael@0: #define NSSLOWKEY_DB_FILE_VERSION 3 michael@0: #endif michael@0: michael@0: #define NSSLOWKEY_VERSION 0 /* what we *create* */ michael@0: michael@0: /* michael@0: ** Typedef for callback to get a password "key". michael@0: */ michael@0: extern const SEC_ASN1Template lg_nsslowkey_PQGParamsTemplate[]; michael@0: extern const SEC_ASN1Template lg_nsslowkey_RSAPrivateKeyTemplate[]; michael@0: extern const SEC_ASN1Template lg_nsslowkey_RSAPrivateKeyTemplate2[]; michael@0: extern const SEC_ASN1Template lg_nsslowkey_DSAPrivateKeyTemplate[]; michael@0: extern const SEC_ASN1Template lg_nsslowkey_DHPrivateKeyTemplate[]; michael@0: extern const SEC_ASN1Template lg_nsslowkey_DHPrivateKeyExportTemplate[]; michael@0: #ifndef NSS_DISABLE_ECC michael@0: #define NSSLOWKEY_EC_PRIVATE_KEY_VERSION 1 /* as per SECG 1 C.4 */ michael@0: extern const SEC_ASN1Template lg_nsslowkey_ECParamsTemplate[]; michael@0: extern const SEC_ASN1Template lg_nsslowkey_ECPrivateKeyTemplate[]; michael@0: #endif /* NSS_DISABLE_ECC */ michael@0: michael@0: extern const SEC_ASN1Template lg_nsslowkey_PrivateKeyInfoTemplate[]; michael@0: extern const SEC_ASN1Template nsslowkey_EncryptedPrivateKeyInfoTemplate[]; michael@0: michael@0: /* michael@0: * PKCS #8 attributes michael@0: */ michael@0: struct NSSLOWKEYAttributeStr { michael@0: SECItem attrType; michael@0: SECItem *attrValue; michael@0: }; michael@0: typedef struct NSSLOWKEYAttributeStr NSSLOWKEYAttribute; michael@0: michael@0: /* michael@0: ** A PKCS#8 private key info object michael@0: */ michael@0: struct NSSLOWKEYPrivateKeyInfoStr { michael@0: PLArenaPool *arena; michael@0: SECItem version; michael@0: SECAlgorithmID algorithm; michael@0: SECItem privateKey; michael@0: NSSLOWKEYAttribute **attributes; michael@0: }; michael@0: typedef struct NSSLOWKEYPrivateKeyInfoStr NSSLOWKEYPrivateKeyInfo; michael@0: #define NSSLOWKEY_PRIVATE_KEY_INFO_VERSION 0 /* what we *create* */ michael@0: michael@0: /* michael@0: ** A PKCS#8 private key info object michael@0: */ michael@0: struct NSSLOWKEYEncryptedPrivateKeyInfoStr { michael@0: PLArenaPool *arena; michael@0: SECAlgorithmID algorithm; michael@0: SECItem encryptedData; michael@0: }; michael@0: typedef struct NSSLOWKEYEncryptedPrivateKeyInfoStr NSSLOWKEYEncryptedPrivateKeyInfo; michael@0: michael@0: michael@0: typedef enum { michael@0: NSSLOWKEYNullKey = 0, michael@0: NSSLOWKEYRSAKey = 1, michael@0: NSSLOWKEYDSAKey = 2, michael@0: NSSLOWKEYDHKey = 4, michael@0: NSSLOWKEYECKey = 5 michael@0: } NSSLOWKEYType; michael@0: michael@0: /* michael@0: ** An RSA public key object. michael@0: */ michael@0: struct NSSLOWKEYPublicKeyStr { michael@0: PLArenaPool *arena; michael@0: NSSLOWKEYType keyType ; michael@0: union { michael@0: RSAPublicKey rsa; michael@0: DSAPublicKey dsa; michael@0: DHPublicKey dh; michael@0: ECPublicKey ec; michael@0: } u; michael@0: }; michael@0: typedef struct NSSLOWKEYPublicKeyStr NSSLOWKEYPublicKey; michael@0: michael@0: /* michael@0: ** Low Level private key object michael@0: ** This is only used by the raw Crypto engines (crypto), keydb (keydb), michael@0: ** and PKCS #11. Everyone else uses the high level key structure. michael@0: */ michael@0: struct NSSLOWKEYPrivateKeyStr { michael@0: PLArenaPool *arena; michael@0: NSSLOWKEYType keyType; michael@0: union { michael@0: RSAPrivateKey rsa; michael@0: DSAPrivateKey dsa; michael@0: DHPrivateKey dh; michael@0: ECPrivateKey ec; michael@0: } u; michael@0: }; michael@0: typedef struct NSSLOWKEYPrivateKeyStr NSSLOWKEYPrivateKey; michael@0: michael@0: michael@0: typedef struct NSSLOWKEYPasswordEntryStr NSSLOWKEYPasswordEntry; michael@0: struct NSSLOWKEYPasswordEntryStr { michael@0: SECItem salt; michael@0: SECItem value; michael@0: unsigned char data[128]; michael@0: }; michael@0: michael@0: michael@0: #endif /* _LOWKEYTI_H_ */