10#include <botan/internal/ffi_util.h>
12#if defined(BOTAN_HAS_NIST_KEYWRAP)
13 #include <botan/block_cipher.h>
14 #include <botan/nist_keywrap.h>
27 uint8_t wrapped_key[],
28 size_t* wrapped_key_len) {
29#if defined(BOTAN_HAS_NIST_KEYWRAP)
31 if(padded != 0 && padded != 1) {
35 bc->set_key(kek, kek_len);
37 std::vector<uint8_t> output;
48 BOTAN_UNUSED(cipher_algo, padded, key, key_len, kek, kek_len, wrapped_key, wrapped_key_len);
55 const uint8_t wrapped_key[],
56 size_t wrapped_key_len,
61#if defined(BOTAN_HAS_NIST_KEYWRAP)
63 if(padded != 0 && padded != 1) {
68 bc->set_key(kek, kek_len);
81 BOTAN_UNUSED(cipher_algo, padded, key, key_len, kek, kek_len, wrapped_key, wrapped_key_len);
90 uint8_t wrapped_key[],
91 size_t* wrapped_key_len) {
92 std::string cipher_name =
"AES-" + std::to_string(8 * kek_len);
94 return botan_nist_kw_enc(cipher_name.c_str(), 0, key, key_len, kek, kek_len, wrapped_key, wrapped_key_len);
98 size_t wrapped_key_len,
103 std::string cipher_name =
"AES-" + std::to_string(8 * kek_len);
105 return botan_nist_kw_dec(cipher_name.c_str(), 0, wrapped_key, wrapped_key_len, kek, kek_len, key, key_len);
static std::unique_ptr< BlockCipher > create_or_throw(std::string_view algo_spec, std::string_view provider="")
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
int botan_nist_kw_enc(const char *cipher_algo, int padded, const uint8_t key[], size_t key_len, const uint8_t kek[], size_t kek_len, uint8_t wrapped_key[], size_t *wrapped_key_len)
int botan_key_unwrap3394(const uint8_t wrapped_key[], size_t wrapped_key_len, const uint8_t kek[], size_t kek_len, uint8_t key[], size_t *key_len)
int botan_key_wrap3394(const uint8_t key[], size_t key_len, const uint8_t kek[], size_t kek_len, uint8_t wrapped_key[], size_t *wrapped_key_len)
int botan_nist_kw_dec(const char *cipher_algo, int padded, const uint8_t wrapped_key[], size_t wrapped_key_len, const uint8_t kek[], size_t kek_len, uint8_t key[], size_t *key_len)
int ffi_guard_thunk(const char *func_name, const std::function< int()> &thunk)
int write_vec_output(uint8_t out[], size_t *out_len, const std::vector< uint8_t, Alloc > &buf)
std::vector< uint8_t > nist_key_wrap(const uint8_t input[], size_t input_len, const BlockCipher &bc)
std::vector< uint8_t > nist_key_wrap_padded(const uint8_t input[], size_t input_len, const BlockCipher &bc)
secure_vector< uint8_t > nist_key_unwrap_padded(const uint8_t input[], size_t input_len, const BlockCipher &bc)
std::vector< T, secure_allocator< T > > secure_vector
secure_vector< uint8_t > nist_key_unwrap(const uint8_t input[], size_t input_len, const BlockCipher &bc)