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