diff options
Diffstat (limited to 'src/lib/libcrypto/cms/cms_ess.c')
| -rw-r--r-- | src/lib/libcrypto/cms/cms_ess.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/lib/libcrypto/cms/cms_ess.c b/src/lib/libcrypto/cms/cms_ess.c index 5f0ab4995b..1d3f092ae8 100644 --- a/src/lib/libcrypto/cms/cms_ess.c +++ b/src/lib/libcrypto/cms/cms_ess.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_ess.c,v 1.15 2019/08/11 10:15:30 jsing Exp $ */ | 1 | /* $OpenBSD: cms_ess.c,v 1.16 2019/08/11 10:38:27 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -145,7 +145,7 @@ CMS_ReceiptRequest_create0(unsigned char *id, int idlen, int allorfirst, | |||
| 145 | return rr; | 145 | return rr; |
| 146 | 146 | ||
| 147 | merr: | 147 | merr: |
| 148 | CMSerr(CMS_F_CMS_RECEIPTREQUEST_CREATE0, ERR_R_MALLOC_FAILURE); | 148 | CMSerror(ERR_R_MALLOC_FAILURE); |
| 149 | 149 | ||
| 150 | err: | 150 | err: |
| 151 | CMS_ReceiptRequest_free(rr); | 151 | CMS_ReceiptRequest_free(rr); |
| @@ -170,7 +170,7 @@ CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr) | |||
| 170 | 170 | ||
| 171 | merr: | 171 | merr: |
| 172 | if (!r) | 172 | if (!r) |
| 173 | CMSerr(CMS_F_CMS_ADD1_RECEIPTREQUEST, ERR_R_MALLOC_FAILURE); | 173 | CMSerror(ERR_R_MALLOC_FAILURE); |
| 174 | 174 | ||
| 175 | OPENSSL_free(rrder); | 175 | OPENSSL_free(rrder); |
| 176 | 176 | ||
| @@ -225,12 +225,12 @@ cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src) | |||
| 225 | unsigned int diglen; | 225 | unsigned int diglen; |
| 226 | 226 | ||
| 227 | if (!cms_msgSigDigest(src, dig, &diglen)) { | 227 | if (!cms_msgSigDigest(src, dig, &diglen)) { |
| 228 | CMSerr(CMS_F_CMS_MSGSIGDIGEST_ADD1, CMS_R_MSGSIGDIGEST_ERROR); | 228 | CMSerror(CMS_R_MSGSIGDIGEST_ERROR); |
| 229 | return 0; | 229 | return 0; |
| 230 | } | 230 | } |
| 231 | if (!CMS_signed_add1_attr_by_NID(dest, NID_id_smime_aa_msgSigDigest, | 231 | if (!CMS_signed_add1_attr_by_NID(dest, NID_id_smime_aa_msgSigDigest, |
| 232 | V_ASN1_OCTET_STRING, dig, diglen)) { | 232 | V_ASN1_OCTET_STRING, dig, diglen)) { |
| 233 | CMSerr(CMS_F_CMS_MSGSIGDIGEST_ADD1, ERR_R_MALLOC_FAILURE); | 233 | CMSerror(ERR_R_MALLOC_FAILURE); |
| 234 | return 0; | 234 | return 0; |
| 235 | } | 235 | } |
| 236 | 236 | ||
| @@ -259,27 +259,27 @@ cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) | |||
| 259 | goto err; | 259 | goto err; |
| 260 | 260 | ||
| 261 | if (sk_CMS_SignerInfo_num(sis) != 1) { | 261 | if (sk_CMS_SignerInfo_num(sis) != 1) { |
| 262 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NEED_ONE_SIGNER); | 262 | CMSerror(CMS_R_NEED_ONE_SIGNER); |
| 263 | goto err; | 263 | goto err; |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | /* Check receipt content type */ | 266 | /* Check receipt content type */ |
| 267 | if (OBJ_obj2nid(CMS_get0_eContentType(cms)) != NID_id_smime_ct_receipt) { | 267 | if (OBJ_obj2nid(CMS_get0_eContentType(cms)) != NID_id_smime_ct_receipt) { |
| 268 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NOT_A_SIGNED_RECEIPT); | 268 | CMSerror(CMS_R_NOT_A_SIGNED_RECEIPT); |
| 269 | goto err; | 269 | goto err; |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | /* Extract and decode receipt content */ | 272 | /* Extract and decode receipt content */ |
| 273 | pcont = CMS_get0_content(cms); | 273 | pcont = CMS_get0_content(cms); |
| 274 | if (!pcont || !*pcont) { | 274 | if (!pcont || !*pcont) { |
| 275 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_CONTENT); | 275 | CMSerror(CMS_R_NO_CONTENT); |
| 276 | goto err; | 276 | goto err; |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | rct = ASN1_item_unpack(*pcont, &CMS_Receipt_it); | 279 | rct = ASN1_item_unpack(*pcont, &CMS_Receipt_it); |
| 280 | 280 | ||
| 281 | if (!rct) { | 281 | if (!rct) { |
| 282 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_RECEIPT_DECODE_ERROR); | 282 | CMSerror(CMS_R_RECEIPT_DECODE_ERROR); |
| 283 | goto err; | 283 | goto err; |
| 284 | } | 284 | } |
| 285 | 285 | ||
| @@ -292,7 +292,7 @@ cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) | |||
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | if (i == sk_CMS_SignerInfo_num(osis)) { | 294 | if (i == sk_CMS_SignerInfo_num(osis)) { |
| 295 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_MATCHING_SIGNATURE); | 295 | CMSerror(CMS_R_NO_MATCHING_SIGNATURE); |
| 296 | goto err; | 296 | goto err; |
| 297 | } | 297 | } |
| 298 | 298 | ||
| @@ -304,23 +304,22 @@ cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) | |||
| 304 | OBJ_nid2obj(NID_id_smime_aa_msgSigDigest), -3, V_ASN1_OCTET_STRING); | 304 | OBJ_nid2obj(NID_id_smime_aa_msgSigDigest), -3, V_ASN1_OCTET_STRING); |
| 305 | 305 | ||
| 306 | if (!msig) { | 306 | if (!msig) { |
| 307 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_MSGSIGDIGEST); | 307 | CMSerror(CMS_R_NO_MSGSIGDIGEST); |
| 308 | goto err; | 308 | goto err; |
| 309 | } | 309 | } |
| 310 | 310 | ||
| 311 | if (!cms_msgSigDigest(osi, dig, &diglen)) { | 311 | if (!cms_msgSigDigest(osi, dig, &diglen)) { |
| 312 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_MSGSIGDIGEST_ERROR); | 312 | CMSerror(CMS_R_MSGSIGDIGEST_ERROR); |
| 313 | goto err; | 313 | goto err; |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | if (diglen != (unsigned int)msig->length) { | 316 | if (diglen != (unsigned int)msig->length) { |
| 317 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_MSGSIGDIGEST_WRONG_LENGTH); | 317 | CMSerror(CMS_R_MSGSIGDIGEST_WRONG_LENGTH); |
| 318 | goto err; | 318 | goto err; |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | if (memcmp(dig, msig->data, diglen)) { | 321 | if (memcmp(dig, msig->data, diglen)) { |
| 322 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, | 322 | CMSerror(CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE); |
| 323 | CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE); | ||
| 324 | goto err; | 323 | goto err; |
| 325 | } | 324 | } |
| 326 | 325 | ||
| @@ -329,27 +328,27 @@ cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) | |||
| 329 | octype = CMS_signed_get0_data_by_OBJ(osi, | 328 | octype = CMS_signed_get0_data_by_OBJ(osi, |
| 330 | OBJ_nid2obj(NID_pkcs9_contentType), -3, V_ASN1_OBJECT); | 329 | OBJ_nid2obj(NID_pkcs9_contentType), -3, V_ASN1_OBJECT); |
| 331 | if (!octype) { | 330 | if (!octype) { |
| 332 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_CONTENT_TYPE); | 331 | CMSerror(CMS_R_NO_CONTENT_TYPE); |
| 333 | goto err; | 332 | goto err; |
| 334 | } | 333 | } |
| 335 | 334 | ||
| 336 | /* Compare details in receipt request */ | 335 | /* Compare details in receipt request */ |
| 337 | 336 | ||
| 338 | if (OBJ_cmp(octype, rct->contentType)) { | 337 | if (OBJ_cmp(octype, rct->contentType)) { |
| 339 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_CONTENT_TYPE_MISMATCH); | 338 | CMSerror(CMS_R_CONTENT_TYPE_MISMATCH); |
| 340 | goto err; | 339 | goto err; |
| 341 | } | 340 | } |
| 342 | 341 | ||
| 343 | /* Get original receipt request details */ | 342 | /* Get original receipt request details */ |
| 344 | 343 | ||
| 345 | if (CMS_get1_ReceiptRequest(osi, &rr) <= 0) { | 344 | if (CMS_get1_ReceiptRequest(osi, &rr) <= 0) { |
| 346 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_RECEIPT_REQUEST); | 345 | CMSerror(CMS_R_NO_RECEIPT_REQUEST); |
| 347 | goto err; | 346 | goto err; |
| 348 | } | 347 | } |
| 349 | 348 | ||
| 350 | if (ASN1_STRING_cmp(rr->signedContentIdentifier, | 349 | if (ASN1_STRING_cmp(rr->signedContentIdentifier, |
| 351 | rct->signedContentIdentifier)) { | 350 | rct->signedContentIdentifier)) { |
| 352 | CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_CONTENTIDENTIFIER_MISMATCH); | 351 | CMSerror(CMS_R_CONTENTIDENTIFIER_MISMATCH); |
| 353 | goto err; | 352 | goto err; |
| 354 | } | 353 | } |
| 355 | 354 | ||
| @@ -379,7 +378,7 @@ cms_encode_Receipt(CMS_SignerInfo *si) | |||
| 379 | /* Get original receipt request details */ | 378 | /* Get original receipt request details */ |
| 380 | 379 | ||
| 381 | if (CMS_get1_ReceiptRequest(si, &rr) <= 0) { | 380 | if (CMS_get1_ReceiptRequest(si, &rr) <= 0) { |
| 382 | CMSerr(CMS_F_CMS_ENCODE_RECEIPT, CMS_R_NO_RECEIPT_REQUEST); | 381 | CMSerror(CMS_R_NO_RECEIPT_REQUEST); |
| 383 | goto err; | 382 | goto err; |
| 384 | } | 383 | } |
| 385 | 384 | ||
| @@ -388,7 +387,7 @@ cms_encode_Receipt(CMS_SignerInfo *si) | |||
| 388 | ctype = CMS_signed_get0_data_by_OBJ(si, | 387 | ctype = CMS_signed_get0_data_by_OBJ(si, |
| 389 | OBJ_nid2obj(NID_pkcs9_contentType), -3, V_ASN1_OBJECT); | 388 | OBJ_nid2obj(NID_pkcs9_contentType), -3, V_ASN1_OBJECT); |
| 390 | if (!ctype) { | 389 | if (!ctype) { |
| 391 | CMSerr(CMS_F_CMS_ENCODE_RECEIPT, CMS_R_NO_CONTENT_TYPE); | 390 | CMSerror(CMS_R_NO_CONTENT_TYPE); |
| 392 | goto err; | 391 | goto err; |
| 393 | } | 392 | } |
| 394 | 393 | ||
