Skip to content

authenticode-parser fails to build with OpenSSL 4.0 #23

Description

@loqs

Describe the bug
authenticode-parser fails to build with OpenSSL 4.0 as certain structures have been made opaque and can no longer be accessed directly.
authenticode-parser is bundled by https://github.com/VirusTotal/yara and Debian has produced a patch for the bundled authenticode-parser.

To Reproduce

$ git clone https://github.com/avast/authenticode-parser.git
$ cmake -B build -S authenticode-parser
$ cmake --build build
....
/build/authenticode-parser/src/authenticode-parser/src/certificate.c: In function ‘parse_name_attributes’:
/build/authenticode-parser/src/authenticode-parser/src/certificate.c:62:38: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   62 |         X509_NAME_ENTRY* entryName = X509_NAME_get_entry(raw, i);
      |                                      ^~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/certificate.c:63:35: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   63 |         ASN1_STRING* asn1String = X509_NAME_ENTRY_get_data(entryName);
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/certificate.c:68:47: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
   68 |         if (byte_array_init(&array, asn1String->data, asn1String->length) == -1)
      |                                               ^~
/build/authenticode-parser/src/authenticode-parser/src/certificate.c:68:65: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
   68 |         if (byte_array_init(&array, asn1String->data, asn1String->length) == -1)
      |                                                                 ^~
/build/authenticode-parser/src/authenticode-parser/src/certificate.c: In function ‘certificate_new’:
/build/authenticode-parser/src/authenticode-parser/src/certificate.c:291:29: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  291 |     X509_NAME* issuerName = X509_get_issuer_name(x509);
      |                             ^~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/certificate.c:300:30: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  300 |     X509_NAME* subjectName = X509_get_subject_name(x509);
      |                              ^~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/authenticode.dir/build.make:135: CMakeFiles/authenticode.dir/src/certificate.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c: In function ‘get_content’:
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:81:47: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
   81 |     int len = content->d.other->value.sequence->length;
      |                                               ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:82:59: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
   82 |     const uint8_t* data = content->d.other->value.sequence->data;
      |                                                           ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c: In function ‘parse_program_name’:
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:91:53: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
   91 |     const uint8_t* spcData = spcAttr->value.sequence->data;
      |                                                     ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:92:41: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
   92 |     int spcLen = spcAttr->value.sequence->length;
      |                                         ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c: In function ‘parse_nested_authenticode’:
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:131:29: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  131 |         ASN1_TYPE* nested = X509_ATTRIBUTE_get0_type(attr, i);
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:134:41: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  134 |         int len = nested->value.sequence->length;
      |                                         ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:135:53: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  135 |         const uint8_t* data = nested->value.sequence->data;
      |                                                     ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c: In function ‘parse_pkcs9_countersig’:
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:162:29: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  162 |         ASN1_TYPE* nested = X509_ATTRIBUTE_get0_type(attr, i);
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:165:41: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  165 |         int len = nested->value.sequence->length;
      |                                         ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:166:53: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  166 |         const uint8_t* data = nested->value.sequence->data;
      |                                                     ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c: In function ‘parse_ms_countersig’:
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:193:29: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  193 |         ASN1_TYPE* nested = X509_ATTRIBUTE_get0_type(attr, i);
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:196:41: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  196 |         int len = nested->value.sequence->length;
      |                                         ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:197:53: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  197 |         const uint8_t* data = nested->value.sequence->data;
      |                                                     ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c: In function ‘authenticode_verify’:
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:212:79: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  212 |     const uint8_t* contentData = p7->d.sign->contents->d.other->value.sequence->data;
      |                                                                               ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:213:68: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  213 |     long contentLen = p7->d.sign->contents->d.other->value.sequence->length;
      |                                                                    ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c: In function ‘authenticode_new’:
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:318:42: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  318 |     int digestLen = messageDigest->digest->length;
      |                                          ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:319:54: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  319 |     const uint8_t* digestData = messageDigest->digest->data;
      |                                                      ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:366:25: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  366 |     ASN1_TYPE* digest = PKCS7_get_signed_attribute(si, NID_pkcs9_messageDigest);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:375:42: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  375 |     digestLen = digest->value.asn1_string->length;
      |                                          ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:376:43: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  376 |     digestData = digest->value.asn1_string->data;
      |                                           ^~
