8 #include <botan/rfc3394.h>
9 #include <botan/block_cipher.h>
10 #include <botan/loadstor.h>
11 #include <botan/exceptn.h>
18 if(key.size() % 8 != 0)
21 if(kek.
size() != 16 && kek.
size() != 24 && kek.
size() != 32)
28 const size_t n = key.size() / 8;
33 for(
size_t i = 0; i != 8; ++i)
36 copy_mem(&R[8], key.data(), key.size());
38 for(
size_t j = 0; j <= 5; ++j)
40 for(
size_t i = 1; i <= n; ++i)
42 const uint32_t t = (n * j) + i;
46 aes->encrypt(A.data());
49 uint8_t t_buf[4] = { 0 };
63 if(key.size() < 16 || key.size() % 8 != 0)
66 if(kek.
size() != 16 && kek.
size() != 24 && kek.
size() != 32)
73 const size_t n = (key.size() - 8) / 8;
78 for(
size_t i = 0; i != 8; ++i)
81 copy_mem(R.data(), &key[8], key.size() - 8);
83 for(
size_t j = 0; j <= 5; ++j)
85 for(
size_t i = n; i != 0; --i)
87 const uint32_t t = (5 - j) * n + i;
89 uint8_t t_buf[4] = { 0 };
96 aes->decrypt(A.data());
void xor_buf(T out[], const T in[], size_t length)
void store_be(uint16_t in, uint8_t out[2])
std::string to_string(const BER_Object &obj)
secure_vector< uint8_t > rfc3394_keywrap(const secure_vector< uint8_t > &key, const SymmetricKey &kek)
uint64_t load_be< uint64_t >(const uint8_t in[], size_t off)
std::vector< T, secure_allocator< T >> secure_vector
void copy_mem(T *out, const T *in, size_t n)
static std::unique_ptr< BlockCipher > create_or_throw(const std::string &algo_spec, const std::string &provider="")
secure_vector< uint8_t > rfc3394_keyunwrap(const secure_vector< uint8_t > &key, const SymmetricKey &kek)