summaryrefslogtreecommitdiffstats
path: root/crypto/asn1/a_type.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2008-02-11 13:59:33 +0000
committerDr. Stephen Henson <steve@openssl.org>2008-02-11 13:59:33 +0000
commit1ad90a916b4e3295173853d5da7f6a68cbad53f1 (patch)
tree116549f9b3d731de9d70ed66e8914b37ae0115b3 /crypto/asn1/a_type.c
parent8ab9025e316706c0c253dd61fc0f56857f4d24d0 (diff)
Extend attribute setting routines to support non-string types.
Diffstat (limited to 'crypto/asn1/a_type.c')
-rw-r--r--crypto/asn1/a_type.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/crypto/asn1/a_type.c b/crypto/asn1/a_type.c
index 6a1e5a7a5a..52523d210a 100644
--- a/crypto/asn1/a_type.c
+++ b/crypto/asn1/a_type.c
@@ -77,9 +77,36 @@ void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value)
ASN1_primitive_free((ASN1_VALUE **)tmp_a, NULL);
}
a->type=type;
- a->value.ptr=value;
+ if (type == V_ASN1_BOOLEAN)
+ a->value.boolean = value ? 0xff : 0;
+ else
+ a->value.ptr=value;
}
+int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value)
+ {
+ if (!value || (type == V_ASN1_BOOLEAN))
+ {
+ ASN1_TYPE_set(a, type, (void *)value);
+ }
+ else if (type == V_ASN1_OBJECT)
+ {
+ ASN1_OBJECT *odup;
+ odup = OBJ_dup(value);
+ if (!odup)
+ return 0;
+ ASN1_TYPE_set(a, type, odup);
+ }
+ else
+ {
+ ASN1_STRING *sdup;
+ sdup = ASN1_STRING_dup(sdup);
+ if (!sdup)
+ return 0;
+ ASN1_TYPE_set(a, type, sdup);
+ }
+ return 1;
+ }
IMPLEMENT_STACK_OF(ASN1_TYPE)
IMPLEMENT_ASN1_SET_OF(ASN1_TYPE)