/src/Botan-3.13.0/build/include/public/botan/nist_keywrap.h
Line | Count | Source |
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 | | |
13 | | namespace Botan { |
14 | | |
15 | | class 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 | | */ |
24 | | std::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 | | */ |
33 | 0 | inline std::vector<uint8_t> nist_key_wrap(std::span<const uint8_t> input, const BlockCipher& bc) { |
34 | 0 | return nist_key_wrap(input.data(), input.size(), bc); |
35 | 0 | } |
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 | | */ |
45 | | secure_vector<uint8_t> BOTAN_PUBLIC_API(2, 4) |
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 | | */ |
55 | 0 | inline secure_vector<uint8_t> nist_key_unwrap(std::span<const uint8_t> input, const BlockCipher& bc) { |
56 | 0 | return nist_key_unwrap(input.data(), input.size(), bc); |
57 | 0 | } |
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 | | */ |
66 | | std::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 | | */ |
75 | 0 | inline std::vector<uint8_t> nist_key_wrap_padded(std::span<const uint8_t> input, const BlockCipher& bc) { |
76 | 0 | return nist_key_wrap_padded(input.data(), input.size(), bc); |
77 | 0 | } |
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 | | */ |
87 | | secure_vector<uint8_t> BOTAN_PUBLIC_API(2, 4) |
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 | | */ |
97 | 0 | inline secure_vector<uint8_t> nist_key_unwrap_padded(std::span<const uint8_t> input, const BlockCipher& bc) { |
98 | 0 | return nist_key_unwrap_padded(input.data(), input.size(), bc); |
99 | 0 | } |
100 | | |
101 | | } // namespace Botan |
102 | | |
103 | | #endif |