Commit b135d256 authored by Niels Möller's avatar Niels Möller

Deleted nettle subdirectory.

parent 7b24dccf
2012-07-13 Niels Möller <nisse@lysator.liu.se>
* nettle: Deleted the nettle subdirectory.
Always use the installed nettle library, don't look for it in the
build tree.
* .bootstrap: Deleted all references to the nettle subdirectory.
......
#! /bin/sh
autoconf && autoheader
*.d
*.po
*.s
*.tar.gz
*.tar.gz.asc
.lib
autom4te.cache
Makefile
aesdata
config.cache
config.h
config.h.in
config.log
config.m4
config.make
config.status
configure
desdata
keymap.h
nettle-stdint.h
nettle.aux
nettle.cp
nettle.cps
nettle.dvi
nettle.fn
nettle.html
nettle.info*
nettle.ky
nettle.log
nettle.pdf
nettle.pg
nettle.ps
nettle.toc
nettle.tp
nettle.tps
nettle.vr
nettle.vrs
parity.h
rotors.h
shadata
stamp-h
stamp-h.in
/*.d
/*.po
/*.s
/*.tar.gz
/*.tar.gz.asc
/.lib
/autom4te.cache
/Makefile
/aesdata
/config.cache
/config.h
/config.h.in
/config.log
/config.m4
/config.make
/config.status
/configure
/desdata
/keymap.h
/nettle-stdint.h
/nettle.aux
/nettle.cp
/nettle.cps
/nettle.dvi
/nettle.fn
/nettle.html
/nettle.info*
/nettle.ky
/nettle.log
/nettle.pdf
/nettle.pg
/nettle.ps
/nettle.toc
/nettle.tp
/nettle.tps
/nettle.vr
/nettle.vrs
/parity.h
/rotors.h
/shadata
/stamp-h
/stamp-h.in
Please see the Nettle manual.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
What is Nettle? A quote from the introduction in the Nettle Manual:
Nettle is a cryptographic library that is designed to fit easily in more
or less any context: In crypto toolkits for object-oriented languages
(C++, Python, Pike, ...), in applications like LSH or GNUPG, or even in
kernel space. In most contexts, you need more than the basic
cryptographic algorithms, you also need some way to keep track of available
algorithms, their properties and variants. You often have some algorithm
selection process, often dictated by a protocol you want to implement.
And as the requirements of applications differ in subtle and not so
subtle ways, an API that fits one application well can be a pain to use
in a different context. And that is why there are so many different
cryptographic libraries around.
Nettle tries to avoid this problem by doing one thing, the low-level
crypto stuff, and providing a simple but general interface to it.
In particular, Nettle doesn't do algorithm selection. It doesn't do
memory allocation. It doesn't do any I/O.
The idea is that one can build several application and context specific
interfaces on top of Nettle, and share the code, test cases, benchmarks,
documentation, etc. Examples are the Nettle module for the Pike
language, and LSH, which both use an object-oriented abstraction on top
of the library.
Nettle is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation. See the file COPYING.LIB for details.
Build nettle with the usual ./configure && make && make check && make
install. Read the manual. Mail me if you have any questions or
suggestions.
You can also build Nettle from cvs, see
http://www.lysator.liu.se/~nisse/nettle/ for current instructions.
You may want to subscribe to the nettle-bugs mailing list. See
<URL: http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs>.
Happy hacking,
/Niels Möller <nisse@lysator.liu.se>
Public key support, analogous to that provided by RSAREF. Suggested by
Dan Egnor. Signatures are done now, but RSA encryption is still
missing. References:
http://download.gale.org/rsaref20.tar.Z
http://www.openssl.org/docs/crypto/evp.html
http://www.openssl.org/docs/crypto/rsa.html
More feedback modes, in order of decreasing priority: CBC-MAC, OFB,
and CFB. Suggested by Rafael 'Dido' Sevilla. References:
http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf
Valgrind reports errors on the des-compat test program. Investigate.
The make rules for building position independent *_p.o files doesn't
get dependencies right.
/* aes-decrypt-internal.c
*
* Decryption function for the aes/rijndael block cipher.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2002 Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include "aes-internal.h"
#include "macros.h"
void
_nettle_aes_decrypt(const struct aes_ctx *ctx,
const struct aes_table *T,
unsigned length, uint8_t *dst,
const uint8_t *src)
{
FOR_BLOCKS(length, dst, src, AES_BLOCK_SIZE)
{
uint32_t w0, w1, w2, w3; /* working ciphertext */
uint32_t t0, t1, t2, t3;
unsigned round;
/* Get clear text, using little-endian byte order.
* Also XOR with the first subkey. */
w0 = LE_READ_UINT32(src) ^ ctx->keys[0];
w1 = LE_READ_UINT32(src + 4) ^ ctx->keys[1];
w2 = LE_READ_UINT32(src + 8) ^ ctx->keys[2];
w3 = LE_READ_UINT32(src + 12) ^ ctx->keys[3];
for (round = 1; round < ctx->nrounds; round++)
{
t0 = AES_ROUND(T, w0, w3, w2, w1, ctx->keys[4*round]);
t1 = AES_ROUND(T, w1, w0, w3, w2, ctx->keys[4*round + 1]);
t2 = AES_ROUND(T, w2, w1, w0, w3, ctx->keys[4*round + 2]);
t3 = AES_ROUND(T, w3, w2, w1, w0, ctx->keys[4*round + 3]);
/* We could unroll the loop twice, to avoid these
assignments. If all eight variables fit in registers,
that should give a slight speedup. */
w0 = t0;
w1 = t1;
w2 = t2;
w3 = t3;
}
/* Final round */
t0 = AES_FINAL_ROUND(T, w0, w3, w2, w1, ctx->keys[4*round]);
t1 = AES_FINAL_ROUND(T, w1, w0, w3, w2, ctx->keys[4*round + 1]);
t2 = AES_FINAL_ROUND(T, w2, w1, w0, w3, ctx->keys[4*round + 2]);
t3 = AES_FINAL_ROUND(T, w3, w2, w1, w0, ctx->keys[4*round + 3]);
LE_WRITE_UINT32(dst, t0);
LE_WRITE_UINT32(dst + 8, t2);
LE_WRITE_UINT32(dst + 4, t1);
LE_WRITE_UINT32(dst + 12, t3);
}
}
This diff is collapsed.
/* aes-encrypt-internal.c
*
* Encryption function for the aes/rijndael block cipher.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2002 Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include "aes-internal.h"
#include "macros.h"
void
_nettle_aes_encrypt(const struct aes_ctx *ctx,
const struct aes_table *T,
unsigned length, uint8_t *dst,
const uint8_t *src)
{
FOR_BLOCKS(length, dst, src, AES_BLOCK_SIZE)
{
uint32_t w0, w1, w2, w3; /* working ciphertext */
uint32_t t0, t1, t2, t3;
unsigned round;
/* Get clear text, using little-endian byte order.
* Also XOR with the first subkey. */
w0 = LE_READ_UINT32(src) ^ ctx->keys[0];
w1 = LE_READ_UINT32(src + 4) ^ ctx->keys[1];
w2 = LE_READ_UINT32(src + 8) ^ ctx->keys[2];
w3 = LE_READ_UINT32(src + 12) ^ ctx->keys[3];
for (round = 1; round < ctx->nrounds; round++)
{
t0 = AES_ROUND(T, w0, w1, w2, w3, ctx->keys[4*round]);
t1 = AES_ROUND(T, w1, w2, w3, w0, ctx->keys[4*round + 1]);
t2 = AES_ROUND(T, w2, w3, w0, w1, ctx->keys[4*round + 2]);
t3 = AES_ROUND(T, w3, w0, w1, w2, ctx->keys[4*round + 3]);
/* We could unroll the loop twice, to avoid these
assignments. If all eight variables fit in registers,
that should give a slight speedup. */
w0 = t0;
w1 = t1;
w2 = t2;
w3 = t3;
}
/* Final round */
t0 = AES_FINAL_ROUND(T, w0, w1, w2, w3, ctx->keys[4*round]);
t1 = AES_FINAL_ROUND(T, w1, w2, w3, w0, ctx->keys[4*round + 1]);
t2 = AES_FINAL_ROUND(T, w2, w3, w0, w1, ctx->keys[4*round + 2]);
t3 = AES_FINAL_ROUND(T, w3, w0, w1, w2, ctx->keys[4*round + 3]);
LE_WRITE_UINT32(dst, t0);
LE_WRITE_UINT32(dst + 8, t2);
LE_WRITE_UINT32(dst + 4, t1);
LE_WRITE_UINT32(dst + 12, t3);
}
}
/* Some stats, all for AES 128:
A. Table-driven indexing (the approach of the old unified
_aes_crypt function).
B. Unrolling the j-loop.
C. Eliminated the use of IDXk(j) in the main loop.
D. Put wtxt in four scalar variables.
E. Also put t in four scalar variables.
P4 2.2 GHz AMD Duron 1.4GHz
MB/s code size
A 35.9 0x202 17 MB/s
B 37.3 0x334
C 33.0 0x2a7
D 40.7 0x3f9
E 42.9 0x44a 26 MB/s
*/
This diff is collapsed.
/* aes-encrypt.c
*
* Encryption function for the aes/rijndael block cipher.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2002 Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include "aes-internal.h"
/* The main point on this function is to help the assembler
implementations of _nettle_aes_encrypt to get the table pointer.
For PIC code, the details can be complex and system dependent. */
void
aes_encrypt(const struct aes_ctx *ctx,
unsigned length, uint8_t *dst,
const uint8_t *src)
{
assert(!(length % AES_BLOCK_SIZE) );
_aes_encrypt(ctx, &_aes_encrypt_table,
length, dst, src);
}
/* aes-internal.h
*
* The aes/rijndael block cipher.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2001 Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef NETTLE_AES_INTERNAL_H_INCLUDED
#define NETTLE_AES_INTERNAL_H_INCLUDED
#include "aes.h"
/* Name mangling */
#define _aes_encrypt _nettle_aes_encrypt
#define _aes_decrypt _nettle_aes_decrypt
#define _aes_encrypt_table _nettle_aes_encrypt_table
/* Define to use only small tables. */
#ifndef AES_SMALL
# define AES_SMALL 0
#endif
#if AES_SMALL
# define AES_TABLE_SIZE 1
#else
# define AES_TABLE_SIZE 4
#endif
struct aes_table
{
uint8_t sbox[0x100];
uint32_t table[AES_TABLE_SIZE][0x100];
};
void
_aes_encrypt(const struct aes_ctx *ctx,
const struct aes_table *T,
unsigned length, uint8_t *dst,
const uint8_t *src);
void
_aes_decrypt(const struct aes_ctx *ctx,
const struct aes_table *T,
unsigned length, uint8_t *dst,
const uint8_t *src);
/* Macros */
#define ROTBYTE(x) (((x) >> 8) | (((x) & 0xff) << 24))
#define ROTRBYTE(x) (((x) << 8) | (((x) >> 24) & 0xff))
#define SUBBYTE(x, box) (((box)[((x) & 0xff)]) | \
((box)[(((x) >> 8) & 0xff)] << 8) | \
((box)[(((x) >> 16) & 0xff)] << 16) | \
((box)[(((x) >> 24) & 0xff)] << 24))
/* Get the byte with index 0, 1, 2 and 3 */
#define B0(x) ((x) & 0xff)
#define B1(x) (((x) >> 8) & 0xff)
#define B2(x) (((x) >> 16) & 0xff)
#define B3(x) (((x) >> 24) & 0xff)
#define AES_ROUND(T, w0, w1, w2, w3, k) \
(( T->table[0][ B0(w0) ] \
^ T->table[1][ B1(w1) ] \
^ T->table[2][ B2(w2) ] \
^ T->table[3][ B3(w3) ]) ^ (k))
#define AES_FINAL_ROUND(T, w0, w1, w2, w3, k) \
(( (uint32_t) T->sbox[ B0(w0) ] \
| ((uint32_t) T->sbox[ B1(w1) ] << 8) \
| ((uint32_t) T->sbox[ B2(w2) ] << 16) \
| ((uint32_t) T->sbox[ B3(w3) ] << 24)) ^ (k))
/* Globally visible so that the same sbox table can be used by aes_set_encrypt_key */
extern const struct aes_table _aes_encrypt_table;
#define aes_sbox (_aes_encrypt_table.sbox)
#endif /* NETTLE_AES_INTERNAL_H_INCLUDED */
/* aes-meta.c */
/* nettle, low-level cryptographics library
*
* Copyright (C) 2002 Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "nettle-meta.h"
#include "aes.h"
const struct nettle_cipher nettle_aes128
= _NETTLE_CIPHER_SEP(aes, AES, 128);
const struct nettle_cipher nettle_aes192
= _NETTLE_CIPHER_SEP(aes, AES, 192);
const struct nettle_cipher nettle_aes256
= _NETTLE_CIPHER_SEP(aes, AES, 256);
/* aes-set-decrypt-key.c
*
* Inverse key setup for the aes/rijndael block cipher.
*/
/* nettle, low-level cryptographics library
*