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

Go to the source code of this file.

Functions

 BOTAN_FFI_DECLARE_STRUCT (botan_mac_struct, Botan::MessageAuthenticationCode, 0xA06E8FC1)
 
int botan_mac_clear (botan_mac_t mac)
 
int botan_mac_destroy (botan_mac_t mac)
 
int botan_mac_final (botan_mac_t mac, uint8_t out[])
 
int botan_mac_get_keyspec (botan_mac_t mac, size_t *out_minimum_keylength, size_t *out_maximum_keylength, size_t *out_keylength_modulo)
 
int botan_mac_init (botan_mac_t *mac, const char *mac_name, uint32_t flags)
 
int botan_mac_name (botan_mac_t mac, char *name, size_t *name_len)
 
int botan_mac_output_length (botan_mac_t mac, size_t *out)
 
int botan_mac_set_key (botan_mac_t mac, const uint8_t *key, size_t key_len)
 
int botan_mac_update (botan_mac_t mac, const uint8_t *buf, size_t len)
 

Function Documentation

◆ BOTAN_FFI_DECLARE_STRUCT()

BOTAN_FFI_DECLARE_STRUCT ( botan_mac_struct  ,
Botan::MessageAuthenticationCode  ,
0xA06E8FC1   
)

◆ botan_mac_clear()

int botan_mac_clear ( botan_mac_t  mac)

Definition at line 49 of file ffi_mac.cpp.

50  {
51  return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, { m.clear(); });
52  }
BigInt const BigInt & m
Definition: bigint.h:1094
#define BOTAN_FFI_DO(T, obj, param, block)
Definition: ffi_util.h:92

References BOTAN_FFI_DO, and Botan::m.

◆ botan_mac_destroy()

int botan_mac_destroy ( botan_mac_t  mac)

Definition at line 34 of file ffi_mac.cpp.

35  {
36  return BOTAN_FFI_CHECKED_DELETE(mac);
37  }
#define BOTAN_FFI_CHECKED_DELETE(o)
Definition: ffi_util.h:120

References BOTAN_FFI_CHECKED_DELETE.

◆ botan_mac_final()

int botan_mac_final ( botan_mac_t  mac,
uint8_t  out[] 
)

Definition at line 59 of file ffi_mac.cpp.

60  {
61  return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, { m.final(out); });
62  }
BigInt const BigInt & m
Definition: bigint.h:1094
size_t char * out
Definition: ffi.h:162
#define BOTAN_FFI_DO(T, obj, param, block)
Definition: ffi_util.h:92

References BOTAN_FFI_DO, Botan::m, and out.

◆ botan_mac_get_keyspec()

int botan_mac_get_keyspec ( botan_mac_t  mac,
size_t *  out_minimum_keylength,
size_t *  out_maximum_keylength,
size_t *  out_keylength_modulo 
)

Definition at line 70 of file ffi_mac.cpp.

74  {
75  return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, {
77  *out_minimum_keylength = m.minimum_keylength();
79  *out_maximum_keylength = m.maximum_keylength();
81  *out_keylength_modulo = m.key_spec().keylength_multiple();
82  });
83  }
size_t size_t size_t * out_keylength_modulo
Definition: ffi.h:407
size_t size_t * out_maximum_keylength
Definition: ffi.h:407
BigInt const BigInt & m
Definition: bigint.h:1094
#define BOTAN_FFI_DO(T, obj, param, block)
Definition: ffi_util.h:92
size_t * out_minimum_keylength
Definition: ffi.h:407

References BOTAN_FFI_DO, Botan::m, out_keylength_modulo, out_maximum_keylength, and out_minimum_keylength.

◆ botan_mac_init()

int botan_mac_init ( botan_mac_t mac,
const char *  mac_name,
uint32_t  flags 
)

Definition at line 17 of file ffi_mac.cpp.

18  {
19  return ffi_guard_thunk(__func__, [=]() -> int {
20  if(!mac || !mac_name || flags != 0)
22 
23  std::unique_ptr<Botan::MessageAuthenticationCode> m =
24  Botan::MessageAuthenticationCode::create(mac_name);
25 
26  if(m == nullptr)
28 
29  *mac = new botan_mac_struct(m.release());
30  return BOTAN_FFI_SUCCESS;
31  });
32  }
int ffi_guard_thunk(const char *func_name, std::function< int()> thunk)
Definition: ffi.cpp:86
BigInt const BigInt & m
Definition: bigint.h:1094
const char * mac_name
Definition: ffi.h:345
size_t char uint32_t flags
Definition: ffi.h:162

References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, Botan_FFI::ffi_guard_thunk(), flags, Botan::m, and mac_name.

◆ botan_mac_name()

int botan_mac_name ( botan_mac_t  mac,
char *  name,
size_t *  name_len 
)

Definition at line 64 of file ffi_mac.cpp.

65  {
66  return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, {
67  return write_str_output(name, name_len, m.name()); });
68  }
char * name
Definition: ffi.h:330
int write_str_output(uint8_t out[], size_t *out_len, const std::string &str)
Definition: ffi_util.h:151
BigInt const BigInt & m
Definition: bigint.h:1094
char size_t * name_len
Definition: ffi.h:330
#define BOTAN_FFI_DO(T, obj, param, block)
Definition: ffi_util.h:92

References BOTAN_FFI_DO, Botan::m, name, name_len, and Botan_FFI::write_str_output().

◆ botan_mac_output_length()

int botan_mac_output_length ( botan_mac_t  mac,
size_t *  out 
)

Definition at line 44 of file ffi_mac.cpp.

45  {
46  return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, { *out = m.output_length(); });
47  }
BigInt const BigInt & m
Definition: bigint.h:1094
size_t char * out
Definition: ffi.h:162
#define BOTAN_FFI_DO(T, obj, param, block)
Definition: ffi_util.h:92

References BOTAN_FFI_DO, Botan::m, and out.

◆ botan_mac_set_key()

int botan_mac_set_key ( botan_mac_t  mac,
const uint8_t *  key,
size_t  key_len 
)

Definition at line 39 of file ffi_mac.cpp.

40  {
41  return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, { m.set_key(key, key_len); });
42  }
BigInt const BigInt & m
Definition: bigint.h:1094
const uint8_t * key
Definition: ffi.h:362
#define BOTAN_FFI_DO(T, obj, param, block)
Definition: ffi_util.h:92
const uint8_t size_t key_len
Definition: ffi.h:362

References BOTAN_FFI_DO, key, key_len, and Botan::m.

◆ botan_mac_update()

int botan_mac_update ( botan_mac_t  mac,
const uint8_t *  buf,
size_t  len 
)

Definition at line 54 of file ffi_mac.cpp.

55  {
56  return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, { m.update(buf, len); });
57  }
const uint8_t * buf
Definition: ffi.h:371
BigInt const BigInt & m
Definition: bigint.h:1094
const uint8_t size_t len
Definition: ffi.h:139
#define BOTAN_FFI_DO(T, obj, param, block)
Definition: ffi_util.h:92

References BOTAN_FFI_DO, buf, len, and Botan::m.