diff options
Diffstat (limited to 'src/lib/libcrypto/cms/cms_att.c')
-rw-r--r-- | src/lib/libcrypto/cms/cms_att.c | 122 |
1 files changed, 69 insertions, 53 deletions
diff --git a/src/lib/libcrypto/cms/cms_att.c b/src/lib/libcrypto/cms/cms_att.c index 5b71722ebc..c6bc784fb8 100644 --- a/src/lib/libcrypto/cms/cms_att.c +++ b/src/lib/libcrypto/cms/cms_att.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -60,134 +60,150 @@ | |||
60 | 60 | ||
61 | /* CMS SignedData Attribute utilities */ | 61 | /* CMS SignedData Attribute utilities */ |
62 | 62 | ||
63 | int CMS_signed_get_attr_count(const CMS_SignerInfo *si) | 63 | int |
64 | CMS_signed_get_attr_count(const CMS_SignerInfo *si) | ||
64 | { | 65 | { |
65 | return X509at_get_attr_count(si->signedAttrs); | 66 | return X509at_get_attr_count(si->signedAttrs); |
66 | } | 67 | } |
67 | 68 | ||
68 | int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid, | 69 | int |
69 | int lastpos) | 70 | CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid, int lastpos) |
70 | { | 71 | { |
71 | return X509at_get_attr_by_NID(si->signedAttrs, nid, lastpos); | 72 | return X509at_get_attr_by_NID(si->signedAttrs, nid, lastpos); |
72 | } | 73 | } |
73 | 74 | ||
74 | int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj, | 75 | int |
75 | int lastpos) | 76 | CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj, |
77 | int lastpos) | ||
76 | { | 78 | { |
77 | return X509at_get_attr_by_OBJ(si->signedAttrs, obj, lastpos); | 79 | return X509at_get_attr_by_OBJ(si->signedAttrs, obj, lastpos); |
78 | } | 80 | } |
79 | 81 | ||
80 | X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc) | 82 | X509_ATTRIBUTE * |
83 | CMS_signed_get_attr(const CMS_SignerInfo *si, int loc) | ||
81 | { | 84 | { |
82 | return X509at_get_attr(si->signedAttrs, loc); | 85 | return X509at_get_attr(si->signedAttrs, loc); |
83 | } | 86 | } |
84 | 87 | ||
85 | X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc) | 88 | X509_ATTRIBUTE * |
89 | CMS_signed_delete_attr(CMS_SignerInfo *si, int loc) | ||
86 | { | 90 | { |
87 | return X509at_delete_attr(si->signedAttrs, loc); | 91 | return X509at_delete_attr(si->signedAttrs, loc); |
88 | } | 92 | } |
89 | 93 | ||
90 | int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr) | 94 | int |
95 | CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr) | ||
91 | { | 96 | { |
92 | if(X509at_add1_attr(&si->signedAttrs, attr)) return 1; | 97 | if (X509at_add1_attr(&si->signedAttrs, attr)) |
98 | return 1; | ||
93 | return 0; | 99 | return 0; |
94 | } | 100 | } |
95 | 101 | ||
96 | int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si, | 102 | int |
97 | const ASN1_OBJECT *obj, int type, | 103 | CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *obj, |
98 | const void *bytes, int len) | 104 | int type, const void *bytes, int len) |
99 | { | 105 | { |
100 | if(X509at_add1_attr_by_OBJ(&si->signedAttrs, obj, | 106 | if (X509at_add1_attr_by_OBJ(&si->signedAttrs, obj, type, bytes, len)) |
101 | type, bytes, len)) return 1; | 107 | return 1; |
102 | return 0; | 108 | return 0; |
103 | } | 109 | } |
104 | 110 | ||
105 | int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si, | 111 | int |
106 | int nid, int type, | 112 | CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si, int nid, int type, |
107 | const void *bytes, int len) | 113 | const void *bytes, int len) |
108 | { | 114 | { |
109 | if(X509at_add1_attr_by_NID(&si->signedAttrs, nid, | 115 | if (X509at_add1_attr_by_NID(&si->signedAttrs, nid, type, bytes, len)) |
110 | type, bytes, len)) return 1; | 116 | return 1; |
111 | return 0; | 117 | return 0; |
112 | } | 118 | } |
113 | 119 | ||
114 | int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si, | 120 | int |
115 | const char *attrname, int type, | 121 | CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si, const char *attrname, int type, |
116 | const void *bytes, int len) | 122 | const void *bytes, int len) |
117 | { | 123 | { |
118 | if(X509at_add1_attr_by_txt(&si->signedAttrs, attrname, | 124 | if (X509at_add1_attr_by_txt(&si->signedAttrs, attrname, type, |
119 | type, bytes, len)) return 1; | 125 | bytes, len)) |
126 | return 1; | ||
120 | return 0; | 127 | return 0; |
121 | } | 128 | } |
122 | 129 | ||
123 | void *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid, | 130 | void * |
124 | int lastpos, int type) | 131 | CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid, int lastpos, |
132 | int type) | ||
125 | { | 133 | { |
126 | return X509at_get0_data_by_OBJ(si->signedAttrs, oid, lastpos, type); | 134 | return X509at_get0_data_by_OBJ(si->signedAttrs, oid, lastpos, type); |
127 | } | 135 | } |
128 | 136 | ||
129 | int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si) | 137 | int |
138 | CMS_unsigned_get_attr_count(const CMS_SignerInfo *si) | ||
130 | { | 139 | { |
131 | return X509at_get_attr_count(si->unsignedAttrs); | 140 | return X509at_get_attr_count(si->unsignedAttrs); |
132 | } | 141 | } |
133 | 142 | ||
134 | int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid, | 143 | int |
135 | int lastpos) | 144 | CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid, int lastpos) |
136 | { | 145 | { |
137 | return X509at_get_attr_by_NID(si->unsignedAttrs, nid, lastpos); | 146 | return X509at_get_attr_by_NID(si->unsignedAttrs, nid, lastpos); |
138 | } | 147 | } |
139 | 148 | ||
140 | int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj, | 149 | int |
141 | int lastpos) | 150 | CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj, |
151 | int lastpos) | ||
142 | { | 152 | { |
143 | return X509at_get_attr_by_OBJ(si->unsignedAttrs, obj, lastpos); | 153 | return X509at_get_attr_by_OBJ(si->unsignedAttrs, obj, lastpos); |
144 | } | 154 | } |
145 | 155 | ||
146 | X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc) | 156 | X509_ATTRIBUTE * |
157 | CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc) | ||
147 | { | 158 | { |
148 | return X509at_get_attr(si->unsignedAttrs, loc); | 159 | return X509at_get_attr(si->unsignedAttrs, loc); |
149 | } | 160 | } |
150 | 161 | ||
151 | X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc) | 162 | X509_ATTRIBUTE * |
163 | CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc) | ||
152 | { | 164 | { |
153 | return X509at_delete_attr(si->unsignedAttrs, loc); | 165 | return X509at_delete_attr(si->unsignedAttrs, loc); |
154 | } | 166 | } |
155 | 167 | ||
156 | int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr) | 168 | int |
169 | CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr) | ||
157 | { | 170 | { |
158 | if(X509at_add1_attr(&si->unsignedAttrs, attr)) return 1; | 171 | if (X509at_add1_attr(&si->unsignedAttrs, attr)) |
172 | return 1; | ||
159 | return 0; | 173 | return 0; |
160 | } | 174 | } |
161 | 175 | ||
162 | int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si, | 176 | int |
163 | const ASN1_OBJECT *obj, int type, | 177 | CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *obj, |
164 | const void *bytes, int len) | 178 | int type, const void *bytes, int len) |
165 | { | 179 | { |
166 | if(X509at_add1_attr_by_OBJ(&si->unsignedAttrs, obj, | 180 | if (X509at_add1_attr_by_OBJ(&si->unsignedAttrs, obj, type, bytes, len)) |
167 | type, bytes, len)) return 1; | 181 | return 1; |
168 | return 0; | 182 | return 0; |
169 | } | 183 | } |
170 | 184 | ||
171 | int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si, | 185 | int |
172 | int nid, int type, | 186 | CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si, int nid, int type, |
173 | const void *bytes, int len) | 187 | const void *bytes, int len) |
174 | { | 188 | { |
175 | if(X509at_add1_attr_by_NID(&si->unsignedAttrs, nid, | 189 | if (X509at_add1_attr_by_NID(&si->unsignedAttrs, nid, type, bytes, len)) |
176 | type, bytes, len)) return 1; | 190 | return 1; |
177 | return 0; | 191 | return 0; |
178 | } | 192 | } |
179 | 193 | ||
180 | int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si, | 194 | int |
181 | const char *attrname, int type, | 195 | CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si, const char *attrname, |
182 | const void *bytes, int len) | 196 | int type, const void *bytes, int len) |
183 | { | 197 | { |
184 | if(X509at_add1_attr_by_txt(&si->unsignedAttrs, attrname, | 198 | if (X509at_add1_attr_by_txt(&si->unsignedAttrs, attrname, type, |
185 | type, bytes, len)) return 1; | 199 | bytes, len)) |
200 | return 1; | ||
186 | return 0; | 201 | return 0; |
187 | } | 202 | } |
188 | 203 | ||
189 | void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid, | 204 | void * |
190 | int lastpos, int type) | 205 | CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid, |
206 | int lastpos, int type) | ||
191 | { | 207 | { |
192 | return X509at_get0_data_by_OBJ(si->unsignedAttrs, oid, lastpos, type); | 208 | return X509at_get0_data_by_OBJ(si->unsignedAttrs, oid, lastpos, type); |
193 | } | 209 | } |