OLD | NEW |
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 #include "plarena.h" | 5 #include "plarena.h" |
6 #include "seccomon.h" | 6 #include "seccomon.h" |
7 #include "secitem.h" | 7 #include "secitem.h" |
8 #include "secoidt.h" | 8 #include "secoidt.h" |
9 #include "secasn1.h" | 9 #include "secasn1.h" |
10 #include "secder.h" | 10 #include "secder.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 name->l.prev = name->l.next = &name->l; | 149 name->l.prev = name->l.next = &name->l; |
150 } | 150 } |
151 return name; | 151 return name; |
152 } | 152 } |
153 | 153 |
154 /* Copy content of one General Name to another. | 154 /* Copy content of one General Name to another. |
155 ** Caller has allocated destination general name. | 155 ** Caller has allocated destination general name. |
156 ** This function does not change the destinate's GeneralName's list linkage. | 156 ** This function does not change the destinate's GeneralName's list linkage. |
157 */ | 157 */ |
158 SECStatus | 158 SECStatus |
159 cert_CopyOneGeneralName(PRArenaPool *arena, | 159 cert_CopyOneGeneralName(PLArenaPool *arena, |
160 CERTGeneralName *dest, | 160 CERTGeneralName *dest, |
161 CERTGeneralName *src) | 161 CERTGeneralName *src) |
162 { | 162 { |
163 SECStatus rv; | 163 SECStatus rv; |
164 void *mark = NULL; | 164 void *mark = NULL; |
165 | 165 |
166 PORT_Assert(dest != NULL); | 166 PORT_Assert(dest != NULL); |
167 dest->type = src->type; | 167 dest->type = src->type; |
168 | 168 |
169 mark = PORT_ArenaMark(arena); | 169 mark = PORT_ArenaMark(arena); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 PZ_DestroyLock(lock); | 214 PZ_DestroyLock(lock); |
215 } else { | 215 } else { |
216 PZ_Unlock(lock); | 216 PZ_Unlock(lock); |
217 } | 217 } |
218 } | 218 } |
219 return; | 219 return; |
220 } | 220 } |
221 | 221 |
222 CERTGeneralNameList * | 222 CERTGeneralNameList * |
223 CERT_CreateGeneralNameList(CERTGeneralName *name) { | 223 CERT_CreateGeneralNameList(CERTGeneralName *name) { |
224 PRArenaPool *arena; | 224 PLArenaPool *arena; |
225 CERTGeneralNameList *list = NULL; | 225 CERTGeneralNameList *list = NULL; |
226 | 226 |
227 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 227 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
228 if (arena == NULL) { | 228 if (arena == NULL) { |
229 goto done; | 229 goto done; |
230 } | 230 } |
231 list = PORT_ArenaZNew(arena, CERTGeneralNameList); | 231 list = PORT_ArenaZNew(arena, CERTGeneralNameList); |
232 if (!list) | 232 if (!list) |
233 goto loser; | 233 goto loser; |
234 if (name != NULL) { | 234 if (name != NULL) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 281 |
282 CERTNameConstraint * | 282 CERTNameConstraint * |
283 CERT_GetPrevNameConstraint(CERTNameConstraint *current) | 283 CERT_GetPrevNameConstraint(CERTNameConstraint *current) |
284 { | 284 { |
285 PRCList *prev; | 285 PRCList *prev; |
286 prev = current->l.prev; | 286 prev = current->l.prev; |
287 return (CERTNameConstraint *) (((char *) prev) - offsetof(CERTNameConstraint
, l)); | 287 return (CERTNameConstraint *) (((char *) prev) - offsetof(CERTNameConstraint
, l)); |
288 } | 288 } |
289 | 289 |
290 SECItem * | 290 SECItem * |
291 CERT_EncodeGeneralName(CERTGeneralName *genName, SECItem *dest, PRArenaPool *are
na) | 291 CERT_EncodeGeneralName(CERTGeneralName *genName, SECItem *dest, PLArenaPool *are
na) |
292 { | 292 { |
293 | 293 |
294 const SEC_ASN1Template * template; | 294 const SEC_ASN1Template * template; |
295 | 295 |
296 PORT_Assert(arena); | 296 PORT_Assert(arena); |
297 if (arena == NULL) { | 297 if (arena == NULL) { |
298 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 298 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
299 return NULL; | 299 return NULL; |
300 } | 300 } |
301 /* TODO: mark arena */ | 301 /* TODO: mark arena */ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 goto loser; | 338 goto loser; |
339 } | 339 } |
340 /* TODO: unmark arena */ | 340 /* TODO: unmark arena */ |
341 return dest; | 341 return dest; |
342 loser: | 342 loser: |
343 /* TODO: release arena back to mark */ | 343 /* TODO: release arena back to mark */ |
344 return NULL; | 344 return NULL; |
345 } | 345 } |
346 | 346 |
347 SECItem ** | 347 SECItem ** |
348 cert_EncodeGeneralNames(PRArenaPool *arena, CERTGeneralName *names) | 348 cert_EncodeGeneralNames(PLArenaPool *arena, CERTGeneralName *names) |
349 { | 349 { |
350 CERTGeneralName *current_name; | 350 CERTGeneralName *current_name; |
351 SECItem **items = NULL; | 351 SECItem **items = NULL; |
352 int count = 0; | 352 int count = 0; |
353 int i; | 353 int i; |
354 PRCList *head; | 354 PRCList *head; |
355 | 355 |
356 PORT_Assert(arena); | 356 PORT_Assert(arena); |
357 /* TODO: mark arena */ | 357 /* TODO: mark arena */ |
358 current_name = names; | 358 current_name = names; |
(...skipping 19 matching lines...) Expand all Loading... |
378 } | 378 } |
379 items[i] = NULL; | 379 items[i] = NULL; |
380 /* TODO: unmark arena */ | 380 /* TODO: unmark arena */ |
381 return items; | 381 return items; |
382 loser: | 382 loser: |
383 /* TODO: release arena to mark */ | 383 /* TODO: release arena to mark */ |
384 return NULL; | 384 return NULL; |
385 } | 385 } |
386 | 386 |
387 CERTGeneralName * | 387 CERTGeneralName * |
388 CERT_DecodeGeneralName(PRArenaPool *reqArena, | 388 CERT_DecodeGeneralName(PLArenaPool *reqArena, |
389 SECItem *encodedName, | 389 SECItem *encodedName, |
390 CERTGeneralName *genName) | 390 CERTGeneralName *genName) |
391 { | 391 { |
392 const SEC_ASN1Template * template; | 392 const SEC_ASN1Template * template; |
393 CERTGeneralNameType genNameType; | 393 CERTGeneralNameType genNameType; |
394 SECStatus rv = SECSuccess; | 394 SECStatus rv = SECSuccess; |
395 SECItem* newEncodedName; | 395 SECItem* newEncodedName; |
396 | 396 |
397 if (!reqArena) { | 397 if (!reqArena) { |
398 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 398 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } | 440 } |
441 | 441 |
442 /* TODO: unmark arena */ | 442 /* TODO: unmark arena */ |
443 return genName; | 443 return genName; |
444 loser: | 444 loser: |
445 /* TODO: release arena to mark */ | 445 /* TODO: release arena to mark */ |
446 return NULL; | 446 return NULL; |
447 } | 447 } |
448 | 448 |
449 CERTGeneralName * | 449 CERTGeneralName * |
450 cert_DecodeGeneralNames (PRArenaPool *arena, | 450 cert_DecodeGeneralNames (PLArenaPool *arena, |
451 SECItem **encodedGenName) | 451 SECItem **encodedGenName) |
452 { | 452 { |
453 PRCList *head = NULL; | 453 PRCList *head = NULL; |
454 PRCList *tail = NULL; | 454 PRCList *tail = NULL; |
455 CERTGeneralName *currentName = NULL; | 455 CERTGeneralName *currentName = NULL; |
456 | 456 |
457 PORT_Assert(arena); | 457 PORT_Assert(arena); |
458 if (!encodedGenName || !arena) { | 458 if (!encodedGenName || !arena) { |
459 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 459 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
460 return NULL; | 460 return NULL; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 next = CERT_GetNextGeneralName(name); | 499 next = CERT_GetNextGeneralName(name); |
500 PORT_Free(name); | 500 PORT_Free(name); |
501 name = next; | 501 name = next; |
502 } while (name != first); | 502 } while (name != first); |
503 return SECSuccess; | 503 return SECSuccess; |
504 } | 504 } |
505 | 505 |
506 static SECItem * | 506 static SECItem * |
507 cert_EncodeNameConstraint(CERTNameConstraint *constraint, | 507 cert_EncodeNameConstraint(CERTNameConstraint *constraint, |
508 SECItem *dest, | 508 SECItem *dest, |
509 » » » PRArenaPool *arena) | 509 » » » PLArenaPool *arena) |
510 { | 510 { |
511 PORT_Assert(arena); | 511 PORT_Assert(arena); |
512 if (dest == NULL) { | 512 if (dest == NULL) { |
513 dest = PORT_ArenaZNew(arena, SECItem); | 513 dest = PORT_ArenaZNew(arena, SECItem); |
514 if (dest == NULL) { | 514 if (dest == NULL) { |
515 return NULL; | 515 return NULL; |
516 } | 516 } |
517 } | 517 } |
518 CERT_EncodeGeneralName(&(constraint->name), &(constraint->DERName), arena); | 518 CERT_EncodeGeneralName(&(constraint->name), &(constraint->DERName), arena); |
519 | 519 |
520 dest = SEC_ASN1EncodeItem (arena, dest, constraint, | 520 dest = SEC_ASN1EncodeItem (arena, dest, constraint, |
521 CERTNameConstraintTemplate); | 521 CERTNameConstraintTemplate); |
522 return dest; | 522 return dest; |
523 } | 523 } |
524 | 524 |
525 SECStatus | 525 SECStatus |
526 cert_EncodeNameConstraintSubTree(CERTNameConstraint *constraints, | 526 cert_EncodeNameConstraintSubTree(CERTNameConstraint *constraints, |
527 » » » PRArenaPool *arena, | 527 » » » PLArenaPool *arena, |
528 SECItem ***dest, | 528 SECItem ***dest, |
529 PRBool permited) | 529 PRBool permited) |
530 { | 530 { |
531 CERTNameConstraint *current_constraint = constraints; | 531 CERTNameConstraint *current_constraint = constraints; |
532 SECItem **items = NULL; | 532 SECItem **items = NULL; |
533 int count = 0; | 533 int count = 0; |
534 int i; | 534 int i; |
535 PRCList *head; | 535 PRCList *head; |
536 | 536 |
537 PORT_Assert(arena); | 537 PORT_Assert(arena); |
(...skipping 25 matching lines...) Expand all Loading... |
563 } | 563 } |
564 /* TODO: unmark arena */ | 564 /* TODO: unmark arena */ |
565 return SECSuccess; | 565 return SECSuccess; |
566 loser: | 566 loser: |
567 /* TODO: release arena to mark */ | 567 /* TODO: release arena to mark */ |
568 return SECFailure; | 568 return SECFailure; |
569 } | 569 } |
570 | 570 |
571 SECStatus | 571 SECStatus |
572 cert_EncodeNameConstraints(CERTNameConstraints *constraints, | 572 cert_EncodeNameConstraints(CERTNameConstraints *constraints, |
573 » » » PRArenaPool *arena, | 573 » » » PLArenaPool *arena, |
574 SECItem *dest) | 574 SECItem *dest) |
575 { | 575 { |
576 SECStatus rv = SECSuccess; | 576 SECStatus rv = SECSuccess; |
577 | 577 |
578 PORT_Assert(arena); | 578 PORT_Assert(arena); |
579 /* TODO: mark arena */ | 579 /* TODO: mark arena */ |
580 if (constraints->permited != NULL) { | 580 if (constraints->permited != NULL) { |
581 rv = cert_EncodeNameConstraintSubTree(constraints->permited, arena, | 581 rv = cert_EncodeNameConstraintSubTree(constraints->permited, arena, |
582 &constraints->DERPermited, | 582 &constraints->DERPermited, |
583 PR_TRUE); | 583 PR_TRUE); |
(...skipping 16 matching lines...) Expand all Loading... |
600 } | 600 } |
601 /* TODO: unmark arena */ | 601 /* TODO: unmark arena */ |
602 return SECSuccess; | 602 return SECSuccess; |
603 loser: | 603 loser: |
604 /* TODO: release arena to mark */ | 604 /* TODO: release arena to mark */ |
605 return SECFailure; | 605 return SECFailure; |
606 } | 606 } |
607 | 607 |
608 | 608 |
609 CERTNameConstraint * | 609 CERTNameConstraint * |
610 cert_DecodeNameConstraint(PRArenaPool *reqArena, | 610 cert_DecodeNameConstraint(PLArenaPool *reqArena, |
611 SECItem *encodedConstraint) | 611 SECItem *encodedConstraint) |
612 { | 612 { |
613 CERTNameConstraint *constraint; | 613 CERTNameConstraint *constraint; |
614 SECStatus rv = SECSuccess; | 614 SECStatus rv = SECSuccess; |
615 CERTGeneralName *temp; | 615 CERTGeneralName *temp; |
616 SECItem* newEncodedConstraint; | 616 SECItem* newEncodedConstraint; |
617 | 617 |
618 if (!reqArena) { | 618 if (!reqArena) { |
619 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 619 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
620 return NULL; | 620 return NULL; |
(...skipping 24 matching lines...) Expand all Loading... |
645 */ | 645 */ |
646 constraint->name.l.prev = constraint->name.l.next = &(constraint->name.l); | 646 constraint->name.l.prev = constraint->name.l.next = &(constraint->name.l); |
647 /* TODO: unmark arena */ | 647 /* TODO: unmark arena */ |
648 return constraint; | 648 return constraint; |
649 loser: | 649 loser: |
650 /* TODO: release arena back to mark */ | 650 /* TODO: release arena back to mark */ |
651 return NULL; | 651 return NULL; |
652 } | 652 } |
653 | 653 |
654 CERTNameConstraint * | 654 CERTNameConstraint * |
655 cert_DecodeNameConstraintSubTree(PRArenaPool *arena, | 655 cert_DecodeNameConstraintSubTree(PLArenaPool *arena, |
656 SECItem **subTree, | 656 SECItem **subTree, |
657 PRBool permited) | 657 PRBool permited) |
658 { | 658 { |
659 CERTNameConstraint *current = NULL; | 659 CERTNameConstraint *current = NULL; |
660 CERTNameConstraint *first = NULL; | 660 CERTNameConstraint *first = NULL; |
661 CERTNameConstraint *last = NULL; | 661 CERTNameConstraint *last = NULL; |
662 int i = 0; | 662 int i = 0; |
663 | 663 |
664 PORT_Assert(arena); | 664 PORT_Assert(arena); |
665 /* TODO: mark arena */ | 665 /* TODO: mark arena */ |
(...skipping 12 matching lines...) Expand all Loading... |
678 } | 678 } |
679 first->l.prev = &(current->l); | 679 first->l.prev = &(current->l); |
680 /* TODO: unmark arena */ | 680 /* TODO: unmark arena */ |
681 return first; | 681 return first; |
682 loser: | 682 loser: |
683 /* TODO: release arena back to mark */ | 683 /* TODO: release arena back to mark */ |
684 return NULL; | 684 return NULL; |
685 } | 685 } |
686 | 686 |
687 CERTNameConstraints * | 687 CERTNameConstraints * |
688 cert_DecodeNameConstraints(PRArenaPool *reqArena, | 688 cert_DecodeNameConstraints(PLArenaPool *reqArena, |
689 const SECItem *encodedConstraints) | 689 const SECItem *encodedConstraints) |
690 { | 690 { |
691 CERTNameConstraints *constraints; | 691 CERTNameConstraints *constraints; |
692 SECStatus rv; | 692 SECStatus rv; |
693 SECItem* newEncodedConstraints; | 693 SECItem* newEncodedConstraints; |
694 | 694 |
695 if (!reqArena) { | 695 if (!reqArena) { |
696 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 696 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
697 return NULL; | 697 return NULL; |
698 } | 698 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 ** If the source chain has more than one member, and the destination chain | 744 ** If the source chain has more than one member, and the destination chain |
745 ** has only one member, then this function allocates new structs for all but | 745 ** has only one member, then this function allocates new structs for all but |
746 ** the first copy from the arena and links them into the destination list. | 746 ** the first copy from the arena and links them into the destination list. |
747 ** If the destination struct is part of a list with more than one member, | 747 ** If the destination struct is part of a list with more than one member, |
748 ** then this function traverses both the source and destination lists, | 748 ** then this function traverses both the source and destination lists, |
749 ** copying each source struct to the corresponding dest struct. | 749 ** copying each source struct to the corresponding dest struct. |
750 ** In that case, the destination list MUST contain at least as many | 750 ** In that case, the destination list MUST contain at least as many |
751 ** structs as the source list or some dest entries will be overwritten. | 751 ** structs as the source list or some dest entries will be overwritten. |
752 */ | 752 */ |
753 SECStatus | 753 SECStatus |
754 CERT_CopyGeneralName(PRArenaPool *arena, | 754 CERT_CopyGeneralName(PLArenaPool *arena, |
755 CERTGeneralName *dest, | 755 CERTGeneralName *dest, |
756 CERTGeneralName *src) | 756 CERTGeneralName *src) |
757 { | 757 { |
758 SECStatus rv; | 758 SECStatus rv; |
759 CERTGeneralName *destHead = dest; | 759 CERTGeneralName *destHead = dest; |
760 CERTGeneralName *srcHead = src; | 760 CERTGeneralName *srcHead = src; |
761 | 761 |
762 PORT_Assert(dest != NULL); | 762 PORT_Assert(dest != NULL); |
763 if (!dest) { | 763 if (!dest) { |
764 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 764 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 if (list != NULL) { | 801 if (list != NULL) { |
802 PZ_Lock(list->lock); | 802 PZ_Lock(list->lock); |
803 list->refCount++; | 803 list->refCount++; |
804 PZ_Unlock(list->lock); | 804 PZ_Unlock(list->lock); |
805 } | 805 } |
806 return list; | 806 return list; |
807 } | 807 } |
808 | 808 |
809 /* Allocate space and copy CERTNameConstraint from src to dest */ | 809 /* Allocate space and copy CERTNameConstraint from src to dest */ |
810 CERTNameConstraint * | 810 CERTNameConstraint * |
811 CERT_CopyNameConstraint(PRArenaPool *arena, | 811 CERT_CopyNameConstraint(PLArenaPool *arena, |
812 CERTNameConstraint *dest, | 812 CERTNameConstraint *dest, |
813 CERTNameConstraint *src) | 813 CERTNameConstraint *src) |
814 { | 814 { |
815 SECStatus rv; | 815 SECStatus rv; |
816 | 816 |
817 /* TODO: mark arena */ | 817 /* TODO: mark arena */ |
818 if (dest == NULL) { | 818 if (dest == NULL) { |
819 dest = PORT_ArenaZNew(arena, CERTNameConstraint); | 819 dest = PORT_ArenaZNew(arena, CERTNameConstraint); |
820 if (!dest) | 820 if (!dest) |
821 goto loser; | 821 goto loser; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 constraint->l.next = constraint->l.prev = &constraint->l; | 908 constraint->l.next = constraint->l.prev = &constraint->l; |
909 list = cert_CombineConstraintsLists(list, constraint); | 909 list = cert_CombineConstraintsLists(list, constraint); |
910 return list; | 910 return list; |
911 } | 911 } |
912 | 912 |
913 | 913 |
914 SECStatus | 914 SECStatus |
915 CERT_GetNameConstraintByType (CERTNameConstraint *constraints, | 915 CERT_GetNameConstraintByType (CERTNameConstraint *constraints, |
916 CERTGeneralNameType type, | 916 CERTGeneralNameType type, |
917 CERTNameConstraint **returnList, | 917 CERTNameConstraint **returnList, |
918 » » » PRArenaPool *arena) | 918 » » » PLArenaPool *arena) |
919 { | 919 { |
920 CERTNameConstraint *current = NULL; | 920 CERTNameConstraint *current = NULL; |
921 void *mark = NULL; | 921 void *mark = NULL; |
922 | 922 |
923 *returnList = NULL; | 923 *returnList = NULL; |
924 if (!constraints) | 924 if (!constraints) |
925 return SECSuccess; | 925 return SECSuccess; |
926 | 926 |
927 mark = PORT_ArenaMark(arena); | 927 mark = PORT_ArenaMark(arena); |
928 | 928 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 | 1048 |
1049 loser: | 1049 loser: |
1050 /* TODO: release arena back to mark */ | 1050 /* TODO: release arena back to mark */ |
1051 return SECFailure; | 1051 return SECFailure; |
1052 } | 1052 } |
1053 | 1053 |
1054 /* Extract all names except Subject Common Name from a cert | 1054 /* Extract all names except Subject Common Name from a cert |
1055 ** in preparation for a name constraints test. | 1055 ** in preparation for a name constraints test. |
1056 */ | 1056 */ |
1057 CERTGeneralName * | 1057 CERTGeneralName * |
1058 CERT_GetCertificateNames(CERTCertificate *cert, PRArenaPool *arena) | 1058 CERT_GetCertificateNames(CERTCertificate *cert, PLArenaPool *arena) |
1059 { | 1059 { |
1060 return CERT_GetConstrainedCertificateNames(cert, arena, PR_FALSE); | 1060 return CERT_GetConstrainedCertificateNames(cert, arena, PR_FALSE); |
1061 } | 1061 } |
1062 | 1062 |
1063 /* This function is called by CERT_VerifyCertChain to extract all | 1063 /* This function is called by CERT_VerifyCertChain to extract all |
1064 ** names from a cert in preparation for a name constraints test. | 1064 ** names from a cert in preparation for a name constraints test. |
1065 */ | 1065 */ |
1066 CERTGeneralName * | 1066 CERTGeneralName * |
1067 CERT_GetConstrainedCertificateNames(const CERTCertificate *cert, | 1067 CERT_GetConstrainedCertificateNames(const CERTCertificate *cert, |
1068 PRArenaPool *arena, | 1068 PLArenaPool *arena, |
1069 PRBool includeSubjectCommonName) | 1069 PRBool includeSubjectCommonName) |
1070 { | 1070 { |
1071 CERTGeneralName *DN; | 1071 CERTGeneralName *DN; |
1072 CERTGeneralName *SAN; | 1072 CERTGeneralName *SAN; |
1073 PRUint32 numDNSNames = 0; | 1073 PRUint32 numDNSNames = 0; |
1074 SECStatus rv; | 1074 SECStatus rv; |
1075 | 1075 |
1076 if (!arena) { | 1076 if (!arena) { |
1077 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 1077 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
1078 return NULL; | 1078 return NULL; |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 if (rv == SECFailure) { | 1518 if (rv == SECFailure) { |
1519 PORT_ArenaRelease(arena, mark); | 1519 PORT_ArenaRelease(arena, mark); |
1520 } else { | 1520 } else { |
1521 PORT_ArenaUnmark(arena, mark); | 1521 PORT_ArenaUnmark(arena, mark); |
1522 } | 1522 } |
1523 return rv; | 1523 return rv; |
1524 } | 1524 } |
1525 | 1525 |
1526 /* Extract the name constraints extension from the CA cert. */ | 1526 /* Extract the name constraints extension from the CA cert. */ |
1527 SECStatus | 1527 SECStatus |
1528 CERT_FindNameConstraintsExten(PRArenaPool *arena, | 1528 CERT_FindNameConstraintsExten(PLArenaPool *arena, |
1529 CERTCertificate *cert, | 1529 CERTCertificate *cert, |
1530 CERTNameConstraints **constraints) | 1530 CERTNameConstraints **constraints) |
1531 { | 1531 { |
1532 SECStatus rv = SECSuccess; | 1532 SECStatus rv = SECSuccess; |
1533 SECItem constraintsExtension; | 1533 SECItem constraintsExtension; |
1534 void *mark = NULL; | 1534 void *mark = NULL; |
1535 | 1535 |
1536 *constraints = NULL; | 1536 *constraints = NULL; |
1537 | 1537 |
1538 rv = CERT_FindCertExtension(cert, SEC_OID_X509_NAME_CONSTRAINTS, | 1538 rv = CERT_FindCertExtension(cert, SEC_OID_X509_NAME_CONSTRAINTS, |
(...skipping 19 matching lines...) Expand all Loading... |
1558 PORT_ArenaUnmark(arena, mark); | 1558 PORT_ArenaUnmark(arena, mark); |
1559 } | 1559 } |
1560 | 1560 |
1561 return rv; | 1561 return rv; |
1562 } | 1562 } |
1563 | 1563 |
1564 /* Verify name against all the constraints relevant to that type of | 1564 /* Verify name against all the constraints relevant to that type of |
1565 ** the name. | 1565 ** the name. |
1566 */ | 1566 */ |
1567 SECStatus | 1567 SECStatus |
1568 CERT_CheckNameSpace(PRArenaPool *arena, | 1568 CERT_CheckNameSpace(PLArenaPool *arena, |
1569 const CERTNameConstraints *constraints, | 1569 const CERTNameConstraints *constraints, |
1570 const CERTGeneralName *currentName) | 1570 const CERTGeneralName *currentName) |
1571 { | 1571 { |
1572 CERTNameConstraint *matchingConstraints; | 1572 CERTNameConstraint *matchingConstraints; |
1573 SECStatus rv = SECSuccess; | 1573 SECStatus rv = SECSuccess; |
1574 | 1574 |
1575 if (constraints->excluded != NULL) { | 1575 if (constraints->excluded != NULL) { |
1576 rv = CERT_GetNameConstraintByType(constraints->excluded, | 1576 rv = CERT_GetNameConstraintByType(constraints->excluded, |
1577 currentName->type, | 1577 currentName->type, |
1578 &matchingConstraints, arena); | 1578 &matchingConstraints, arena); |
(...skipping 28 matching lines...) Expand all Loading... |
1607 ** Test each and every name in namesList against all the constraints | 1607 ** Test each and every name in namesList against all the constraints |
1608 ** relevant to that type of name. | 1608 ** relevant to that type of name. |
1609 ** Returns NULL in pBadCert for success, if all names are acceptable. | 1609 ** Returns NULL in pBadCert for success, if all names are acceptable. |
1610 ** If some name is not acceptable, returns a pointer to the cert that | 1610 ** If some name is not acceptable, returns a pointer to the cert that |
1611 ** contained that name. | 1611 ** contained that name. |
1612 */ | 1612 */ |
1613 SECStatus | 1613 SECStatus |
1614 CERT_CompareNameSpace(CERTCertificate *cert, | 1614 CERT_CompareNameSpace(CERTCertificate *cert, |
1615 CERTGeneralName *namesList, | 1615 CERTGeneralName *namesList, |
1616 CERTCertificate **certsList, | 1616 CERTCertificate **certsList, |
1617 » » PRArenaPool *reqArena, | 1617 » » PLArenaPool *reqArena, |
1618 CERTCertificate **pBadCert) | 1618 CERTCertificate **pBadCert) |
1619 { | 1619 { |
1620 SECStatus rv = SECSuccess; | 1620 SECStatus rv = SECSuccess; |
1621 CERTNameConstraints *constraints; | 1621 CERTNameConstraints *constraints; |
1622 CERTGeneralName *currentName; | 1622 CERTGeneralName *currentName; |
1623 int count = 0; | 1623 int count = 0; |
1624 CERTCertificate *badCert = NULL; | 1624 CERTCertificate *badCert = NULL; |
1625 | 1625 |
1626 /* If no names to check, then no names can be bad. */ | 1626 /* If no names to check, then no names can be bad. */ |
1627 if (!namesList) | 1627 if (!namesList) |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 #endif | 1748 #endif |
1749 | 1749 |
1750 #if 0 | 1750 #if 0 |
1751 /* This function is not exported from NSS shared libraries, and is not | 1751 /* This function is not exported from NSS shared libraries, and is not |
1752 ** used inside of NSS. | 1752 ** used inside of NSS. |
1753 ** XXX it doesn't check for failed allocations. :-( | 1753 ** XXX it doesn't check for failed allocations. :-( |
1754 */ | 1754 */ |
1755 void * | 1755 void * |
1756 CERT_GetGeneralNameFromListByType(CERTGeneralNameList *list, | 1756 CERT_GetGeneralNameFromListByType(CERTGeneralNameList *list, |
1757 CERTGeneralNameType type, | 1757 CERTGeneralNameType type, |
1758 » » » » PRArenaPool *arena) | 1758 » » » » PLArenaPool *arena) |
1759 { | 1759 { |
1760 CERTName *name = NULL; | 1760 CERTName *name = NULL; |
1761 SECItem *item = NULL; | 1761 SECItem *item = NULL; |
1762 OtherName *other = NULL; | 1762 OtherName *other = NULL; |
1763 OtherName *tmpOther = NULL; | 1763 OtherName *tmpOther = NULL; |
1764 void *data; | 1764 void *data; |
1765 | 1765 |
1766 PZ_Lock(list->lock); | 1766 PZ_Lock(list->lock); |
1767 data = CERT_GetGeneralNameByType(list->name, type, PR_FALSE); | 1767 data = CERT_GetGeneralNameByType(list->name, type, PR_FALSE); |
1768 if (data != NULL) { | 1768 if (data != NULL) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 break; | 1853 break; |
1854 } | 1854 } |
1855 list->name = cert_CombineNamesLists(list->name, name); | 1855 list->name = cert_CombineNamesLists(list->name, name); |
1856 list->len++; | 1856 list->len++; |
1857 done: | 1857 done: |
1858 PZ_Unlock(list->lock); | 1858 PZ_Unlock(list->lock); |
1859 } | 1859 } |
1860 return; | 1860 return; |
1861 } | 1861 } |
1862 #endif | 1862 #endif |
OLD | NEW |