blob: db33805eca52775e042cca2829ee8219ef40e942 [file] [log] [blame]
Ben Lindstrom0256e8b2001-08-06 21:24:11 +00001/* $OpenBSD: rijndael.h,v 1.9 2001/07/30 16:23:30 stevesk Exp $ */
Ben Lindstromb22c2b82001-03-05 06:50:47 +00002
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. */
Ben Lindstrom0256e8b2001-08-06 21:24:11 +00009
10/*
11 -----------------------------------------------------------------------
12 Copyright (c) 2001 Dr Brian Gladman <brg@gladman.uk.net>, Worcester, UK
13
14 TERMS
15
16 Redistribution and use in source and binary forms, with or without
17 modification, are permitted provided that the following conditions
18 are met:
19 1. Redistributions of source code must retain the above copyright
20 notice, this list of conditions and the following disclaimer.
21 2. Redistributions in binary form must reproduce the above copyright
22 notice, this list of conditions and the following disclaimer in the
23 documentation and/or other materials provided with the distribution.
24
25 This software is provided 'as is' with no guarantees of correctness or
26 fitness for purpose.
27 -----------------------------------------------------------------------
28*/
Ben Lindstrom36579d32001-01-29 07:39:26 +000029
Ben Lindstromfa1b3d02000-12-10 01:55:37 +000030#ifndef _RIJNDAEL_H_
31#define _RIJNDAEL_H_
Damien Miller874d77b2000-10-14 16:23:11 +110032
Ben Lindstromfa1b3d02000-12-10 01:55:37 +000033#include "config.h"
Damien Miller59939352000-10-15 12:21:32 +110034
Ben Lindstromfa1b3d02000-12-10 01:55:37 +000035/* 1. Standard types for AES cryptography source code */
Damien Miller874d77b2000-10-14 16:23:11 +110036
Ben Lindstromfa1b3d02000-12-10 01:55:37 +000037typedef u_int8_t u1byte; /* an 8 bit unsigned character type */
38typedef u_int16_t u2byte; /* a 16 bit unsigned integer type */
39typedef u_int32_t u4byte; /* a 32 bit unsigned integer type */
Damien Miller874d77b2000-10-14 16:23:11 +110040
Ben Lindstromfa1b3d02000-12-10 01:55:37 +000041typedef int8_t s1byte; /* an 8 bit signed character type */
42typedef int16_t s2byte; /* a 16 bit signed integer type */
43typedef int32_t s4byte; /* a 32 bit signed integer type */
Damien Miller874d77b2000-10-14 16:23:11 +110044
Ben Lindstromfa1b3d02000-12-10 01:55:37 +000045typedef struct _rijndael_ctx {
46 u4byte k_len;
47 int decrypt;
48 u4byte e_key[64];
49 u4byte d_key[64];
50} rijndael_ctx;
Damien Miller874d77b2000-10-14 16:23:11 +110051
Ben Lindstromfa1b3d02000-12-10 01:55:37 +000052
53/* 2. Standard interface for AES cryptographic routines */
54
55/* These are all based on 32 bit unsigned values and will therefore */
56/* require endian conversions for big-endian architectures */
57
Ben Lindstromddb4f242001-05-10 23:26:11 +000058rijndael_ctx *
59rijndael_set_key __P((rijndael_ctx *, const u4byte *, const u4byte, int));
Ben Lindstromfa1b3d02000-12-10 01:55:37 +000060void rijndael_encrypt __P((rijndael_ctx *, const u4byte *, u4byte *));
61void rijndael_decrypt __P((rijndael_ctx *, const u4byte *, u4byte *));
62
63#endif /* _RIJNDAEL_H_ */