|
1 AES for lua |
|
2 ----------- |
|
3 |
|
4 This files contain an implementation of AES in lua. The only additional library |
|
5 needed is bitlib. |
|
6 |
|
7 Usage |
|
8 ----- |
|
9 |
|
10 aeslua.lua contains a simple API to encrypt and decrypt lua strings. |
|
11 |
|
12 To encrypt the string "geheim" with the password "password" use: |
|
13 |
|
14 require("aeslua"); |
|
15 cipher = aeslua.encrypt("password", "secret"); |
|
16 |
|
17 and to decrypt the string again: |
|
18 |
|
19 plain = aeslua.decrypt("password", cipher); |
|
20 |
|
21 You can also specify the key size and the encryption mode. For further examples |
|
22 look into the file src/testcryptotest.lua. |
|
23 |
|
24 To use AES directly, have a look at aes.lua and at the example usage in |
|
25 testaes.lua. |
|
26 |
|
27 Installation |
|
28 ------------ |
|
29 |
|
30 Edit the LIBDIR variable in the Makefile and run |
|
31 |
|
32 make install |
|
33 |
|
34 Speed |
|
35 ----- |
|
36 |
|
37 The implementation is rather optimized (it uses tables for most AES operations) |
|
38 but still cannot compete with AES written in other languages. Typical AES |
|
39 implementations reach several 100 MBit per second, this implementation only |
|
40 reaches 400 kBit per second. The most plausible reason is the heavy reliance |
|
41 of AES on bit operations. As lua numbers are doubles bitlib needs to convert |
|
42 them to long values for each bit operation. |
|
43 |
|
44 So if you need to encrypt much data with AES, do yourself a favor and use a |
|
45 C-Implementation. But if you only need to encrypt short strings and you have |
|
46 no control over the lua environment (like in games :-)) use this library. |
|
47 |
|
48 Matthias Hilbig (hilbig@upb.de) |