Botan 3.13.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* KW (key unwrap). See RFC 3394 and NIST SP800-38F
39* @param input the value to be decrypted, output of nist_key_wrap
40* @param input_len length of input
41* @param bc a keyed 128-bit block cipher that will be used to decrypt input
42* @return input decrypted under NIST key wrap algorithm
43* Throws an exception if decryption fails.
44*/
46 nist_key_unwrap(const uint8_t input[], size_t input_len, const BlockCipher& bc);
47
48/**
49* KW (key unwrap). See RFC 3394 and NIST SP800-38F
50* @param input the value to be decrypted, output of nist_key_wrap
51* @param bc a keyed 128-bit block cipher that will be used to decrypt input
52* @return input decrypted under NIST key wrap algorithm
53* Throws an exception if decryption fails.
54*/
55inline secure_vector<uint8_t> nist_key_unwrap(std::span<const uint8_t> input, const BlockCipher& bc) {
56 return nist_key_unwrap(input.data(), input.size(), bc);
57}
58
59/**
60* KWP (key wrap with padding). See RFC 5649 and NIST SP800-38F
61* @param input the value to be encrypted
62* @param input_len length of input
63* @param bc a keyed 128-bit block cipher that will be used to encrypt input
64* @return input encrypted under NIST key wrap algorithm
65*/
66std::vector<uint8_t> BOTAN_PUBLIC_API(2, 4)
67 nist_key_wrap_padded(const uint8_t input[], size_t input_len, const BlockCipher& bc);
68
69/**
70* KWP (key wrap with padding). See RFC 5649 and NIST SP800-38F
71* @param input the value to be encrypted
72* @param bc a keyed 128-bit block cipher that will be used to encrypt input
73* @return input encrypted under NIST key wrap algorithm
74*/
75inline std::vector<uint8_t> nist_key_wrap_padded(std::span<const uint8_t> input, const BlockCipher& bc) {
76 return nist_key_wrap_padded(input.data(), input.size(), bc);
77}
78
79/**
80* KWP (key unwrap with padding). See RFC 5649 and NIST SP800-38F
81* @param input the value to be decrypted, output of nist_key_wrap
82* @param input_len length of input
83* @param bc a keyed 128-bit block cipher that will be used to decrypt input
84* @return input decrypted under NIST key wrap algorithm
85* Throws an exception if decryption fails.
86*/
88 nist_key_unwrap_padded(const uint8_t input[], size_t input_len, const BlockCipher& bc);
89
90/**
91* KWP (key unwrap with padding). See RFC 5649 and NIST SP800-38F
92* @param input the value to be decrypted, output of nist_key_wrap
93* @param bc a keyed 128-bit block cipher that will be used to decrypt input
94* @return input decrypted under NIST key wrap algorithm
95* Throws an exception if decryption fails.
96*/
97inline secure_vector<uint8_t> nist_key_unwrap_padded(std::span<const uint8_t> input, const BlockCipher& bc) {
98 return nist_key_unwrap_padded(input.data(), input.size(), bc);
99}
100
101} // namespace Botan
102
103#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:128
secure_vector< uint8_t > nist_key_unwrap(const uint8_t input[], size_t input_len, const BlockCipher &bc)