lowkeyti.h (3428B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 #ifndef _LOWKEYTI_H_ 5 #define _LOWKEYTI_H_ 1 6 7 #include "blapit.h" 8 #include "prtypes.h" 9 #include "plarena.h" 10 #include "secitem.h" 11 #include "secasn1t.h" 12 #include "secoidt.h" 13 14 /* 15 * a key in/for the data base 16 */ 17 struct NSSLOWKEYDBKeyStr { 18 PLArenaPool *arena; 19 int version; 20 char *nickname; 21 SECItem salt; 22 SECItem derPK; 23 }; 24 typedef struct NSSLOWKEYDBKeyStr NSSLOWKEYDBKey; 25 26 typedef struct NSSLOWKEYDBHandleStr NSSLOWKEYDBHandle; 27 28 #ifdef NSS_USE_KEY4_DB 29 #define NSSLOWKEY_DB_FILE_VERSION 4 30 #else 31 #define NSSLOWKEY_DB_FILE_VERSION 3 32 #endif 33 34 #define NSSLOWKEY_VERSION 0 /* what we *create* */ 35 36 /* 37 ** Typedef for callback to get a password "key". 38 */ 39 extern const SEC_ASN1Template lg_nsslowkey_PQGParamsTemplate[]; 40 extern const SEC_ASN1Template lg_nsslowkey_RSAPrivateKeyTemplate[]; 41 extern const SEC_ASN1Template lg_nsslowkey_RSAPrivateKeyTemplate2[]; 42 extern const SEC_ASN1Template lg_nsslowkey_DSAPrivateKeyTemplate[]; 43 extern const SEC_ASN1Template lg_nsslowkey_DHPrivateKeyTemplate[]; 44 extern const SEC_ASN1Template lg_nsslowkey_DHPrivateKeyExportTemplate[]; 45 #define NSSLOWKEY_EC_PRIVATE_KEY_VERSION 1 /* as per SECG 1 C.4 */ 46 extern const SEC_ASN1Template lg_nsslowkey_ECPrivateKeyTemplate[]; 47 48 extern const SEC_ASN1Template lg_nsslowkey_PrivateKeyInfoTemplate[]; 49 extern const SEC_ASN1Template nsslowkey_EncryptedPrivateKeyInfoTemplate[]; 50 51 /* 52 * PKCS #8 attributes 53 */ 54 struct NSSLOWKEYAttributeStr { 55 SECItem attrType; 56 SECItem *attrValue; 57 }; 58 typedef struct NSSLOWKEYAttributeStr NSSLOWKEYAttribute; 59 60 /* 61 ** A PKCS#8 private key info object 62 */ 63 struct NSSLOWKEYPrivateKeyInfoStr { 64 PLArenaPool *arena; 65 SECItem version; 66 SECAlgorithmID algorithm; 67 SECItem privateKey; 68 NSSLOWKEYAttribute **attributes; 69 }; 70 typedef struct NSSLOWKEYPrivateKeyInfoStr NSSLOWKEYPrivateKeyInfo; 71 #define NSSLOWKEY_PRIVATE_KEY_INFO_VERSION 0 /* what we *create* */ 72 73 /* 74 ** A PKCS#8 private key info object 75 */ 76 struct NSSLOWKEYEncryptedPrivateKeyInfoStr { 77 PLArenaPool *arena; 78 SECAlgorithmID algorithm; 79 SECItem encryptedData; 80 }; 81 typedef struct NSSLOWKEYEncryptedPrivateKeyInfoStr NSSLOWKEYEncryptedPrivateKeyInfo; 82 83 typedef enum { 84 NSSLOWKEYNullKey = 0, 85 NSSLOWKEYRSAKey = 1, 86 NSSLOWKEYDSAKey = 2, 87 NSSLOWKEYDHKey = 4, 88 NSSLOWKEYECKey = 5 89 } NSSLOWKEYType; 90 91 /* 92 ** An RSA public key object. 93 */ 94 struct NSSLOWKEYPublicKeyStr { 95 PLArenaPool *arena; 96 NSSLOWKEYType keyType; 97 union { 98 RSAPublicKey rsa; 99 DSAPublicKey dsa; 100 DHPublicKey dh; 101 ECPublicKey ec; 102 } u; 103 }; 104 typedef struct NSSLOWKEYPublicKeyStr NSSLOWKEYPublicKey; 105 106 /* 107 ** Low Level private key object 108 ** This is only used by the raw Crypto engines (crypto), keydb (keydb), 109 ** and PKCS #11. Everyone else uses the high level key structure. 110 */ 111 struct NSSLOWKEYPrivateKeyStr { 112 PLArenaPool *arena; 113 NSSLOWKEYType keyType; 114 union { 115 RSAPrivateKey rsa; 116 DSAPrivateKey dsa; 117 DHPrivateKey dh; 118 ECPrivateKey ec; 119 } u; 120 }; 121 typedef struct NSSLOWKEYPrivateKeyStr NSSLOWKEYPrivateKey; 122 123 typedef struct NSSLOWKEYPasswordEntryStr NSSLOWKEYPasswordEntry; 124 struct NSSLOWKEYPasswordEntryStr { 125 SECItem salt; 126 SECItem value; 127 unsigned char data[128]; 128 }; 129 130 #endif /* _LOWKEYTI_H_ */