security/nss/lib/pki/nsspkit.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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
michael@0 5 #ifndef NSSPKIT_H
michael@0 6 #define NSSPKIT_H
michael@0 7
michael@0 8 /*
michael@0 9 * nsspkit.h
michael@0 10 *
michael@0 11 * This file defines the types of the top-level PKI objects.
michael@0 12 */
michael@0 13
michael@0 14 #ifndef NSSBASET_H
michael@0 15 #include "nssbaset.h"
michael@0 16 #endif /* NSSBASET_H */
michael@0 17
michael@0 18 PR_BEGIN_EXTERN_C
michael@0 19
michael@0 20 /*
michael@0 21 * NSSCertificate
michael@0 22 *
michael@0 23 * This is the public representation of a Certificate. The certificate
michael@0 24 * may be one found on a smartcard or other token, one decoded from data
michael@0 25 * received as part of a protocol, one constructed from constituent
michael@0 26 * parts, etc. Usually it is associated with ("in") a trust domain; as
michael@0 27 * it can be verified only within a trust domain. The underlying type
michael@0 28 * of certificate may be of any supported standard, e.g. PKIX, PGP, etc.
michael@0 29 *
michael@0 30 * People speak of "verifying (with) the server's, or correspondant's,
michael@0 31 * certificate"; for simple operations we support that simplification
michael@0 32 * by implementing public-key crypto operations as methods on this type.
michael@0 33 */
michael@0 34
michael@0 35 struct NSSCertificateStr;
michael@0 36 typedef struct NSSCertificateStr NSSCertificate;
michael@0 37
michael@0 38 /*
michael@0 39 * NSSUserCertificate
michael@0 40 *
michael@0 41 * A ``User'' certificate is one for which the private key is available.
michael@0 42 * People speak of "using my certificate to sign my email" and "using
michael@0 43 * my certificate to authenticate to (or login to) the server"; for
michael@0 44 * simple operations, we support that simplification by implementing
michael@0 45 * private-key crypto operations as methods on this type.
michael@0 46 *
michael@0 47 * The current design only weakly distinguishes between certificates
michael@0 48 * and user certificates: as far as the compiler goes they're
michael@0 49 * interchangeable; debug libraries only have one common pointer-tracker;
michael@0 50 * etc. However, attempts to do private-key operations on a certificate
michael@0 51 * for which the private key is not available will fail.
michael@0 52 *
michael@0 53 * Open design question: should these types be more firmly separated?
michael@0 54 */
michael@0 55
michael@0 56 typedef NSSCertificate NSSUserCertificate;
michael@0 57
michael@0 58 /*
michael@0 59 * NSSPrivateKey
michael@0 60 *
michael@0 61 * This is the public representation of a Private Key. In general,
michael@0 62 * the actual value of the key is not available, but operations may
michael@0 63 * be performed with it.
michael@0 64 */
michael@0 65
michael@0 66 struct NSSPrivateKeyStr;
michael@0 67 typedef struct NSSPrivateKeyStr NSSPrivateKey;
michael@0 68
michael@0 69 /*
michael@0 70 * NSSPublicKey
michael@0 71 *
michael@0 72 */
michael@0 73
michael@0 74 struct NSSPublicKeyStr;
michael@0 75 typedef struct NSSPublicKeyStr NSSPublicKey;
michael@0 76
michael@0 77 /*
michael@0 78 * NSSSymmetricKey
michael@0 79 *
michael@0 80 */
michael@0 81
michael@0 82 struct NSSSymmetricKeyStr;
michael@0 83 typedef struct NSSSymmetricKeyStr NSSSymmetricKey;
michael@0 84
michael@0 85 /*
michael@0 86 * NSSTrustDomain
michael@0 87 *
michael@0 88 * A Trust Domain is the field in which certificates may be validated.
michael@0 89 * A trust domain will generally have one or more cryptographic modules
michael@0 90 * open; these modules perform the cryptographic operations, and
michael@0 91 * provide the basic "root" trust information from which the trust in
michael@0 92 * a specific certificate or key depends.
michael@0 93 *
michael@0 94 * A client program, or a simple server, would typically have one
michael@0 95 * trust domain. A server supporting multiple "virtual servers" might
michael@0 96 * have a separate trust domain for each virtual server. The separate
michael@0 97 * trust domains might share some modules (e.g., a hardware crypto
michael@0 98 * accelerator) but not others (e.g., the tokens storing the different
michael@0 99 * servers' private keys, or the databases with each server's trusted
michael@0 100 * root certificates).
michael@0 101 *
michael@0 102 * This object descends from the "permananet database" in the old code.
michael@0 103 */
michael@0 104
michael@0 105 struct NSSTrustDomainStr;
michael@0 106 typedef struct NSSTrustDomainStr NSSTrustDomain;
michael@0 107
michael@0 108 /*
michael@0 109 * NSSCryptoContext
michael@0 110 *
michael@0 111 * A Crypto Context is a short-term, "helper" object which is used
michael@0 112 * for the lifetime of one ongoing "crypto operation." Such an
michael@0 113 * operation may be the creation of a signed message, the use of an
michael@0 114 * TLS socket connection, etc. Each crypto context is "in" a
michael@0 115 * specific trust domain, and it may have associated with it a
michael@0 116 * distinguished certificate, public key, private key, and/or
michael@0 117 * symmetric key. It can also temporarily hold and use temporary
michael@0 118 * data (e.g. intermediate certificates) which is not stored
michael@0 119 * permanently in the trust domain.
michael@0 120 *
michael@0 121 * In OO terms, this interface inherits interfaces from the trust
michael@0 122 * domain, the certificates, and the keys. It also provides
michael@0 123 * streaming crypto operations.
michael@0 124 *
michael@0 125 * This object descends from the "temporary database" concept in the
michael@0 126 * old code, but it has changed a lot as a result of what we've
michael@0 127 * learned.
michael@0 128 */
michael@0 129
michael@0 130 typedef struct NSSCryptoContextStr NSSCryptoContext;
michael@0 131
michael@0 132 /*
michael@0 133 * fgmr others
michael@0 134 */
michael@0 135
michael@0 136 /*
michael@0 137 * OBJECT IDENTIFIER
michael@0 138 *
michael@0 139 * This is the basic OID that crops up everywhere.
michael@0 140 */
michael@0 141
michael@0 142 struct NSSOIDStr; /* unused opaque structure */
michael@0 143 typedef struct NSSOIDStr NSSOID;
michael@0 144
michael@0 145 /*
michael@0 146 * NSSTime
michael@0 147 *
michael@0 148 * Unfortunately, we need an "exceptional" value to indicate
michael@0 149 * an error upon return, or "no value" on input. Note that zero
michael@0 150 * is a perfectly valid value for both time_t and PRTime.
michael@0 151 *
michael@0 152 * If we were to create a "range" object, with two times for
michael@0 153 * Not Before and Not After, we would have an obvious place for
michael@0 154 * the somewhat arbitrary logic involved in comparing them.
michael@0 155 *
michael@0 156 * Failing that, let's have an NSSTime_CompareRanges function.
michael@0 157 */
michael@0 158
michael@0 159 struct NSSTimeStr;
michael@0 160 typedef struct NSSTimeStr NSSTime;
michael@0 161
michael@0 162 struct NSSTrustStr;
michael@0 163 typedef struct NSSTrustStr NSSTrust;
michael@0 164
michael@0 165 /*
michael@0 166 * NSSUsage
michael@0 167 *
michael@0 168 * This is trickier than originally planned; I'll write up a
michael@0 169 * doc on it.
michael@0 170 *
michael@0 171 * We'd still like nsspki.h to have a list of common usages,
michael@0 172 * e.g.:
michael@0 173 *
michael@0 174 * extern const NSSUsage *NSSUsage_ClientAuth;
michael@0 175 * extern const NSSUsage *NSSUsage_ServerAuth;
michael@0 176 * extern const NSSUsage *NSSUsage_SignEmail;
michael@0 177 * extern const NSSUsage *NSSUsage_EncryptEmail;
michael@0 178 * etc.
michael@0 179 */
michael@0 180
michael@0 181 struct NSSUsageStr;
michael@0 182 typedef struct NSSUsageStr NSSUsage;
michael@0 183
michael@0 184 /*
michael@0 185 * NSSPolicies
michael@0 186 *
michael@0 187 * Placeholder, for now.
michael@0 188 */
michael@0 189
michael@0 190 struct NSSPoliciesStr;
michael@0 191 typedef struct NSSPoliciesStr NSSPolicies;
michael@0 192
michael@0 193 /*
michael@0 194 * NSSAlgorithmAndParameters
michael@0 195 *
michael@0 196 * Algorithm is an OID
michael@0 197 * Parameters depend on the algorithm
michael@0 198 */
michael@0 199
michael@0 200 struct NSSAlgorithmAndParametersStr;
michael@0 201 typedef struct NSSAlgorithmAndParametersStr NSSAlgorithmAndParameters;
michael@0 202
michael@0 203 /*
michael@0 204 * NSSCallback
michael@0 205 *
michael@0 206 * At minimum, a "challenge" method and a closure argument.
michael@0 207 * Usually the challenge will just be prompting for a password.
michael@0 208 * How OO do we want to make it?
michael@0 209 */
michael@0 210
michael@0 211 typedef struct NSSCallbackStr NSSCallback;
michael@0 212
michael@0 213 struct NSSCallbackStr {
michael@0 214 /* Prompt for a password to initialize a slot. */
michael@0 215 PRStatus (* getInitPW)(NSSUTF8 *slotName, void *arg,
michael@0 216 NSSUTF8 **ssoPW, NSSUTF8 **userPW);
michael@0 217 /* Prompt for oldPW and newPW in order to change the
michael@0 218 * password on a slot.
michael@0 219 */
michael@0 220 PRStatus (* getNewPW)(NSSUTF8 *slotName, PRUint32 *retries, void *arg,
michael@0 221 NSSUTF8 **oldPW, NSSUTF8 **newPW);
michael@0 222 /* Prompt for slot password. */
michael@0 223 PRStatus (* getPW)(NSSUTF8 *slotName, PRUint32 *retries, void *arg,
michael@0 224 NSSUTF8 **password);
michael@0 225 void *arg;
michael@0 226 };
michael@0 227
michael@0 228 /* set errors - user cancelled, ... */
michael@0 229
michael@0 230 typedef PRUint32 NSSOperations;
michael@0 231 /* 1) Do we want these to be preprocessor definitions or constants? */
michael@0 232 /* 2) What is the correct and complete list? */
michael@0 233
michael@0 234 #define NSSOperations_ENCRYPT 0x0001
michael@0 235 #define NSSOperations_DECRYPT 0x0002
michael@0 236 #define NSSOperations_WRAP 0x0004
michael@0 237 #define NSSOperations_UNWRAP 0x0008
michael@0 238 #define NSSOperations_SIGN 0x0010
michael@0 239 #define NSSOperations_SIGN_RECOVER 0x0020
michael@0 240 #define NSSOperations_VERIFY 0x0040
michael@0 241 #define NSSOperations_VERIFY_RECOVER 0x0080
michael@0 242
michael@0 243 struct NSSPKIXCertificateStr;
michael@0 244
michael@0 245 PR_END_EXTERN_C
michael@0 246
michael@0 247 #endif /* NSSPKIT_H */

mercurial