Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/cms/cms_io.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /* | - | ||||||
2 | * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||
3 | * | - | ||||||
4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||
5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||
6 | * in the file LICENSE in the source distribution or at | - | ||||||
7 | * https://www.openssl.org/source/license.html | - | ||||||
8 | */ | - | ||||||
9 | - | |||||||
10 | #include <openssl/asn1t.h> | - | ||||||
11 | #include <openssl/x509.h> | - | ||||||
12 | #include <openssl/err.h> | - | ||||||
13 | #include <openssl/pem.h> | - | ||||||
14 | #include <openssl/cms.h> | - | ||||||
15 | #include "cms_lcl.h" | - | ||||||
16 | - | |||||||
17 | int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) | - | ||||||
18 | { | - | ||||||
19 | ASN1_OCTET_STRING **pos; | - | ||||||
20 | pos = CMS_get0_content(cms); | - | ||||||
21 | if (pos == NULL)
| 0-36 | ||||||
22 | return 0; never executed: return 0; | 0 | ||||||
23 | if (*pos == NULL)
| 0-36 | ||||||
24 | *pos = ASN1_OCTET_STRING_new(); never executed: *pos = ASN1_OCTET_STRING_new(); | 0 | ||||||
25 | if (*pos != NULL) {
| 0-36 | ||||||
26 | (*pos)->flags |= ASN1_STRING_FLAG_NDEF; | - | ||||||
27 | (*pos)->flags &= ~ASN1_STRING_FLAG_CONT; | - | ||||||
28 | *boundary = &(*pos)->data; | - | ||||||
29 | return 1; executed 36 times by 1 test: return 1; Executed by:
| 36 | ||||||
30 | } | - | ||||||
31 | CMSerr(CMS_F_CMS_STREAM, ERR_R_MALLOC_FAILURE); | - | ||||||
32 | return 0; never executed: return 0; | 0 | ||||||
33 | } | - | ||||||
34 | - | |||||||
35 | CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms) | - | ||||||
36 | { | - | ||||||
37 | return ASN1_item_d2i_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); executed 1409 times by 1 test: return ASN1_item_d2i_bio((&(CMS_ContentInfo_it)), bp, cms); Executed by:
| 1409 | ||||||
38 | } | - | ||||||
39 | - | |||||||
40 | int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms) | - | ||||||
41 | { | - | ||||||
42 | return ASN1_item_i2d_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); executed 280 times by 1 test: return ASN1_item_i2d_bio((&(CMS_ContentInfo_it)), bp, cms); Executed by:
| 280 | ||||||
43 | } | - | ||||||
44 | - | |||||||
45 | IMPLEMENT_PEM_rw_const(CMS, CMS_ContentInfo, PEM_STRING_CMS, CMS_ContentInfo) executed 11 times by 1 test: return PEM_ASN1_read_bio((d2i_of_void *)d2i_CMS_ContentInfo, "CMS",bp,(void **)x,cb,u); Executed by:
never executed: return PEM_ASN1_read((d2i_of_void *)d2i_CMS_ContentInfo, "CMS",fp,(void **)x,cb,u); never executed: return PEM_ASN1_write_bio((i2d_of_void *)i2d_CMS_ContentInfo,"CMS",bp,(void *)x, ((void *)0) , ((void *)0) ,0, ((void *)0) , ((void *)0) ); never executed: return PEM_ASN1_write((i2d_of_void *)i2d_CMS_ContentInfo,"CMS",fp,(void *)x, ((void *)0) , ((void *)0) ,0, ((void *)0) , ((void *)0) ); | 0-11 | ||||||
46 | - | |||||||
47 | BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms) | - | ||||||
48 | { | - | ||||||
49 | return BIO_new_NDEF(out, (ASN1_VALUE *)cms, never executed: return BIO_new_NDEF(out, (ASN1_VALUE *)cms, (&(CMS_ContentInfo_it))); | 0 | ||||||
50 | ASN1_ITEM_rptr(CMS_ContentInfo)); never executed: return BIO_new_NDEF(out, (ASN1_VALUE *)cms, (&(CMS_ContentInfo_it))); | 0 | ||||||
51 | } | - | ||||||
52 | - | |||||||
53 | /* CMS wrappers round generalised stream and MIME routines */ | - | ||||||
54 | - | |||||||
55 | int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags) | - | ||||||
56 | { | - | ||||||
57 | return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)cms, in, flags, executed 19 times by 1 test: return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)cms, in, flags, (&(CMS_ContentInfo_it))); Executed by:
| 19 | ||||||
58 | ASN1_ITEM_rptr(CMS_ContentInfo)); executed 19 times by 1 test: return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)cms, in, flags, (&(CMS_ContentInfo_it))); Executed by:
| 19 | ||||||
59 | } | - | ||||||
60 | - | |||||||
61 | int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, | - | ||||||
62 | int flags) | - | ||||||
63 | { | - | ||||||
64 | return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *)cms, in, flags, executed 11 times by 1 test: return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *)cms, in, flags, "CMS", (&(CMS_ContentInfo_it))); Executed by:
| 11 | ||||||
65 | "CMS", ASN1_ITEM_rptr(CMS_ContentInfo)); executed 11 times by 1 test: return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *)cms, in, flags, "CMS", (&(CMS_ContentInfo_it))); Executed by:
| 11 | ||||||
66 | } | - | ||||||
67 | - | |||||||
68 | int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags) | - | ||||||
69 | { | - | ||||||
70 | STACK_OF(X509_ALGOR) *mdalgs; | - | ||||||
71 | int ctype_nid = OBJ_obj2nid(cms->contentType); | - | ||||||
72 | int econt_nid = OBJ_obj2nid(CMS_get0_eContentType(cms)); | - | ||||||
73 | if (ctype_nid == NID_pkcs7_signed)
| 8-17 | ||||||
74 | mdalgs = cms->d.signedData->digestAlgorithms; executed 8 times by 1 test: mdalgs = cms->d.signedData->digestAlgorithms; Executed by:
| 8 | ||||||
75 | else | - | ||||||
76 | mdalgs = NULL; executed 17 times by 1 test: mdalgs = ((void *)0) ; Executed by:
| 17 | ||||||
77 | - | |||||||
78 | return SMIME_write_ASN1(bio, (ASN1_VALUE *)cms, data, flags, executed 25 times by 1 test: return SMIME_write_ASN1(bio, (ASN1_VALUE *)cms, data, flags, ctype_nid, econt_nid, mdalgs, (&(CMS_ContentInfo_it))); Executed by:
| 25 | ||||||
79 | ctype_nid, econt_nid, mdalgs, executed 25 times by 1 test: return SMIME_write_ASN1(bio, (ASN1_VALUE *)cms, data, flags, ctype_nid, econt_nid, mdalgs, (&(CMS_ContentInfo_it))); Executed by:
| 25 | ||||||
80 | ASN1_ITEM_rptr(CMS_ContentInfo)); executed 25 times by 1 test: return SMIME_write_ASN1(bio, (ASN1_VALUE *)cms, data, flags, ctype_nid, econt_nid, mdalgs, (&(CMS_ContentInfo_it))); Executed by:
| 25 | ||||||
81 | } | - | ||||||
82 | - | |||||||
83 | CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont) | - | ||||||
84 | { | - | ||||||
85 | return (CMS_ContentInfo *)SMIME_read_ASN1(bio, bcont, executed 27 times by 1 test: return (CMS_ContentInfo *)SMIME_read_ASN1(bio, bcont, (&(CMS_ContentInfo_it)) ); Executed by:
| 27 | ||||||
86 | ASN1_ITEM_rptr executed 27 times by 1 test: return (CMS_ContentInfo *)SMIME_read_ASN1(bio, bcont, (&(CMS_ContentInfo_it)) ); Executed by:
| 27 | ||||||
87 | (CMS_ContentInfo)); executed 27 times by 1 test: return (CMS_ContentInfo *)SMIME_read_ASN1(bio, bcont, (&(CMS_ContentInfo_it)) ); Executed by:
| 27 | ||||||
88 | } | - | ||||||
Source code | Switch to Preprocessed file |