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 routines for PKCS7 implementation, none of which are exported. | 6 * Support routines for PKCS7 implementation, none of which are exported. |
7 * This file should only contain things that are needed by both the | 7 * This file should only contain things that are needed by both the |
8 * encoding/creation side *and* the decoding/decryption side. Anything | 8 * encoding/creation side *and* the decoding/decryption side. Anything |
9 * else should be static routines in the appropriate file. | 9 * else should be static routines in the appropriate file. |
10 */ | 10 */ |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 196 |
197 /* | 197 /* |
198 * These are placed after the CreateContextBySymKey() because some | 198 * These are placed after the CreateContextBySymKey() because some |
199 * mechanisms have to generate their IVs from their card (i.e. FORTEZZA). | 199 * mechanisms have to generate their IVs from their card (i.e. FORTEZZA). |
200 * Don't move it from here. | 200 * Don't move it from here. |
201 */ | 201 */ |
202 if (needToEncodeAlgid) { | 202 if (needToEncodeAlgid) { |
203 rv = PK11_ParamToAlgid(algtag,param,poolp,algid); | 203 rv = PK11_ParamToAlgid(algtag,param,poolp,algid); |
204 if(rv != SECSuccess) { | 204 if(rv != SECSuccess) { |
205 PORT_Free (result); | 205 PORT_Free (result); |
206 SECITEM_FreeItem(param,PR_TRUE); | 206 » SECITEM_FreeItem(param,PR_TRUE); |
| 207 » PK11_DestroyContext(ciphercx, PR_TRUE); |
207 return NULL; | 208 return NULL; |
208 } | 209 } |
209 } | 210 } |
210 SECITEM_FreeItem(param,PR_TRUE); | 211 SECITEM_FreeItem(param,PR_TRUE); |
211 | 212 |
212 result->cx = ciphercx; | 213 result->cx = ciphercx; |
213 result->doit = (sec_pkcs7_cipher_function) PK11_CipherOp; | 214 result->doit = (sec_pkcs7_cipher_function) PK11_CipherOp; |
214 result->destroy = (sec_pkcs7_cipher_destroy) PK11_DestroyContext; | 215 result->destroy = (sec_pkcs7_cipher_destroy) PK11_DestroyContext; |
215 result->encrypt = PR_TRUE; | 216 result->encrypt = PR_TRUE; |
216 result->pending_count = 0; | 217 result->pending_count = 0; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 * the same as the length of the padding, and that all data is padded. | 391 * the same as the length of the padding, and that all data is padded. |
391 * (Even data that starts out with an exact multiple of blocks gets | 392 * (Even data that starts out with an exact multiple of blocks gets |
392 * added to it another block, all of which is padding.) | 393 * added to it another block, all of which is padding.) |
393 */ | 394 */ |
394 SECStatus | 395 SECStatus |
395 sec_PKCS7Decrypt (sec_PKCS7CipherObject *obj, unsigned char *output, | 396 sec_PKCS7Decrypt (sec_PKCS7CipherObject *obj, unsigned char *output, |
396 unsigned int *output_len_p, unsigned int max_output_len, | 397 unsigned int *output_len_p, unsigned int max_output_len, |
397 const unsigned char *input, unsigned int input_len, | 398 const unsigned char *input, unsigned int input_len, |
398 PRBool final) | 399 PRBool final) |
399 { | 400 { |
400 int blocks, bsize, pcount, padsize; | 401 unsigned int blocks, bsize, pcount, padsize; |
401 unsigned int max_needed, ifraglen, ofraglen, output_len; | 402 unsigned int max_needed, ifraglen, ofraglen, output_len; |
402 unsigned char *pbuf; | 403 unsigned char *pbuf; |
403 SECStatus rv; | 404 SECStatus rv; |
404 | 405 |
405 PORT_Assert (! obj->encrypt); | 406 PORT_Assert (! obj->encrypt); |
406 | 407 |
407 /* | 408 /* |
408 * Check that we have enough room for the output. Our caller should | 409 * Check that we have enough room for the output. Our caller should |
409 * already handle this; failure is really an internal error (i.e. bug). | 410 * already handle this; failure is really an internal error (i.e. bug). |
410 */ | 411 */ |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 theTemplate = SEC_PointerToPKCS7EncryptedDataTemplate; | 1311 theTemplate = SEC_PointerToPKCS7EncryptedDataTemplate; |
1311 break; | 1312 break; |
1312 } | 1313 } |
1313 return theTemplate; | 1314 return theTemplate; |
1314 } | 1315 } |
1315 | 1316 |
1316 /* | 1317 /* |
1317 * End of templates. Do not add stuff after this; put new code | 1318 * End of templates. Do not add stuff after this; put new code |
1318 * up above the start of the template definitions. | 1319 * up above the start of the template definitions. |
1319 */ | 1320 */ |
OLD | NEW |