1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/softoken/legacydb/lowkeyti.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,137 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 +#ifndef _LOWKEYTI_H_ 1.8 +#define _LOWKEYTI_H_ 1 1.9 + 1.10 +#include "blapit.h" 1.11 +#include "prtypes.h" 1.12 +#include "plarena.h" 1.13 +#include "secitem.h" 1.14 +#include "secasn1t.h" 1.15 +#include "secoidt.h" 1.16 + 1.17 + 1.18 +/* 1.19 + * a key in/for the data base 1.20 + */ 1.21 +struct NSSLOWKEYDBKeyStr { 1.22 + PLArenaPool *arena; 1.23 + int version; 1.24 + char *nickname; 1.25 + SECItem salt; 1.26 + SECItem derPK; 1.27 +}; 1.28 +typedef struct NSSLOWKEYDBKeyStr NSSLOWKEYDBKey; 1.29 + 1.30 +typedef struct NSSLOWKEYDBHandleStr NSSLOWKEYDBHandle; 1.31 + 1.32 +#ifdef NSS_USE_KEY4_DB 1.33 +#define NSSLOWKEY_DB_FILE_VERSION 4 1.34 +#else 1.35 +#define NSSLOWKEY_DB_FILE_VERSION 3 1.36 +#endif 1.37 + 1.38 +#define NSSLOWKEY_VERSION 0 /* what we *create* */ 1.39 + 1.40 +/* 1.41 +** Typedef for callback to get a password "key". 1.42 +*/ 1.43 +extern const SEC_ASN1Template lg_nsslowkey_PQGParamsTemplate[]; 1.44 +extern const SEC_ASN1Template lg_nsslowkey_RSAPrivateKeyTemplate[]; 1.45 +extern const SEC_ASN1Template lg_nsslowkey_RSAPrivateKeyTemplate2[]; 1.46 +extern const SEC_ASN1Template lg_nsslowkey_DSAPrivateKeyTemplate[]; 1.47 +extern const SEC_ASN1Template lg_nsslowkey_DHPrivateKeyTemplate[]; 1.48 +extern const SEC_ASN1Template lg_nsslowkey_DHPrivateKeyExportTemplate[]; 1.49 +#ifndef NSS_DISABLE_ECC 1.50 +#define NSSLOWKEY_EC_PRIVATE_KEY_VERSION 1 /* as per SECG 1 C.4 */ 1.51 +extern const SEC_ASN1Template lg_nsslowkey_ECParamsTemplate[]; 1.52 +extern const SEC_ASN1Template lg_nsslowkey_ECPrivateKeyTemplate[]; 1.53 +#endif /* NSS_DISABLE_ECC */ 1.54 + 1.55 +extern const SEC_ASN1Template lg_nsslowkey_PrivateKeyInfoTemplate[]; 1.56 +extern const SEC_ASN1Template nsslowkey_EncryptedPrivateKeyInfoTemplate[]; 1.57 + 1.58 +/* 1.59 + * PKCS #8 attributes 1.60 + */ 1.61 +struct NSSLOWKEYAttributeStr { 1.62 + SECItem attrType; 1.63 + SECItem *attrValue; 1.64 +}; 1.65 +typedef struct NSSLOWKEYAttributeStr NSSLOWKEYAttribute; 1.66 + 1.67 +/* 1.68 +** A PKCS#8 private key info object 1.69 +*/ 1.70 +struct NSSLOWKEYPrivateKeyInfoStr { 1.71 + PLArenaPool *arena; 1.72 + SECItem version; 1.73 + SECAlgorithmID algorithm; 1.74 + SECItem privateKey; 1.75 + NSSLOWKEYAttribute **attributes; 1.76 +}; 1.77 +typedef struct NSSLOWKEYPrivateKeyInfoStr NSSLOWKEYPrivateKeyInfo; 1.78 +#define NSSLOWKEY_PRIVATE_KEY_INFO_VERSION 0 /* what we *create* */ 1.79 + 1.80 +/* 1.81 +** A PKCS#8 private key info object 1.82 +*/ 1.83 +struct NSSLOWKEYEncryptedPrivateKeyInfoStr { 1.84 + PLArenaPool *arena; 1.85 + SECAlgorithmID algorithm; 1.86 + SECItem encryptedData; 1.87 +}; 1.88 +typedef struct NSSLOWKEYEncryptedPrivateKeyInfoStr NSSLOWKEYEncryptedPrivateKeyInfo; 1.89 + 1.90 + 1.91 +typedef enum { 1.92 + NSSLOWKEYNullKey = 0, 1.93 + NSSLOWKEYRSAKey = 1, 1.94 + NSSLOWKEYDSAKey = 2, 1.95 + NSSLOWKEYDHKey = 4, 1.96 + NSSLOWKEYECKey = 5 1.97 +} NSSLOWKEYType; 1.98 + 1.99 +/* 1.100 +** An RSA public key object. 1.101 +*/ 1.102 +struct NSSLOWKEYPublicKeyStr { 1.103 + PLArenaPool *arena; 1.104 + NSSLOWKEYType keyType ; 1.105 + union { 1.106 + RSAPublicKey rsa; 1.107 + DSAPublicKey dsa; 1.108 + DHPublicKey dh; 1.109 + ECPublicKey ec; 1.110 + } u; 1.111 +}; 1.112 +typedef struct NSSLOWKEYPublicKeyStr NSSLOWKEYPublicKey; 1.113 + 1.114 +/* 1.115 +** Low Level private key object 1.116 +** This is only used by the raw Crypto engines (crypto), keydb (keydb), 1.117 +** and PKCS #11. Everyone else uses the high level key structure. 1.118 +*/ 1.119 +struct NSSLOWKEYPrivateKeyStr { 1.120 + PLArenaPool *arena; 1.121 + NSSLOWKEYType keyType; 1.122 + union { 1.123 + RSAPrivateKey rsa; 1.124 + DSAPrivateKey dsa; 1.125 + DHPrivateKey dh; 1.126 + ECPrivateKey ec; 1.127 + } u; 1.128 +}; 1.129 +typedef struct NSSLOWKEYPrivateKeyStr NSSLOWKEYPrivateKey; 1.130 + 1.131 + 1.132 +typedef struct NSSLOWKEYPasswordEntryStr NSSLOWKEYPasswordEntry; 1.133 +struct NSSLOWKEYPasswordEntryStr { 1.134 + SECItem salt; 1.135 + SECItem value; 1.136 + unsigned char data[128]; 1.137 +}; 1.138 + 1.139 + 1.140 +#endif /* _LOWKEYTI_H_ */