1
0
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 from
2e4c5ec462 (commitcomment-141379351)

Follow-up to e973493f99 #1393
Follow-up to 2e4c5ec462 #1349
Closes #1421
This commit is contained in:
Seo Suchan
2024-07-11 13:27:36 +09:00
committed by Viktor Szakats
parent 42ef8f3f0b
commit 1628f6cab8
2 changed files with 8 additions and 13 deletions

View File

@@ -593,8 +593,8 @@ jobs:
cmake: -DCRYPTO_BACKEND=Libgcrypt cmake: -DCRYPTO_BACKEND=Libgcrypt
- name: 'mbedTLS' - name: 'mbedTLS'
install: mbedtls install: mbedtls
configure: --with-crypto=mbedtls "--with-libmbedcrypto-prefix=$(brew --prefix)" CPPFLAGS=-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" -DCMAKE_C_FLAGS=-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"
steps: steps:
- name: 'install packages' - name: 'install packages'
run: brew install automake libtool ${{ matrix.crypto.install }} run: brew install automake libtool ${{ matrix.crypto.install }}

View File

@@ -1276,6 +1276,11 @@ cleanup:
return *ctx ? 0 : -1; 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 /* _libssh2_ecdsa_new_private
* *
* Creates a new private key given a file path and password * 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; unsigned char *data;
size_t data_len; size_t data_len;
#if MBEDTLS_VERSION_NUMBER >= 0x03060000 && \ /* FIXME: Reimplement this functionality via a public API. */
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
if(mbedtls_pk_load_file(filename, &data, &data_len)) if(mbedtls_pk_load_file(filename, &data, &data_len))
goto cleanup; 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); _libssh2_mbedtls_parse_openssh_key(ctx, session, data, data_len, pwd);
cleanup: cleanup:
#endif
mbedtls_pk_free(&pkey); mbedtls_pk_free(&pkey);