security/nss/lib/pki/cryptocontext.c

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

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
michael@0 5 #ifndef DEV_H
michael@0 6 #include "dev.h"
michael@0 7 #endif /* DEV_H */
michael@0 8
michael@0 9 #ifndef PKIM_H
michael@0 10 #include "pkim.h"
michael@0 11 #endif /* PKIM_H */
michael@0 12
michael@0 13 #ifndef PKISTORE_H
michael@0 14 #include "pkistore.h"
michael@0 15 #endif /* PKISTORE_H */
michael@0 16
michael@0 17 extern const NSSError NSS_ERROR_NOT_FOUND;
michael@0 18 extern const NSSError NSS_ERROR_INVALID_ARGUMENT;
michael@0 19
michael@0 20 NSS_IMPLEMENT NSSCryptoContext *
michael@0 21 nssCryptoContext_Create (
michael@0 22 NSSTrustDomain *td,
michael@0 23 NSSCallback *uhhOpt
michael@0 24 )
michael@0 25 {
michael@0 26 NSSArena *arena;
michael@0 27 NSSCryptoContext *rvCC;
michael@0 28 arena = NSSArena_Create();
michael@0 29 if (!arena) {
michael@0 30 return NULL;
michael@0 31 }
michael@0 32 rvCC = nss_ZNEW(arena, NSSCryptoContext);
michael@0 33 if (!rvCC) {
michael@0 34 return NULL;
michael@0 35 }
michael@0 36 rvCC->td = td;
michael@0 37 rvCC->arena = arena;
michael@0 38 rvCC->certStore = nssCertificateStore_Create(rvCC->arena);
michael@0 39 if (!rvCC->certStore) {
michael@0 40 nssArena_Destroy(arena);
michael@0 41 return NULL;
michael@0 42 }
michael@0 43
michael@0 44 return rvCC;
michael@0 45 }
michael@0 46
michael@0 47 NSS_IMPLEMENT PRStatus
michael@0 48 NSSCryptoContext_Destroy (
michael@0 49 NSSCryptoContext *cc
michael@0 50 )
michael@0 51 {
michael@0 52 PRStatus status = PR_SUCCESS;
michael@0 53 PORT_Assert(cc->certStore);
michael@0 54 if (cc->certStore) {
michael@0 55 status = nssCertificateStore_Destroy(cc->certStore);
michael@0 56 if (status == PR_FAILURE) {
michael@0 57 return status;
michael@0 58 }
michael@0 59 } else {
michael@0 60 status = PR_FAILURE;
michael@0 61 }
michael@0 62 nssArena_Destroy(cc->arena);
michael@0 63 return status;
michael@0 64 }
michael@0 65
michael@0 66 NSS_IMPLEMENT PRStatus
michael@0 67 NSSCryptoContext_SetDefaultCallback (
michael@0 68 NSSCryptoContext *td,
michael@0 69 NSSCallback *newCallback,
michael@0 70 NSSCallback **oldCallbackOpt
michael@0 71 )
michael@0 72 {
michael@0 73 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 74 return PR_FAILURE;
michael@0 75 }
michael@0 76
michael@0 77 NSS_IMPLEMENT NSSCallback *
michael@0 78 NSSCryptoContext_GetDefaultCallback (
michael@0 79 NSSCryptoContext *td,
michael@0 80 PRStatus *statusOpt
michael@0 81 )
michael@0 82 {
michael@0 83 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 84 return NULL;
michael@0 85 }
michael@0 86
michael@0 87 NSS_IMPLEMENT NSSTrustDomain *
michael@0 88 NSSCryptoContext_GetTrustDomain (
michael@0 89 NSSCryptoContext *td
michael@0 90 )
michael@0 91 {
michael@0 92 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 93 return NULL;
michael@0 94 }
michael@0 95
michael@0 96
michael@0 97 NSS_IMPLEMENT NSSCertificate *
michael@0 98 NSSCryptoContext_FindOrImportCertificate (
michael@0 99 NSSCryptoContext *cc,
michael@0 100 NSSCertificate *c
michael@0 101 )
michael@0 102 {
michael@0 103 NSSCertificate *rvCert = NULL;
michael@0 104
michael@0 105 PORT_Assert(cc->certStore);
michael@0 106 if (!cc->certStore) {
michael@0 107 nss_SetError(NSS_ERROR_INVALID_ARGUMENT);
michael@0 108 return rvCert;
michael@0 109 }
michael@0 110 rvCert = nssCertificateStore_FindOrAdd(cc->certStore, c);
michael@0 111 if (rvCert == c && c->object.cryptoContext != cc) {
michael@0 112 PORT_Assert(!c->object.cryptoContext);
michael@0 113 c->object.cryptoContext = cc;
michael@0 114 }
michael@0 115 if (rvCert) {
michael@0 116 /* an NSSCertificate cannot be part of two crypto contexts
michael@0 117 ** simultaneously. If this assertion fails, then there is
michael@0 118 ** a serious Stan design flaw.
michael@0 119 */
michael@0 120 PORT_Assert(cc == c->object.cryptoContext);
michael@0 121 }
michael@0 122 return rvCert;
michael@0 123 }
michael@0 124
michael@0 125 NSS_IMPLEMENT NSSCertificate *
michael@0 126 NSSCryptoContext_ImportPKIXCertificate (
michael@0 127 NSSCryptoContext *cc,
michael@0 128 struct NSSPKIXCertificateStr *pc
michael@0 129 )
michael@0 130 {
michael@0 131 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 132 return NULL;
michael@0 133 }
michael@0 134
michael@0 135 NSS_IMPLEMENT NSSCertificate *
michael@0 136 NSSCryptoContext_ImportEncodedCertificate (
michael@0 137 NSSCryptoContext *cc,
michael@0 138 NSSBER *ber
michael@0 139 )
michael@0 140 {
michael@0 141 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 142 return NULL;
michael@0 143 }
michael@0 144
michael@0 145 NSS_IMPLEMENT PRStatus
michael@0 146 NSSCryptoContext_ImportEncodedPKIXCertificateChain (
michael@0 147 NSSCryptoContext *cc,
michael@0 148 NSSBER *ber
michael@0 149 )
michael@0 150 {
michael@0 151 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 152 return PR_FAILURE;
michael@0 153 }
michael@0 154
michael@0 155 NSS_IMPLEMENT PRStatus
michael@0 156 nssCryptoContext_ImportTrust (
michael@0 157 NSSCryptoContext *cc,
michael@0 158 NSSTrust *trust
michael@0 159 )
michael@0 160 {
michael@0 161 PRStatus nssrv;
michael@0 162 PORT_Assert(cc->certStore);
michael@0 163 if (!cc->certStore) {
michael@0 164 return PR_FAILURE;
michael@0 165 }
michael@0 166 nssrv = nssCertificateStore_AddTrust(cc->certStore, trust);
michael@0 167 #if 0
michael@0 168 if (nssrv == PR_SUCCESS) {
michael@0 169 trust->object.cryptoContext = cc;
michael@0 170 }
michael@0 171 #endif
michael@0 172 return nssrv;
michael@0 173 }
michael@0 174
michael@0 175 NSS_IMPLEMENT PRStatus
michael@0 176 nssCryptoContext_ImportSMIMEProfile (
michael@0 177 NSSCryptoContext *cc,
michael@0 178 nssSMIMEProfile *profile
michael@0 179 )
michael@0 180 {
michael@0 181 PRStatus nssrv;
michael@0 182 PORT_Assert(cc->certStore);
michael@0 183 if (!cc->certStore) {
michael@0 184 return PR_FAILURE;
michael@0 185 }
michael@0 186 nssrv = nssCertificateStore_AddSMIMEProfile(cc->certStore, profile);
michael@0 187 #if 0
michael@0 188 if (nssrv == PR_SUCCESS) {
michael@0 189 profile->object.cryptoContext = cc;
michael@0 190 }
michael@0 191 #endif
michael@0 192 return nssrv;
michael@0 193 }
michael@0 194
michael@0 195 NSS_IMPLEMENT NSSCertificate *
michael@0 196 NSSCryptoContext_FindBestCertificateByNickname (
michael@0 197 NSSCryptoContext *cc,
michael@0 198 const NSSUTF8 *name,
michael@0 199 NSSTime *timeOpt, /* NULL for "now" */
michael@0 200 NSSUsage *usage,
michael@0 201 NSSPolicies *policiesOpt /* NULL for none */
michael@0 202 )
michael@0 203 {
michael@0 204 NSSCertificate **certs;
michael@0 205 NSSCertificate *rvCert = NULL;
michael@0 206 PORT_Assert(cc->certStore);
michael@0 207 if (!cc->certStore) {
michael@0 208 return NULL;
michael@0 209 }
michael@0 210 certs = nssCertificateStore_FindCertificatesByNickname(cc->certStore,
michael@0 211 name,
michael@0 212 NULL, 0, NULL);
michael@0 213 if (certs) {
michael@0 214 rvCert = nssCertificateArray_FindBestCertificate(certs,
michael@0 215 timeOpt,
michael@0 216 usage,
michael@0 217 policiesOpt);
michael@0 218 nssCertificateArray_Destroy(certs);
michael@0 219 }
michael@0 220 return rvCert;
michael@0 221 }
michael@0 222
michael@0 223 NSS_IMPLEMENT NSSCertificate **
michael@0 224 NSSCryptoContext_FindCertificatesByNickname (
michael@0 225 NSSCryptoContext *cc,
michael@0 226 NSSUTF8 *name,
michael@0 227 NSSCertificate *rvOpt[],
michael@0 228 PRUint32 maximumOpt, /* 0 for no max */
michael@0 229 NSSArena *arenaOpt
michael@0 230 )
michael@0 231 {
michael@0 232 NSSCertificate **rvCerts;
michael@0 233 PORT_Assert(cc->certStore);
michael@0 234 if (!cc->certStore) {
michael@0 235 return NULL;
michael@0 236 }
michael@0 237 rvCerts = nssCertificateStore_FindCertificatesByNickname(cc->certStore,
michael@0 238 name,
michael@0 239 rvOpt,
michael@0 240 maximumOpt,
michael@0 241 arenaOpt);
michael@0 242 return rvCerts;
michael@0 243 }
michael@0 244
michael@0 245 NSS_IMPLEMENT NSSCertificate *
michael@0 246 NSSCryptoContext_FindCertificateByIssuerAndSerialNumber (
michael@0 247 NSSCryptoContext *cc,
michael@0 248 NSSDER *issuer,
michael@0 249 NSSDER *serialNumber
michael@0 250 )
michael@0 251 {
michael@0 252 PORT_Assert(cc->certStore);
michael@0 253 if (!cc->certStore) {
michael@0 254 return NULL;
michael@0 255 }
michael@0 256 return nssCertificateStore_FindCertificateByIssuerAndSerialNumber(
michael@0 257 cc->certStore,
michael@0 258 issuer,
michael@0 259 serialNumber);
michael@0 260 }
michael@0 261
michael@0 262 NSS_IMPLEMENT NSSCertificate *
michael@0 263 NSSCryptoContext_FindBestCertificateBySubject (
michael@0 264 NSSCryptoContext *cc,
michael@0 265 NSSDER *subject,
michael@0 266 NSSTime *timeOpt,
michael@0 267 NSSUsage *usage,
michael@0 268 NSSPolicies *policiesOpt
michael@0 269 )
michael@0 270 {
michael@0 271 NSSCertificate **certs;
michael@0 272 NSSCertificate *rvCert = NULL;
michael@0 273 PORT_Assert(cc->certStore);
michael@0 274 if (!cc->certStore) {
michael@0 275 return NULL;
michael@0 276 }
michael@0 277 certs = nssCertificateStore_FindCertificatesBySubject(cc->certStore,
michael@0 278 subject,
michael@0 279 NULL, 0, NULL);
michael@0 280 if (certs) {
michael@0 281 rvCert = nssCertificateArray_FindBestCertificate(certs,
michael@0 282 timeOpt,
michael@0 283 usage,
michael@0 284 policiesOpt);
michael@0 285 nssCertificateArray_Destroy(certs);
michael@0 286 }
michael@0 287 return rvCert;
michael@0 288 }
michael@0 289
michael@0 290 NSS_IMPLEMENT NSSCertificate **
michael@0 291 nssCryptoContext_FindCertificatesBySubject (
michael@0 292 NSSCryptoContext *cc,
michael@0 293 NSSDER *subject,
michael@0 294 NSSCertificate *rvOpt[],
michael@0 295 PRUint32 maximumOpt, /* 0 for no max */
michael@0 296 NSSArena *arenaOpt
michael@0 297 )
michael@0 298 {
michael@0 299 NSSCertificate **rvCerts;
michael@0 300 PORT_Assert(cc->certStore);
michael@0 301 if (!cc->certStore) {
michael@0 302 return NULL;
michael@0 303 }
michael@0 304 rvCerts = nssCertificateStore_FindCertificatesBySubject(cc->certStore,
michael@0 305 subject,
michael@0 306 rvOpt,
michael@0 307 maximumOpt,
michael@0 308 arenaOpt);
michael@0 309 return rvCerts;
michael@0 310 }
michael@0 311
michael@0 312 NSS_IMPLEMENT NSSCertificate **
michael@0 313 NSSCryptoContext_FindCertificatesBySubject (
michael@0 314 NSSCryptoContext *cc,
michael@0 315 NSSDER *subject,
michael@0 316 NSSCertificate *rvOpt[],
michael@0 317 PRUint32 maximumOpt, /* 0 for no max */
michael@0 318 NSSArena *arenaOpt
michael@0 319 )
michael@0 320 {
michael@0 321 return nssCryptoContext_FindCertificatesBySubject(cc, subject,
michael@0 322 rvOpt, maximumOpt,
michael@0 323 arenaOpt);
michael@0 324 }
michael@0 325
michael@0 326 NSS_IMPLEMENT NSSCertificate *
michael@0 327 NSSCryptoContext_FindBestCertificateByNameComponents (
michael@0 328 NSSCryptoContext *cc,
michael@0 329 NSSUTF8 *nameComponents,
michael@0 330 NSSTime *timeOpt,
michael@0 331 NSSUsage *usage,
michael@0 332 NSSPolicies *policiesOpt
michael@0 333 )
michael@0 334 {
michael@0 335 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 336 return NULL;
michael@0 337 }
michael@0 338
michael@0 339 NSS_IMPLEMENT NSSCertificate **
michael@0 340 NSSCryptoContext_FindCertificatesByNameComponents (
michael@0 341 NSSCryptoContext *cc,
michael@0 342 NSSUTF8 *nameComponents,
michael@0 343 NSSCertificate *rvOpt[],
michael@0 344 PRUint32 maximumOpt, /* 0 for no max */
michael@0 345 NSSArena *arenaOpt
michael@0 346 )
michael@0 347 {
michael@0 348 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 349 return NULL;
michael@0 350 }
michael@0 351
michael@0 352 NSS_IMPLEMENT NSSCertificate *
michael@0 353 NSSCryptoContext_FindCertificateByEncodedCertificate (
michael@0 354 NSSCryptoContext *cc,
michael@0 355 NSSBER *encodedCertificate
michael@0 356 )
michael@0 357 {
michael@0 358 PORT_Assert(cc->certStore);
michael@0 359 if (!cc->certStore) {
michael@0 360 return NULL;
michael@0 361 }
michael@0 362 return nssCertificateStore_FindCertificateByEncodedCertificate(
michael@0 363 cc->certStore,
michael@0 364 encodedCertificate);
michael@0 365 }
michael@0 366
michael@0 367 NSS_IMPLEMENT NSSCertificate *
michael@0 368 NSSCryptoContext_FindBestCertificateByEmail (
michael@0 369 NSSCryptoContext *cc,
michael@0 370 NSSASCII7 *email,
michael@0 371 NSSTime *timeOpt,
michael@0 372 NSSUsage *usage,
michael@0 373 NSSPolicies *policiesOpt
michael@0 374 )
michael@0 375 {
michael@0 376 NSSCertificate **certs;
michael@0 377 NSSCertificate *rvCert = NULL;
michael@0 378
michael@0 379 PORT_Assert(cc->certStore);
michael@0 380 if (!cc->certStore) {
michael@0 381 return NULL;
michael@0 382 }
michael@0 383 certs = nssCertificateStore_FindCertificatesByEmail(cc->certStore,
michael@0 384 email,
michael@0 385 NULL, 0, NULL);
michael@0 386 if (certs) {
michael@0 387 rvCert = nssCertificateArray_FindBestCertificate(certs,
michael@0 388 timeOpt,
michael@0 389 usage,
michael@0 390 policiesOpt);
michael@0 391 nssCertificateArray_Destroy(certs);
michael@0 392 }
michael@0 393 return rvCert;
michael@0 394 }
michael@0 395
michael@0 396 NSS_IMPLEMENT NSSCertificate **
michael@0 397 NSSCryptoContext_FindCertificatesByEmail (
michael@0 398 NSSCryptoContext *cc,
michael@0 399 NSSASCII7 *email,
michael@0 400 NSSCertificate *rvOpt[],
michael@0 401 PRUint32 maximumOpt, /* 0 for no max */
michael@0 402 NSSArena *arenaOpt
michael@0 403 )
michael@0 404 {
michael@0 405 NSSCertificate **rvCerts;
michael@0 406 PORT_Assert(cc->certStore);
michael@0 407 if (!cc->certStore) {
michael@0 408 return NULL;
michael@0 409 }
michael@0 410 rvCerts = nssCertificateStore_FindCertificatesByEmail(cc->certStore,
michael@0 411 email,
michael@0 412 rvOpt,
michael@0 413 maximumOpt,
michael@0 414 arenaOpt);
michael@0 415 return rvCerts;
michael@0 416 }
michael@0 417
michael@0 418 NSS_IMPLEMENT NSSCertificate *
michael@0 419 NSSCryptoContext_FindCertificateByOCSPHash (
michael@0 420 NSSCryptoContext *cc,
michael@0 421 NSSItem *hash
michael@0 422 )
michael@0 423 {
michael@0 424 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 425 return NULL;
michael@0 426 }
michael@0 427
michael@0 428 NSS_IMPLEMENT NSSCertificate *
michael@0 429 NSSCryptoContext_FindBestUserCertificate (
michael@0 430 NSSCryptoContext *cc,
michael@0 431 NSSTime *timeOpt,
michael@0 432 NSSUsage *usage,
michael@0 433 NSSPolicies *policiesOpt
michael@0 434 )
michael@0 435 {
michael@0 436 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 437 return NULL;
michael@0 438 }
michael@0 439
michael@0 440 NSS_IMPLEMENT NSSCertificate **
michael@0 441 NSSCryptoContext_FindUserCertificates (
michael@0 442 NSSCryptoContext *cc,
michael@0 443 NSSTime *timeOpt,
michael@0 444 NSSUsage *usageOpt,
michael@0 445 NSSPolicies *policiesOpt,
michael@0 446 NSSCertificate **rvOpt,
michael@0 447 PRUint32 rvLimit, /* zero for no limit */
michael@0 448 NSSArena *arenaOpt
michael@0 449 )
michael@0 450 {
michael@0 451 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 452 return NULL;
michael@0 453 }
michael@0 454
michael@0 455 NSS_IMPLEMENT NSSCertificate *
michael@0 456 NSSCryptoContext_FindBestUserCertificateForSSLClientAuth (
michael@0 457 NSSCryptoContext *cc,
michael@0 458 NSSUTF8 *sslHostOpt,
michael@0 459 NSSDER *rootCAsOpt[], /* null pointer for none */
michael@0 460 PRUint32 rootCAsMaxOpt, /* zero means list is null-terminated */
michael@0 461 NSSAlgorithmAndParameters *apOpt,
michael@0 462 NSSPolicies *policiesOpt
michael@0 463 )
michael@0 464 {
michael@0 465 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 466 return NULL;
michael@0 467 }
michael@0 468
michael@0 469 NSS_IMPLEMENT NSSCertificate **
michael@0 470 NSSCryptoContext_FindUserCertificatesForSSLClientAuth (
michael@0 471 NSSCryptoContext *cc,
michael@0 472 NSSUTF8 *sslHostOpt,
michael@0 473 NSSDER *rootCAsOpt[], /* null pointer for none */
michael@0 474 PRUint32 rootCAsMaxOpt, /* zero means list is null-terminated */
michael@0 475 NSSAlgorithmAndParameters *apOpt,
michael@0 476 NSSPolicies *policiesOpt,
michael@0 477 NSSCertificate **rvOpt,
michael@0 478 PRUint32 rvLimit, /* zero for no limit */
michael@0 479 NSSArena *arenaOpt
michael@0 480 )
michael@0 481 {
michael@0 482 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 483 return NULL;
michael@0 484 }
michael@0 485
michael@0 486 NSS_IMPLEMENT NSSCertificate *
michael@0 487 NSSCryptoContext_FindBestUserCertificateForEmailSigning (
michael@0 488 NSSCryptoContext *cc,
michael@0 489 NSSASCII7 *signerOpt,
michael@0 490 NSSASCII7 *recipientOpt,
michael@0 491 /* anything more here? */
michael@0 492 NSSAlgorithmAndParameters *apOpt,
michael@0 493 NSSPolicies *policiesOpt
michael@0 494 )
michael@0 495 {
michael@0 496 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 497 return NULL;
michael@0 498 }
michael@0 499
michael@0 500 NSS_IMPLEMENT NSSCertificate *
michael@0 501 NSSCryptoContext_FindUserCertificatesForEmailSigning (
michael@0 502 NSSCryptoContext *cc,
michael@0 503 NSSASCII7 *signerOpt, /* fgmr or a more general name? */
michael@0 504 NSSASCII7 *recipientOpt,
michael@0 505 /* anything more here? */
michael@0 506 NSSAlgorithmAndParameters *apOpt,
michael@0 507 NSSPolicies *policiesOpt,
michael@0 508 NSSCertificate **rvOpt,
michael@0 509 PRUint32 rvLimit, /* zero for no limit */
michael@0 510 NSSArena *arenaOpt
michael@0 511 )
michael@0 512 {
michael@0 513 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 514 return NULL;
michael@0 515 }
michael@0 516
michael@0 517 NSS_IMPLEMENT NSSTrust *
michael@0 518 nssCryptoContext_FindTrustForCertificate (
michael@0 519 NSSCryptoContext *cc,
michael@0 520 NSSCertificate *cert
michael@0 521 )
michael@0 522 {
michael@0 523 PORT_Assert(cc->certStore);
michael@0 524 if (!cc->certStore) {
michael@0 525 return NULL;
michael@0 526 }
michael@0 527 return nssCertificateStore_FindTrustForCertificate(cc->certStore, cert);
michael@0 528 }
michael@0 529
michael@0 530 NSS_IMPLEMENT nssSMIMEProfile *
michael@0 531 nssCryptoContext_FindSMIMEProfileForCertificate (
michael@0 532 NSSCryptoContext *cc,
michael@0 533 NSSCertificate *cert
michael@0 534 )
michael@0 535 {
michael@0 536 PORT_Assert(cc->certStore);
michael@0 537 if (!cc->certStore) {
michael@0 538 return NULL;
michael@0 539 }
michael@0 540 return nssCertificateStore_FindSMIMEProfileForCertificate(cc->certStore,
michael@0 541 cert);
michael@0 542 }
michael@0 543
michael@0 544 NSS_IMPLEMENT PRStatus
michael@0 545 NSSCryptoContext_GenerateKeyPair (
michael@0 546 NSSCryptoContext *cc,
michael@0 547 NSSAlgorithmAndParameters *ap,
michael@0 548 NSSPrivateKey **pvkOpt,
michael@0 549 NSSPublicKey **pbkOpt,
michael@0 550 PRBool privateKeyIsSensitive,
michael@0 551 NSSToken *destination,
michael@0 552 NSSCallback *uhhOpt
michael@0 553 )
michael@0 554 {
michael@0 555 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 556 return PR_FAILURE;
michael@0 557 }
michael@0 558
michael@0 559 NSS_IMPLEMENT NSSSymmetricKey *
michael@0 560 NSSCryptoContext_GenerateSymmetricKey (
michael@0 561 NSSCryptoContext *cc,
michael@0 562 NSSAlgorithmAndParameters *ap,
michael@0 563 PRUint32 keysize,
michael@0 564 NSSToken *destination,
michael@0 565 NSSCallback *uhhOpt
michael@0 566 )
michael@0 567 {
michael@0 568 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 569 return NULL;
michael@0 570 }
michael@0 571
michael@0 572 NSS_IMPLEMENT NSSSymmetricKey *
michael@0 573 NSSCryptoContext_GenerateSymmetricKeyFromPassword (
michael@0 574 NSSCryptoContext *cc,
michael@0 575 NSSAlgorithmAndParameters *ap,
michael@0 576 NSSUTF8 *passwordOpt, /* if null, prompt */
michael@0 577 NSSToken *destinationOpt,
michael@0 578 NSSCallback *uhhOpt
michael@0 579 )
michael@0 580 {
michael@0 581 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 582 return NULL;
michael@0 583 }
michael@0 584
michael@0 585 NSS_IMPLEMENT NSSSymmetricKey *
michael@0 586 NSSCryptoContext_FindSymmetricKeyByAlgorithmAndKeyID (
michael@0 587 NSSCryptoContext *cc,
michael@0 588 NSSOID *algorithm,
michael@0 589 NSSItem *keyID,
michael@0 590 NSSCallback *uhhOpt
michael@0 591 )
michael@0 592 {
michael@0 593 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 594 return NULL;
michael@0 595 }
michael@0 596
michael@0 597 struct token_session_str {
michael@0 598 NSSToken *token;
michael@0 599 nssSession *session;
michael@0 600 };
michael@0 601
michael@0 602 NSS_IMPLEMENT NSSItem *
michael@0 603 NSSCryptoContext_Decrypt (
michael@0 604 NSSCryptoContext *cc,
michael@0 605 NSSAlgorithmAndParameters *apOpt,
michael@0 606 NSSItem *encryptedData,
michael@0 607 NSSCallback *uhhOpt,
michael@0 608 NSSItem *rvOpt,
michael@0 609 NSSArena *arenaOpt
michael@0 610 )
michael@0 611 {
michael@0 612 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 613 return NULL;
michael@0 614 }
michael@0 615
michael@0 616 NSS_IMPLEMENT PRStatus
michael@0 617 NSSCryptoContext_BeginDecrypt (
michael@0 618 NSSCryptoContext *cc,
michael@0 619 NSSAlgorithmAndParameters *apOpt,
michael@0 620 NSSCallback *uhhOpt
michael@0 621 )
michael@0 622 {
michael@0 623 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 624 return PR_FAILURE;
michael@0 625 }
michael@0 626
michael@0 627 NSS_IMPLEMENT NSSItem *
michael@0 628 NSSCryptoContext_ContinueDecrypt (
michael@0 629 NSSCryptoContext *cc,
michael@0 630 NSSItem *data,
michael@0 631 NSSItem *rvOpt,
michael@0 632 NSSArena *arenaOpt
michael@0 633 )
michael@0 634 {
michael@0 635 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 636 return NULL;
michael@0 637 }
michael@0 638
michael@0 639 NSS_IMPLEMENT NSSItem *
michael@0 640 NSSCryptoContext_FinishDecrypt (
michael@0 641 NSSCryptoContext *cc,
michael@0 642 NSSItem *rvOpt,
michael@0 643 NSSArena *arenaOpt
michael@0 644 )
michael@0 645 {
michael@0 646 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 647 return NULL;
michael@0 648 }
michael@0 649
michael@0 650 NSS_IMPLEMENT NSSItem *
michael@0 651 NSSCryptoContext_Sign (
michael@0 652 NSSCryptoContext *cc,
michael@0 653 NSSAlgorithmAndParameters *apOpt,
michael@0 654 NSSItem *data,
michael@0 655 NSSCallback *uhhOpt,
michael@0 656 NSSItem *rvOpt,
michael@0 657 NSSArena *arenaOpt
michael@0 658 )
michael@0 659 {
michael@0 660 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 661 return NULL;
michael@0 662 }
michael@0 663
michael@0 664 NSS_IMPLEMENT PRStatus
michael@0 665 NSSCryptoContext_BeginSign (
michael@0 666 NSSCryptoContext *cc,
michael@0 667 NSSAlgorithmAndParameters *apOpt,
michael@0 668 NSSCallback *uhhOpt
michael@0 669 )
michael@0 670 {
michael@0 671 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 672 return PR_FAILURE;
michael@0 673 }
michael@0 674
michael@0 675 NSS_IMPLEMENT PRStatus
michael@0 676 NSSCryptoContext_ContinueSign (
michael@0 677 NSSCryptoContext *cc,
michael@0 678 NSSItem *data
michael@0 679 )
michael@0 680 {
michael@0 681 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 682 return PR_FAILURE;
michael@0 683 }
michael@0 684
michael@0 685 NSS_IMPLEMENT NSSItem *
michael@0 686 NSSCryptoContext_FinishSign (
michael@0 687 NSSCryptoContext *cc,
michael@0 688 NSSItem *rvOpt,
michael@0 689 NSSArena *arenaOpt
michael@0 690 )
michael@0 691 {
michael@0 692 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 693 return NULL;
michael@0 694 }
michael@0 695
michael@0 696 NSS_IMPLEMENT NSSItem *
michael@0 697 NSSCryptoContext_SignRecover (
michael@0 698 NSSCryptoContext *cc,
michael@0 699 NSSAlgorithmAndParameters *apOpt,
michael@0 700 NSSItem *data,
michael@0 701 NSSCallback *uhhOpt,
michael@0 702 NSSItem *rvOpt,
michael@0 703 NSSArena *arenaOpt
michael@0 704 )
michael@0 705 {
michael@0 706 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 707 return NULL;
michael@0 708 }
michael@0 709
michael@0 710 NSS_IMPLEMENT PRStatus
michael@0 711 NSSCryptoContext_BeginSignRecover (
michael@0 712 NSSCryptoContext *cc,
michael@0 713 NSSAlgorithmAndParameters *apOpt,
michael@0 714 NSSCallback *uhhOpt
michael@0 715 )
michael@0 716 {
michael@0 717 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 718 return PR_FAILURE;
michael@0 719 }
michael@0 720
michael@0 721 NSS_IMPLEMENT NSSItem *
michael@0 722 NSSCryptoContext_ContinueSignRecover (
michael@0 723 NSSCryptoContext *cc,
michael@0 724 NSSItem *data,
michael@0 725 NSSItem *rvOpt,
michael@0 726 NSSArena *arenaOpt
michael@0 727 )
michael@0 728 {
michael@0 729 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 730 return NULL;
michael@0 731 }
michael@0 732
michael@0 733 NSS_IMPLEMENT NSSItem *
michael@0 734 NSSCryptoContext_FinishSignRecover (
michael@0 735 NSSCryptoContext *cc,
michael@0 736 NSSItem *rvOpt,
michael@0 737 NSSArena *arenaOpt
michael@0 738 )
michael@0 739 {
michael@0 740 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 741 return NULL;
michael@0 742 }
michael@0 743
michael@0 744 NSS_IMPLEMENT NSSSymmetricKey *
michael@0 745 NSSCryptoContext_UnwrapSymmetricKey (
michael@0 746 NSSCryptoContext *cc,
michael@0 747 NSSAlgorithmAndParameters *apOpt,
michael@0 748 NSSItem *wrappedKey,
michael@0 749 NSSCallback *uhhOpt
michael@0 750 )
michael@0 751 {
michael@0 752 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 753 return NULL;
michael@0 754 }
michael@0 755
michael@0 756 NSS_IMPLEMENT NSSSymmetricKey *
michael@0 757 NSSCryptoContext_DeriveSymmetricKey (
michael@0 758 NSSCryptoContext *cc,
michael@0 759 NSSPublicKey *bk,
michael@0 760 NSSAlgorithmAndParameters *apOpt,
michael@0 761 NSSOID *target,
michael@0 762 PRUint32 keySizeOpt, /* zero for best allowed */
michael@0 763 NSSOperations operations,
michael@0 764 NSSCallback *uhhOpt
michael@0 765 )
michael@0 766 {
michael@0 767 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 768 return NULL;
michael@0 769 }
michael@0 770
michael@0 771 NSS_IMPLEMENT NSSItem *
michael@0 772 NSSCryptoContext_Encrypt (
michael@0 773 NSSCryptoContext *cc,
michael@0 774 NSSAlgorithmAndParameters *apOpt,
michael@0 775 NSSItem *data,
michael@0 776 NSSCallback *uhhOpt,
michael@0 777 NSSItem *rvOpt,
michael@0 778 NSSArena *arenaOpt
michael@0 779 )
michael@0 780 {
michael@0 781 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 782 return NULL;
michael@0 783 }
michael@0 784
michael@0 785 NSS_IMPLEMENT PRStatus
michael@0 786 NSSCryptoContext_BeginEncrypt (
michael@0 787 NSSCryptoContext *cc,
michael@0 788 NSSAlgorithmAndParameters *apOpt,
michael@0 789 NSSCallback *uhhOpt
michael@0 790 )
michael@0 791 {
michael@0 792 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 793 return PR_FAILURE;
michael@0 794 }
michael@0 795
michael@0 796 NSS_IMPLEMENT NSSItem *
michael@0 797 NSSCryptoContext_ContinueEncrypt (
michael@0 798 NSSCryptoContext *cc,
michael@0 799 NSSItem *data,
michael@0 800 NSSItem *rvOpt,
michael@0 801 NSSArena *arenaOpt
michael@0 802 )
michael@0 803 {
michael@0 804 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 805 return NULL;
michael@0 806 }
michael@0 807
michael@0 808 NSS_IMPLEMENT NSSItem *
michael@0 809 NSSCryptoContext_FinishEncrypt (
michael@0 810 NSSCryptoContext *cc,
michael@0 811 NSSItem *rvOpt,
michael@0 812 NSSArena *arenaOpt
michael@0 813 )
michael@0 814 {
michael@0 815 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 816 return NULL;
michael@0 817 }
michael@0 818
michael@0 819 NSS_IMPLEMENT PRStatus
michael@0 820 NSSCryptoContext_Verify (
michael@0 821 NSSCryptoContext *cc,
michael@0 822 NSSAlgorithmAndParameters *apOpt,
michael@0 823 NSSItem *data,
michael@0 824 NSSItem *signature,
michael@0 825 NSSCallback *uhhOpt
michael@0 826 )
michael@0 827 {
michael@0 828 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 829 return PR_FAILURE;
michael@0 830 }
michael@0 831
michael@0 832 NSS_IMPLEMENT PRStatus
michael@0 833 NSSCryptoContext_BeginVerify (
michael@0 834 NSSCryptoContext *cc,
michael@0 835 NSSAlgorithmAndParameters *apOpt,
michael@0 836 NSSItem *signature,
michael@0 837 NSSCallback *uhhOpt
michael@0 838 )
michael@0 839 {
michael@0 840 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 841 return PR_FAILURE;
michael@0 842 }
michael@0 843
michael@0 844 NSS_IMPLEMENT PRStatus
michael@0 845 NSSCryptoContext_ContinueVerify (
michael@0 846 NSSCryptoContext *cc,
michael@0 847 NSSItem *data
michael@0 848 )
michael@0 849 {
michael@0 850 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 851 return PR_FAILURE;
michael@0 852 }
michael@0 853
michael@0 854 NSS_IMPLEMENT PRStatus
michael@0 855 NSSCryptoContext_FinishVerify (
michael@0 856 NSSCryptoContext *cc
michael@0 857 )
michael@0 858 {
michael@0 859 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 860 return PR_FAILURE;
michael@0 861 }
michael@0 862
michael@0 863 NSS_IMPLEMENT NSSItem *
michael@0 864 NSSCryptoContext_VerifyRecover (
michael@0 865 NSSCryptoContext *cc,
michael@0 866 NSSAlgorithmAndParameters *apOpt,
michael@0 867 NSSItem *signature,
michael@0 868 NSSCallback *uhhOpt,
michael@0 869 NSSItem *rvOpt,
michael@0 870 NSSArena *arenaOpt
michael@0 871 )
michael@0 872 {
michael@0 873 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 874 return NULL;
michael@0 875 }
michael@0 876
michael@0 877 NSS_IMPLEMENT PRStatus
michael@0 878 NSSCryptoContext_BeginVerifyRecover (
michael@0 879 NSSCryptoContext *cc,
michael@0 880 NSSAlgorithmAndParameters *apOpt,
michael@0 881 NSSCallback *uhhOpt
michael@0 882 )
michael@0 883 {
michael@0 884 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 885 return PR_FAILURE;
michael@0 886 }
michael@0 887
michael@0 888 NSS_IMPLEMENT NSSItem *
michael@0 889 NSSCryptoContext_ContinueVerifyRecover (
michael@0 890 NSSCryptoContext *cc,
michael@0 891 NSSItem *data,
michael@0 892 NSSItem *rvOpt,
michael@0 893 NSSArena *arenaOpt
michael@0 894 )
michael@0 895 {
michael@0 896 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 897 return NULL;
michael@0 898 }
michael@0 899
michael@0 900 NSS_IMPLEMENT NSSItem *
michael@0 901 NSSCryptoContext_FinishVerifyRecover (
michael@0 902 NSSCryptoContext *cc,
michael@0 903 NSSItem *rvOpt,
michael@0 904 NSSArena *arenaOpt
michael@0 905 )
michael@0 906 {
michael@0 907 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 908 return NULL;
michael@0 909 }
michael@0 910
michael@0 911 NSS_IMPLEMENT NSSItem *
michael@0 912 NSSCryptoContext_WrapSymmetricKey (
michael@0 913 NSSCryptoContext *cc,
michael@0 914 NSSAlgorithmAndParameters *apOpt,
michael@0 915 NSSSymmetricKey *keyToWrap,
michael@0 916 NSSCallback *uhhOpt,
michael@0 917 NSSItem *rvOpt,
michael@0 918 NSSArena *arenaOpt
michael@0 919 )
michael@0 920 {
michael@0 921 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 922 return NULL;
michael@0 923 }
michael@0 924
michael@0 925 NSS_IMPLEMENT NSSItem *
michael@0 926 NSSCryptoContext_Digest (
michael@0 927 NSSCryptoContext *cc,
michael@0 928 NSSAlgorithmAndParameters *apOpt,
michael@0 929 NSSItem *data,
michael@0 930 NSSCallback *uhhOpt,
michael@0 931 NSSItem *rvOpt,
michael@0 932 NSSArena *arenaOpt
michael@0 933 )
michael@0 934 {
michael@0 935 return nssToken_Digest(cc->token, cc->session, apOpt,
michael@0 936 data, rvOpt, arenaOpt);
michael@0 937 }
michael@0 938
michael@0 939 NSS_IMPLEMENT PRStatus
michael@0 940 NSSCryptoContext_BeginDigest (
michael@0 941 NSSCryptoContext *cc,
michael@0 942 NSSAlgorithmAndParameters *apOpt,
michael@0 943 NSSCallback *uhhOpt
michael@0 944 )
michael@0 945 {
michael@0 946 return nssToken_BeginDigest(cc->token, cc->session, apOpt);
michael@0 947 }
michael@0 948
michael@0 949 NSS_IMPLEMENT PRStatus
michael@0 950 NSSCryptoContext_ContinueDigest (
michael@0 951 NSSCryptoContext *cc,
michael@0 952 NSSAlgorithmAndParameters *apOpt,
michael@0 953 NSSItem *item
michael@0 954 )
michael@0 955 {
michael@0 956 /*
michael@0 957 NSSAlgorithmAndParameters *ap;
michael@0 958 ap = (apOpt) ? apOpt : cc->ap;
michael@0 959 */
michael@0 960 /* why apOpt? can't change it at this point... */
michael@0 961 return nssToken_ContinueDigest(cc->token, cc->session, item);
michael@0 962 }
michael@0 963
michael@0 964 NSS_IMPLEMENT NSSItem *
michael@0 965 NSSCryptoContext_FinishDigest (
michael@0 966 NSSCryptoContext *cc,
michael@0 967 NSSItem *rvOpt,
michael@0 968 NSSArena *arenaOpt
michael@0 969 )
michael@0 970 {
michael@0 971 return nssToken_FinishDigest(cc->token, cc->session, rvOpt, arenaOpt);
michael@0 972 }
michael@0 973
michael@0 974 NSS_IMPLEMENT NSSCryptoContext *
michael@0 975 NSSCryptoContext_Clone (
michael@0 976 NSSCryptoContext *cc
michael@0 977 )
michael@0 978 {
michael@0 979 nss_SetError(NSS_ERROR_NOT_FOUND);
michael@0 980 return NULL;
michael@0 981 }
michael@0 982

mercurial