Botan 3.9.0
Crypto and TLS for C&
nist_keywrap.h
Go to the documentation of this file.
1/*
2* (C) 2011,2017 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_NIST_KEY_WRAP_H_
8#define BOTAN_NIST_KEY_WRAP_H_
9
10#include <botan/secmem.h>
11#include <span>
12
13namespace Botan {
14
15class BlockCipher;
16
17/**
18* Key wrap. See RFC 3394 and NIST SP800-38F
19* @param input the value to be encrypted
20* @param input_len length of input, must be a multiple of 8
21* @param bc a keyed 128-bit block cipher that will be used to encrypt input
22* @return input encrypted under NIST key wrap algorithm
23*/
24std::vector<uint8_t> BOTAN_PUBLIC_API(2, 4)
25 nist_key_wrap(const uint8_t input[], size_t input_len, const BlockCipher& bc);
26
27/**
28* Key wrap. See RFC 3394 and NIST SP800-38F
29* @param input the value to be encrypted
30* @param bc a keyed 128-bit block cipher that will be used to encrypt input
31* @return input encrypted under NIST key wrap algorithm
32*/
33inline std::vector<uint8_t> nist_key_wrap(std::span<const uint8_t> input, const BlockCipher& bc) {
34 return nist_key_wrap(input.data(), input.size(), bc);
35}
36
37/**
38* @param input the value to be decrypted, output of nist_key_wrap
39* @param input_len length of input
40* @param bc a keyed 128-bit block cipher that will be used to decrypt input
41* @return input decrypted under NIST key wrap algorithm
42* Throws an exception if decryption fails.
43*/
45 nist_key_unwrap(const uint8_t input[], size_t input_len, const BlockCipher& bc);
46
47/**
48* @param input the value to be decrypted, output of nist_key_wrap
49* @param bc a keyed 128-bit block cipher that will be used to decrypt input
50* @return input decrypted under NIST key wrap algorithm
51* Throws an exception if decryption fails.
52*/
53inline secure_vector<uint8_t> nist_key_unwrap(std::span<const uint8_t> input, const BlockCipher& bc) {
54 return nist_key_unwrap(input.data(), input.size(), bc);
55}
56
57/**
58* KWP (key wrap with padding). See RFC 5649 and NIST SP800-38F
59* @param input the value to be encrypted
60* @param input_len length of input
61* @param bc a keyed 128-bit block cipher that will be used to encrypt input
62* @return input encrypted under NIST key wrap algorithm
63*/
64std::vector<uint8_t> BOTAN_PUBLIC_API(2, 4)
65 nist_key_wrap_padded(const uint8_t input[], size_t input_len, const BlockCipher& bc);
66
67/**
68* KWP (key wrap with padding). See RFC 5649 and NIST SP800-38F
69* @param input the value to be encrypted
70* @param bc a keyed 128-bit block cipher that will be used to encrypt input
71* @return input encrypted under NIST key wrap algorithm
72*/
73inline std::vector<uint8_t> nist_key_wrap_padded(std::span<const uint8_t> input, const BlockCipher& bc) {
74 return nist_key_wrap_padded(input.data(), input.size(), bc);
75}
76
77/**
78* @param input the value to be decrypted, output of nist_key_wrap
79* @param input_len length of input
80* @param bc a keyed 128-bit block cipher that will be used to decrypt input
81* @return input decrypted under NIST key wrap algorithm
82* Throws an exception if decryption fails.
83*/
85 nist_key_unwrap_padded(const uint8_t input[], size_t input_len, const BlockCipher& bc);
86
87/**
88* @param input the value to be decrypted, output of nist_key_wrap
89* @param bc a keyed 128-bit block cipher that will be used to decrypt input
90* @return input decrypted under NIST key wrap algorithm
91* Throws an exception if decryption fails.
92*/
93inline secure_vector<uint8_t> nist_key_unwrap_padded(std::span<const uint8_t> input, const BlockCipher& bc) {
94 return nist_key_unwrap_padded(input.data(), input.size(), bc);
95}
96
97} // namespace Botan
98
99#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
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
Definition secmem.h:69
secure_vector< uint8_t > nist_key_unwrap(const uint8_t input[], size_t input_len, const BlockCipher &bc)