source: trunk/minix/drivers/random/aes/rijndael-api.h@ 19

Last change on this file since 19 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 2.6 KB
Line 
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 __RIJNDAEL_API_H
11#define __RIJNDAEL_API_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
22typedef 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/* Function prototypes. */
29
30int rijndael_makekey(rd_keyinstance *_key,
31 size_t _keylen, const void *_keymaterial);
32
33ssize_t rijndael_ecb_encrypt(rd_keyinstance *_key,
34 const void *_input, void *_output, size_t _length, void *_dummyIV);
35
36ssize_t rijndael_ecb_decrypt(rd_keyinstance *_key,
37 const void *_input, void *_output, size_t _length, void *_dummyIV);
38
39ssize_t rijndael_cbc_encrypt(rd_keyinstance *_key,
40 const void *_input, void *_output, size_t _length, void *_IV);
41
42ssize_t rijndael_cbc_decrypt(rd_keyinstance *_key,
43 const void *_input, void *_output, size_t _length, void *_IV);
44
45ssize_t rijndael_cfb1_encrypt(rd_keyinstance *_key,
46 const void *_input, void *_output, size_t _length, void *_IV);
47
48ssize_t rijndael_cfb1_decrypt(rd_keyinstance *_key,
49 const void *_input, void *_output, size_t _length, void *_IV);
50
51ssize_t rijndael_cfb8_encrypt(rd_keyinstance *_key,
52 const void *_input, void *_output, size_t _length, void *_IV);
53
54ssize_t rijndael_cfb8_decrypt(rd_keyinstance *_key,
55 const void *_input, void *_output, size_t _length, void *_IV);
56
57ssize_t rijndael_pad(void *_input, size_t _length);
58
59ssize_t rijndael_unpad(const void *_input, size_t _length);
60
61typedef ssize_t (*rd_function)(rd_keyinstance *_key,
62 const void *_input, void *_output, size_t _length, void *_IV);
63
64#ifdef INTERMEDIATE_VALUE_KAT
65
66void cipherEncryptUpdateRounds(rd_keyinstance *key,
67 const void *input, void *output, int rounds);
68
69void cipherDecryptUpdateRounds(rd_keyinstance *key,
70 const void *input, void *output, int rounds);
71
72#endif /* INTERMEDIATE_VALUE_KAT */
73
74#endif /* __RIJNDAEL_API_H */
75
76/*
77 * $PchId: rijndael-api.h,v 1.2 2001/01/10 22:02:21 philip Exp $
78 */
Note: See TracBrowser for help on using the repository browser.