Coverage Report

Created: 2018-08-29 13:53

/src/openssl/crypto/cms/cms_att.c
Line
Count
Source (jump to first uncovered line)
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/pem.h>
12
#include <openssl/x509v3.h>
13
#include <openssl/err.h>
14
#include <openssl/cms.h>
15
#include "cms_lcl.h"
16
17
/* CMS SignedData Attribute utilities */
18
19
int CMS_signed_get_attr_count(const CMS_SignerInfo *si)
20
0
{
21
0
    return X509at_get_attr_count(si->signedAttrs);
22
0
}
23
24
int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid, int lastpos)
25
0
{
26
0
    return X509at_get_attr_by_NID(si->signedAttrs, nid, lastpos);
27
0
}
28
29
int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj,
30
                               int lastpos)
31
0
{
32
0
    return X509at_get_attr_by_OBJ(si->signedAttrs, obj, lastpos);
33
0
}
34
35
X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc)
36
0
{
37
0
    return X509at_get_attr(si->signedAttrs, loc);
38
0
}
39
40
X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc)
41
0
{
42
0
    return X509at_delete_attr(si->signedAttrs, loc);
43
0
}
44
45
int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr)
46
0
{
47
0
    if (X509at_add1_attr(&si->signedAttrs, attr))
48
0
        return 1;
49
0
    return 0;
50
0
}
51
52
int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,
53
                                const ASN1_OBJECT *obj, int type,
54
                                const void *bytes, int len)
55
0
{
56
0
    if (X509at_add1_attr_by_OBJ(&si->signedAttrs, obj, type, bytes, len))
57
0
        return 1;
58
0
    return 0;
59
0
}
60
61
int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,
62
                                int nid, int type, const void *bytes, int len)
63
0
{
64
0
    if (X509at_add1_attr_by_NID(&si->signedAttrs, nid, type, bytes, len))
65
0
        return 1;
66
0
    return 0;
67
0
}
68
69
int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,
70
                                const char *attrname, int type,
71
                                const void *bytes, int len)
72
0
{
73
0
    if (X509at_add1_attr_by_txt(&si->signedAttrs, attrname, type, bytes, len))
74
0
        return 1;
75
0
    return 0;
76
0
}
77
78
void *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *oid,
79
                                  int lastpos, int type)
80
0
{
81
0
    return X509at_get0_data_by_OBJ(si->signedAttrs, oid, lastpos, type);
82
0
}
83
84
int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si)
85
0
{
86
0
    return X509at_get_attr_count(si->unsignedAttrs);
87
0
}
88
89
int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
90
                                 int lastpos)
91
0
{
92
0
    return X509at_get_attr_by_NID(si->unsignedAttrs, nid, lastpos);
93
0
}
94
95
int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si,
96
                                 const ASN1_OBJECT *obj, int lastpos)
97
0
{
98
0
    return X509at_get_attr_by_OBJ(si->unsignedAttrs, obj, lastpos);
99
0
}
100
101
X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc)
102
0
{
103
0
    return X509at_get_attr(si->unsignedAttrs, loc);
104
0
}
105
106
X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc)
107
0
{
108
0
    return X509at_delete_attr(si->unsignedAttrs, loc);
109
0
}
110
111
int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr)
112
0
{
113
0
    if (X509at_add1_attr(&si->unsignedAttrs, attr))
114
0
        return 1;
115
0
    return 0;
116
0
}
117
118
int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,
119
                                  const ASN1_OBJECT *obj, int type,
120
                                  const void *bytes, int len)
121
0
{
122
0
    if (X509at_add1_attr_by_OBJ(&si->unsignedAttrs, obj, type, bytes, len))
123
0
        return 1;
124
0
    return 0;
125
0
}
126
127
int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,
128
                                  int nid, int type,
129
                                  const void *bytes, int len)
130
0
{
131
0
    if (X509at_add1_attr_by_NID(&si->unsignedAttrs, nid, type, bytes, len))
132
0
        return 1;
133
0
    return 0;
134
0
}
135
136
int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,
137
                                  const char *attrname, int type,
138
                                  const void *bytes, int len)
139
0
{
140
0
    if (X509at_add1_attr_by_txt(&si->unsignedAttrs, attrname,
141
0
                                type, bytes, len))
142
0
        return 1;
143
0
    return 0;
144
0
}
145
146
void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
147
                                    int lastpos, int type)
148
0
{
149
0
    return X509at_get0_data_by_OBJ(si->unsignedAttrs, oid, lastpos, type);
150
0
}
151
152
/* Specific attribute cases */