-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaes.h
76 lines (60 loc) · 2.85 KB
/
aes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include "gsl-lite.hpp"
#include "types.h"
#include <array>
#include <cstdint>
#include <vector>
namespace AES128 {
constexpr size_t NUM_SBOXES = 200;
constexpr size_t BLOCK_SIZE = 16;
constexpr size_t KEY_SIZE = 16;
constexpr size_t NUM_BLOCKS = 1;
bool aes_128(const std::vector<uint8_t> &key_in,
const std::vector<uint8_t> &plaintext_in,
std::vector<uint8_t> &ciphertext_out);
std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
aes_128_with_sbox_output(const std::vector<uint8_t> &key_in,
const std::vector<uint8_t> &plaintext_in,
std::vector<uint8_t> &ciphertext_out);
void aes_128_s_shares(const std::vector<gsl::span<uint8_t>> &key_in,
const std::vector<gsl::span<uint8_t>> &t_shares,
const std::vector<uint8_t> &plaintext_in,
std::vector<gsl::span<uint8_t>> &ciphertext_shares_out,
std::vector<gsl::span<uint8_t>> &s_shares_out);
} // namespace AES128
namespace AES192 {
constexpr size_t NUM_SBOXES = 416;
constexpr size_t BLOCK_SIZE = 16;
constexpr size_t KEY_SIZE = 24;
constexpr size_t NUM_BLOCKS = 2;
bool aes_192(const std::vector<uint8_t> &key_in,
const std::vector<uint8_t> &plaintexts_in,
std::vector<uint8_t> &ciphertexts_out);
std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
aes_192_with_sbox_output(const std::vector<uint8_t> &key_in,
const std::vector<uint8_t> &plaintext_in,
std::vector<uint8_t> &ciphertext_out);
void aes_192_s_shares(const std::vector<gsl::span<uint8_t>> &key_in,
const std::vector<gsl::span<uint8_t>> &t_shares,
const std::vector<uint8_t> &plaintext_in,
std::vector<gsl::span<uint8_t>> &ciphertext_shares_out,
std::vector<gsl::span<uint8_t>> &s_shares_out);
} // namespace AES192
namespace AES256 {
constexpr size_t NUM_SBOXES = 500;
constexpr size_t BLOCK_SIZE = 16;
constexpr size_t KEY_SIZE = 32;
constexpr size_t NUM_BLOCKS = 2;
bool aes_256(const std::vector<uint8_t> &key_in,
const std::vector<uint8_t> &plaintexts_in,
std::vector<uint8_t> &ciphertexts_out);
std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
aes_256_with_sbox_output(const std::vector<uint8_t> &key_in,
const std::vector<uint8_t> &plaintext_in,
std::vector<uint8_t> &ciphertext_out);
void aes_256_s_shares(const std::vector<gsl::span<uint8_t>> &key_in,
const std::vector<gsl::span<uint8_t>> &t_shares,
const std::vector<uint8_t> &plaintext_in,
std::vector<gsl::span<uint8_t>> &ciphertext_shares_out,
std::vector<gsl::span<uint8_t>> &s_shares_out);
} // namespace AES256