lowkeyti.h (3413B)
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 ** Typedef for callback to get a password "key". 16 */ 17 extern const SEC_ASN1Template nsslowkey_PQGParamsTemplate[]; 18 extern const SEC_ASN1Template nsslowkey_RSAPrivateKeyTemplate[]; 19 extern const SEC_ASN1Template nsslowkey_DSAPrivateKeyTemplate[]; 20 extern const SEC_ASN1Template nsslowkey_DSAPrivateKeyExportTemplate[]; 21 extern const SEC_ASN1Template nsslowkey_DHPrivateKeyTemplate[]; 22 extern const SEC_ASN1Template nsslowkey_DHPrivateKeyExportTemplate[]; 23 #define NSSLOWKEY_EC_PRIVATE_KEY_VERSION 1 /* as per SECG 1 C.4 */ 24 extern const SEC_ASN1Template nsslowkey_ECPrivateKeyTemplate[]; 25 extern const SEC_ASN1Template nsslowkey_PQBothSeedAndPrivateKeyTemplate[]; 26 extern const SEC_ASN1Template nsslowkey_PQSeedTemplate[]; 27 extern const SEC_ASN1Template nsslowkey_PQPrivateKeyTemplate[]; 28 29 extern const SEC_ASN1Template nsslowkey_PrivateKeyInfoTemplate[]; 30 extern const SEC_ASN1Template nsslowkey_EncryptedPrivateKeyInfoTemplate[]; 31 extern const SEC_ASN1Template nsslowkey_SubjectPublicKeyInfoTemplate[]; 32 extern const SEC_ASN1Template nsslowkey_RSAPublicKeyTemplate[]; 33 34 /* 35 * PKCS #8 attributes 36 */ 37 struct NSSLOWKEYAttributeStr { 38 SECItem attrType; 39 SECItem *attrValue; 40 }; 41 typedef struct NSSLOWKEYAttributeStr NSSLOWKEYAttribute; 42 43 /* 44 ** A PKCS#8 private key info object 45 */ 46 struct NSSLOWKEYPrivateKeyInfoStr { 47 PLArenaPool *arena; 48 SECItem version; 49 SECAlgorithmID algorithm; 50 SECItem privateKey; 51 NSSLOWKEYAttribute **attributes; 52 }; 53 typedef struct NSSLOWKEYPrivateKeyInfoStr NSSLOWKEYPrivateKeyInfo; 54 #define NSSLOWKEY_PRIVATE_KEY_INFO_VERSION 0 /* what we *create* */ 55 56 struct NSSLOWKEYSubjectPublicKeyInfoStr { 57 PLArenaPool *arena; 58 SECAlgorithmID algorithm; 59 SECItem subjectPublicKey; 60 }; 61 typedef struct NSSLOWKEYSubjectPublicKeyInfoStr NSSLOWKEYSubjectPublicKeyInfo; 62 63 typedef enum { 64 NSSLOWKEYNullKey = 0, 65 NSSLOWKEYRSAKey = 1, 66 NSSLOWKEYDSAKey = 2, 67 NSSLOWKEYDHKey = 4, 68 NSSLOWKEYECKey = 5, 69 NSSLOWKEYMLDSAKey = 6, 70 } NSSLOWKEYType; 71 72 /* 73 ** An RSA public key object. 74 */ 75 struct NSSLOWKEYPublicKeyStr { 76 PLArenaPool *arena; 77 NSSLOWKEYType keyType; 78 union { 79 RSAPublicKey rsa; 80 DSAPublicKey dsa; 81 DHPublicKey dh; 82 ECPublicKey ec; 83 MLDSAPublicKey mldsa; 84 } u; 85 }; 86 typedef struct NSSLOWKEYPublicKeyStr NSSLOWKEYPublicKey; 87 88 typedef struct GenPostQuantumPrivateKeyStr GenPostQuantumPrivateKey; 89 struct GenPostQuantumPrivateKeyStr { 90 SECItem seedItem; 91 SECItem keyItem; 92 }; 93 94 /* 95 ** Low Level private key object 96 ** This is only used by the raw Crypto engines (crypto), keydb (keydb), 97 ** and PKCS #11. Everyone else uses the high level key structure. 98 */ 99 struct NSSLOWKEYPrivateKeyStr { 100 PLArenaPool *arena; 101 NSSLOWKEYType keyType; 102 union { 103 RSAPrivateKey rsa; 104 DSAPrivateKey dsa; 105 DHPrivateKey dh; 106 ECPrivateKey ec; 107 GenPostQuantumPrivateKey genpq; /* used to decode post quantum keys */ 108 MLDSAPrivateKey mldsa; 109 } u; 110 }; 111 typedef struct NSSLOWKEYPrivateKeyStr NSSLOWKEYPrivateKey; 112 113 #endif /* _LOWKEYTI_H_ */