10Duke Enterprise C++ SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
AESSecretKey.h
1
#ifndef TENDUKE_CRYPTO_AES_AESSECRETKEY_H
2
#define TENDUKE_CRYPTO_AES_AESSECRETKEY_H
3
4
#include "./AESGCMCipher.h"
5
#include "../SecretKey.h"
6
#include "../../../utl/DataSpan.h"
7
8
#include <cstdint>
9
#include <memory>
10
11
namespace
tenduke
{
namespace
crypto
{
namespace
aes {
12
13
class
AESSecretKey :
public
virtual
SecretKey
14
{
15
public
:
16
explicit
AESSecretKey(std::unique_ptr<::tenduke::utl::DataSpan> key)
17
: data(std::move(key))
18
{
19
}
20
21
// The key is not copyable
22
AESSecretKey(
const
AESSecretKey&) =
delete
;
23
AESSecretKey& operator=(
const
AESSecretKey&) =
delete
;
24
25
// The key is movable
26
AESSecretKey(AESSecretKey&& other)
noexcept
=
default
;
27
AESSecretKey& operator=(AESSecretKey&& other)
noexcept
=
default
;
28
33
virtual
std::unique_ptr<::tenduke::crypto::aes::AESGCMCipher>
gcmCipher
()
const
= 0;
34
35
virtual
uint32_t numBits()
const
36
{
37
// AES key size is at most 32 bytes
38
return
static_cast<
uint32_t
>
(
size
() * 8);
39
}
40
41
const
unsigned
char
*
raw
()
const override
42
{
43
return
data->data();
44
}
45
46
size_t
size
()
const override
47
{
48
return
data->size_bytes();
49
}
50
51
private
:
52
std::unique_ptr<::tenduke::utl::DataSpan> data;
53
};
54
55
}}}
56
57
#endif
//TENDUKE_CRYPTO_AES_AESSECRETKEY_H
tenduke::crypto::aes::AESSecretKey::gcmCipher
virtual std::unique_ptr<::tenduke::crypto::aes::AESGCMCipher > gcmCipher() const =0
Returns AES-GCM cipher, which uses this key for operations.
tenduke::crypto::aes::AESSecretKey::size
size_t size() const override
Returns the size of the key in bytes.
Definition
AESSecretKey.h:46
tenduke::crypto::aes::AESSecretKey::raw
const unsigned char * raw() const override
Returns the raw key data as a byte array.
Definition
AESSecretKey.h:41
tenduke::crypto
Cryptography services.
Definition
AbstractCiphers.h:18
tenduke
Root for classes, functions and globals of 10Duke C++ Client.
Definition
APIRequest.h:4
core
core
src
crypto
symmetric
aes
AESSecretKey.h
Generated by
1.17.0