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 /* | 5 /* |
6 * Support for various policy related extensions | 6 * Support for various policy related extensions |
7 */ | 7 */ |
8 | 8 |
9 #include "seccomon.h" | 9 #include "seccomon.h" |
10 #include "secport.h" | 10 #include "secport.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 curlen++; | 141 curlen++; |
142 tmpstr++; | 142 tmpstr++; |
143 } | 143 } |
144 | 144 |
145 return; | 145 return; |
146 } | 146 } |
147 | 147 |
148 CERTCertificatePolicies * | 148 CERTCertificatePolicies * |
149 CERT_DecodeCertificatePoliciesExtension(const SECItem *extnValue) | 149 CERT_DecodeCertificatePoliciesExtension(const SECItem *extnValue) |
150 { | 150 { |
151 PRArenaPool *arena = NULL; | 151 PLArenaPool *arena = NULL; |
152 SECStatus rv; | 152 SECStatus rv; |
153 CERTCertificatePolicies *policies; | 153 CERTCertificatePolicies *policies; |
154 CERTPolicyInfo **policyInfos, *policyInfo; | 154 CERTPolicyInfo **policyInfos, *policyInfo; |
155 CERTPolicyQualifier **policyQualifiers, *policyQualifier; | 155 CERTPolicyQualifier **policyQualifiers, *policyQualifier; |
156 SECItem newExtnValue; | 156 SECItem newExtnValue; |
157 | 157 |
158 /* make a new arena */ | 158 /* make a new arena */ |
159 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 159 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
160 | 160 |
161 if ( !arena ) { | 161 if ( !arena ) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 { | 217 { |
218 if ( policies != NULL ) { | 218 if ( policies != NULL ) { |
219 PORT_FreeArena(policies->arena, PR_FALSE); | 219 PORT_FreeArena(policies->arena, PR_FALSE); |
220 } | 220 } |
221 return; | 221 return; |
222 } | 222 } |
223 | 223 |
224 CERTCertificatePolicyMappings * | 224 CERTCertificatePolicyMappings * |
225 CERT_DecodePolicyMappingsExtension(SECItem *extnValue) | 225 CERT_DecodePolicyMappingsExtension(SECItem *extnValue) |
226 { | 226 { |
227 PRArenaPool *arena = NULL; | 227 PLArenaPool *arena = NULL; |
228 SECStatus rv; | 228 SECStatus rv; |
229 CERTCertificatePolicyMappings *mappings; | 229 CERTCertificatePolicyMappings *mappings; |
230 SECItem newExtnValue; | 230 SECItem newExtnValue; |
231 | 231 |
232 /* make a new arena */ | 232 /* make a new arena */ |
233 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 233 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
234 if ( !arena ) { | 234 if ( !arena ) { |
235 goto loser; | 235 goto loser; |
236 } | 236 } |
237 | 237 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 275 } |
276 return SECSuccess; | 276 return SECSuccess; |
277 } | 277 } |
278 | 278 |
279 SECStatus | 279 SECStatus |
280 CERT_DecodePolicyConstraintsExtension | 280 CERT_DecodePolicyConstraintsExtension |
281 (CERTCertificatePolicyConstraints *decodedValue, | 281 (CERTCertificatePolicyConstraints *decodedValue, |
282 const SECItem *encodedValue) | 282 const SECItem *encodedValue) |
283 { | 283 { |
284 CERTCertificatePolicyConstraints decodeContext; | 284 CERTCertificatePolicyConstraints decodeContext; |
285 PRArenaPool *arena = NULL; | 285 PLArenaPool *arena = NULL; |
286 SECStatus rv = SECSuccess; | 286 SECStatus rv = SECSuccess; |
287 | 287 |
288 /* initialize so we can tell when an optional component is omitted */ | 288 /* initialize so we can tell when an optional component is omitted */ |
289 PORT_Memset(&decodeContext, 0, sizeof(decodeContext)); | 289 PORT_Memset(&decodeContext, 0, sizeof(decodeContext)); |
290 | 290 |
291 /* make a new arena */ | 291 /* make a new arena */ |
292 arena = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE); | 292 arena = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE); |
293 if (!arena) { | 293 if (!arena) { |
294 return SECFailure; | 294 return SECFailure; |
295 } | 295 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } while (0); | 331 } while (0); |
332 | 332 |
333 PORT_FreeArena(arena, PR_FALSE); | 333 PORT_FreeArena(arena, PR_FALSE); |
334 return(rv); | 334 return(rv); |
335 } | 335 } |
336 | 336 |
337 SECStatus CERT_DecodeInhibitAnyExtension | 337 SECStatus CERT_DecodeInhibitAnyExtension |
338 (CERTCertificateInhibitAny *decodedValue, SECItem *encodedValue) | 338 (CERTCertificateInhibitAny *decodedValue, SECItem *encodedValue) |
339 { | 339 { |
340 CERTCertificateInhibitAny decodeContext; | 340 CERTCertificateInhibitAny decodeContext; |
341 PRArenaPool *arena = NULL; | 341 PLArenaPool *arena = NULL; |
342 SECStatus rv = SECSuccess; | 342 SECStatus rv = SECSuccess; |
343 | 343 |
344 /* make a new arena */ | 344 /* make a new arena */ |
345 arena = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE); | 345 arena = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE); |
346 if ( !arena ) { | 346 if ( !arena ) { |
347 return SECFailure; | 347 return SECFailure; |
348 } | 348 } |
349 | 349 |
350 do { | 350 do { |
351 | 351 |
(...skipping 11 matching lines...) Expand all Loading... |
363 | 363 |
364 } while (0); | 364 } while (0); |
365 | 365 |
366 PORT_FreeArena(arena, PR_FALSE); | 366 PORT_FreeArena(arena, PR_FALSE); |
367 return(rv); | 367 return(rv); |
368 } | 368 } |
369 | 369 |
370 CERTUserNotice * | 370 CERTUserNotice * |
371 CERT_DecodeUserNotice(SECItem *noticeItem) | 371 CERT_DecodeUserNotice(SECItem *noticeItem) |
372 { | 372 { |
373 PRArenaPool *arena = NULL; | 373 PLArenaPool *arena = NULL; |
374 SECStatus rv; | 374 SECStatus rv; |
375 CERTUserNotice *userNotice; | 375 CERTUserNotice *userNotice; |
376 SECItem newNoticeItem; | 376 SECItem newNoticeItem; |
377 | 377 |
378 /* make a new arena */ | 378 /* make a new arena */ |
379 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 379 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
380 | 380 |
381 if ( !arena ) { | 381 if ( !arena ) { |
382 goto loser; | 382 goto loser; |
383 } | 383 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 597 |
598 const SEC_ASN1Template CERT_OidSeqTemplate[] = { | 598 const SEC_ASN1Template CERT_OidSeqTemplate[] = { |
599 { SEC_ASN1_SEQUENCE_OF | SEC_ASN1_XTRN, | 599 { SEC_ASN1_SEQUENCE_OF | SEC_ASN1_XTRN, |
600 offsetof(CERTOidSequence, oids), | 600 offsetof(CERTOidSequence, oids), |
601 SEC_ASN1_SUB(SEC_ObjectIDTemplate) } | 601 SEC_ASN1_SUB(SEC_ObjectIDTemplate) } |
602 }; | 602 }; |
603 | 603 |
604 CERTOidSequence * | 604 CERTOidSequence * |
605 CERT_DecodeOidSequence(const SECItem *seqItem) | 605 CERT_DecodeOidSequence(const SECItem *seqItem) |
606 { | 606 { |
607 PRArenaPool *arena = NULL; | 607 PLArenaPool *arena = NULL; |
608 SECStatus rv; | 608 SECStatus rv; |
609 CERTOidSequence *oidSeq; | 609 CERTOidSequence *oidSeq; |
610 SECItem newSeqItem; | 610 SECItem newSeqItem; |
611 | 611 |
612 /* make a new arena */ | 612 /* make a new arena */ |
613 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 613 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
614 | 614 |
615 if ( !arena ) { | 615 if ( !arena ) { |
616 goto loser; | 616 goto loser; |
617 } | 617 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 CERT_DestroyOidSequence(oidSeq); | 701 CERT_DestroyOidSequence(oidSeq); |
702 } | 702 } |
703 if (extItem.data != NULL) { | 703 if (extItem.data != NULL) { |
704 PORT_Free(extItem.data); | 704 PORT_Free(extItem.data); |
705 } | 705 } |
706 return(ret); | 706 return(ret); |
707 } | 707 } |
708 | 708 |
709 | 709 |
710 SECStatus | 710 SECStatus |
711 CERT_EncodePolicyConstraintsExtension(PRArenaPool *arena, | 711 CERT_EncodePolicyConstraintsExtension(PLArenaPool *arena, |
712 CERTCertificatePolicyConstraints *constr, | 712 CERTCertificatePolicyConstraints *constr, |
713 SECItem *dest) | 713 SECItem *dest) |
714 { | 714 { |
715 SECStatus rv = SECSuccess; | 715 SECStatus rv = SECSuccess; |
716 | 716 |
717 PORT_Assert(constr != NULL && dest != NULL); | 717 PORT_Assert(constr != NULL && dest != NULL); |
718 if (constr == NULL || dest == NULL) { | 718 if (constr == NULL || dest == NULL) { |
719 return SECFailure; | 719 return SECFailure; |
720 } | 720 } |
721 | 721 |
722 if (SEC_ASN1EncodeItem (arena, dest, constr, | 722 if (SEC_ASN1EncodeItem (arena, dest, constr, |
723 CERT_PolicyConstraintsTemplate) == NULL) { | 723 CERT_PolicyConstraintsTemplate) == NULL) { |
724 rv = SECFailure; | 724 rv = SECFailure; |
725 } | 725 } |
726 return(rv); | 726 return(rv); |
727 } | 727 } |
728 | 728 |
729 SECStatus | 729 SECStatus |
730 CERT_EncodePolicyMappingExtension(PRArenaPool *arena, | 730 CERT_EncodePolicyMappingExtension(PLArenaPool *arena, |
731 CERTCertificatePolicyMappings *mapping, | 731 CERTCertificatePolicyMappings *mapping, |
732 SECItem *dest) | 732 SECItem *dest) |
733 { | 733 { |
734 SECStatus rv = SECSuccess; | 734 SECStatus rv = SECSuccess; |
735 | 735 |
736 PORT_Assert(mapping != NULL && dest != NULL); | 736 PORT_Assert(mapping != NULL && dest != NULL); |
737 if (mapping == NULL || dest == NULL) { | 737 if (mapping == NULL || dest == NULL) { |
738 return SECFailure; | 738 return SECFailure; |
739 } | 739 } |
740 | 740 |
741 if (SEC_ASN1EncodeItem (arena, dest, mapping, | 741 if (SEC_ASN1EncodeItem (arena, dest, mapping, |
742 CERT_PolicyMappingsTemplate) == NULL) { | 742 CERT_PolicyMappingsTemplate) == NULL) { |
743 rv = SECFailure; | 743 rv = SECFailure; |
744 } | 744 } |
745 return(rv); | 745 return(rv); |
746 } | 746 } |
747 | 747 |
748 | 748 |
749 | 749 |
750 SECStatus | 750 SECStatus |
751 CERT_EncodeCertPoliciesExtension(PRArenaPool *arena, | 751 CERT_EncodeCertPoliciesExtension(PLArenaPool *arena, |
752 CERTPolicyInfo **info, | 752 CERTPolicyInfo **info, |
753 SECItem *dest) | 753 SECItem *dest) |
754 { | 754 { |
755 SECStatus rv = SECSuccess; | 755 SECStatus rv = SECSuccess; |
756 | 756 |
757 PORT_Assert(info != NULL && dest != NULL); | 757 PORT_Assert(info != NULL && dest != NULL); |
758 if (info == NULL || dest == NULL) { | 758 if (info == NULL || dest == NULL) { |
759 return SECFailure; | 759 return SECFailure; |
760 } | 760 } |
761 | 761 |
762 if (SEC_ASN1EncodeItem (arena, dest, info, | 762 if (SEC_ASN1EncodeItem (arena, dest, info, |
763 CERT_CertificatePoliciesTemplate) == NULL) { | 763 CERT_CertificatePoliciesTemplate) == NULL) { |
764 rv = SECFailure; | 764 rv = SECFailure; |
765 } | 765 } |
766 return(rv); | 766 return(rv); |
767 } | 767 } |
768 | 768 |
769 SECStatus | 769 SECStatus |
770 CERT_EncodeUserNotice(PRArenaPool *arena, | 770 CERT_EncodeUserNotice(PLArenaPool *arena, |
771 CERTUserNotice *notice, | 771 CERTUserNotice *notice, |
772 SECItem *dest) | 772 SECItem *dest) |
773 { | 773 { |
774 SECStatus rv = SECSuccess; | 774 SECStatus rv = SECSuccess; |
775 | 775 |
776 PORT_Assert(notice != NULL && dest != NULL); | 776 PORT_Assert(notice != NULL && dest != NULL); |
777 if (notice == NULL || dest == NULL) { | 777 if (notice == NULL || dest == NULL) { |
778 return SECFailure; | 778 return SECFailure; |
779 } | 779 } |
780 | 780 |
781 if (SEC_ASN1EncodeItem(arena, dest, | 781 if (SEC_ASN1EncodeItem(arena, dest, |
782 notice, CERT_UserNoticeTemplate) == NULL) { | 782 notice, CERT_UserNoticeTemplate) == NULL) { |
783 rv = SECFailure; | 783 rv = SECFailure; |
784 } | 784 } |
785 | 785 |
786 return(rv); | 786 return(rv); |
787 } | 787 } |
788 | 788 |
789 SECStatus | 789 SECStatus |
790 CERT_EncodeNoticeReference(PRArenaPool *arena, | 790 CERT_EncodeNoticeReference(PLArenaPool *arena, |
791 CERTNoticeReference *reference, | 791 CERTNoticeReference *reference, |
792 SECItem *dest) | 792 SECItem *dest) |
793 { | 793 { |
794 SECStatus rv = SECSuccess; | 794 SECStatus rv = SECSuccess; |
795 | 795 |
796 PORT_Assert(reference != NULL && dest != NULL); | 796 PORT_Assert(reference != NULL && dest != NULL); |
797 if (reference == NULL || dest == NULL) { | 797 if (reference == NULL || dest == NULL) { |
798 return SECFailure; | 798 return SECFailure; |
799 } | 799 } |
800 | 800 |
801 if (SEC_ASN1EncodeItem (arena, dest, reference, | 801 if (SEC_ASN1EncodeItem (arena, dest, reference, |
802 CERT_NoticeReferenceTemplate) == NULL) { | 802 CERT_NoticeReferenceTemplate) == NULL) { |
803 rv = SECFailure; | 803 rv = SECFailure; |
804 } | 804 } |
805 | 805 |
806 return(rv); | 806 return(rv); |
807 } | 807 } |
808 | 808 |
809 SECStatus | 809 SECStatus |
810 CERT_EncodeInhibitAnyExtension(PRArenaPool *arena, | 810 CERT_EncodeInhibitAnyExtension(PLArenaPool *arena, |
811 CERTCertificateInhibitAny *certInhibitAny, | 811 CERTCertificateInhibitAny *certInhibitAny, |
812 SECItem *dest) | 812 SECItem *dest) |
813 { | 813 { |
814 SECStatus rv = SECSuccess; | 814 SECStatus rv = SECSuccess; |
815 | 815 |
816 PORT_Assert(certInhibitAny != NULL && dest != NULL); | 816 PORT_Assert(certInhibitAny != NULL && dest != NULL); |
817 if (certInhibitAny == NULL || dest == NULL) { | 817 if (certInhibitAny == NULL || dest == NULL) { |
818 return SECFailure; | 818 return SECFailure; |
819 } | 819 } |
820 | 820 |
821 if (SEC_ASN1EncodeItem (arena, dest, certInhibitAny, | 821 if (SEC_ASN1EncodeItem (arena, dest, certInhibitAny, |
822 CERT_InhibitAnyTemplate) == NULL) { | 822 CERT_InhibitAnyTemplate) == NULL) { |
823 rv = SECFailure; | 823 rv = SECFailure; |
824 } | 824 } |
825 return(rv); | 825 return(rv); |
826 } | 826 } |
OLD | NEW |