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 * PKCS7 decoding, verification. | 6 * PKCS7 decoding, verification. |
7 */ | 7 */ |
8 | 8 |
9 #include "p7local.h" | 9 #include "p7local.h" |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 }; | 37 }; |
38 | 38 |
39 struct SEC_PKCS7DecoderContextStr { | 39 struct SEC_PKCS7DecoderContextStr { |
40 SEC_ASN1DecoderContext *dcx; | 40 SEC_ASN1DecoderContext *dcx; |
41 SEC_PKCS7ContentInfo *cinfo; | 41 SEC_PKCS7ContentInfo *cinfo; |
42 SEC_PKCS7DecoderContentCallback cb; | 42 SEC_PKCS7DecoderContentCallback cb; |
43 void *cb_arg; | 43 void *cb_arg; |
44 SECKEYGetPasswordKey pwfn; | 44 SECKEYGetPasswordKey pwfn; |
45 void *pwfn_arg; | 45 void *pwfn_arg; |
46 struct sec_pkcs7_decoder_worker worker; | 46 struct sec_pkcs7_decoder_worker worker; |
47 PRArenaPool *tmp_poolp; | 47 PLArenaPool *tmp_poolp; |
48 int error; | 48 int error; |
49 SEC_PKCS7GetDecryptKeyCallback dkcb; | 49 SEC_PKCS7GetDecryptKeyCallback dkcb; |
50 void *dkcb_arg; | 50 void *dkcb_arg; |
51 SEC_PKCS7DecryptionAllowedCallback decrypt_allowed_cb; | 51 SEC_PKCS7DecryptionAllowedCallback decrypt_allowed_cb; |
52 }; | 52 }; |
53 | 53 |
54 /* | 54 /* |
55 * Handle one worker, decrypting and digesting the data as necessary. | 55 * Handle one worker, decrypting and digesting the data as necessary. |
56 * | 56 * |
57 * XXX If/when we support nested contents, this probably needs to be | 57 * XXX If/when we support nested contents, this probably needs to be |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 (PRBool)(p7dcx->cb != NULL)); | 299 (PRBool)(p7dcx->cb != NULL)); |
300 return SECSuccess; | 300 return SECSuccess; |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 /* | 304 /* |
305 * Close out all of the digest contexts, storing the results in "digestsp". | 305 * Close out all of the digest contexts, storing the results in "digestsp". |
306 */ | 306 */ |
307 static SECStatus | 307 static SECStatus |
308 sec_pkcs7_decoder_finish_digests (SEC_PKCS7DecoderContext *p7dcx, | 308 sec_pkcs7_decoder_finish_digests (SEC_PKCS7DecoderContext *p7dcx, |
309 » » » » PRArenaPool *poolp, | 309 » » » » PLArenaPool *poolp, |
310 SECItem ***digestsp) | 310 SECItem ***digestsp) |
311 { | 311 { |
312 struct sec_pkcs7_decoder_worker *worker; | 312 struct sec_pkcs7_decoder_worker *worker; |
313 const SECHashObject *digobj; | 313 const SECHashObject *digobj; |
314 void *digcx; | 314 void *digcx; |
315 SECItem **digests, *digest; | 315 SECItem **digests, *digest; |
316 int i; | 316 int i; |
317 void *mark; | 317 void *mark; |
318 | 318 |
319 /* | 319 /* |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 */ | 576 */ |
577 if (p7dcx->cb != NULL) | 577 if (p7dcx->cb != NULL) |
578 return SECFailure; | 578 return SECFailure; |
579 else | 579 else |
580 return SECSuccess; /* Let the decoding continue. */ | 580 return SECSuccess; /* Let the decoding continue. */ |
581 } | 581 } |
582 | 582 |
583 | 583 |
584 static SECStatus | 584 static SECStatus |
585 sec_pkcs7_decoder_finish_decrypt (SEC_PKCS7DecoderContext *p7dcx, | 585 sec_pkcs7_decoder_finish_decrypt (SEC_PKCS7DecoderContext *p7dcx, |
586 » » » » PRArenaPool *poolp, | 586 » » » » PLArenaPool *poolp, |
587 SEC_PKCS7EncryptedContentInfo *enccinfo) | 587 SEC_PKCS7EncryptedContentInfo *enccinfo) |
588 { | 588 { |
589 struct sec_pkcs7_decoder_worker *worker; | 589 struct sec_pkcs7_decoder_worker *worker; |
590 | 590 |
591 /* | 591 /* |
592 * XXX Handling nested contents would mean that there is a chain | 592 * XXX Handling nested contents would mean that there is a chain |
593 * of workers -- one per each level of content. The following | 593 * of workers -- one per each level of content. The following |
594 * would want to find the last worker in the chain. | 594 * would want to find the last worker in the chain. |
595 */ | 595 */ |
596 worker = &(p7dcx->worker); | 596 worker = &(p7dcx->worker); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 SEC_PKCS7DecoderContext * | 951 SEC_PKCS7DecoderContext * |
952 SEC_PKCS7DecoderStart(SEC_PKCS7DecoderContentCallback cb, void *cb_arg, | 952 SEC_PKCS7DecoderStart(SEC_PKCS7DecoderContentCallback cb, void *cb_arg, |
953 SECKEYGetPasswordKey pwfn, void *pwfn_arg, | 953 SECKEYGetPasswordKey pwfn, void *pwfn_arg, |
954 SEC_PKCS7GetDecryptKeyCallback decrypt_key_cb, | 954 SEC_PKCS7GetDecryptKeyCallback decrypt_key_cb, |
955 void *decrypt_key_cb_arg, | 955 void *decrypt_key_cb_arg, |
956 SEC_PKCS7DecryptionAllowedCallback decrypt_allowed_cb) | 956 SEC_PKCS7DecryptionAllowedCallback decrypt_allowed_cb) |
957 { | 957 { |
958 SEC_PKCS7DecoderContext *p7dcx; | 958 SEC_PKCS7DecoderContext *p7dcx; |
959 SEC_ASN1DecoderContext *dcx; | 959 SEC_ASN1DecoderContext *dcx; |
960 SEC_PKCS7ContentInfo *cinfo; | 960 SEC_PKCS7ContentInfo *cinfo; |
961 PRArenaPool *poolp; | 961 PLArenaPool *poolp; |
962 | 962 |
963 poolp = PORT_NewArena (1024); /* XXX what is right value? */ | 963 poolp = PORT_NewArena (1024); /* XXX what is right value? */ |
964 if (poolp == NULL) | 964 if (poolp == NULL) |
965 return NULL; | 965 return NULL; |
966 | 966 |
967 cinfo = (SEC_PKCS7ContentInfo*)PORT_ArenaZAlloc (poolp, sizeof(*cinfo)); | 967 cinfo = (SEC_PKCS7ContentInfo*)PORT_ArenaZAlloc (poolp, sizeof(*cinfo)); |
968 if (cinfo == NULL) { | 968 if (cinfo == NULL) { |
969 PORT_FreeArena (poolp, PR_FALSE); | 969 PORT_FreeArena (poolp, PR_FALSE); |
970 return NULL; | 970 return NULL; |
971 } | 971 } |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1923 /* | 1923 /* |
1924 * No signature, or more than one, means no deal. | 1924 * No signature, or more than one, means no deal. |
1925 */ | 1925 */ |
1926 if (signerinfos == NULL || signerinfos[0] == NULL || signerinfos[1] != NULL) | 1926 if (signerinfos == NULL || signerinfos[0] == NULL || signerinfos[1] != NULL) |
1927 return NULL; | 1927 return NULL; |
1928 | 1928 |
1929 attr = sec_PKCS7FindAttribute (signerinfos[0]->authAttr, | 1929 attr = sec_PKCS7FindAttribute (signerinfos[0]->authAttr, |
1930 SEC_OID_PKCS9_SIGNING_TIME, PR_TRUE); | 1930 SEC_OID_PKCS9_SIGNING_TIME, PR_TRUE); |
1931 return sec_PKCS7AttributeValue (attr); | 1931 return sec_PKCS7AttributeValue (attr); |
1932 } | 1932 } |
OLD | NEW |