openssl: Update PKCS#7 API to OpenSSL 1.1.0
authorTobias Brunner <tobias@strongswan.org>
Mon, 27 Jun 2016 15:22:34 +0000 (17:22 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 29 Jun 2016 09:09:37 +0000 (11:09 +0200)
src/libstrongswan/plugins/openssl/openssl_pkcs7.c

index 891e829..f10987c 100644 (file)
 
 #include <openssl/cms.h>
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#define X509_ATTRIBUTE_get0_object(attr) ({ (attr)->object; })
+#endif
+
 typedef struct private_openssl_pkcs7_t private_openssl_pkcs7_t;
 
 /**
@@ -432,11 +436,11 @@ METHOD(pkcs7_t, get_attribute, bool,
        for (i = 0; i < CMS_signed_get_attr_count(si); i++)
        {
                attr = CMS_signed_get_attr(si, i);
-               if (!attr->single && sk_ASN1_TYPE_num(attr->value.set) == 1 &&
-                       openssl_asn1_known_oid(attr->object) == oid)
+               if (X509_ATTRIBUTE_count(attr) == 1 &&
+                       openssl_asn1_known_oid(X509_ATTRIBUTE_get0_object(attr)) == oid)
                {
                        /* get first value in SET */
-                       type = sk_ASN1_TYPE_value(attr->value.set, 0);
+                       type = X509_ATTRIBUTE_get0_type(attr, 0);
                        chunk = wrapped = openssl_i2chunk(ASN1_TYPE, type);
                        if (asn1_unwrap(&chunk, &chunk) != 0x100 /* ASN1_INVALID */)
                        {