diff --git a/dockerfiles/base/Dockerfile b/dockerfiles/base/Dockerfile index 4024368b..bc2b016d 100644 --- a/dockerfiles/base/Dockerfile +++ b/dockerfiles/base/Dockerfile @@ -1,10 +1,10 @@ -FROM ubuntu:focal +FROM ubuntu:jammy # Install MoCOCrW dependencies (except OpenSSL) RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install \ ca-certificates \ clang \ - clang-format-10 \ + clang-format-11 \ cmake \ g++ \ git \ diff --git a/src/mococrw/openssl_lib.h b/src/mococrw/openssl_lib.h index 87c406df..df45b27f 100644 --- a/src/mococrw/openssl_lib.h +++ b/src/mococrw/openssl_lib.h @@ -353,7 +353,7 @@ class OpenSSLLib size_t tbslen) noexcept; static int SSL_EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md) noexcept; static int SSL_EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int len) noexcept; - static EC_KEY *SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) noexcept; + static const EC_KEY *SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) noexcept; static int SSL_EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, diff --git a/src/mococrw/openssl_wrap.h b/src/mococrw/openssl_wrap.h index 3ffb39ff..6b1490c4 100644 --- a/src/mococrw/openssl_wrap.h +++ b/src/mococrw/openssl_wrap.h @@ -1425,7 +1425,7 @@ enum class EllipticCurvePointConversionForm { }; -EC_KEY *_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey); +const EC_KEY *_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey); void _PKCS5_PBKDF2_HMAC(const std::vector pass, const std::vector salt, diff --git a/src/openssl_lib.cpp b/src/openssl_lib.cpp index 61df36f7..279212c5 100644 --- a/src/openssl_lib.cpp +++ b/src/openssl_lib.cpp @@ -757,7 +757,7 @@ int OpenSSLLib::SSL_EVP_PKEY_CTX_set_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD return EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md); } -EC_KEY *OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) noexcept +EC_KEY *OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY* pkey) noexcept { return EVP_PKEY_get0_EC_KEY(pkey); } diff --git a/src/openssl_wrap.cpp b/src/openssl_wrap.cpp index d47f66e7..c6e97026 100644 --- a/src/openssl_wrap.cpp +++ b/src/openssl_wrap.cpp @@ -1323,7 +1323,7 @@ void _RAND_bytes(unsigned char *buf, int num) void _CRYPTO_malloc_init() { return lib::OpenSSLLib::SSL_CRYPTO_malloc_init(); } -EC_KEY *_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) +const EC_KEY *_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) { return OpensslCallPtr::callChecked(lib::OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY, pkey); } @@ -1494,7 +1494,8 @@ std::vector _EC_KEY_key2buf(const EVP_PKEY *evp, point_conversion_form_ */ EVP_PKEY *evp_ = const_cast(evp); unsigned char *pbuf; - EC_KEY *key = OpensslCallPtr::callChecked(lib::OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY, evp_); + const EC_KEY *key = + OpensslCallPtr::callChecked(lib::OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY, evp_); size_t length = OpensslCallIsPositive::callChecked( lib::OpenSSLLib::SSL_EC_KEY_key2buf, key, form, &pbuf, nullptr); std::vector result(pbuf, pbuf + length); diff --git a/tests/unit/openssl_lib_mock.cpp b/tests/unit/openssl_lib_mock.cpp index 0fc8fd92..ce3ca8d8 100644 --- a/tests/unit/openssl_lib_mock.cpp +++ b/tests/unit/openssl_lib_mock.cpp @@ -886,7 +886,7 @@ int OpenSSLLib::SSL_EVP_MD_size(const EVP_MD *md) noexcept { return OpenSSLLibMockManager::getMockInterface().SSL_EVP_MD_size(md); } -EC_KEY *OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) noexcept +const EC_KEY *OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) noexcept { return OpenSSLLibMockManager::getMockInterface().SSL_EVP_PKEY_get0_EC_KEY(pkey); } diff --git a/tests/unit/test_key.cpp b/tests/unit/test_key.cpp index c157b474..8e60c8ce 100644 --- a/tests/unit/test_key.cpp +++ b/tests/unit/test_key.cpp @@ -386,7 +386,7 @@ TEST_F(KeyHandlingTests, testGetSize) EXPECT_EQ(_eccKeyPairSecp521r1.getKeySize(), 521); EXPECT_EQ(_eccKeyPairSect571r1.getKeySize(), 570); EXPECT_EQ(_Ed448KeyPair.getKeySize(), 456); - EXPECT_EQ(_Ed25519KeyPair.getKeySize(), 253); + EXPECT_EQ(_Ed25519KeyPair.getKeySize(), 256); auto rsaKey1024 = AsymmetricKeypair::generate(mococrw::RSASpec{1024}); EXPECT_EQ(rsaKey1024.getKeySize(), 1024); }