PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
rijndael.h
Go to the documentation of this file.
1 /*
2  * contrib/pgcrypto/rijndael.h
3  *
4  * $OpenBSD: rijndael.h,v 1.3 2001/05/09 23:01:32 markus Exp $ */
5 
6 /* This is an independent implementation of the encryption algorithm: */
7 /* */
8 /* RIJNDAEL by Joan Daemen and Vincent Rijmen */
9 /* */
10 /* which is a candidate algorithm in the Advanced Encryption Standard */
11 /* programme of the US National Institute of Standards and Technology. */
12 /* */
13 /* Copyright in this implementation is held by Dr B R Gladman but I */
14 /* hereby give permission for its free direct or derivative use subject */
15 /* to acknowledgment of its origin and compliance with any conditions */
16 /* that the originators of the algorithm place on its exploitation. */
17 /* */
18 /* Dr Brian Gladman (gladman@seven77.demon.co.uk) 14th January 1999 */
19 
20 #ifndef _RIJNDAEL_H_
21 #define _RIJNDAEL_H_
22 
23 /* 1. Standard types for AES cryptography source code */
24 
25 typedef uint8 u1byte; /* an 8 bit unsigned character type */
26 typedef uint16 u2byte; /* a 16 bit unsigned integer type */
27 typedef uint32 u4byte; /* a 32 bit unsigned integer type */
28 
29 typedef int8 s1byte; /* an 8 bit signed character type */
30 typedef int16 s2byte; /* a 16 bit signed integer type */
31 typedef int32 s4byte; /* a 32 bit signed integer type */
32 
33 typedef struct _rijndael_ctx
34 {
36  int decrypt;
39 } rijndael_ctx;
40 
41 
42 /* 2. Standard interface for AES cryptographic routines */
43 
44 /* These are all based on 32 bit unsigned values and will therefore */
45 /* require endian conversions for big-endian architectures */
46 
48  rijndael_set_key(rijndael_ctx *, const u4byte *, const u4byte, int);
49 void rijndael_encrypt(rijndael_ctx *, const u4byte *, u4byte *);
50 void rijndael_decrypt(rijndael_ctx *, const u4byte *, u4byte *);
51 
52 /* conventional interface */
53 
54 void aes_set_key(rijndael_ctx *ctx, const uint8 *key, unsigned keybits, int enc);
55 void aes_ecb_encrypt(rijndael_ctx *ctx, uint8 *data, unsigned len);
56 void aes_ecb_decrypt(rijndael_ctx *ctx, uint8 *data, unsigned len);
57 void aes_cbc_encrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len);
58 void aes_cbc_decrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len);
59 
60 #endif /* _RIJNDAEL_H_ */
signed short int16
Definition: c.h:252
rijndael_ctx * rijndael_set_key(rijndael_ctx *, const u4byte *, const u4byte, int)
Definition: rijndael.c:305
void aes_cbc_encrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len)
Definition: rijndael.c:545
unsigned char uint8
Definition: c.h:263
uint32 u4byte
Definition: rijndael.h:27
signed int int32
Definition: c.h:253
u4byte k_len
Definition: rijndael.h:35
unsigned short uint16
Definition: c.h:264
uint8 u1byte
Definition: rijndael.h:25
struct pg_encoding enc
Definition: encode.c:522
unsigned int uint32
Definition: c.h:265
void aes_cbc_decrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len)
Definition: rijndael.c:567
u4byte d_key[64]
Definition: rijndael.h:38
signed char int8
Definition: c.h:251
int16 s2byte
Definition: rijndael.h:30
struct _rijndael_ctx rijndael_ctx
uint16 u2byte
Definition: rijndael.h:26
int32 s4byte
Definition: rijndael.h:31
void aes_ecb_encrypt(rijndael_ctx *ctx, uint8 *data, unsigned len)
Definition: rijndael.c:513
u4byte e_key[64]
Definition: rijndael.h:37
void aes_set_key(rijndael_ctx *ctx, const uint8 *key, unsigned keybits, int enc)
Definition: rijndael.c:504
void aes_ecb_decrypt(rijndael_ctx *ctx, uint8 *data, unsigned len)
Definition: rijndael.c:529
int8 s1byte
Definition: rijndael.h:29
void rijndael_encrypt(rijndael_ctx *, const u4byte *, u4byte *)
Definition: rijndael.c:387
void rijndael_decrypt(rijndael_ctx *, const u4byte *, u4byte *)
Definition: rijndael.c:451