diff options
Diffstat (limited to 'src/pubkey/pubkey.cpp')
-rw-r--r-- | src/pubkey/pubkey.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/pubkey/pubkey.cpp b/src/pubkey/pubkey.cpp index 6e63f9fc9..c27cf4a05 100644 --- a/src/pubkey/pubkey.cpp +++ b/src/pubkey/pubkey.cpp @@ -38,33 +38,33 @@ PK_Encryptor_EME::PK_Encryptor_EME(const Public_Key& key, throw Lookup_Error("PK_Encryptor_EME: No working engine for " + key.algo_name()); - eme = (eme_name == "Raw") ? 0 : get_eme(eme_name); + eme = (eme_name == "Raw") ? nullptr : get_eme(eme_name); } /* * Encrypt a message */ -SecureVector<byte> +std::vector<byte> PK_Encryptor_EME::enc(const byte in[], size_t length, RandomNumberGenerator& rng) const { if(eme) { - SecureVector<byte> encoded = + secure_vector<byte> encoded = eme->encode(in, length, op->max_input_bits(), rng); if(8*(encoded.size() - 1) + high_bit(encoded[0]) > op->max_input_bits()) throw Invalid_Argument("PK_Encryptor_EME: Input is too large"); - return op->encrypt(&encoded[0], encoded.size(), rng); + return unlock(op->encrypt(&encoded[0], encoded.size(), rng)); } else { if(8*(length - 1) + high_bit(in[0]) > op->max_input_bits()) throw Invalid_Argument("PK_Encryptor_EME: Input is too large"); - return op->encrypt(&in[0], length, rng); + return unlock(op->encrypt(&in[0], length, rng)); } } @@ -98,17 +98,17 @@ PK_Decryptor_EME::PK_Decryptor_EME(const Private_Key& key, throw Lookup_Error("PK_Decryptor_EME: No working engine for " + key.algo_name()); - eme = (eme_name == "Raw") ? 0 : get_eme(eme_name); + eme = (eme_name == "Raw") ? nullptr : get_eme(eme_name); } /* * Decrypt a message */ -SecureVector<byte> PK_Decryptor_EME::dec(const byte msg[], - size_t length) const +secure_vector<byte> PK_Decryptor_EME::dec(const byte msg[], + size_t length) const { try { - SecureVector<byte> decrypted = op->decrypt(msg, length); + secure_vector<byte> decrypted = op->decrypt(msg, length); if(eme) return eme->decode(decrypted, op->max_input_bits()); else @@ -130,8 +130,8 @@ PK_Signer::PK_Signer(const Private_Key& key, { Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); - op = 0; - verify_op = 0; + op = nullptr; + verify_op = nullptr; while(const Engine* engine = i.next()) { @@ -156,7 +156,7 @@ PK_Signer::PK_Signer(const Private_Key& key, /* * Sign a message */ -SecureVector<byte> PK_Signer::sign_message(const byte msg[], size_t length, +std::vector<byte> PK_Signer::sign_message(const byte msg[], size_t length, RandomNumberGenerator& rng) { update(msg, length); @@ -174,16 +174,16 @@ void PK_Signer::update(const byte in[], size_t length) /* * Check the signature we just created, to help prevent fault attacks */ -bool PK_Signer::self_test_signature(const MemoryRegion<byte>& msg, - const MemoryRegion<byte>& sig) const +bool PK_Signer::self_test_signature(const std::vector<byte>& msg, + const std::vector<byte>& sig) const { if(!verify_op) return true; // checking disabled, assume ok if(verify_op->with_recovery()) { - SecureVector<byte> recovered = - verify_op->verify_mr(&sig[0], sig.size()); + std::vector<byte> recovered = + unlock(verify_op->verify_mr(&sig[0], sig.size())); if(msg.size() > recovered.size()) { @@ -206,13 +206,13 @@ bool PK_Signer::self_test_signature(const MemoryRegion<byte>& msg, /* * Create a signature */ -SecureVector<byte> PK_Signer::signature(RandomNumberGenerator& rng) +std::vector<byte> PK_Signer::signature(RandomNumberGenerator& rng) { - SecureVector<byte> encoded = emsa->encoding_of(emsa->raw_data(), - op->max_input_bits(), - rng); + std::vector<byte> encoded = unlock(emsa->encoding_of(emsa->raw_data(), + op->max_input_bits(), + rng)); - SecureVector<byte> plain_sig = op->sign(&encoded[0], encoded.size(), rng); + std::vector<byte> plain_sig = unlock(op->sign(&encoded[0], encoded.size(), rng)); BOTAN_ASSERT(self_test_signature(encoded, plain_sig), "PK_Signer consistency check failed"); @@ -234,11 +234,11 @@ SecureVector<byte> PK_Signer::signature(RandomNumberGenerator& rng) .start_cons(SEQUENCE) .encode_list(sig_parts) .end_cons() - .get_contents(); + .get_contents_unlocked(); } else throw Encoding_Error("PK_Signer: Unknown signature format " + - to_string(sig_format)); + std::to_string(sig_format)); } /* @@ -307,7 +307,7 @@ bool PK_Verifier::check_signature(const byte sig[], size_t length) BER_Decoder ber_sig = decoder.start_cons(SEQUENCE); size_t count = 0; - SecureVector<byte> real_sig; + std::vector<byte> real_sig; while(ber_sig.more_items()) { BigInt sig_part; @@ -324,7 +324,7 @@ bool PK_Verifier::check_signature(const byte sig[], size_t length) } else throw Decoding_Error("PK_Verifier: Unknown signature format " + - to_string(sig_format)); + std::to_string(sig_format)); } catch(Invalid_Argument) { return false; } } @@ -332,19 +332,19 @@ bool PK_Verifier::check_signature(const byte sig[], size_t length) /* * Verify a signature */ -bool PK_Verifier::validate_signature(const MemoryRegion<byte>& msg, +bool PK_Verifier::validate_signature(const secure_vector<byte>& msg, const byte sig[], size_t sig_len) { if(op->with_recovery()) { - SecureVector<byte> output_of_key = op->verify_mr(sig, sig_len); + secure_vector<byte> output_of_key = op->verify_mr(sig, sig_len); return emsa->verify(output_of_key, msg, op->max_input_bits()); } else { Null_RNG rng; - SecureVector<byte> encoded = + secure_vector<byte> encoded = emsa->encoding_of(msg, op->max_input_bits(), rng); return op->verify(&encoded[0], encoded.size(), sig, sig_len); @@ -370,14 +370,14 @@ PK_Key_Agreement::PK_Key_Agreement(const PK_Key_Agreement_Key& key, throw Lookup_Error("PK_Key_Agreement: No working engine for " + key.algo_name()); - kdf = (kdf_name == "Raw") ? 0 : get_kdf(kdf_name); + kdf = (kdf_name == "Raw") ? nullptr : get_kdf(kdf_name); } SymmetricKey PK_Key_Agreement::derive_key(size_t key_len, const byte in[], size_t in_len, const byte params[], size_t params_len) const { - SecureVector<byte> z = op->agree(in, in_len); + secure_vector<byte> z = op->agree(in, in_len); if(!kdf) return z; |