From b85d5831364495af8bed5ec709f22c489159ebc0 Mon Sep 17 00:00:00 2001 From: Daniel Neus Date: Tue, 28 Jun 2016 17:03:07 +0200 Subject: fix build with disabled pkcs11 module --- src/tests/test_pkcs11.cpp | 5 +++++ src/tests/test_pkcs11_high_level.cpp | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/tests/test_pkcs11.cpp b/src/tests/test_pkcs11.cpp index 676e3f21a..85110cabf 100644 --- a/src/tests/test_pkcs11.cpp +++ b/src/tests/test_pkcs11.cpp @@ -7,6 +7,9 @@ #include "test_pkcs11.h" namespace Botan_Tests { + +#if defined(BOTAN_HAS_PKCS11) + using namespace Botan; using namespace PKCS11; @@ -39,4 +42,6 @@ std::vector PKCS11_Test::run_pkcs11_tests(const std::string& name, return results; } +#endif + } diff --git a/src/tests/test_pkcs11_high_level.cpp b/src/tests/test_pkcs11_high_level.cpp index f68203496..1fe2e6883 100644 --- a/src/tests/test_pkcs11_high_level.cpp +++ b/src/tests/test_pkcs11_high_level.cpp @@ -29,12 +29,12 @@ #include #include -#if defined(BOTAN_HAS_RSA) +#if defined(BOTAN_HAS_RSA) && defined(BOTAN_HAS_PKCS11) #include #include #endif -#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO) +#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO) && defined(BOTAN_HAS_PKCS11) #include #include #include @@ -43,7 +43,7 @@ #include #endif -#if defined(BOTAN_HAS_X509_CERTIFICATES) +#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_HAS_PKCS11) #include #endif -- cgit v1.2.3 From d70e8347738df1e1e061514cc42413006a1ab9a1 Mon Sep 17 00:00:00 2001 From: Daniel Neus Date: Tue, 28 Jun 2016 18:03:39 +0200 Subject: use NULL_RNG to make clear that the RNG is not used --- src/lib/prov/pkcs11/p11_ecdh.cpp | 14 ++------------ src/lib/prov/pkcs11/p11_ecdsa.cpp | 14 ++------------ 2 files changed, 4 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/lib/prov/pkcs11/p11_ecdh.cpp b/src/lib/prov/pkcs11/p11_ecdh.cpp index 82c1716af..de24d6da4 100644 --- a/src/lib/prov/pkcs11/p11_ecdh.cpp +++ b/src/lib/prov/pkcs11/p11_ecdh.cpp @@ -15,12 +15,7 @@ #include #include #include - -#if defined(BOTAN_HAS_SYSTEM_RNG) - #include -#else - #include -#endif +#include namespace Botan { @@ -33,14 +28,9 @@ ECDH_PublicKey PKCS11_ECDH_PublicKey::export_key() const ECDH_PrivateKey PKCS11_ECDH_PrivateKey::export_key() const { - -#if defined(BOTAN_HAS_SYSTEM_RNG) - System_RNG rng; -#else - AutoSeeded_RNG rng; -#endif auto priv_key = get_attribute_value(AttributeType::Value); + Null_RNG rng; return ECDH_PrivateKey(rng, domain(), BigInt::decode(priv_key)); } diff --git a/src/lib/prov/pkcs11/p11_ecdsa.cpp b/src/lib/prov/pkcs11/p11_ecdsa.cpp index 4aeacda72..078bc429d 100644 --- a/src/lib/prov/pkcs11/p11_ecdsa.cpp +++ b/src/lib/prov/pkcs11/p11_ecdsa.cpp @@ -14,12 +14,7 @@ #include #include #include - -#if defined(BOTAN_HAS_SYSTEM_RNG) - #include -#else - #include -#endif +#include namespace Botan { namespace PKCS11 { @@ -47,14 +42,9 @@ bool PKCS11_ECDSA_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) ECDSA_PrivateKey PKCS11_ECDSA_PrivateKey::export_key() const { - -#if defined(BOTAN_HAS_SYSTEM_RNG) - System_RNG rng; -#else - AutoSeeded_RNG rng; -#endif auto priv_key = get_attribute_value(AttributeType::Value); + Null_RNG rng; return ECDSA_PrivateKey(rng, domain(), BigInt::decode(priv_key)); } -- cgit v1.2.3 From dae2bff6dab46c6c9d0ce5f62d0eac8f058c670b Mon Sep 17 00:00:00 2001 From: Daniel Neus Date: Tue, 28 Jun 2016 18:19:41 +0200 Subject: reuse BigInt::encode_1363 instead of self written logic --- src/lib/prov/pkcs11/p11_rsa.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src') diff --git a/src/lib/prov/pkcs11/p11_rsa.cpp b/src/lib/prov/pkcs11/p11_rsa.cpp index 331e1d0a7..9e5675301 100644 --- a/src/lib/prov/pkcs11/p11_rsa.cpp +++ b/src/lib/prov/pkcs11/p11_rsa.cpp @@ -163,12 +163,7 @@ class PKCS11_RSA_Decryption_Operation : public PK_Ops::Decryption // Unblind for RSA/RAW decryption if(!m_mechanism.padding_size()) { - secure_vector unblinded_data = BigInt::encode_locked(m_blinder.unblind(BigInt::decode(decrypted_data))); - - // pad possible leading zeros that were stripped off during conversion to BigInt - secure_vector padded_result(m_key.get_n().bits() / 8 - unblinded_data.size()); - padded_result.insert(padded_result.end(), unblinded_data.begin(), unblinded_data.end()); - decrypted_data = padded_result; + decrypted_data = BigInt::encode_1363(m_blinder.unblind(BigInt::decode(decrypted_data)), m_key.get_n().bits() / 8 ); } valid_mask = 0xFF; -- cgit v1.2.3 From e6e8151cf6900d3a1b83ebb40527022438aefa8f Mon Sep 17 00:00:00 2001 From: Daniel Neus Date: Tue, 28 Jun 2016 18:25:44 +0200 Subject: check for asn1 and pubkey module presence --- src/tests/test_pkcs11_high_level.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tests/test_pkcs11_high_level.cpp b/src/tests/test_pkcs11_high_level.cpp index 1fe2e6883..3be2b7268 100644 --- a/src/tests/test_pkcs11_high_level.cpp +++ b/src/tests/test_pkcs11_high_level.cpp @@ -26,8 +26,13 @@ #include #endif -#include -#include +#if defined(BOTAN_HAS_ASN1) + #include +#endif + +#if defined (BOTAN_HAS_PUBLIC_KEY_CRYPTO) + #include +#endif #if defined(BOTAN_HAS_RSA) && defined(BOTAN_HAS_PKCS11) #include -- cgit v1.2.3 From 8bfa53524298db986bd284272beecabfd8e13ba9 Mon Sep 17 00:00:00 2001 From: Daniel Neus Date: Tue, 28 Jun 2016 21:36:45 +0200 Subject: fix some warnings and one compile error --- src/lib/prov/pkcs11/p11_ecc_key.cpp | 2 +- src/lib/prov/pkcs11/p11_ecdh.h | 4 ++-- src/lib/prov/pkcs11/p11_ecdsa.h | 4 ++-- src/lib/prov/pkcs11/p11_mechanism.cpp | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lib/prov/pkcs11/p11_ecc_key.cpp b/src/lib/prov/pkcs11/p11_ecc_key.cpp index 4382b8c2b..0c3e879d9 100644 --- a/src/lib/prov/pkcs11/p11_ecc_key.cpp +++ b/src/lib/prov/pkcs11/p11_ecc_key.cpp @@ -40,7 +40,7 @@ EC_PublicKeyImportProperties::EC_PublicKeyImportProperties(const std::vector ec_parameters = get_attribute_value(AttributeType::EcParams); m_domain_params = EC_Group(unlock(ec_parameters)); diff --git a/src/lib/prov/pkcs11/p11_ecdh.h b/src/lib/prov/pkcs11/p11_ecdh.h index 9a73be1c5..749a00d52 100644 --- a/src/lib/prov/pkcs11/p11_ecdh.h +++ b/src/lib/prov/pkcs11/p11_ecdh.h @@ -33,7 +33,7 @@ class BOTAN_DLL PKCS11_ECDH_PublicKey final : public PKCS11_EC_PublicKey * @param handle the handle of the ECDH public key */ PKCS11_ECDH_PublicKey(Session& session, ObjectHandle handle) - : PKCS11_EC_PublicKey(session, handle) + : EC_PublicKey(), PKCS11_EC_PublicKey(session, handle) {} /** @@ -42,7 +42,7 @@ class BOTAN_DLL PKCS11_ECDH_PublicKey final : public PKCS11_EC_PublicKey * @param props the attributes of the public key */ PKCS11_ECDH_PublicKey(Session& session, const EC_PublicKeyImportProperties& props) - : PKCS11_EC_PublicKey(session, props) + : EC_PublicKey(), PKCS11_EC_PublicKey(session, props) {} inline std::string algo_name() const override diff --git a/src/lib/prov/pkcs11/p11_ecdsa.h b/src/lib/prov/pkcs11/p11_ecdsa.h index 2ac59e028..d3d07a780 100644 --- a/src/lib/prov/pkcs11/p11_ecdsa.h +++ b/src/lib/prov/pkcs11/p11_ecdsa.h @@ -31,7 +31,7 @@ class BOTAN_DLL PKCS11_ECDSA_PublicKey final : public PKCS11_EC_PublicKey, publi * @param handle the handle of the ECDSA public key */ PKCS11_ECDSA_PublicKey(Session& session, ObjectHandle handle) - : PKCS11_EC_PublicKey(session, handle) + : EC_PublicKey(), PKCS11_EC_PublicKey(session, handle) {} /** @@ -40,7 +40,7 @@ class BOTAN_DLL PKCS11_ECDSA_PublicKey final : public PKCS11_EC_PublicKey, publi * @param props the attributes of the public key */ PKCS11_ECDSA_PublicKey(Session& session, const EC_PublicKeyImportProperties& props) - : PKCS11_EC_PublicKey(session, props) + : EC_PublicKey(), PKCS11_EC_PublicKey(session, props) {} inline std::string algo_name() const override diff --git a/src/lib/prov/pkcs11/p11_mechanism.cpp b/src/lib/prov/pkcs11/p11_mechanism.cpp index b3cc1c83b..299f211c3 100644 --- a/src/lib/prov/pkcs11/p11_mechanism.cpp +++ b/src/lib/prov/pkcs11/p11_mechanism.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -208,7 +209,7 @@ MechanismWrapper MechanismWrapper::create_ecdsa_mechanism(const std::string& has if(hash_name != "Raw") { - hash_name = hash_for_deterministic_signature(hash); + hash_name = hash_for_emsa(hash); } auto mechanism_type = EcdsaHash.find(hash_name); -- cgit v1.2.3 From 02fbb280da57ae714574de86601d17528aef0194 Mon Sep 17 00:00:00 2001 From: Daniel Neus Date: Tue, 28 Jun 2016 21:38:32 +0200 Subject: remove unnecessary include --- src/lib/prov/pkcs11/p11_mechanism.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/lib/prov/pkcs11/p11_mechanism.cpp b/src/lib/prov/pkcs11/p11_mechanism.cpp index 299f211c3..07ac00770 100644 --- a/src/lib/prov/pkcs11/p11_mechanism.cpp +++ b/src/lib/prov/pkcs11/p11_mechanism.cpp @@ -7,7 +7,6 @@ */ #include -#include #include #include -- cgit v1.2.3