Botan  2.7.0
Crypto and TLS for C++11
Functions
ffi_keywrap.cpp File Reference
#include <botan/ffi.h>
#include <botan/internal/ffi_util.h>

Go to the source code of this file.

Functions

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)
 

Function Documentation

◆ botan_key_unwrap3394()

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 
)

Definition at line 34 of file ffi_keywrap.cpp.

References BOTAN_CURRENT_FUNCTION, BOTAN_FFI_ERROR_NOT_IMPLEMENTED, Botan_FFI::ffi_guard_thunk(), Botan::rfc3394_keyunwrap(), and Botan_FFI::write_vec_output().

37  {
38 #if defined(BOTAN_HAS_RFC3394_KEYWRAP)
39  return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int {
40  const Botan::SymmetricKey kek_sym(kek, kek_len);
41  const Botan::secure_vector<uint8_t> key_ct(wrapped_key, wrapped_key + wrapped_key_len);
42  const Botan::secure_vector<uint8_t> key_pt = Botan::rfc3394_keyunwrap(key_ct, kek_sym);
43  return write_vec_output(key, key_len, key_pt);
44  });
45 #else
47 #endif
48  }
int ffi_guard_thunk(const char *func_name, Thunk thunk)
Definition: ffi_util.h:64
int write_vec_output(uint8_t out[], size_t *out_len, const std::vector< uint8_t, Alloc > &buf)
Definition: ffi_util.h:146
#define BOTAN_CURRENT_FUNCTION
Definition: compiler.h:143
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
secure_vector< uint8_t > rfc3394_keyunwrap(const secure_vector< uint8_t > &key, const SymmetricKey &kek)
Definition: rfc3394.cpp:28

◆ botan_key_wrap3394()

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 
)

Key wrapping as per RFC 3394

Definition at line 18 of file ffi_keywrap.cpp.

References BOTAN_CURRENT_FUNCTION, BOTAN_FFI_ERROR_NOT_IMPLEMENTED, Botan_FFI::ffi_guard_thunk(), Botan::rfc3394_keywrap(), and Botan_FFI::write_vec_output().

21  {
22 #if defined(BOTAN_HAS_RFC3394_KEYWRAP)
23  return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int {
24  const Botan::SymmetricKey kek_sym(kek, kek_len);
25  const Botan::secure_vector<uint8_t> key_pt(key, key + key_len);
26  const Botan::secure_vector<uint8_t> key_ct = Botan::rfc3394_keywrap(key_pt, kek_sym);
27  return write_vec_output(wrapped_key, wrapped_key_len, key_ct);
28  });
29 #else
31 #endif
32  }
int ffi_guard_thunk(const char *func_name, Thunk thunk)
Definition: ffi_util.h:64
int write_vec_output(uint8_t out[], size_t *out_len, const std::vector< uint8_t, Alloc > &buf)
Definition: ffi_util.h:146
#define BOTAN_CURRENT_FUNCTION
Definition: compiler.h:143
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
secure_vector< uint8_t > rfc3394_keywrap(const secure_vector< uint8_t > &key, const SymmetricKey &kek)
Definition: rfc3394.cpp:14