Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: mozilla/security/nss/lib/pki/pki3hack.c

Issue 10961060: Update NSS to NSS 3.14 Beta 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Merge nss-static2.patch into nss-static.patch Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 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 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/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 #ifdef DEBUG 5 #ifdef DEBUG
6 static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.109 $ $ Date: 2012/07/27 21:41:52 $"; 6 static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.109 $ $ Date: 2012/07/27 21:41:52 $";
7 #endif /* DEBUG */ 7 #endif /* DEBUG */
8 8
9 /* 9 /*
10 * Hacks to integrate NSS 3.4 and NSS 4.0 certificates. 10 * Hacks to integrate NSS 3.4 and NSS 4.0 certificates.
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } else { 405 } else {
406 certType = cc->nsCertType; 406 certType = cc->nsCertType;
407 } 407 }
408 if (!(certType & requiredCertType)) { 408 if (!(certType & requiredCertType)) {
409 match = PR_FALSE; 409 match = PR_FALSE;
410 } 410 }
411 } 411 }
412 return match; 412 return match;
413 } 413 }
414 414
415 static PRBool
416 nss3certificate_isTrustedForUsage(nssDecodedCert *dc, const NSSUsage *usage)
417 {
418 CERTCertificate *cc;
419 PRBool ca;
420 SECStatus secrv;
421 unsigned int requiredFlags;
422 unsigned int trustFlags;
423 SECTrustType trustType;
424 CERTCertTrust trust;
425
426 /* This is for NSS 3.3 functions that do not specify a usage */
427 if (usage->anyUsage) {
428 return PR_FALSE; /* XXX is this right? */
429 }
430 cc = (CERTCertificate *)dc->data;
431 ca = usage->nss3lookingForCA;
432 if (!ca) {
433 PRBool trusted;
434 unsigned int failedFlags;
435 secrv = cert_CheckLeafTrust(cc, usage->nss3usage,
436 &failedFlags, &trusted);
437 return secrv == SECSuccess && trusted;
438 }
439 secrv = CERT_TrustFlagsForCACertUsage(usage->nss3usage, &requiredFlags,
440 &trustType);
441 if (secrv != SECSuccess) {
442 return PR_FALSE;
443 }
444 secrv = CERT_GetCertTrust(cc, &trust);
445 if (secrv != SECSuccess) {
446 return PR_FALSE;
447 }
448 if (trustType == trustTypeNone) {
449 /* normally trustTypeNone usages accept any of the given trust bits
450 * being on as acceptable. */
451 trustFlags = trust.sslFlags | trust.emailFlags |
452 trust.objectSigningFlags;
453 } else {
454 trustFlags = SEC_GET_TRUST_FLAGS(&trust, trustType);
455 }
456 return (trustFlags & requiredFlags) == requiredFlags;
457 }
458
415 static NSSASCII7 * 459 static NSSASCII7 *
416 nss3certificate_getEmailAddress(nssDecodedCert *dc) 460 nss3certificate_getEmailAddress(nssDecodedCert *dc)
417 { 461 {
418 CERTCertificate *cc = (CERTCertificate *)dc->data; 462 CERTCertificate *cc = (CERTCertificate *)dc->data;
419 return (cc && cc->emailAddr && cc->emailAddr[0]) 463 return (cc && cc->emailAddr && cc->emailAddr[0])
420 ? (NSSASCII7 *)cc->emailAddr : NULL; 464 ? (NSSASCII7 *)cc->emailAddr : NULL;
421 } 465 }
422 466
423 static PRStatus 467 static PRStatus
424 nss3certificate_getDERSerialNumber(nssDecodedCert *dc, 468 nss3certificate_getDERSerialNumber(nssDecodedCert *dc,
(...skipping 30 matching lines...) Expand all
455 rvDC->type = NSSCertificateType_PKIX; 499 rvDC->type = NSSCertificateType_PKIX;
456 rvDC->data = (void *)cert; 500 rvDC->data = (void *)cert;
457 rvDC->getIdentifier = nss3certificate_getIdentifier; 501 rvDC->getIdentifier = nss3certificate_getIdentifier;
458 rvDC->getIssuerIdentifier = nss3certificate_getIssuerIdentifier; 502 rvDC->getIssuerIdentifier = nss3certificate_getIssuerIdentifier;
459 rvDC->matchIdentifier = nss3certificate_matchIdentifier; 503 rvDC->matchIdentifier = nss3certificate_matchIdentifier;
460 rvDC->isValidIssuer = nss3certificate_isValidIssuer; 504 rvDC->isValidIssuer = nss3certificate_isValidIssuer;
461 rvDC->getUsage = nss3certificate_getUsage; 505 rvDC->getUsage = nss3certificate_getUsage;
462 rvDC->isValidAtTime = nss3certificate_isValidAtTime; 506 rvDC->isValidAtTime = nss3certificate_isValidAtTime;
463 rvDC->isNewerThan = nss3certificate_isNewerThan; 507 rvDC->isNewerThan = nss3certificate_isNewerThan;
464 rvDC->matchUsage = nss3certificate_matchUsage; 508 rvDC->matchUsage = nss3certificate_matchUsage;
509 rvDC->isTrustedForUsage = nss3certificate_isTrustedForUsage;
465 rvDC->getEmailAddress = nss3certificate_getEmailAddress; 510 rvDC->getEmailAddress = nss3certificate_getEmailAddress;
466 rvDC->getDERSerialNumber = nss3certificate_getDERSerialNumber; 511 rvDC->getDERSerialNumber = nss3certificate_getDERSerialNumber;
467 } else { 512 } else {
468 CERT_DestroyCertificate(cert); 513 CERT_DestroyCertificate(cert);
469 } 514 }
470 } 515 }
471 return rvDC; 516 return rvDC;
472 } 517 }
473 518
474 static nssDecodedCert * 519 static nssDecodedCert *
475 create_decoded_pkix_cert_from_nss3cert ( 520 create_decoded_pkix_cert_from_nss3cert (
476 NSSArena *arenaOpt, 521 NSSArena *arenaOpt,
477 CERTCertificate *cc 522 CERTCertificate *cc
478 ) 523 )
479 { 524 {
480 nssDecodedCert *rvDC = nss_ZNEW(arenaOpt, nssDecodedCert); 525 nssDecodedCert *rvDC = nss_ZNEW(arenaOpt, nssDecodedCert);
481 if (rvDC) { 526 if (rvDC) {
482 rvDC->type = NSSCertificateType_PKIX; 527 rvDC->type = NSSCertificateType_PKIX;
483 rvDC->data = (void *)cc; 528 rvDC->data = (void *)cc;
484 rvDC->getIdentifier = nss3certificate_getIdentifier; 529 rvDC->getIdentifier = nss3certificate_getIdentifier;
485 rvDC->getIssuerIdentifier = nss3certificate_getIssuerIdentifier; 530 rvDC->getIssuerIdentifier = nss3certificate_getIssuerIdentifier;
486 rvDC->matchIdentifier = nss3certificate_matchIdentifier; 531 rvDC->matchIdentifier = nss3certificate_matchIdentifier;
487 rvDC->isValidIssuer = nss3certificate_isValidIssuer; 532 rvDC->isValidIssuer = nss3certificate_isValidIssuer;
488 rvDC->getUsage = nss3certificate_getUsage; 533 rvDC->getUsage = nss3certificate_getUsage;
489 rvDC->isValidAtTime = nss3certificate_isValidAtTime; 534 rvDC->isValidAtTime = nss3certificate_isValidAtTime;
490 rvDC->isNewerThan = nss3certificate_isNewerThan; 535 rvDC->isNewerThan = nss3certificate_isNewerThan;
491 rvDC->matchUsage = nss3certificate_matchUsage; 536 rvDC->matchUsage = nss3certificate_matchUsage;
537 rvDC->isTrustedForUsage = nss3certificate_isTrustedForUsage;
492 rvDC->getEmailAddress = nss3certificate_getEmailAddress; 538 rvDC->getEmailAddress = nss3certificate_getEmailAddress;
539 rvDC->getDERSerialNumber = nss3certificate_getDERSerialNumber;
493 } 540 }
494 return rvDC; 541 return rvDC;
495 } 542 }
496 543
497 NSS_IMPLEMENT PRStatus 544 NSS_IMPLEMENT PRStatus
498 nssDecodedPKIXCertificate_Destroy ( 545 nssDecodedPKIXCertificate_Destroy (
499 nssDecodedCert *dc 546 nssDecodedCert *dc
500 ) 547 )
501 { 548 {
502 CERTCertificate *cert = (CERTCertificate *)dc->data; 549 CERTCertificate *cert = (CERTCertificate *)dc->data;
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 td = STAN_GetDefaultTrustDomain(); 1413 td = STAN_GetDefaultTrustDomain();
1367 cc = STAN_GetDefaultCryptoContext(); 1414 cc = STAN_GetDefaultCryptoContext();
1368 printf("\n\nCertificates in the cache:\n"); 1415 printf("\n\nCertificates in the cache:\n");
1369 nssTrustDomain_DumpCacheInfo(td, cert_dump_iter, NULL); 1416 nssTrustDomain_DumpCacheInfo(td, cert_dump_iter, NULL);
1370 printf("\n\nCertificates in the temporary store:\n"); 1417 printf("\n\nCertificates in the temporary store:\n");
1371 if (cc->certStore) { 1418 if (cc->certStore) {
1372 nssCertificateStore_DumpStoreInfo(cc->certStore, cert_dump_iter, NULL); 1419 nssCertificateStore_DumpStoreInfo(cc->certStore, cert_dump_iter, NULL);
1373 } 1420 }
1374 } 1421 }
1375 1422
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698