Skip to content

Commit

Permalink
openssl3.0: Fix compile errors
Browse files Browse the repository at this point in the history
The compile errors are fixed.
These were mainly const correctness problems.

However the >200 warnings are not fixed, yet.
Most of them are deprecation warnings.

The docker container for test execution is updated from focal (20.04
LTS) to Jammy (22.04 LTS) as Jammy already ships openssl3.0.x.
  • Loading branch information
Tobias Kaufmann authored and Tobias Kaufmann committed Dec 9, 2022
1 parent efb8dd1 commit c6db586
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docker-build-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion src/mococrw/openssl_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/mococrw/openssl_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t> pass,
const std::vector<uint8_t> salt,
Expand Down
2 changes: 1 addition & 1 deletion src/openssl_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
const EC_KEY* OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY* pkey) noexcept
{
return EVP_PKEY_get0_EC_KEY(pkey);
}
Expand Down
4 changes: 2 additions & 2 deletions src/openssl_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -1494,7 +1494,7 @@ std::vector<uint8_t> _EC_KEY_key2buf(const EVP_PKEY *evp, point_conversion_form_
*/
EVP_PKEY *evp_ = const_cast<EVP_PKEY *>(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<uint8_t> result(pbuf, pbuf + length);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/openssl_lib_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit c6db586

Please sign in to comment.