aboutsummaryrefslogtreecommitdiffstats
path: root/checks/ecdsa.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'checks/ecdsa.cpp')
-rw-r--r--checks/ecdsa.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/checks/ecdsa.cpp b/checks/ecdsa.cpp
index 5cf353e58..554f72dd7 100644
--- a/checks/ecdsa.cpp
+++ b/checks/ecdsa.cpp
@@ -32,7 +32,7 @@ using namespace Botan;
namespace {
-std::string to_hex(const SecureVector<byte>& bin)
+std::string to_hex(const std::vector<byte>& bin)
{
return hex_encode(&bin[0], bin.size());
}
@@ -54,7 +54,7 @@ void test_hash_larger_than_n(RandomNumberGenerator& rng)
ECDSA_PrivateKey priv_key(rng, dom_pars);
- SecureVector<byte> message(20);
+ std::vector<byte> message(20);
for(size_t i = 0; i != message.size(); ++i)
message[i] = i;
@@ -64,14 +64,14 @@ void test_hash_larger_than_n(RandomNumberGenerator& rng)
PK_Signer pk_signer_224(priv_key, "EMSA1_BSI(SHA-224)");
// Verify we can sign and verify with SHA-160
- SecureVector<byte> signature_160 = pk_signer_160.sign_message(message, rng);
+ std::vector<byte> signature_160 = pk_signer_160.sign_message(message, rng);
CHECK(pk_verifier_160.verify_message(message, signature_160));
bool signature_failed = false;
try
{
- SecureVector<byte> signature_224 = pk_signer_224.sign_message(message, rng);
+ std::vector<byte> signature_224 = pk_signer_224.sign_message(message, rng);
}
catch(Encoding_Error)
{
@@ -84,7 +84,7 @@ void test_hash_larger_than_n(RandomNumberGenerator& rng)
// sign it with the normal EMSA1
PK_Signer pk_signer(priv_key, "EMSA1(SHA-224)");
- SecureVector<byte> signature = pk_signer.sign_message(message, rng);
+ std::vector<byte> signature = pk_signer.sign_message(message, rng);
PK_Verifier pk_verifier(priv_key, "EMSA1_BSI(SHA-224)");
@@ -104,7 +104,7 @@ void test_decode_ecdsa_X509()
CHECK_MESSAGE(to_hex(cert.authority_key_id()) == "0096452DE588F966C4CCDF161DD1F3F5341B71E7", "error reading authority key id from x509 ecdsa certificate");
CHECK_MESSAGE(to_hex(cert.subject_key_id()) == "0096452DE588F966C4CCDF161DD1F3F5341B71E7", "error reading Subject key id from x509 ecdsa certificate");
- std::auto_ptr<X509_PublicKey> pubkey(cert.subject_public_key());
+ std::unique_ptr<X509_PublicKey> pubkey(cert.subject_public_key());
bool ver_ec = cert.check_signature(*pubkey);
CHECK_MESSAGE(ver_ec, "could not positively verify correct selfsigned x509-ecdsa certificate");
}
@@ -116,7 +116,7 @@ void test_decode_ver_link_SHA256()
X509_Certificate root_cert(TEST_DATA_DIR "/root2_SHA256.cer");
X509_Certificate link_cert(TEST_DATA_DIR "/link_SHA256.cer");
- std::auto_ptr<X509_PublicKey> pubkey(root_cert.subject_public_key());
+ std::unique_ptr<X509_PublicKey> pubkey(root_cert.subject_public_key());
bool ver_ec = link_cert.check_signature(*pubkey);
CHECK_MESSAGE(ver_ec, "could not positively verify correct SHA256 link x509-ecdsa certificate");
@@ -128,7 +128,7 @@ void test_decode_ver_link_SHA1()
X509_Certificate root_cert(TEST_DATA_DIR "/root_SHA1.163.crt");
X509_Certificate link_cert(TEST_DATA_DIR "/link_SHA1.166.crt");
- std::auto_ptr<X509_PublicKey> pubkey(root_cert.subject_public_key());
+ std::unique_ptr<X509_PublicKey> pubkey(root_cert.subject_public_key());
bool ver_ec = link_cert.check_signature(*pubkey);
CHECK_MESSAGE(ver_ec, "could not positively verify correct SHA1 link x509-ecdsa certificate");
}
@@ -142,8 +142,8 @@ void test_sign_then_ver(RandomNumberGenerator& rng)
PK_Signer signer(ecdsa, "EMSA1(SHA-1)");
- SecureVector<byte> msg = hex_decode("12345678901234567890abcdef12");
- SecureVector<byte> sig = signer.sign_message(msg, rng);
+ secure_vector<byte> msg = hex_decode("12345678901234567890abcdef12");
+ std::vector<byte> sig = signer.sign_message(msg, rng);
PK_Verifier verifier(ecdsa, "EMSA1(SHA-1)");
@@ -174,7 +174,7 @@ bool test_ec_sign(RandomNumberGenerator& rng)
for(size_t i = 0; i != 256; ++i)
signer.update(static_cast<byte>(i));
- SecureVector<byte> sig = signer.signature(rng);
+ std::vector<byte> sig = signer.signature(rng);
for(u32bit i = 0; i != 256; ++i)
verifier.update(static_cast<byte>(i));
@@ -251,11 +251,11 @@ void test_create_and_verify(RandomNumberGenerator& rng)
std::ofstream priv_key(TEST_DATA_DIR "/dompar_private.pkcs8.pem");
priv_key << PKCS8::PEM_encode(key);
- std::auto_ptr<PKCS8_PrivateKey> loaded_key(PKCS8::load_key(TEST_DATA_DIR "/wo_dompar_private.pkcs8.pem", rng));
+ std::unique_ptr<PKCS8_PrivateKey> loaded_key(PKCS8::load_key(TEST_DATA_DIR "/wo_dompar_private.pkcs8.pem", rng));
ECDSA_PrivateKey* loaded_ec_key = dynamic_cast<ECDSA_PrivateKey*>(loaded_key.get());
CHECK_MESSAGE(loaded_ec_key, "the loaded key could not be converted into an ECDSA_PrivateKey");
- std::auto_ptr<PKCS8_PrivateKey> loaded_key_1(PKCS8::load_key(TEST_DATA_DIR "/rsa_private.pkcs8.pem", rng));
+ std::unique_ptr<PKCS8_PrivateKey> loaded_key_1(PKCS8::load_key(TEST_DATA_DIR "/rsa_private.pkcs8.pem", rng));
ECDSA_PrivateKey* loaded_rsa_key = dynamic_cast<ECDSA_PrivateKey*>(loaded_key_1.get());
CHECK_MESSAGE(!loaded_rsa_key, "the loaded key is ECDSA_PrivateKey -> shouldn't be, is a RSA-Key");
@@ -267,11 +267,11 @@ void test_create_and_verify(RandomNumberGenerator& rng)
std::string G_secp_comp = "04081523d03d4f12cd02879dea4bf6a4f3a7df26ed888f10c5b2235a1274c386a2f218300dee6ed217841164533bcdc903f07a096f9fbf4ee95bac098a111f296f5830fe5c35b3e344d5df3a2256985f64fbe6d0edcc4c61d18bef681dd399df3d0194c5a4315e012e0245ecea56365baa9e8be1f7";
std::string order_g = "0e1a16196e6000000000bc7f1618d867b15bb86474418f";
- // ::SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
- SecureVector<byte> sv_order_g = hex_decode ( order_g );
+ // ::std::vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_order_g = hex_decode ( order_g );
// BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_p_secp("2117607112719756483104013348936480976596328609518055062007450442679169492999007105354629105748524349829824407773719892437896937279095106809");
@@ -289,7 +289,7 @@ void test_create_and_verify(RandomNumberGenerator& rng)
std::string key_odd_oid_str = PKCS8::PEM_encode(key_odd_oid);
DataSource_Memory key_data_src(key_odd_oid_str);
- std::auto_ptr<PKCS8_PrivateKey> loaded_key2(PKCS8::load_key(key_data_src, rng));
+ std::unique_ptr<PKCS8_PrivateKey> loaded_key2(PKCS8::load_key(key_data_src, rng));
if(!dynamic_cast<ECDSA_PrivateKey*>(loaded_key.get()))
{
@@ -343,8 +343,8 @@ void test_curve_registry(RandomNumberGenerator& rng)
PK_Signer signer(ecdsa, "EMSA1(SHA-1)");
PK_Verifier verifier(ecdsa, "EMSA1(SHA-1)");
- SecureVector<byte> msg = hex_decode("12345678901234567890abcdef12");
- SecureVector<byte> sig = signer.sign_message(msg, rng);
+ secure_vector<byte> msg = hex_decode("12345678901234567890abcdef12");
+ std::vector<byte> sig = signer.sign_message(msg, rng);
if(!verifier.verify_message(msg, sig))
std::cout << "Failed testing ECDSA sig for curve " << oids[i] << "\n";
@@ -361,17 +361,17 @@ void test_read_pkcs8(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
- SecureVector<byte> msg = hex_decode("12345678901234567890abcdef12");
+ secure_vector<byte> msg = hex_decode("12345678901234567890abcdef12");
try
{
- std::auto_ptr<PKCS8_PrivateKey> loaded_key(PKCS8::load_key(TEST_DATA_DIR "/wo_dompar_private.pkcs8.pem", rng));
+ std::unique_ptr<PKCS8_PrivateKey> loaded_key(PKCS8::load_key(TEST_DATA_DIR "/wo_dompar_private.pkcs8.pem", rng));
ECDSA_PrivateKey* ecdsa = dynamic_cast<ECDSA_PrivateKey*>(loaded_key.get());
CHECK_MESSAGE(ecdsa, "the loaded key could not be converted into an ECDSA_PrivateKey");
PK_Signer signer(*ecdsa, "EMSA1(SHA-1)");
- SecureVector<byte> sig = signer.sign_message(msg, rng);
+ std::vector<byte> sig = signer.sign_message(msg, rng);
PK_Verifier verifier(*ecdsa, "EMSA1(SHA-1)");
@@ -385,7 +385,7 @@ void test_read_pkcs8(RandomNumberGenerator& rng)
try
{
- std::auto_ptr<PKCS8_PrivateKey> loaded_key_nodp(PKCS8::load_key(TEST_DATA_DIR "/nodompar_private.pkcs8.pem", rng));
+ std::unique_ptr<PKCS8_PrivateKey> loaded_key_nodp(PKCS8::load_key(TEST_DATA_DIR "/nodompar_private.pkcs8.pem", rng));
// anew in each test with unregistered domain-parameters
ECDSA_PrivateKey* ecdsa_nodp = dynamic_cast<ECDSA_PrivateKey*>(loaded_key_nodp.get());
CHECK_MESSAGE(ecdsa_nodp, "the loaded key could not be converted into an ECDSA_PrivateKey");
@@ -393,14 +393,14 @@ void test_read_pkcs8(RandomNumberGenerator& rng)
PK_Signer signer(*ecdsa_nodp, "EMSA1(SHA-1)");
PK_Verifier verifier(*ecdsa_nodp, "EMSA1(SHA-1)");
- SecureVector<byte> signature_nodp = signer.sign_message(msg, rng);
+ std::vector<byte> signature_nodp = signer.sign_message(msg, rng);
CHECK_MESSAGE(verifier.verify_message(msg, signature_nodp),
"generated signature could not be verified positively (no_dom)");
try
{
- std::auto_ptr<PKCS8_PrivateKey> loaded_key_withdp(
+ std::unique_ptr<PKCS8_PrivateKey> loaded_key_withdp(
PKCS8::load_key(TEST_DATA_DIR "/withdompar_private.pkcs8.pem", rng));
std::cout << "Unexpected success: loaded key with unknown OID\n";