Back to index

lightning-sunbird  0.9+nobinonly
lowkeyti.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef _LOWKEYTI_H_
00038 #define _LOWKEYTI_H_ 1
00039 
00040 #include "blapit.h"
00041 #include "prtypes.h"
00042 #include "plarena.h"
00043 #include "secitem.h"
00044 #include "secasn1t.h"
00045 #include "secoidt.h"
00046 /*#include "secmodt.h"
00047 #include "pkcs11t.h" */
00048 
00049 
00050 /*
00051  * a key in/for the data base
00052  */
00053 struct NSSLOWKEYDBKeyStr {
00054     PLArenaPool *arena;
00055     int version;
00056     char *nickname;
00057     SECItem salt;
00058     SECItem derPK;
00059 };
00060 typedef struct NSSLOWKEYDBKeyStr NSSLOWKEYDBKey;
00061 
00062 typedef struct NSSLOWKEYDBHandleStr NSSLOWKEYDBHandle;
00063 
00064 #ifdef NSS_USE_KEY4_DB
00065 #define NSSLOWKEY_DB_FILE_VERSION 4
00066 #else
00067 #define NSSLOWKEY_DB_FILE_VERSION 3
00068 #endif
00069 
00070 #define NSSLOWKEY_VERSION       0  /* what we *create* */
00071 
00072 /*
00073 ** Typedef for callback to get a password "key".
00074 */
00075 extern const SEC_ASN1Template nsslowkey_PQGParamsTemplate[];
00076 extern const SEC_ASN1Template nsslowkey_RSAPrivateKeyTemplate[];
00077 extern const SEC_ASN1Template nsslowkey_DSAPrivateKeyTemplate[];
00078 extern const SEC_ASN1Template nsslowkey_DSAPrivateKeyExportTemplate[];
00079 extern const SEC_ASN1Template nsslowkey_DHPrivateKeyTemplate[];
00080 extern const SEC_ASN1Template nsslowkey_DHPrivateKeyExportTemplate[];
00081 #ifdef NSS_ENABLE_ECC
00082 #define NSSLOWKEY_EC_PRIVATE_KEY_VERSION   1  /* as per SECG 1 C.4 */
00083 extern const SEC_ASN1Template nsslowkey_ECParamsTemplate[];
00084 extern const SEC_ASN1Template nsslowkey_ECPrivateKeyTemplate[];
00085 #endif /* NSS_ENABLE_ECC */
00086 
00087 extern const SEC_ASN1Template nsslowkey_PrivateKeyInfoTemplate[];
00088 extern const SEC_ASN1Template nsslowkey_EncryptedPrivateKeyInfoTemplate[];
00089 
00090 /*
00091  * PKCS #8 attributes
00092  */
00093 struct NSSLOWKEYAttributeStr {
00094     SECItem attrType;
00095     SECItem *attrValue;
00096 };
00097 typedef struct NSSLOWKEYAttributeStr NSSLOWKEYAttribute;
00098 
00099 /*
00100 ** A PKCS#8 private key info object
00101 */
00102 struct NSSLOWKEYPrivateKeyInfoStr {
00103     PLArenaPool *arena;
00104     SECItem version;
00105     SECAlgorithmID algorithm;
00106     SECItem privateKey;
00107     NSSLOWKEYAttribute **attributes;
00108 };
00109 typedef struct NSSLOWKEYPrivateKeyInfoStr NSSLOWKEYPrivateKeyInfo;
00110 #define NSSLOWKEY_PRIVATE_KEY_INFO_VERSION       0      /* what we *create* */
00111 
00112 /*
00113 ** A PKCS#8 private key info object
00114 */
00115 struct NSSLOWKEYEncryptedPrivateKeyInfoStr {
00116     PLArenaPool *arena;
00117     SECAlgorithmID algorithm;
00118     SECItem encryptedData;
00119 };
00120 typedef struct NSSLOWKEYEncryptedPrivateKeyInfoStr NSSLOWKEYEncryptedPrivateKeyInfo;
00121 
00122 
00123 typedef enum { 
00124     NSSLOWKEYNullKey = 0, 
00125     NSSLOWKEYRSAKey = 1, 
00126     NSSLOWKEYDSAKey = 2, 
00127     NSSLOWKEYDHKey = 4,
00128     NSSLOWKEYECKey = 5
00129 } NSSLOWKEYType;
00130 
00131 /*
00132 ** An RSA public key object.
00133 */
00134 struct NSSLOWKEYPublicKeyStr {
00135     PLArenaPool *arena;
00136     NSSLOWKEYType keyType ;
00137     union {
00138         RSAPublicKey rsa;
00139        DSAPublicKey dsa;
00140        DHPublicKey  dh;
00141        ECPublicKey  ec;
00142     } u;
00143 };
00144 typedef struct NSSLOWKEYPublicKeyStr NSSLOWKEYPublicKey;
00145 
00146 /*
00147 ** Low Level private key object
00148 ** This is only used by the raw Crypto engines (crypto), keydb (keydb),
00149 ** and PKCS #11. Everyone else uses the high level key structure.
00150 */
00151 struct NSSLOWKEYPrivateKeyStr {
00152     PLArenaPool *arena;
00153     NSSLOWKEYType keyType;
00154     union {
00155         RSAPrivateKey rsa;
00156        DSAPrivateKey dsa;
00157        DHPrivateKey  dh;
00158        ECPrivateKey  ec;
00159     } u;
00160 };
00161 typedef struct NSSLOWKEYPrivateKeyStr NSSLOWKEYPrivateKey;
00162 
00163 #endif /* _LOWKEYTI_H_ */