mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-17 04:22:32 +03:00
mbedtls: expose mbedtls_pk_load_file() for our use
While it's moved to pk_internal, it won't removed in mbedTLS 3.6 LTS so it's safe to redeclare it on our side to find it. This is implementing emergency fix suggested from2e4c5ec462 (commitcomment-141379351)Follow-up toe973493f99#1393 Follow-up to2e4c5ec462#1349 Closes #1421
This commit is contained in:
committed by
Viktor Szakats
parent
42ef8f3f0b
commit
1628f6cab8
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -593,8 +593,8 @@ jobs:
|
||||
cmake: -DCRYPTO_BACKEND=Libgcrypt
|
||||
- name: 'mbedTLS'
|
||||
install: mbedtls
|
||||
configure: --with-crypto=mbedtls "--with-libmbedcrypto-prefix=$(brew --prefix)" CPPFLAGS=-D_LIBSSH2_DISABLE_MBEDTLS36_PK_LOAD_FILE
|
||||
cmake: -DCRYPTO_BACKEND=mbedTLS "-DMBEDTLS_INCLUDE_DIR=$(brew --prefix)/opt/mbedtls/include" "-DMBEDCRYPTO_LIBRARY=$(brew --prefix)/opt/mbedtls/lib/libmbedcrypto.a" -DCMAKE_C_FLAGS=-D_LIBSSH2_DISABLE_MBEDTLS36_PK_LOAD_FILE
|
||||
configure: --with-crypto=mbedtls "--with-libmbedcrypto-prefix=$(brew --prefix)"
|
||||
cmake: -DCRYPTO_BACKEND=mbedTLS "-DMBEDTLS_INCLUDE_DIR=$(brew --prefix)/opt/mbedtls/include" "-DMBEDCRYPTO_LIBRARY=$(brew --prefix)/opt/mbedtls/lib/libmbedcrypto.a"
|
||||
steps:
|
||||
- name: 'install packages'
|
||||
run: brew install automake libtool ${{ matrix.crypto.install }}
|
||||
|
||||
@@ -1276,6 +1276,11 @@ cleanup:
|
||||
return *ctx ? 0 : -1;
|
||||
}
|
||||
|
||||
/* Force-expose internal mbedTLS function */
|
||||
#if MBEDTLS_VERSION_NUMBER >= 0x03060000
|
||||
int mbedtls_pk_load_file(const char *path, unsigned char **buf, size_t *n);
|
||||
#endif
|
||||
|
||||
/* _libssh2_ecdsa_new_private
|
||||
*
|
||||
* Creates a new private key given a file path and password
|
||||
@@ -1292,16 +1297,7 @@ _libssh2_mbedtls_ecdsa_new_private(libssh2_ecdsa_ctx **ctx,
|
||||
unsigned char *data;
|
||||
size_t data_len;
|
||||
|
||||
#if MBEDTLS_VERSION_NUMBER >= 0x03060000 && \
|
||||
defined(_LIBSSH2_DISABLE_MBEDTLS36_PK_LOAD_FILE)
|
||||
|
||||
/* FIXME: implement this functionality via a public API */
|
||||
(void)session;
|
||||
(void)filename;
|
||||
(void)pwd;
|
||||
data = NULL;
|
||||
data_len = 0;
|
||||
#else
|
||||
/* FIXME: Reimplement this functionality via a public API. */
|
||||
if(mbedtls_pk_load_file(filename, &data, &data_len))
|
||||
goto cleanup;
|
||||
|
||||
@@ -1314,7 +1310,6 @@ _libssh2_mbedtls_ecdsa_new_private(libssh2_ecdsa_ctx **ctx,
|
||||
_libssh2_mbedtls_parse_openssh_key(ctx, session, data, data_len, pwd);
|
||||
|
||||
cleanup:
|
||||
#endif
|
||||
|
||||
mbedtls_pk_free(&pkey);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user