2 * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
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
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>
17 /* CMS SignedData Attribute utilities */
19 int CMS_signed_get_attr_count(const CMS_SignerInfo *si)
21 return X509at_get_attr_count(si->signedAttrs);
24 int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid, int lastpos)
26 return X509at_get_attr_by_NID(si->signedAttrs, nid, lastpos);
29 int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj,
32 return X509at_get_attr_by_OBJ(si->signedAttrs, obj, lastpos);
35 X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc)
37 return X509at_get_attr(si->signedAttrs, loc);
40 X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc)
42 return X509at_delete_attr(si->signedAttrs, loc);
45 int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr)
47 if (X509at_add1_attr(&si->signedAttrs, attr))
52 int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,
53 const ASN1_OBJECT *obj, int type,
54 const void *bytes, int len)
56 if (X509at_add1_attr_by_OBJ(&si->signedAttrs, obj, type, bytes, len))
61 int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,
62 int nid, int type, const void *bytes, int len)
64 if (X509at_add1_attr_by_NID(&si->signedAttrs, nid, type, bytes, len))
69 int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,
70 const char *attrname, int type,
71 const void *bytes, int len)
73 if (X509at_add1_attr_by_txt(&si->signedAttrs, attrname, type, bytes, len))
78 void *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *oid,
79 int lastpos, int type)
81 return X509at_get0_data_by_OBJ(si->signedAttrs, oid, lastpos, type);
84 int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si)
86 return X509at_get_attr_count(si->unsignedAttrs);
89 int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
92 return X509at_get_attr_by_NID(si->unsignedAttrs, nid, lastpos);
95 int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si,
96 const ASN1_OBJECT *obj, int lastpos)
98 return X509at_get_attr_by_OBJ(si->unsignedAttrs, obj, lastpos);
101 X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc)
103 return X509at_get_attr(si->unsignedAttrs, loc);
106 X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc)
108 return X509at_delete_attr(si->unsignedAttrs, loc);
111 int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr)
113 if (X509at_add1_attr(&si->unsignedAttrs, attr))
118 int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,
119 const ASN1_OBJECT *obj, int type,
120 const void *bytes, int len)
122 if (X509at_add1_attr_by_OBJ(&si->unsignedAttrs, obj, type, bytes, len))
127 int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,
129 const void *bytes, int len)
131 if (X509at_add1_attr_by_NID(&si->unsignedAttrs, nid, type, bytes, len))
136 int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,
137 const char *attrname, int type,
138 const void *bytes, int len)
140 if (X509at_add1_attr_by_txt(&si->unsignedAttrs, attrname,
146 void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
147 int lastpos, int type)
149 return X509at_get0_data_by_OBJ(si->unsignedAttrs, oid, lastpos, type);
152 /* Specific attribute cases */