-
Notifications
You must be signed in to change notification settings - Fork 0
/
AES.h
52 lines (41 loc) · 1.35 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
#pragma once
#include <cstdint>
#include "Defines.h"
#include <wmmintrin.h>
#include <xmmintrin.h>
class AES {
public:
AES();
AES(const block& key);
AES(const uint8_t* key);
void setKey(const block& key);
void setKey(const uint8_t* key);
void encryptECB(const block& plaintext, block& ciphertext) const;
block encryptECB(const block& plaintext) const {
block tmp;
encryptECB(plaintext, tmp);
return tmp;
}
void encryptECB_MMO(const block& plaintext, block& ciphertext) const;
block encryptECB_MMO(const block& plaintext) const {
block tmp;
encryptECB_MMO(plaintext, tmp);
return tmp;
}
void decryptECB(const block& ciphertext, block& plaintext) const;
block decryptECB(const block& ciphertext) const {
block tmp;
decryptECB(ciphertext, tmp);
return tmp;
}
void encryptECBBlocks(const block* plaintexts, uint64_t blockLength, block* ciphertexts) const;
void encryptECB_MMO_Blocks(const block* plaintexts, uint64_t blockLength, block* ciphertexts) const;
void encryptCTR(uint64_t baseIdx, uint64_t blockLength, block * ciphertext) const;
block key;
private:
block mRoundKeysEnc[11];
block mRoundKeysDec[11];
};
// An AES instance with a fixed and public key
extern const AES mAesFixedKey;
extern const AES mAesFixedKey2;