Skip to content

Commit

Permalink
Merge bn.h and ossl_common.h to ossl_utils.hpp, and remove unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Nov 28, 2024
1 parent 9be8d3c commit 7a9f582
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 213 deletions.
1 change: 0 additions & 1 deletion src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ configure_file(config.h.in config.h)

if(CRYPTO_BACKEND_OPENSSL)
set(CRYPTO_SOURCES
crypto/bn_ossl.cpp
crypto/dsa_common.cpp
crypto/dsa_ossl.cpp
crypto/ec_curves.cpp
Expand Down
1 change: 0 additions & 1 deletion src/lib/crypto/backend_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#elif defined(CRYPTO_BACKEND_OPENSSL)
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
#include "ossl_common.h"
#if defined(CRYPTO_BACKEND_OPENSSL3)
#include <openssl/provider.h>
#endif
Expand Down
96 changes: 0 additions & 96 deletions src/lib/crypto/bn_ossl.cpp

This file was deleted.

6 changes: 3 additions & 3 deletions src/lib/crypto/dl_ossl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
#include <cstdlib>
#include <string>
#include <cassert>
#include "bn.h"
#include "dl_ossl.h"
#include "ossl_common.h"
#include "utils.h"
#include "ossl_utils.hpp"
#include <openssl/dh.h>
#include <openssl/err.h>
#include <openssl/evp.h>
Expand Down Expand Up @@ -206,7 +205,8 @@ dl_validate_key(rnp::ossl::evp::PKey &pkey, const pgp::mpi *x)
}
int res = EVP_PKEY_param_check(ctx.get());
if (res < 0) {
RNP_LOG("Param validation error: %lu (%s)", ERR_peek_last_error(), ossl_latest_err());
RNP_LOG(
"Param validation error: %lu (%s)", ERR_peek_last_error(), rnp::ossl::latest_err());
}
if (res < 1) {
/* ElGamal specification doesn't seem to restrict P to the safe prime */
Expand Down
7 changes: 2 additions & 5 deletions src/lib/crypto/dl_ossl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@
#ifndef DL_OSSL_H_
#define DL_OSSL_H_

#include "types.h"
#include "config.h"
#include <rnp/rnp_def.h>
#include "mpi.h"
#include "bn.h"
#include <openssl/evp.h>
#include <rnp/rnp_def.h>
#include "ossl_utils.hpp"

rnp::ossl::evp::PKey dl_load_key(const pgp::mpi &mp,
const pgp::mpi *mq,
Expand Down
1 change: 0 additions & 1 deletion src/lib/crypto/dsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "botan_utils.hpp"
#include <rnp/rnp_def.h>
#include "dsa.h"
#include "bn.h"
#include "utils.h"

namespace pgp {
Expand Down
1 change: 0 additions & 1 deletion src/lib/crypto/dsa_ossl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <stdlib.h>
#include <string.h>
#include <rnp/rnp_def.h>
#include "bn.h"
#include "dsa.h"
#include "dl_ossl.h"
#include "utils.h"
Expand Down
1 change: 0 additions & 1 deletion src/lib/crypto/ec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "types.h"
#include "utils.h"
#include "mem.h"
#include "bn.h"
#include "botan_utils.hpp"
#if defined(ENABLE_CRYPTO_REFRESH) || defined(ENABLE_PQC)
#include "x25519.h"
Expand Down
5 changes: 2 additions & 3 deletions src/lib/crypto/ec_ossl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
#include <cassert>
#include "ec.h"
#include "ec_ossl.h"
#include "bn.h"
#include "ossl_common.h"
#include "types.h"
#include "mem.h"
#include "utils.h"
#include "ossl_utils.hpp"
#include <openssl/evp.h>
#include <openssl/objects.h>
#include <openssl/err.h>
Expand Down Expand Up @@ -297,7 +296,7 @@ load_key(const pgp::mpi &keyp, const pgp::mpi *keyx, pgp_curve_t curve)
/* LCOV_EXCL_START */
RNP_LOG("Failed to create EC key with group %s: %s",
curv_desc->openssl_name,
ossl_latest_err());
rnp::ossl::latest_err());
return NULL;
/* LCOV_EXCL_END */
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/crypto/ec_ossl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "types.h"
#include "ec.h"
#include <openssl/evp.h>
#include "bn.h"
#include "ossl_utils.hpp"

namespace pgp {
namespace ec {
Expand Down
1 change: 0 additions & 1 deletion src/lib/crypto/ecdh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "types.h"
#include "utils.h"
#include "mem.h"
#include "bn.h"

// Produces kek of size kek_len which corresponds to length of wrapping key
static bool
Expand Down
1 change: 0 additions & 1 deletion src/lib/crypto/ecdsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "utils.h"
#include <botan/ffi.h>
#include <string.h>
#include "bn.h"
#include "botan_utils.hpp"

static bool
Expand Down
1 change: 0 additions & 1 deletion src/lib/crypto/ecdsa_ossl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "ecdsa.h"
#include "utils.h"
#include <string.h>
#include "bn.h"
#include "ec_ossl.h"
#include <openssl/evp.h>
#include <openssl/err.h>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/crypto/eddsa_ossl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "ec.h"
#include "ec_ossl.h"
#include "utils.h"
#include "bn.h"
#include "ossl_utils.hpp"
#include <openssl/evp.h>
#include <openssl/objects.h>
#include <openssl/err.h>
Expand Down
1 change: 0 additions & 1 deletion src/lib/crypto/elgamal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <rnp/rnp_def.h>
#include "elgamal.h"
#include "utils.h"
#include "bn.h"

// Max supported key byte size
#define ELGAMAL_MAX_P_BYTELEN BITS_TO_BYTES(PGP_MPINT_BITS)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/crypto/elgamal_ossl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
*/

#include <cstdlib>
#include <string>
#include <cstring>
#include <cassert>
#include <rnp/rnp_def.h>
#include "elgamal.h"
#include "dl_ossl.h"
#include "utils.h"
#include "bn.h"
#include "mem.h"
#include "ossl_utils.hpp"
#include <openssl/bn.h>
#include <openssl/dh.h>
#include <openssl/err.h>
Expand Down
40 changes: 0 additions & 40 deletions src/lib/crypto/ossl_common.h

This file was deleted.

Loading

0 comments on commit 7a9f582

Please sign in to comment.