add aes support
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12508 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -5,7 +5,7 @@ include $(top_srcdir)/Makefile.am.common
|
||||
lib_LTLIBRARIES = libdes.la
|
||||
libdes_la_LDFLAGS = -version-info 3:1:0
|
||||
|
||||
include_HEADERS = des.h md4.h md5.h sha.h rc4.h
|
||||
include_HEADERS = des.h md4.h md5.h sha.h rc4.h aes.h
|
||||
|
||||
build_HEADERZ = $(include_HEADERS)
|
||||
|
||||
@@ -20,6 +20,7 @@ des_SOURCES = des.c des_ver.h
|
||||
LDADD = $(lib_LTLIBRARIES)
|
||||
|
||||
libdes_la_SOURCES = \
|
||||
aes.c \
|
||||
cbc3_enc.c \
|
||||
cbc_cksm.c \
|
||||
cbc_enc.c \
|
||||
@@ -48,6 +49,7 @@ libdes_la_SOURCES = \
|
||||
rc4_skey.c \
|
||||
rc4_enc.c \
|
||||
read_pwd.c \
|
||||
rijndael-alg-fst.c \
|
||||
rnd_keys.c \
|
||||
set_key.c \
|
||||
sha.c \
|
||||
|
77
lib/des/aes.c
Normal file
77
lib/des/aes.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2003 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
||||
RCSID("$Id$");
|
||||
#endif
|
||||
|
||||
#ifdef KRB5
|
||||
#include <krb5-types.h>
|
||||
#elif defined(KRB4)
|
||||
#include <ktypes.h>
|
||||
#endif
|
||||
|
||||
#include "rijndael-alg-fst.h"
|
||||
#include "aes.h"
|
||||
|
||||
int
|
||||
AES_set_encrypt_key(const unsigned char *userkey, const int bits, AES_KEY *key)
|
||||
{
|
||||
key->rounds = rijndaelKeySetupEnc(key->key, userkey, bits);
|
||||
if (key->rounds == 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
AES_set_decrypt_key(const unsigned char *userkey, const int bits, AES_KEY *key)
|
||||
{
|
||||
key->rounds = rijndaelKeySetupDec(key->key, userkey, bits);
|
||||
if (key->rounds == 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
AES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key)
|
||||
{
|
||||
rijndaelEncrypt(key->key, key->rounds, in, out);
|
||||
}
|
||||
|
||||
void
|
||||
AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key)
|
||||
{
|
||||
rijndaelDecrypt(key->key, key->rounds, in, out);
|
||||
}
|
54
lib/des/aes.h
Normal file
54
lib/des/aes.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2003 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef KRB5
|
||||
#include <krb5-types.h>
|
||||
#elif defined(KRB4)
|
||||
#include <ktypes.h>
|
||||
#endif
|
||||
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define AES_MAXNR 14
|
||||
|
||||
typedef struct aes_key {
|
||||
u_int32_t key[(AES_MAXNR+1)*4];
|
||||
int rounds;
|
||||
} AES_KEY;
|
||||
|
||||
int AES_set_encrypt_key(const unsigned char *, const int, AES_KEY *);
|
||||
int AES_set_decrypt_key(const unsigned char *, const int, AES_KEY *);
|
||||
|
||||
void AES_encrypt(const unsigned char *, unsigned char *, const AES_KEY *);
|
||||
void AES_decrypt(const unsigned char *, unsigned char *, const AES_KEY *);
|
1233
lib/des/rijndael-alg-fst.c
Normal file
1233
lib/des/rijndael-alg-fst.c
Normal file
File diff suppressed because it is too large
Load Diff
40
lib/des/rijndael-alg-fst.h
Normal file
40
lib/des/rijndael-alg-fst.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* $NetBSD: rijndael-alg-fst.h,v 1.2 2000/10/02 17:19:15 itojun Exp $ */
|
||||
/* $KAME: rijndael-alg-fst.h,v 1.5 2003/07/15 10:47:16 itojun Exp $ */
|
||||
/**
|
||||
* rijndael-alg-fst.h
|
||||
*
|
||||
* @version 3.0 (December 2000)
|
||||
*
|
||||
* Optimised ANSI C code for the Rijndael cipher (now AES)
|
||||
*
|
||||
* @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
|
||||
* @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
|
||||
* @author Paulo Barreto <paulo.barreto@terra.com.br>
|
||||
*
|
||||
* This code is hereby placed in the public domain.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __RIJNDAEL_ALG_FST_H
|
||||
#define __RIJNDAEL_ALG_FST_H
|
||||
|
||||
#define RIJNDAEL_MAXKC (256/32)
|
||||
#define RIJNDAEL_MAXKB (256/8)
|
||||
#define RIJNDAEL_MAXNR 14
|
||||
|
||||
int rijndaelKeySetupEnc(u_int32_t rk[/*4*(Nr + 1)*/], const u_int8_t cipherKey[], int keyBits);
|
||||
int rijndaelKeySetupDec(u_int32_t rk[/*4*(Nr + 1)*/], const u_int8_t cipherKey[], int keyBits);
|
||||
void rijndaelEncrypt(const u_int32_t rk[/*4*(Nr + 1)*/], int Nr, const u_int8_t pt[16], u_int8_t ct[16]);
|
||||
void rijndaelDecrypt(const u_int32_t rk[/*4*(Nr + 1)*/], int Nr, const u_int8_t ct[16], u_int8_t pt[16]);
|
||||
|
||||
#endif /* __RIJNDAEL_ALG_FST_H */
|
Reference in New Issue
Block a user