source: project/wiki/eggref/4/aes @ 33289

Last change on this file since 33289 was 33289, checked in by Alaric Snell-Pym, 5 years ago

Ported docs from chicken 3 version of this egg

File size: 4.5 KB
Line 
1[[tags:egg]]
2
3== AES
4
5=== Introduction
6
7The aes egg implements the AES / Rijndael cryptosystem.
8
9It does not provide any higher-level operations such as encryption 'modes'; it just provides two procedures per variant of the algorithm, which take a key (as a blob of the correct length) and return a procedure that maps 16-byte blobs to 16-byte blobs - one for encryption, one for decryption.
10
11Rather conflating the purpose of the egg but usefully for writing tests, there are also procedures provided for converting between blobs and hexadecimal strings.
12
13=== Examples
14
15<enscript highlight="scheme">
16(use aes)
17(use crypto-tools) ; for the hexstring functions
18(define encryptor (make-aes128-encryptor (hexstring->blob "00010203050607080A0B0C0D0F101112")))
19(define decryptor (make-aes128-decryptor (hexstring->blob "00010203050607080A0B0C0D0F101112")))
20(define encrypted (encryptor (hexstring->blob "506812A45F08C889B97F5980038B8359")))
21(define decrypted (decryptor encrypted))
22
23(blob->hexstring encrypted)
24 => "d8f532538289ef7d06b506a4fd5be9c9"
25
26(blob->hexstring decrypted)
27 => "506812a45f08c889b97f5980038b8359"
28</enscript>
29
30=== Library functions
31
32<procedure>(make-aes128-encryptor BLOB) => PROCESSOR</procedure>
33<procedure>(make-aes128-decryptor BLOB) => PROCESSOR</procedure>
34<procedure>(make-aes192-encryptor BLOB) => PROCESSOR</procedure>
35<procedure>(make-aes192-decryptor BLOB) => PROCESSOR</procedure>
36<procedure>(make-aes256-encryptor BLOB) => PROCESSOR</procedure>
37<procedure>(make-aes256-decryptor BLOB) => PROCESSOR</procedure>
38
39Using the supplied blob as a raw key, return a procedure that maps 16-byte blobs to 16-byte blobs, either encrypting or decrypting them with the specified key. The key is not modified in any way; if you just split your data into blocks (with padding) and encrypt each, you will merely be operating in ECB mode, which isn't very secure.
40
41128-bit keys must be 16 bytes long, 192-bit keys 24 bytes, and 256-bit keys 32 bytes. Otherwise, an error will be signalled. Likewise, passing a blob of other than 16 bytes to a `PROCESSOR` will result in an error.
42
43=== Authors
44
45[[alaric-blagrave-snellpym|Alaric B. Snell-Pym]], based on public domain code from [[http://www.efgh.com/software/rijndael.htm]].
46
47My modifications extend no further than pasting it together and putting static modifiers on all the functions.
48
49The author of the original code is "Philip J. Erdelsky <pje@efgh.com>", who based it on code by Vincent Rijmen  vincent.rijmen@esat.kuleuven.ac.be, Antoon Bosselaers antoon.bosselaers@esat.kuleuven.ac.be, and Paulo Barreto paulo.barreto@terra.com.br
50
51=== License
52
53The C code is based on public-domain code.
54
55However, the Scheme wrapper is subject to the following license:
56
57  Copyright (c) 2003-2009, Warhead.org.uk Ltd
58  All rights reserved.
59
60  Redistribution and use in source and binary forms, with or without
61  modification, are permitted provided that the following conditions
62  are met:
63
64  Redistributions of source code must retain the above copyright
65  notice, this list of conditions and the following disclaimer.
66
67  Redistributions in binary form must reproduce the above copyright
68  notice, this list of conditions and the following disclaimer in the
69  documentation and/or other materials provided with the distribution.
70
71  Neither the names of Warhead.org.uk Ltd, Snell Systems, nor Kitten
72  Technologies, nor the names of their contributors may be used to
73  endorse or promote products derived from this software without
74  specific prior written permission.
75
76  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
77  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
78  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
79  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
80  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
81  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
82  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
83  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
84  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
85  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
86  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
87  POSSIBILITY OF SUCH DAMAGE.
88
89=== Requirements
90
91The C implementation of the AES code is entirely embedded in the egg.
92
93=== Version History
94
95* 1.4: Fixed compiler warnings
96* 1.3: Fixed metadata
97* 1.2: Ported to chicken 4
98* 1.1: Removed non-AES-specific support functionality into the [[crypto-tools]] egg
99* 1.0: Initial release
Note: See TracBrowser for help on using the repository browser.