#include <openssl/x509v3.h>
#include <openssl/err.h>
#include <openssl/cms.h>
-#include "cms_local.h"
#include "internal/nelem.h"
+#include "crypto/x509.h"
+#include "cms_local.h"
/*-
* Attribute flags.
int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr)
{
- if (X509at_add1_attr(&si->signedAttrs, attr))
+ if (ossl_x509at_add1_attr(&si->signedAttrs, attr))
return 1;
return 0;
}
const ASN1_OBJECT *obj, int type,
const void *bytes, int len)
{
- if (X509at_add1_attr_by_OBJ(&si->signedAttrs, obj, type, bytes, len))
+ if (ossl_x509at_add1_attr_by_OBJ(&si->signedAttrs, obj, type, bytes, len))
return 1;
return 0;
}
int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,
int nid, int type, const void *bytes, int len)
{
- if (X509at_add1_attr_by_NID(&si->signedAttrs, nid, type, bytes, len))
+ if (ossl_x509at_add1_attr_by_NID(&si->signedAttrs, nid, type, bytes, len))
return 1;
return 0;
}
const char *attrname, int type,
const void *bytes, int len)
{
- if (X509at_add1_attr_by_txt(&si->signedAttrs, attrname, type, bytes, len))
+ if (ossl_x509at_add1_attr_by_txt(&si->signedAttrs, attrname, type, bytes,
+ len))
return 1;
return 0;
}
int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr)
{
- if (X509at_add1_attr(&si->unsignedAttrs, attr))
+ if (ossl_x509at_add1_attr(&si->unsignedAttrs, attr))
return 1;
return 0;
}
const ASN1_OBJECT *obj, int type,
const void *bytes, int len)
{
- if (X509at_add1_attr_by_OBJ(&si->unsignedAttrs, obj, type, bytes, len))
+ if (ossl_x509at_add1_attr_by_OBJ(&si->unsignedAttrs, obj, type, bytes, len))
return 1;
return 0;
}
int nid, int type,
const void *bytes, int len)
{
- if (X509at_add1_attr_by_NID(&si->unsignedAttrs, nid, type, bytes, len))
+ if (ossl_x509at_add1_attr_by_NID(&si->unsignedAttrs, nid, type, bytes, len))
return 1;
return 0;
}
const char *attrname, int type,
const void *bytes, int len)
{
- if (X509at_add1_attr_by_txt(&si->unsignedAttrs, attrname,
- type, bytes, len))
+ if (ossl_x509at_add1_attr_by_txt(&si->unsignedAttrs, attrname,
+ type, bytes, len))
return 1;
return 0;
}
return sk_X509_ATTRIBUTE_delete(x, loc);
}
-STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
- X509_ATTRIBUTE *attr)
+STACK_OF(X509_ATTRIBUTE) *ossl_x509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
+ X509_ATTRIBUTE *attr)
{
X509_ATTRIBUTE *new_attr = NULL;
STACK_OF(X509_ATTRIBUTE) *sk = NULL;
ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER);
return NULL;
}
- if (*x != NULL && X509at_get_attr_by_OBJ(*x, attr->object, -1) != -1) {
- ERR_raise(ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE);
- return NULL;
- }
if (*x == NULL) {
if ((sk = sk_X509_ATTRIBUTE_new_null()) == NULL) {
return NULL;
}
+STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
+ X509_ATTRIBUTE *attr)
+{
+ if (x == NULL || attr == NULL) {
+ ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER);
+ return NULL;
+ }
+ if (*x != NULL && X509at_get_attr_by_OBJ(*x, attr->object, -1) != -1) {
+ ERR_raise(ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE);
+ return NULL;
+ }
+
+ return ossl_x509at_add1_attr(x, attr);
+}
+
+STACK_OF(X509_ATTRIBUTE) *ossl_x509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
+ const ASN1_OBJECT *obj,
+ int type,
+ const unsigned char *bytes,
+ int len)
+{
+ X509_ATTRIBUTE *attr;
+ STACK_OF(X509_ATTRIBUTE) *ret;
+
+ attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, type, bytes, len);
+ if (attr == NULL)
+ return 0;
+ ret = ossl_x509at_add1_attr(x, attr);
+ X509_ATTRIBUTE_free(attr);
+ return ret;
+}
+
STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)
**x, const ASN1_OBJECT *obj,
int type,
const unsigned char *bytes,
int len)
+{
+ if (x == NULL || obj == NULL) {
+ ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER);
+ return NULL;
+ }
+ if (*x != NULL && X509at_get_attr_by_OBJ(*x, obj, -1) != -1) {
+ ERR_raise(ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE);
+ return NULL;
+ }
+
+ return ossl_x509at_add1_attr_by_OBJ(x, obj, type, bytes, len);
+}
+
+STACK_OF(X509_ATTRIBUTE) *ossl_x509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
+ int nid, int type,
+ const unsigned char *bytes,
+ int len)
{
X509_ATTRIBUTE *attr;
STACK_OF(X509_ATTRIBUTE) *ret;
- attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, type, bytes, len);
+ attr = X509_ATTRIBUTE_create_by_NID(NULL, nid, type, bytes, len);
if (attr == NULL)
return 0;
- ret = X509at_add1_attr(x, attr);
+ ret = ossl_x509at_add1_attr(x, attr);
X509_ATTRIBUTE_free(attr);
return ret;
}
**x, int nid, int type,
const unsigned char *bytes,
int len)
+{
+ if (x == NULL) {
+ ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER);
+ return NULL;
+ }
+ if (*x != NULL && X509at_get_attr_by_NID(*x, nid, -1) != -1) {
+ ERR_raise(ERR_LIB_X509, X509_R_DUPLICATE_ATTRIBUTE);
+ return NULL;
+ }
+
+ return ossl_x509at_add1_attr_by_NID(x, nid, type, bytes, len);
+}
+
+STACK_OF(X509_ATTRIBUTE) *ossl_x509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
+ const char *attrname,
+ int type,
+ const unsigned char *bytes,
+ int len)
{
X509_ATTRIBUTE *attr;
STACK_OF(X509_ATTRIBUTE) *ret;
- attr = X509_ATTRIBUTE_create_by_NID(NULL, nid, type, bytes, len);
+ attr = X509_ATTRIBUTE_create_by_txt(NULL, attrname, type, bytes, len);
if (attr == NULL)
return 0;
- ret = X509at_add1_attr(x, attr);
+ ret = ossl_x509at_add1_attr(x, attr);
X509_ATTRIBUTE_free(attr);
return ret;
}
int x509v3_add_len_value_uchar(const char *name, const unsigned char *value,
size_t vallen, STACK_OF(CONF_VALUE) **extlist);
+/* Attribute addition functions not checking for duplicate attributes */
+STACK_OF(X509_ATTRIBUTE) *ossl_x509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
+ X509_ATTRIBUTE *attr);
+STACK_OF(X509_ATTRIBUTE) *ossl_x509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
+ const ASN1_OBJECT *obj,
+ int type,
+ const unsigned char *bytes,
+ int len);
+STACK_OF(X509_ATTRIBUTE) *ossl_x509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
+ int nid, int type,
+ const unsigned char *bytes,
+ int len);
+STACK_OF(X509_ATTRIBUTE) *ossl_x509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
+ const char *attrname,
+ int type,
+ const unsigned char *bytes,
+ int len);
#endif /* OSSL_CRYPTO_X509_H */