Skip to content

Commit ed5969f

Browse files
Tobias KaufmannTobias Kaufmann
authored andcommitted
openssl3.0: Fix compile errors
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.
1 parent 2712195 commit ed5969f

File tree

7 files changed

+10
-9
lines changed

7 files changed

+10
-9
lines changed

dockerfiles/base/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM ubuntu:focal
1+
FROM ubuntu:jammy
22

33
# Install MoCOCrW dependencies (except OpenSSL)
44
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install \
55
ca-certificates \
66
clang \
7-
clang-format-10 \
7+
clang-format-11 \
88
cmake \
99
g++ \
1010
git \

src/mococrw/openssl_lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class OpenSSLLib
353353
size_t tbslen) noexcept;
354354
static int SSL_EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md) noexcept;
355355
static int SSL_EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int len) noexcept;
356-
static EC_KEY *SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) noexcept;
356+
static const EC_KEY *SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) noexcept;
357357
static int SSL_EVP_DigestSignInit(EVP_MD_CTX *ctx,
358358
EVP_PKEY_CTX **pctx,
359359
const EVP_MD *type,

src/mococrw/openssl_wrap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ enum class EllipticCurvePointConversionForm {
14251425

14261426
};
14271427

1428-
EC_KEY *_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey);
1428+
const EC_KEY *_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey);
14291429

14301430
void _PKCS5_PBKDF2_HMAC(const std::vector<uint8_t> pass,
14311431
const std::vector<uint8_t> salt,

src/openssl_lib.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ int OpenSSLLib::SSL_EVP_PKEY_CTX_set_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD
757757
return EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md);
758758
}
759759

760-
EC_KEY *OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) noexcept
760+
EC_KEY *OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY* pkey) noexcept
761761
{
762762
return EVP_PKEY_get0_EC_KEY(pkey);
763763
}

src/openssl_wrap.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ void _RAND_bytes(unsigned char *buf, int num)
13231323

13241324
void _CRYPTO_malloc_init() { return lib::OpenSSLLib::SSL_CRYPTO_malloc_init(); }
13251325

1326-
EC_KEY *_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
1326+
const EC_KEY *_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
13271327
{
13281328
return OpensslCallPtr::callChecked(lib::OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY, pkey);
13291329
}
@@ -1494,7 +1494,8 @@ std::vector<uint8_t> _EC_KEY_key2buf(const EVP_PKEY *evp, point_conversion_form_
14941494
*/
14951495
EVP_PKEY *evp_ = const_cast<EVP_PKEY *>(evp);
14961496
unsigned char *pbuf;
1497-
EC_KEY *key = OpensslCallPtr::callChecked(lib::OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY, evp_);
1497+
const EC_KEY *key =
1498+
OpensslCallPtr::callChecked(lib::OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY, evp_);
14981499
size_t length = OpensslCallIsPositive::callChecked(
14991500
lib::OpenSSLLib::SSL_EC_KEY_key2buf, key, form, &pbuf, nullptr);
15001501
std::vector<uint8_t> result(pbuf, pbuf + length);

tests/unit/openssl_lib_mock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ int OpenSSLLib::SSL_EVP_MD_size(const EVP_MD *md) noexcept
886886
{
887887
return OpenSSLLibMockManager::getMockInterface().SSL_EVP_MD_size(md);
888888
}
889-
EC_KEY *OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) noexcept
889+
const EC_KEY *OpenSSLLib::SSL_EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) noexcept
890890
{
891891
return OpenSSLLibMockManager::getMockInterface().SSL_EVP_PKEY_get0_EC_KEY(pkey);
892892
}

tests/unit/test_key.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ TEST_F(KeyHandlingTests, testGetSize)
386386
EXPECT_EQ(_eccKeyPairSecp521r1.getKeySize(), 521);
387387
EXPECT_EQ(_eccKeyPairSect571r1.getKeySize(), 570);
388388
EXPECT_EQ(_Ed448KeyPair.getKeySize(), 456);
389-
EXPECT_EQ(_Ed25519KeyPair.getKeySize(), 253);
389+
EXPECT_EQ(_Ed25519KeyPair.getKeySize(), 256);
390390
auto rsaKey1024 = AsymmetricKeypair::generate(mococrw::RSASpec{1024});
391391
EXPECT_EQ(rsaKey1024.getKeySize(), 1024);
392392
}

0 commit comments

Comments
 (0)