From d94fcd8b69e78d1eba1e1c1066ff8347a0578ad7 Mon Sep 17 00:00:00 2001 From: Maxime Vincent Date: Tue, 28 Mar 2017 11:42:30 +0200 Subject: [PATCH] Implemented wolfSSL_EVP_PKEY_base_id, wolfSSL_BIO_read_filename. Added wolfSSL_EVP_PKEY_type stub --- src/ssl.c | 39 ++++++++++++++++++++++++++++++--------- support/wolfssl.pc | 2 +- wolfssl/openssl/pem.h | 3 +++ wolfssl/openssl/ssl.h | 2 ++ 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index a1c12f7d5..73a8fca30 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -20941,11 +20941,14 @@ WOLFSSL_EVP_PKEY* wolfSSL_PEM_read_bio_PrivateKey(WOLFSSL_BIO* bio, int wolfSSL_EVP_PKEY_type(int type) { - (void)type; + // XXX FIXME + (void) type; + return EVP_PKEY_RSA; +} - WOLFSSL_MSG("wolfSSL_EVP_PKEY_type not implemented"); - - return SSL_FATAL_ERROR; +int wolfSSL_EVP_PKEY_base_id(const EVP_PKEY *pkey) +{ + return EVP_PKEY_type(pkey->type); } @@ -21626,12 +21629,30 @@ void* wolfSSL_GetRsaDecCtx(WOLFSSL* ssl) } int wolfSSL_BIO_read_filename(WOLFSSL_BIO *b, const char *name) { - (void)b; - (void)name; - WOLFSSL_ENTER("wolfSSL_BIO_read_filename"); - WOLFSSL_STUB("wolfSSL_BIO_read_filename"); + #ifndef NO_FILESYSTEM + XFILE fp; + + WOLFSSL_ENTER("wolfSSL_BIO_new_file"); - return 0; + if ((wolfSSL_BIO_get_fp(b, &fp) == SSL_SUCCESS) && (fp != NULL)) + { + XFCLOSE(fp); + } + + fp = XFOPEN(name, "r"); + if (fp == NULL) + return SSL_BAD_FILE; + + if (wolfSSL_BIO_set_fp(b, fp, BIO_CLOSE) != SSL_SUCCESS) { + return SSL_BAD_FILE; + } + + return SSL_SUCCESS; + #else + (void)name; + (void)b; + return SSL_NOT_IMPLEMENTED; + #endif } #ifdef HAVE_ECC diff --git a/support/wolfssl.pc b/support/wolfssl.pc index 476dff764..332856616 100644 --- a/support/wolfssl.pc +++ b/support/wolfssl.pc @@ -1,4 +1,4 @@ -prefix=/usr/local +prefix=/usr exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include diff --git a/wolfssl/openssl/pem.h b/wolfssl/openssl/pem.h index 60624aa5c..d9d671877 100644 --- a/wolfssl/openssl/pem.h +++ b/wolfssl/openssl/pem.h @@ -99,6 +99,9 @@ int wolfSSL_PEM_write_bio_PrivateKey(WOLFSSL_BIO* bio, WOLFSSL_EVP_PKEY* key, WOLFSSL_API int wolfSSL_EVP_PKEY_type(int type); +WOLFSSL_API +int wolfSSL_EVP_PKEY_base_id(const EVP_PKEY *pkey); + #if !defined(NO_FILESYSTEM) WOLFSSL_API WOLFSSL_EVP_PKEY *wolfSSL_PEM_read_PUBKEY(FILE *fp, EVP_PKEY **x, diff --git a/wolfssl/openssl/ssl.h b/wolfssl/openssl/ssl.h index 60b1ea647..5ff1a3167 100644 --- a/wolfssl/openssl/ssl.h +++ b/wolfssl/openssl/ssl.h @@ -322,6 +322,8 @@ typedef WOLFSSL_X509_STORE_CTX X509_STORE_CTX; #define X509_OBJECT_free_contents wolfSSL_X509_OBJECT_free_contents #define EVP_PKEY_new wolfSSL_PKEY_new #define EVP_PKEY_free wolfSSL_EVP_PKEY_free +#define EVP_PKEY_type wolfSSL_EVP_PKEY_type +#define EVP_PKEY_base_id wolfSSL_EVP_PKEY_base_id #define X509_cmp_current_time wolfSSL_X509_cmp_current_time #define sk_X509_REVOKED_num wolfSSL_sk_X509_REVOKED_num #define X509_CRL_get_REVOKED wolfSSL_X509_CRL_get_REVOKED