1 | /* rijndael-api.h - Rijndael encryption programming interface.
|
---|
2 | * Author: Kees J. Bot
|
---|
3 | * 3 Nov 2000
|
---|
4 | * Heavily based on the original API code by Antoon Bosselaers,
|
---|
5 | * Vincent Rijmen, and Paulo Barreto, but with a different interface.
|
---|
6 | *
|
---|
7 | * This code (.h and .c) is in the public domain.
|
---|
8 | */
|
---|
9 |
|
---|
10 | #ifndef _CRYPTO__RIJNDAEL_H
|
---|
11 | #define _CRYPTO__RIJNDAEL_H
|
---|
12 |
|
---|
13 | /* Error codes. */
|
---|
14 | #define RD_BAD_KEY_MAT -1 /* Key material not of correct length */
|
---|
15 | #define RD_BAD_BLOCK_LENGTH -2 /* Data is not a block multiple */
|
---|
16 | #define RD_BAD_DATA -3 /* Data contents are invalid (bad padding?) */
|
---|
17 |
|
---|
18 | /* Key information. */
|
---|
19 | #define RD_KEY_HEX -1 /* Key is in hex (otherwise octet length) */
|
---|
20 | #define RD_MAXROUNDS 14 /* Max number of encryption rounds. */
|
---|
21 |
|
---|
22 | typedef struct {
|
---|
23 | int rounds; /* Key-length-dependent number of rounds */
|
---|
24 | unsigned char encsched[RD_MAXROUNDS+1][4][4]; /* Encr key schedule */
|
---|
25 | unsigned char decsched[RD_MAXROUNDS+1][4][4]; /* Decr key schedule */
|
---|
26 | } rd_keyinstance;
|
---|
27 |
|
---|
28 | #define AES_BLOCKSIZE 16
|
---|
29 |
|
---|
30 | /* Function prototypes. */
|
---|
31 |
|
---|
32 | int rijndael_makekey(rd_keyinstance *_key,
|
---|
33 | size_t _keylen, const void *_keymaterial);
|
---|
34 |
|
---|
35 | ssize_t rijndael_ecb_encrypt(rd_keyinstance *_key,
|
---|
36 | const void *_input, void *_output, size_t _length, void *_dummyIV);
|
---|
37 |
|
---|
38 | ssize_t rijndael_ecb_decrypt(rd_keyinstance *_key,
|
---|
39 | const void *_input, void *_output, size_t _length, void *_dummyIV);
|
---|
40 |
|
---|
41 | ssize_t rijndael_cbc_encrypt(rd_keyinstance *_key,
|
---|
42 | const void *_input, void *_output, size_t _length, void *_IV);
|
---|
43 |
|
---|
44 | ssize_t rijndael_cbc_decrypt(rd_keyinstance *_key,
|
---|
45 | const void *_input, void *_output, size_t _length, void *_IV);
|
---|
46 |
|
---|
47 | ssize_t rijndael_cfb1_encrypt(rd_keyinstance *_key,
|
---|
48 | const void *_input, void *_output, size_t _length, void *_IV);
|
---|
49 |
|
---|
50 | ssize_t rijndael_cfb1_decrypt(rd_keyinstance *_key,
|
---|
51 | const void *_input, void *_output, size_t _length, void *_IV);
|
---|
52 |
|
---|
53 | ssize_t rijndael_cfb8_encrypt(rd_keyinstance *_key,
|
---|
54 | const void *_input, void *_output, size_t _length, void *_IV);
|
---|
55 |
|
---|
56 | ssize_t rijndael_cfb8_decrypt(rd_keyinstance *_key,
|
---|
57 | const void *_input, void *_output, size_t _length, void *_IV);
|
---|
58 |
|
---|
59 | ssize_t rijndael_pad(void *_input, size_t _length);
|
---|
60 |
|
---|
61 | ssize_t rijndael_unpad(const void *_input, size_t _length);
|
---|
62 |
|
---|
63 | typedef ssize_t (*rd_function)(rd_keyinstance *_key,
|
---|
64 | const void *_input, void *_output, size_t _length, void *_IV);
|
---|
65 |
|
---|
66 | #ifdef INTERMEDIATE_VALUE_KAT
|
---|
67 |
|
---|
68 | void cipherEncryptUpdateRounds(rd_keyinstance *key,
|
---|
69 | const void *input, void *output, int rounds);
|
---|
70 |
|
---|
71 | void cipherDecryptUpdateRounds(rd_keyinstance *key,
|
---|
72 | const void *input, void *output, int rounds);
|
---|
73 |
|
---|
74 | #endif /* INTERMEDIATE_VALUE_KAT */
|
---|
75 |
|
---|
76 | #endif /* _CRYPTO__RIJNDAEL_H */
|
---|
77 |
|
---|
78 | /*
|
---|
79 | * $PchId: rijndael.h,v 1.1 2005/06/01 10:13:45 philip Exp $
|
---|
80 | */
|
---|