forked from hackedteam/core-win32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaes_alg.h
85 lines (75 loc) · 2.16 KB
/
aes_alg.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
77
78
79
80
81
82
83
84
85
#ifndef _AES_H
#define _AES_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \brief AES context structure
*/
typedef struct
{
unsigned long erk[64]; /*!< encryption round keys */
unsigned long drk[64]; /*!< decryption round keys */
int nr; /*!< number of rounds */
}
aes_context;
/**
* \brief AES key schedule
*
* \param ctx AES context to be initialized
* \param key the secret key
* \param keysize must be 128, 192 or 256
*/
void aes_set_key( aes_context *ctx, unsigned char *key, int keysize );
/**
* \brief AES block encryption (ECB mode)
*
* \param ctx AES context
* \param input plaintext block
* \param output ciphertext block
*/
void aes_encrypt( aes_context *ctx,
unsigned char input[16],
unsigned char output[16] );
/**
* \brief AES block decryption (ECB mode)
*
* \param ctx AES context
* \param input ciphertext block
* \param output plaintext block
*/
void aes_decrypt( aes_context *ctx,
unsigned char input[16],
unsigned char output[16] );
/**
* \brief AES-CBC buffer encryption
*
* \param ctx AES context
* \param iv initialization vector (modified after use)
* \param input buffer holding the plaintext
* \param output buffer holding the ciphertext
* \param len length of the data to be encrypted
*/
void aes_cbc_encrypt( aes_context *ctx,
unsigned char iv[16],
unsigned char *input,
unsigned char *output,
int len );
/**
* \brief AES-CBC buffer decryption
*
* \param ctx AES context
* \param iv initialization vector (modified after use)
* \param input buffer holding the ciphertext
* \param output buffer holding the plaintext
* \param len length of the data to be decrypted
*/
void aes_cbc_decrypt( aes_context *ctx,
unsigned char iv[16],
unsigned char *input,
unsigned char *output,
int len );
#ifdef __cplusplus
}
#endif
#endif