diff options
Diffstat (limited to 'src/lib/pubkey/mceies/mceies.cpp')
-rw-r--r-- | src/lib/pubkey/mceies/mceies.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/lib/pubkey/mceies/mceies.cpp b/src/lib/pubkey/mceies/mceies.cpp index 253e9ddee..e50df3156 100644 --- a/src/lib/pubkey/mceies/mceies.cpp +++ b/src/lib/pubkey/mceies/mceies.cpp @@ -14,14 +14,14 @@ namespace Botan { namespace { -secure_vector<byte> aead_key(const secure_vector<byte>& mk, +secure_vector<uint8_t> aead_key(const secure_vector<uint8_t>& mk, const AEAD_Mode& aead) { // Fold the key as required for the AEAD mode in use if(aead.valid_keylength(mk.size())) return mk; - secure_vector<byte> r(aead.key_spec().maximum_keylength()); + secure_vector<uint8_t> r(aead.key_spec().maximum_keylength()); for(size_t i = 0; i != mk.size(); ++i) r[i % r.size()] ^= mk[i]; return r; @@ -29,16 +29,16 @@ secure_vector<byte> aead_key(const secure_vector<byte>& mk, } -secure_vector<byte> +secure_vector<uint8_t> mceies_encrypt(const McEliece_PublicKey& pubkey, - const byte pt[], size_t pt_len, - const byte ad[], size_t ad_len, + const uint8_t pt[], size_t pt_len, + const uint8_t ad[], size_t ad_len, RandomNumberGenerator& rng, const std::string& algo) { PK_KEM_Encryptor kem_op(pubkey, rng, "KDF1(SHA-512)"); - secure_vector<byte> mce_ciphertext, mce_key; + secure_vector<uint8_t> mce_ciphertext, mce_key; kem_op.encrypt(mce_ciphertext, mce_key, 64, rng); const size_t mce_code_bytes = (pubkey.get_code_length() + 7) / 8; @@ -54,9 +54,9 @@ mceies_encrypt(const McEliece_PublicKey& pubkey, aead->set_key(aead_key(mce_key, *aead)); aead->set_associated_data(ad, ad_len); - const secure_vector<byte> nonce = rng.random_vec(nonce_len); + const secure_vector<uint8_t> nonce = rng.random_vec(nonce_len); - secure_vector<byte> msg(mce_ciphertext.size() + nonce.size() + pt_len); + secure_vector<uint8_t> msg(mce_ciphertext.size() + nonce.size() + pt_len); copy_mem(msg.data(), mce_ciphertext.data(), mce_ciphertext.size()); copy_mem(msg.data() + mce_ciphertext.size(), nonce.data(), nonce.size()); copy_mem(msg.data() + mce_ciphertext.size() + nonce.size(), pt, pt_len); @@ -66,10 +66,10 @@ mceies_encrypt(const McEliece_PublicKey& pubkey, return msg; } -secure_vector<byte> +secure_vector<uint8_t> mceies_decrypt(const McEliece_PrivateKey& privkey, - const byte ct[], size_t ct_len, - const byte ad[], size_t ad_len, + const uint8_t ct[], size_t ct_len, + const uint8_t ad[], size_t ad_len, const std::string& algo) { try @@ -88,12 +88,12 @@ mceies_decrypt(const McEliece_PrivateKey& privkey, if(ct_len < mce_code_bytes + nonce_len + aead->tag_size()) throw Exception("Input message too small to be valid"); - const secure_vector<byte> mce_key = kem_op.decrypt(ct, mce_code_bytes, 64); + const secure_vector<uint8_t> mce_key = kem_op.decrypt(ct, mce_code_bytes, 64); aead->set_key(aead_key(mce_key, *aead)); aead->set_associated_data(ad, ad_len); - secure_vector<byte> pt(ct + mce_code_bytes + nonce_len, ct + ct_len); + secure_vector<uint8_t> pt(ct + mce_code_bytes + nonce_len, ct + ct_len); aead->start(&ct[mce_code_bytes], nonce_len); aead->finish(pt, 0); |