Skip to content

openssl: building with v3 no-deprecated misses HMAC_CTX_*() functions #1235

Closed

Description

@vszakats

Describe the bug
Tried compiling libssh2 (latest master) with an OpenSSL 3
configured with its no-deprecated option.

To Reproduce

  1. build OpenSSL 3 with no-deprecated:
    ./Configure no-depcrecated
  2. build libssh2 against the above OpenSSL.

Expected behavior
Successful build.

Version (please complete the following information):

  • OS and version: (any)
  • libssh2 version: 1.11.1-DEV master
  • crypto backend and version: OpenSSL 3 + no-deprecated

Additional context
It seems to come down to missing HMAC_*() APIs and a remaining
reference to EC_KEY [FIXED in #1236]
.

I used a patched curl-for-win build for tests. Here is the output
(this is a macOS build with Xcode):

In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:34:
src/knownhost.c:424:21: error: implicit declaration of function 'HMAC_CTX_new' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                    libssh2_hmac_ctx_init(ctx);
                    ^
src/openssl.h:330:42: note: expanded from macro 'libssh2_hmac_ctx_init'
#define libssh2_hmac_ctx_init(ctx) ctx = HMAC_CTX_new()
                                         ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:34:
src/knownhost.c:424:21: warning: incompatible integer to pointer conversion assigning to 'HMAC_CTX *' (aka 'struct hmac_ctx_st *') from 'int' [-Wint-conversion]
                    libssh2_hmac_ctx_init(ctx);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/openssl.h:330:40: note: expanded from macro 'libssh2_hmac_ctx_init'
#define libssh2_hmac_ctx_init(ctx) ctx = HMAC_CTX_new()
                                       ^ ~~~~~~~~~~~~~~
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:34:
src/knownhost.c:431:21: error: implicit declaration of function 'HMAC_Init_ex' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                    libssh2_hmac_sha1_init(&ctx, (unsigned char *)node->salt,
                    ^
src/openssl.h:332:5: note: expanded from macro 'libssh2_hmac_sha1_init'
    HMAC_Init_ex(*(ctx), key, (int)keylen, EVP_sha1(), NULL)
    ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:34:
src/knownhost.c:433:21: error: implicit declaration of function 'HMAC_Update' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                    libssh2_hmac_update(ctx, (unsigned char *)host,
                    ^
src/openssl.h:348:5: note: expanded from macro 'libssh2_hmac_update'
    HMAC_Update(ctx, data, datalen)
    ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:34:
src/knownhost.c:435:21: error: implicit declaration of function 'HMAC_Final' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                    libssh2_hmac_final(ctx, hash);
                    ^
src/openssl.h:350:39: note: expanded from macro 'libssh2_hmac_final'
#define libssh2_hmac_final(ctx, data) HMAC_Final(ctx, data, NULL)
                                      ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:34:
src/knownhost.c:436:21: error: implicit declaration of function 'HMAC_CTX_free' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                    libssh2_hmac_cleanup(&ctx);
                    ^
src/openssl.h:351:35: note: expanded from macro 'libssh2_hmac_cleanup'
#define libssh2_hmac_cleanup(ctx) HMAC_CTX_free(*(ctx))
                                  ^
src/knownhost.c:436:21: note: did you mean 'HMAC_CTX_new'?
src/openssl.h:351:35: note: expanded from macro 'libssh2_hmac_cleanup'
#define libssh2_hmac_cleanup(ctx) HMAC_CTX_free(*(ctx))
                                  ^
src/knownhost.c:424:21: note: 'HMAC_CTX_new' declared here
                    libssh2_hmac_ctx_init(ctx);
                    ^
src/openssl.h:330:42: note: expanded from macro 'libssh2_hmac_ctx_init'
#define libssh2_hmac_ctx_init(ctx) ctx = HMAC_CTX_new()
                                         ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:131:5: error: implicit declaration of function 'HMAC_CTX_new' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    libssh2_hmac_ctx_init(ctx);
    ^
src/openssl.h:330:42: note: expanded from macro 'libssh2_hmac_ctx_init'
#define libssh2_hmac_ctx_init(ctx) ctx = HMAC_CTX_new()
                                         ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:131:5: warning: incompatible integer to pointer conversion assigning to 'HMAC_CTX *' (aka 'struct hmac_ctx_st *') from 'int' [-Wint-conversion]
    libssh2_hmac_ctx_init(ctx);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/openssl.h:330:40: note: expanded from macro 'libssh2_hmac_ctx_init'
#define libssh2_hmac_ctx_init(ctx) ctx = HMAC_CTX_new()
                                       ^ ~~~~~~~~~~~~~~
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:132:5: error: implicit declaration of function 'HMAC_Init_ex' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    libssh2_hmac_sha512_init(&ctx, *abstract, 64);
    ^
src/openssl.h:340:5: note: expanded from macro 'libssh2_hmac_sha512_init'
    HMAC_Init_ex(*(ctx), key, (int)keylen, EVP_sha512(), NULL)
    ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:133:5: error: implicit declaration of function 'HMAC_Update' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    libssh2_hmac_update(ctx, seqno_buf, 4);
    ^
src/openssl.h:348:5: note: expanded from macro 'libssh2_hmac_update'
    HMAC_Update(ctx, data, datalen)
    ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:138:5: error: implicit declaration of function 'HMAC_Final' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    libssh2_hmac_final(ctx, buf);
    ^
src/openssl.h:350:39: note: expanded from macro 'libssh2_hmac_final'
#define libssh2_hmac_final(ctx, data) HMAC_Final(ctx, data, NULL)
                                      ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:139:5: error: implicit declaration of function 'HMAC_CTX_free' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    libssh2_hmac_cleanup(&ctx);
    ^
src/openssl.h:351:35: note: expanded from macro 'libssh2_hmac_cleanup'
#define libssh2_hmac_cleanup(ctx) HMAC_CTX_free(*(ctx))
                                  ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:186:5: error: implicit declaration of function 'HMAC_CTX_new' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    libssh2_hmac_ctx_init(ctx);
    ^
src/openssl.h:330:42: note: expanded from macro 'libssh2_hmac_ctx_init'
#define libssh2_hmac_ctx_init(ctx) ctx = HMAC_CTX_new()
                                         ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:186:5: warning: incompatible integer to pointer conversion assigning to 'HMAC_CTX *' (aka 'struct hmac_ctx_st *') from 'int' [-Wint-conversion]
    libssh2_hmac_ctx_init(ctx);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/openssl.h:330:40: note: expanded from macro 'libssh2_hmac_ctx_init'
#define libssh2_hmac_ctx_init(ctx) ctx = HMAC_CTX_new()
                                       ^ ~~~~~~~~~~~~~~
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:187:5: error: implicit declaration of function 'HMAC_Init_ex' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    libssh2_hmac_sha256_init(&ctx, *abstract, 32);
    ^
src/openssl.h:338:5: note: expanded from macro 'libssh2_hmac_sha256_init'
    HMAC_Init_ex(*(ctx), key, (int)keylen, EVP_sha256(), NULL)
    ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:188:5: error: implicit declaration of function 'HMAC_Update' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    libssh2_hmac_update(ctx, seqno_buf, 4);
    ^
src/openssl.h:348:5: note: expanded from macro 'libssh2_hmac_update'
    HMAC_Update(ctx, data, datalen)
    ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:193:5: error: implicit declaration of function 'HMAC_Final' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    libssh2_hmac_final(ctx, buf);
    ^
src/openssl.h:350:39: note: expanded from macro 'libssh2_hmac_final'
#define libssh2_hmac_final(ctx, data) HMAC_Final(ctx, data, NULL)
                                      ^
In file included from ./_a64-mac-sys-bld/src/CMakeFiles/libssh2_static.dir/Unity/unity_0_c.c:37:
src/mac.c:194:5: error: implicit declaration of function 'HMAC_CTX_free' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    libssh2_hmac_cleanup(&ctx);
    ^
src/openssl.h:351:35: note: expanded from macro 'libssh2_hmac_cleanup'
#define libssh2_hmac_cleanup(ctx) HMAC_CTX_free(*(ctx))
                                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
3 warnings and 20 errors generated.

Ref: https://github.com/curl/curl-for-win/actions/runs/6950001225/job/18909297867#step:3:4341

Ref: b0ab005 #1207

/cc @MichaelBuckley

Activity

  1. vszakats commented on Nov 21, 2023

    @vszakats
    MemberAuthor

    Attempt to fix the EC_KEY issue: #1236 [MERGED]

  2. changed the title [-]Errors while compiling with OpenSSL 3 `no-deprecated` build[/-] [+]openssl: building with v3 `no-deprecated` misses `HMAC_CTX_*()` functions[/+] on Nov 24, 2023
  3. added 2 commits that reference this issue on Dec 19, 2023
    81e0e8d
    4ee4846
  4. added a commit that references this issue on Mar 28, 2024
    363dcbf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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