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