~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to contrib/pgcrypto/rijndael.h

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

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