/build/authenticode-parser/src/authenticode-parser/src/authenticode.c:380:26: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  380 |     ASN1_TYPE* spcInfo = PKCS7_get_signed_attribute(si, OBJ_txt2nid(NID_spc_info));
      |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c: In function ‘pkcs9_countersig_new’:
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:144:32: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  144 |     ASN1_TYPE* messageDigest = PKCS7_get_signed_attribute(si, NID_pkcs9_messageDigest);
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:150:57: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  150 |     size_t digestLen = messageDigest->value.octet_string->length;
      |                                                         ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:163:66: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  163 |     const uint8_t* digestData = messageDigest->value.octet_string->data;
      |                                                                  ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:190:38: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  190 |     uint8_t* encData = si->enc_digest->data;
      |                                      ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:191:35: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  191 |     size_t encLen = si->enc_digest->length;
      |                                   ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:223:50: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  223 |             isValid = !memcmp(digest_info->digest->data, calc_digest, mdLen);
      |                                                  ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:238:36: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  238 |     calculate_digest(md, enc_digest->data, enc_digest->length, calc_digest);
      |                                    ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:238:54: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  238 |     calculate_digest(md, enc_digest->data, enc_digest->length, calc_digest);
      |                                                      ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c: In function ‘ms_countersig_impl_get_ts_tst_info_cms_’:
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:272:37: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  272 |     const uint8_t* data = (*content)->data;
      |                                     ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:273:71: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  273 |     TS_TST_INFO* ts_tst_info = d2i_TS_TST_INFO(NULL, &data, (*content)->length);
      |                                                                       ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c: In function ‘ms_countersig_impl_verify_digest_pkcs7_’:
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:362:5: warning: ‘TS_VERIFY_CTX_set_store’ is deprecated: Since OpenSSL 3.4;Unclear semantics, replace with TS_VERIFY_CTX_set0_store(). [-Wdeprecated-declarations]
  362 |     TS_VERIFY_CTX_set_store(ctx, store);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /build/authenticode-parser/src/authenticode-parser/src/countersignature.c:32:
/usr/include/openssl/ts.h:434:13: note: declared here
  434 | X509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s);
      |             ^~~~~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:364:5: warning: ‘TS_VERIFY_CTX_set_certs’ is deprecated: Since OpenSSL 3.4;Unclear semantics, replace with TS_VERIFY_CTX_set0_certs(). [-Wdeprecated-declarations]
  364 |     TS_VERIFY_CTX_set_certs(ctx, impl->funcs->get_certs(impl));
      |     ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/openssl/ts.h:442:17: note: declared here
  442 | STACK_OF(X509) *TS_VERIFY_CTX_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) *certs);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:368:5: warning: ‘TS_VERIFY_CTX_set_imprint’ is deprecated: Since OpenSSL 3.4;Unclear semantics, replace with TS_VERIFY_CTX_set0_imprint(). [-Wdeprecated-declarations]
  368 |     TS_VERIFY_CTX_set_imprint(ctx, digest, digest_size);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/openssl/ts.h:427:16: note: declared here
  427 | unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx,
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c: In function ‘ms_countersig_impl_verify_digest_cms_’:
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:403:26: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  403 |     if (ts_imprint_digest->length != (int)digest_size ||
      |                          ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:404:33: error: invalid use of incomplete typedef ‘ASN1_OCTET_STRING’ {aka ‘struct asn1_string_st’}
  404 |         memcmp(ts_imprint_digest->data, digest, digest_size) != 0) {
      |                                 ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c: In function ‘ms_countersig_new’:
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:557:30: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  557 |     int digestLen = rawDigest->length;
      |                              ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:558:36: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  558 |     uint8_t* digestData = rawDigest->data;
      |                                    ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:574:36: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  574 |     calculate_digest(md, enc_digest->data, enc_digest->length, calc_digest);
      |                                    ^~
/build/authenticode-parser/src/authenticode-parser/src/countersignature.c:574:54: error: invalid use of incomplete typedef ‘ASN1_STRING’ {aka ‘struct asn1_string_st’}
  574 |     calculate_digest(md, enc_digest->data, enc_digest->length, calc_digest);
      |                                                      ^~
make[2]: *** [CMakeFiles/authenticode.dir/build.make:79: CMakeFiles/authenticode.dir/src/authenticode.c.o] Error 1
make[2]: *** [CMakeFiles/authenticode.dir/build.make:121: CMakeFiles/authenticode.dir/src/countersignature.c.o] Error 1

Expected behavior
authenticode-parser should build with OpenSSL 4.0.

** Versions **

  • OS: Arch Linux Rolling
  • authenticode-parser b5d5018

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions