Header And Logo

PostgreSQL
| The world's most advanced open source database.

rijndael.h

Go to the documentation of this file.
00001 /*
00002  * contrib/pgcrypto/rijndael.h
00003  *
00004  *  $OpenBSD: rijndael.h,v 1.3 2001/05/09 23:01:32 markus Exp $ */
00005 
00006 /* This is an independent implementation of the encryption algorithm:   */
00007 /*                                                                      */
00008 /*         RIJNDAEL by Joan Daemen and Vincent Rijmen                   */
00009 /*                                                                      */
00010 /* which is a candidate algorithm in the Advanced Encryption Standard   */
00011 /* programme of the US National Institute of Standards and Technology.  */
00012 /*                                                                      */
00013 /* Copyright in this implementation is held by Dr B R Gladman but I     */
00014 /* hereby give permission for its free direct or derivative use subject */
00015 /* to acknowledgment of its origin and compliance with any conditions   */
00016 /* that the originators of the algorithm place on its exploitation.     */
00017 /*                                                                      */
00018 /* Dr Brian Gladman ([email protected]) 14th January 1999     */
00019 
00020 #ifndef _RIJNDAEL_H_
00021 #define _RIJNDAEL_H_
00022 
00023 /* 1. Standard types for AES cryptography source code               */
00024 
00025 typedef uint8 u1byte;           /* an 8 bit unsigned character type */
00026 typedef uint16 u2byte;          /* a 16 bit unsigned integer type   */
00027 typedef uint32 u4byte;          /* a 32 bit unsigned integer type   */
00028 
00029 typedef int8 s1byte;            /* an 8 bit signed character type   */
00030 typedef int16 s2byte;           /* a 16 bit signed integer type     */
00031 typedef int32 s4byte;           /* a 32 bit signed integer type     */
00032 
00033 typedef struct _rijndael_ctx
00034 {
00035     u4byte      k_len;
00036     int         decrypt;
00037     u4byte      e_key[64];
00038     u4byte      d_key[64];
00039 } rijndael_ctx;
00040 
00041 
00042 /* 2. Standard interface for AES cryptographic routines             */
00043 
00044 /* These are all based on 32 bit unsigned values and will therefore */
00045 /* require endian conversions for big-endian architectures          */
00046 
00047 rijndael_ctx *
00048             rijndael_set_key(rijndael_ctx *, const u4byte *, const u4byte, int);
00049 void        rijndael_encrypt(rijndael_ctx *, const u4byte *, u4byte *);
00050 void        rijndael_decrypt(rijndael_ctx *, const u4byte *, u4byte *);
00051 
00052 /* conventional interface */
00053 
00054 void        aes_set_key(rijndael_ctx *ctx, const uint8 *key, unsigned keybits, int enc);
00055 void        aes_ecb_encrypt(rijndael_ctx *ctx, uint8 *data, unsigned len);
00056 void        aes_ecb_decrypt(rijndael_ctx *ctx, uint8 *data, unsigned len);
00057 void        aes_cbc_encrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len);
00058 void        aes_cbc_decrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len);
00059 
00060 #endif   /* _RIJNDAEL_H_ */