From 628478193789c37bbd49fc82d49c0d005e4f009f Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Wed, 25 Mar 2020 09:49:03 -0400 Subject: [PATCH 1/3] correcting usage of `rsa_exception` in `ecdsa` alg --- include/jwt-cpp/jwt.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h index 4dac8f7..65f21c2 100644 --- a/include/jwt-cpp/jwt.h +++ b/include/jwt-cpp/jwt.h @@ -337,16 +337,16 @@ namespace jwt { if (!private_key.empty()) { std::unique_ptr privkey_bio(BIO_new(BIO_s_mem()), BIO_free_all); if ((size_t)BIO_write(privkey_bio.get(), private_key.data(), private_key.size()) != private_key.size()) - throw rsa_exception("failed to load private key: bio_write failed"); + throw ecdsa_exception("failed to load private key: bio_write failed"); pkey.reset(PEM_read_bio_ECPrivateKey(privkey_bio.get(), nullptr, nullptr, const_cast(private_key_password.c_str())), EC_KEY_free); if (!pkey) - throw rsa_exception("failed to load private key: PEM_read_bio_ECPrivateKey failed"); + throw ecdsa_exception("failed to load private key: PEM_read_bio_ECPrivateKey failed"); size_t keysize = EC_GROUP_get_degree(EC_KEY_get0_group(pkey.get())); if(keysize != signature_length*4 && (signature_length != 132 || keysize != 521)) throw ecdsa_exception("invalid key size"); } if(!pkey) - throw rsa_exception("at least one of public or private key need to be present"); + throw ecdsa_exception("at least one of public or private key need to be present"); if(EC_KEY_check_key(pkey.get()) == 0) throw ecdsa_exception("failed to load key: key is invalid"); From deadb58c237ff4b3b21e75aad7179b926cb5fe7a Mon Sep 17 00:00:00 2001 From: Tyler Stubenvoll Date: Wed, 1 Apr 2020 13:32:42 -0700 Subject: [PATCH 2/3] Fixed cmake for vendored picojson. The CMake file was not handling the case of an internal picojson build, causing include errors in externally built packages. This was due to an inversion of the logic. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b83f26..6e4e3eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ target_link_libraries(jwt-cpp INTERFACE OpenSSL::SSL OpenSSL::Crypto) set(JWT_HEADERS ${JWT_INCLUDE_PATH}/jwt-cpp/base.h ${JWT_INCLUDE_PATH}/jwt-cpp/jwt.h) -if(EXTERNAL_PICOJSON) +if(NOT EXTERNAL_PICOJSON) set(PICO_HEADER ${JWT_INCLUDE_PATH}/picojson/picojson.h) endif() @@ -49,7 +49,7 @@ write_basic_package_version_file( COMPATIBILITY ExactVersion) install(FILES ${JWT_HEADERS} DESTINATION include/jwt-cpp) -if(EXTERNAL_PICOJSON) +if(NOT EXTERNAL_PICOJSON) install(FILES ${PICO_HEADER} DESTINATION include/picojson) endif() From 18761ec28b58eefaebd04fbc57ca1761fa9cf2a8 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Tue, 7 Apr 2020 10:57:22 -0400 Subject: [PATCH 3/3] fixes #57 --- include/jwt-cpp/jwt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h index 4dac8f7..f0a1302 100644 --- a/include/jwt-cpp/jwt.h +++ b/include/jwt-cpp/jwt.h @@ -75,7 +75,7 @@ namespace jwt { inline std::string extract_pubkey_from_cert(const std::string& certstr, const std::string& pw = "") { // TODO: Cannot find the exact version this change happended -#if OPENSSL_VERSION_NUMBER <= 0x1000114fL +#if OPENSSL_VERSION_NUMBER <= 0x10100003L std::unique_ptr certbio(BIO_new_mem_buf(const_cast(certstr.data()), certstr.size()), BIO_free_all); #else std::unique_ptr certbio(BIO_new_mem_buf(certstr.data(), certstr.size()), BIO_free_all);