Commit 3a0e06ba authored by Niels Möller's avatar Niels Möller

Deleted obsolete directory and files

Rev: src/symmetric/Makefile.am.in:1.18(DEAD)
Rev: src/symmetric/bf_test.c:1.3(DEAD)
Rev: src/symmetric/cast.c:1.4(DEAD)
Rev: src/symmetric/cast_sboxes.h:1.2(DEAD)
Rev: src/symmetric/desKerb.c:1.4(DEAD)
Rev: src/symmetric/desQuick.c:1.4(DEAD)
Rev: src/symmetric/desTest.c:1.8(DEAD)
Rev: src/symmetric/desUtil.c:1.4(DEAD)
Rev: src/symmetric/generate_q.c:1.2(DEAD)
Rev: src/symmetric/idea.c:1.4(DEAD)
Rev: src/symmetric/include/.cvsignore:1.4(DEAD)
Rev: src/symmetric/include/Makefile.am.in:1.7(DEAD)
Rev: src/symmetric/include/RCSID.h:1.2(DEAD)
Rev: src/symmetric/include/arcfour.h:1.3(DEAD)
Rev: src/symmetric/include/blowfish.h:1.5(DEAD)
Rev: src/symmetric/include/cast.h:1.4(DEAD)
Rev: src/symmetric/include/crypto_types.h:1.7(DEAD)
Rev: src/symmetric/include/des.h:1.5(DEAD)
Rev: src/symmetric/include/idea.h:1.5(DEAD)
Rev: src/symmetric/include/md5.h:1.4(DEAD)
Rev: src/symmetric/include/rijndael.h:1.2(DEAD)
Rev: src/symmetric/include/serpent.h:1.4(DEAD)
Rev: src/symmetric/include/sha.h:1.5(DEAD)
Rev: src/symmetric/include/twofish.h:1.3(DEAD)
Rev: src/symmetric/include/types.h:1.3(DEAD)
Rev: src/symmetric/rijndael.c:1.3(DEAD)
Rev: src/symmetric/rijndael_test.c:1.2(DEAD)
Rev: src/symmetric/serpentsboxes.h:1.3(DEAD)
Rev: src/symmetric/sha.c:1.6(DEAD)
Rev: src/symmetric/twofish_test.c:1.2(DEAD)
Rev: src/symmetric/util.c:1.2(DEAD)
Rev: src/symmetric/util.h:1.3(DEAD)
parent d0507f2f
## Process this file with make_am to produce Makefile.am
SUBDIRS: include
CVS_HEADERS: cvs_headers
BODY:
AUTOMAKE_OPTIONS = foreign
noinst_LIBRARIES = libsymmetric.a
noinst_PROGRAMS = desTest desdata bf_test twofish_test generate_q rijndael_test
Makefile.am: Makefile.am.in
(cd $(top_srcdir) && $(MAKE) src/symmetric/Makefile.am)
# When compiling with lsh, this is set to to -DLSH -I/path/to/lsh/include
# INCLUDES = @crypto_cpp_flags@
LDADD = libsymmetric.a
desdata_LDADD =
des_headers = parity.h rotors.h keymap.h
BUILT_SOURCES = desSmallFips.c desSmallCore.c desQuickFips.c desQuickCore.c
libsymmetric_a_SOURCES = desCode.h desKerb.c desUtil.c desQuick.c \
$(BUILT_SOURCES) \
sha.c md5.c idea.c arcfour.c cast.c blowfish.c twofish.c rijndael.c \
serpent.c
# Generate DES headers.
$(des_headers): desdata
./desdata $@ > $@T
test -s $@T && mv -f $@T $@
desUtil.o: desUtil.c $(des_headers)
# Generate DES sources. Slowest to quickest.
desSmallFips.c:
@echo > $@ '#include "desCode.h"'
@echo >> $@ 'ENCRYPT(DesSmallFipsEncrypt,TEMPSMALL,\
LOADFIPS,KEYMAPSMALL,SAVEFIPS)'
@echo >> $@ 'DECRYPT(DesSmallFipsDecrypt,TEMPSMALL,\
LOADFIPS,KEYMAPSMALL,SAVEFIPS)'
desSmallCore.c:
@echo > $@ '#include "desCode.h"'
@echo >> $@ 'ENCRYPT(DesSmallCoreEncrypt,TEMPSMALL,\
LOADCORE,KEYMAPSMALL,SAVECORE)'
@echo >> $@ 'DECRYPT(DesSmallCoreDecrypt,TEMPSMALL,\
LOADCORE,KEYMAPSMALL,SAVECORE)'
desQuickFips.c:
@echo > $@ '#include "desCode.h"'
@echo >> $@ 'ENCRYPT(DesQuickFipsEncrypt,TEMPQUICK,\
LOADFIPS,KEYMAPQUICK,SAVEFIPS)'
@echo >> $@ 'DECRYPT(DesQuickFipsDecrypt,TEMPQUICK,\
LOADFIPS,KEYMAPQUICK,SAVEFIPS)'
desQuickCore.c:
@echo > $@ '#include "desCode.h"'
@echo >> $@ 'ENCRYPT(DesQuickCoreEncrypt,TEMPQUICK,\
LOADCORE,KEYMAPQUICK,SAVECORE)'
@echo >> $@ 'DECRYPT(DesQuickCoreDecrypt,TEMPQUICK,\
LOADCORE,KEYMAPQUICK,SAVECORE)'
EXTRA_DIST = $(cvs_headers) $(des_headers) Makefile.am.in descore.README
.PHONY: depend
depend:
rm -f $(DEP_FILES)
make $(DEP_FILES)
# .deps/%.P : %.c
# $(CC) $(CPPFLAGS) $(DEFS) -M -MG $< > $@
MAINTAINERCLEANFILES += $(DEP_FILES)
include $(top_srcdir)/misc/ctags.mk
/* bf_test.c
*
* $Id$
* Test the blow fish implementation. */
#include "blowfish.h"
#include <stdio.h>
#include <stdlib.h>
int main (int argc UNUSED, char **argv UNUSED)
{
if (bf_selftest())
{
fprintf(stderr, "Blowfish works.\n");
return EXIT_SUCCESS;
}
else
{
fprintf(stderr, "ERROR: Blowfish failed.\n");
return EXIT_FAILURE;
}
}
/*
* $Id$
*
* CAST-128 in C
* Written by Steve Reid <sreid@sea-to-sky.net>
* 100% Public Domain - no warranty
* Released 1997.10.11
*
* CAST-128 is documented in
* C. Adams, "The CAST-128 Encryption Algorithm", RFC 2144.
*
*/
/* Adapted to the pike cryptographic toolkit by Niels Mller */
/* Selftest added by J.H.M. Dassen (Ray) <jdassen@wi.LeidenUniv.nl>.
* Released into the public domain. */
#include <assert.h>
#include <cast.h>
#define u8 UINT8
#define u32 UINT32
#include "cast_sboxes.h"
/* Macros to access 8-bit bytes out of a 32-bit word */
#define U8a(x) ( (u8) (x>>24) )
#define U8b(x) ( (u8) ((x>>16)&255) )
#define U8c(x) ( (u8) ((x>>8)&255) )
#define U8d(x) ( (u8) ((x)&255) )
/* Circular left shift */
#define ROL(x, n) ( ((x)<<(n)) | ((x)>>(32-(n))) )
/* CAST-128 uses three different round functions */
#define F1(l, r, i) \
t = ROL(key->xkey[i] + r, key->xkey[i+16]); \
l ^= ((cast_sbox1[U8a(t)] ^ cast_sbox2[U8b(t)]) \
- cast_sbox3[U8c(t)]) + cast_sbox4[U8d(t)];
#define F2(l, r, i) \
t = ROL(key->xkey[i] ^ r, key->xkey[i+16]); \
l ^= ((cast_sbox1[U8a(t)] - cast_sbox2[U8b(t)]) \
+ cast_sbox3[U8c(t)]) ^ cast_sbox4[U8d(t)];
#define F3(l, r, i) \
t = ROL(key->xkey[i] - r, key->xkey[i+16]); \
l ^= ((cast_sbox1[U8a(t)] + cast_sbox2[U8b(t)]) \
^ cast_sbox3[U8c(t)]) - cast_sbox4[U8d(t)];
/***** Encryption Function *****/
void cast_encrypt(struct cast_key *key, const u8 * const inblock, u8 *outblock)
{
u32 t, l, r;
/* Get inblock into l,r */
l = ((u32)inblock[0] << 24) | ((u32)inblock[1] << 16)
| ((u32)inblock[2] << 8) | (u32)inblock[3];
r = ((u32)inblock[4] << 24) | ((u32)inblock[5] << 16)
| ((u32)inblock[6] << 8) | (u32)inblock[7];
/* Do the work */
F1(l, r, 0);
F2(r, l, 1);
F3(l, r, 2);
F1(r, l, 3);
F2(l, r, 4);
F3(r, l, 5);
F1(l, r, 6);
F2(r, l, 7);
F3(l, r, 8);
F1(r, l, 9);
F2(l, r, 10);
F3(r, l, 11);
/* Only do full 16 rounds if key length > 80 bits */
if (key->rounds > 12) {
F1(l, r, 12);
F2(r, l, 13);
F3(l, r, 14);
F1(r, l, 15);
}
/* Put l,r into outblock */
outblock[0] = U8a(r);
outblock[1] = U8b(r);
outblock[2] = U8c(r);
outblock[3] = U8d(r);
outblock[4] = U8a(l);
outblock[5] = U8b(l);
outblock[6] = U8c(l);
outblock[7] = U8d(l);
/* Wipe clean */
t = l = r = 0;
}
/***** Decryption Function *****/
void cast_decrypt(struct cast_key *key, const u8 * const inblock, u8 *outblock)
{
u32 t, l, r;
/* Get inblock into l,r */
r = ((u32)inblock[0] << 24) | ((u32)inblock[1] << 16)
| ((u32)inblock[2] << 8) | (u32)inblock[3];
l = ((u32)inblock[4] << 24) | ((u32)inblock[5] << 16)
| ((u32)inblock[6] << 8) | (u32)inblock[7];
/* Do the work */
/* Only do full 16 rounds if key length > 80 bits */
if (key->rounds > 12) {
F1(r, l, 15);
F3(l, r, 14);
F2(r, l, 13);
F1(l, r, 12);
}
F3(r, l, 11);
F2(l, r, 10);
F1(r, l, 9);
F3(l, r, 8);
F2(r, l, 7);
F1(l, r, 6);
F3(r, l, 5);
F2(l, r, 4);
F1(r, l, 3);
F3(l, r, 2);
F2(r, l, 1);
F1(l, r, 0);
/* Put l,r into outblock */
outblock[0] = U8a(l);
outblock[1] = U8b(l);
outblock[2] = U8c(l);
outblock[3] = U8d(l);
outblock[4] = U8a(r);
outblock[5] = U8b(r);
outblock[6] = U8c(r);
outblock[7] = U8d(r);
/* Wipe clean */
t = l = r = 0;
}
/* Sanity check using the test vectors from
* B.1. Single Plaintext-Key-Ciphertext Sets, RFC 2144
*/
int cast_selftest(void)
{
u8 testkey128[16] = {
0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9A
};
u8 plaintext128[8] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF
};
u8 ciphertext128[8] = {
0x23, 0x8B, 0x4F, 0xE5, 0x84, 0x7E, 0x44, 0xB2
};
u8 testkey80[10] = {
0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
0x23, 0x45
};
u8 plaintext80[8] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF
};
u8 ciphertext80[8] = {
0xEB, 0x6A, 0x71, 0x1A, 0x2C, 0x02, 0x27, 0x1B
};
u8 testkey40[5] = {
0x01, 0x23, 0x45, 0x67, 0x12
};
u8 plaintext40[8] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF
};
u8 ciphertext40[8] = {
0x7A, 0xC8, 0x16, 0xD1, 0x6E, 0x9B, 0x30, 0x2E
};
struct cast_key context;
u8 ciphertext[8];
cast_setkey(&context, testkey128, 16);
cast_encrypt(&context, plaintext128, ciphertext);
if (memcmp(ciphertext, ciphertext128, 8)) {
return 0;
}
cast_setkey(&context, testkey80, 10);
cast_encrypt(&context, plaintext80, ciphertext);
if (memcmp(ciphertext, ciphertext80, 8)) {
return 0;
}
cast_setkey(&context, testkey40, 5);
cast_encrypt(&context, plaintext40, ciphertext);
if (memcmp(ciphertext, ciphertext40, 8)) {
return 0;
}
return 1;
}
/***** Key Schedule *****/
void cast_setkey(struct cast_key *key, const u8 * const rawkey, unsigned keybytes)
{
u32 t[4], z[4], x[4];
unsigned i;
#ifndef NDEBUG
static int initialized = 0;
if (!initialized)
{
initialized = 1;
assert(cast_selftest());
}
#endif
/* Set number of rounds to 12 or 16, depending on key length */
key->rounds = (keybytes <= CAST_SMALL_KEY)
? CAST_SMALL_ROUNDS : CAST_FULL_ROUNDS;
/* Copy key to workspace x */
for (i = 0; i < 4; i++) {
x[i] = 0;
if ((i*4+0) < keybytes) x[i] = (u32)rawkey[i*4+0] << 24;
if ((i*4+1) < keybytes) x[i] |= (u32)rawkey[i*4+1] << 16;
if ((i*4+2) < keybytes) x[i] |= (u32)rawkey[i*4+2] << 8;
if ((i*4+3) < keybytes) x[i] |= (u32)rawkey[i*4+3];
}
/* Generate 32 subkeys, four at a time */
for (i = 0; i < 32; i+=4) {
switch (i & 4) {
case 0:
t[0] = z[0] = x[0] ^ cast_sbox5[U8b(x[3])]
^ cast_sbox6[U8d(x[3])] ^ cast_sbox7[U8a(x[3])]
^ cast_sbox8[U8c(x[3])] ^ cast_sbox7[U8a(x[2])];
t[1] = z[1] = x[2] ^ cast_sbox5[U8a(z[0])]
^ cast_sbox6[U8c(z[0])] ^ cast_sbox7[U8b(z[0])]
^ cast_sbox8[U8d(z[0])] ^ cast_sbox8[U8c(x[2])];
t[2] = z[2] = x[3] ^ cast_sbox5[U8d(z[1])]
^ cast_sbox6[U8c(z[1])] ^ cast_sbox7[U8b(z[1])]
^ cast_sbox8[U8a(z[1])] ^ cast_sbox5[U8b(x[2])];
t[3] = z[3] = x[1] ^ cast_sbox5[U8c(z[2])] ^
cast_sbox6[U8b(z[2])] ^ cast_sbox7[U8d(z[2])]
^ cast_sbox8[U8a(z[2])] ^ cast_sbox6[U8d(x[2])];
break;
case 4:
t[0] = x[0] = z[2] ^ cast_sbox5[U8b(z[1])]
^ cast_sbox6[U8d(z[1])] ^ cast_sbox7[U8a(z[1])]
^ cast_sbox8[U8c(z[1])] ^ cast_sbox7[U8a(z[0])];
t[1] = x[1] = z[0] ^ cast_sbox5[U8a(x[0])]
^ cast_sbox6[U8c(x[0])] ^ cast_sbox7[U8b(x[0])]
^ cast_sbox8[U8d(x[0])] ^ cast_sbox8[U8c(z[0])];
t[2] = x[2] = z[1] ^ cast_sbox5[U8d(x[1])]
^ cast_sbox6[U8c(x[1])] ^ cast_sbox7[U8b(x[1])]
^ cast_sbox8[U8a(x[1])] ^ cast_sbox5[U8b(z[0])];
t[3] = x[3] = z[3] ^ cast_sbox5[U8c(x[2])]
^ cast_sbox6[U8b(x[2])] ^ cast_sbox7[U8d(x[2])]
^ cast_sbox8[U8a(x[2])] ^ cast_sbox6[U8d(z[0])];
break;
}
switch (i & 12) {
case 0:
case 12:
key->xkey[i+0] = cast_sbox5[U8a(t[2])] ^ cast_sbox6[U8b(t[2])]
^ cast_sbox7[U8d(t[1])] ^ cast_sbox8[U8c(t[1])];
key->xkey[i+1] = cast_sbox5[U8c(t[2])] ^ cast_sbox6[U8d(t[2])]
^ cast_sbox7[U8b(t[1])] ^ cast_sbox8[U8a(t[1])];
key->xkey[i+2] = cast_sbox5[U8a(t[3])] ^ cast_sbox6[U8b(t[3])]
^ cast_sbox7[U8d(t[0])] ^ cast_sbox8[U8c(t[0])];
key->xkey[i+3] = cast_sbox5[U8c(t[3])] ^ cast_sbox6[U8d(t[3])]
^ cast_sbox7[U8b(t[0])] ^ cast_sbox8[U8a(t[0])];
break;
case 4:
case 8:
key->xkey[i+0] = cast_sbox5[U8d(t[0])] ^ cast_sbox6[U8c(t[0])]
^ cast_sbox7[U8a(t[3])] ^ cast_sbox8[U8b(t[3])];
key->xkey[i+1] = cast_sbox5[U8b(t[0])] ^ cast_sbox6[U8a(t[0])]
^ cast_sbox7[U8c(t[3])] ^ cast_sbox8[U8d(t[3])];
key->xkey[i+2] = cast_sbox5[U8d(t[1])] ^ cast_sbox6[U8c(t[1])]
^ cast_sbox7[U8a(t[2])] ^ cast_sbox8[U8b(t[2])];
key->xkey[i+3] = cast_sbox5[U8b(t[1])] ^ cast_sbox6[U8a(t[1])]
^ cast_sbox7[U8c(t[2])] ^ cast_sbox8[U8d(t[2])];
break;
}
switch (i & 12) {
case 0:
key->xkey[i+0] ^= cast_sbox5[U8c(z[0])];
key->xkey[i+1] ^= cast_sbox6[U8c(z[1])];
key->xkey[i+2] ^= cast_sbox7[U8b(z[2])];
key->xkey[i+3] ^= cast_sbox8[U8a(z[3])];
break;
case 4:
key->xkey[i+0] ^= cast_sbox5[U8a(x[2])];
key->xkey[i+1] ^= cast_sbox6[U8b(x[3])];
key->xkey[i+2] ^= cast_sbox7[U8d(x[0])];
key->xkey[i+3] ^= cast_sbox8[U8d(x[1])];
break;
case 8:
key->xkey[i+0] ^= cast_sbox5[U8b(z[2])];
key->xkey[i+1] ^= cast_sbox6[U8a(z[3])];
key->xkey[i+2] ^= cast_sbox7[U8c(z[0])];
key->xkey[i+3] ^= cast_sbox8[U8c(z[1])];
break;
case 12:
key->xkey[i+0] ^= cast_sbox5[U8d(x[0])];
key->xkey[i+1] ^= cast_sbox6[U8d(x[1])];
key->xkey[i+2] ^= cast_sbox7[U8a(x[2])];
key->xkey[i+3] ^= cast_sbox8[U8b(x[3])];
break;
}
if (i >= 16) {
key->xkey[i+0] &= 31;
key->xkey[i+1] &= 31;
key->xkey[i+2] &= 31;
key->xkey[i+3] &= 31;
}
}
/* Wipe clean */
for (i = 0; i < 4; i++) {
t[i] = x[i] = z[i] = 0;
}
}
/* Made in Canada */
This diff is collapsed.
/*
* des - fast & portable DES encryption & decryption.
* Copyright (C) 1992 Dana L. How
* Please see the file `descore.README' for the complete copyright notice.
*/
#include "des.h"
#include "RCSID.h"
RCSID2(desKerb_cRcs, "$Id$");
/* permit the default style of des functions to be changed */
DesFunc *DesCryptFuncs[2] = { DesSmallFipsDecrypt, DesSmallFipsEncrypt };
/* kerberos-compatible key schedule function */
int
des_key_sched(const UINT8 *k, UINT32 *s)
{
return DesMethod(s, k);
}
/* kerberos-compatible des coding function */
int
des_ecb_encrypt(const UINT8 *s, UINT8 *d, const UINT32 *r, int e)
{
(*DesCryptFuncs[e])(d, r, s);
return 0;
}
/*
* des - fast & portable DES encryption & decryption.
* Copyright (C) 1992 Dana L. How
* Please see the file `descore.README' for the complete copyright notice.
*
* Slightly edited by Niels Mller, 1997
*/
#include "des.h"
#include "RCSID.h"
RCSID2(desQuick_cRcs, "$Id$");
extern UINT32 des_keymap[];
/* static information */
static int depth = 0; /* keep track of the request depth */
UINT32 des_bigmap[0x4000]; /* big lookup table */
/* fill in the 64k table used by the `quick' option */
void
DesQuickInit(void)
{
int s1, s3, x;
UINT32 * t0, * t1, * t2, * t3;
if ( depth++ )
return;
t0 = des_bigmap;
t1 = t0 + 64;
t2 = t1 + 64;
t3 = t2 + 64;
for ( s3 = 63; s3 >= 0; s3-- ) {
for ( s1 = 63; s1 >= 0; s1-- ) {
x = (s3 << 8) | s1;
t0[x] = des_keymap[s3+128] ^ des_keymap[s1+192];
t1[x] = des_keymap[s3 ] ^ des_keymap[s1+ 64];
t2[x] = des_keymap[s3+384] ^ des_keymap[s1+448];
t3[x] = des_keymap[s3+256] ^ des_keymap[s1+320];
}
}
}
/* free the 64k table, if necessary */
void
DesQuickDone(void)
{
}
/* desTest.c
*
* Exercise the DES routines and collect performance statistics.
*
* $ID:$ */
/* des - fast & portable DES encryption & decryption.
* Copyright (C) 1992 Dana L. How
* Please see the file `descore.README' for the complete copyright notice.
*/
#ifndef lint
char desTest_cRcs[] = "$Id$";
#endif
#include "des.h"
#include <stdio.h>
#if 0
/* define now(w) to be the elapsed time in hundredths of a second */
#ifndef __NT__
# include <sys/time.h>
# include <sys/resource.h>
# include <unistd.h>
/* extern getrusage(); */
static struct rusage usage;
# define now(w) ( \
getrusage(RUSAGE_SELF, &usage), \
usage.ru_utime.tv_sec * 100 + \
usage.ru_utime.tv_usec / 10000 \
)
#else
# include <windows.h>
# define now(w) 0
#endif
#endif /* 0 */
/* test data
* the tests (key0-3, text0-3) are cribbed from code which is (c) 1988 MIT
*/
UINT8 keyt[8] = {0x5d, 0x85, 0x91, 0x73, 0xcb, 0x49, 0xdf, 0x2f};
UINT8 key0[8] = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80};
UINT8 key1[8] = {0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
UINT8 key2[8] = {0x08, 0x19, 0x2a, 0x3b, 0x4c, 0x5d, 0x6e, 0x7f};
UINT8 key3[8] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
UINT8 textt[8] = {0x67, 0x1f, 0xc8, 0x93, 0x46, 0x5e, 0xab, 0x1e};
UINT8 text0[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
UINT8 text1[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40};
UINT8 text2[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
UINT8 text3[8] = {'N', 'o', 'w', ' ', 'i', 's', ' ', 't' };
/* work areas */
DesKeys keys;
UINT8 cipher[8], output[8];
/* noisy interfaces to the routines under test */
static void method(const UINT8 *key)
{
int j;
printf("\nkey:\t");
for ( j = 0; j < 8; j++ )
printf("%02X ", key[j]);
if ( des_key_sched(key, keys) )
printf("W");
printf("\t");
}
static void
encode(const UINT8 *src, UINT8 *dst)
{
int j;
printf("clear:\t");
for (j = 0; j < 8; j++)
printf("%02X ", src[j]);
des_ecb_encrypt(src, dst, keys, 1);
printf("\tcipher:\t");
for (j = 0; j < 8; j++)
printf("%02X ", dst[j]);
printf("\n");
}
static void
decode(const UINT8 *src, UINT8 *dst, const UINT8 *check)
{
int j;
printf("cipher:\t");
for (j = 0; j < 8; j++)
printf("%02X ", src[j]);
des_ecb_encrypt(src, dst, keys, 0);
printf("\tclear:\t");
for (j = 0; j < 8; j++)
printf("%02X ", dst[j]);
if(!memcmp(dst,check,8))
printf("Ok\n");
else
printf("FAIL\n");
}
/* run the tests */
int
main(int argc UNUSED, char **argv UNUSED)
{
int j, n;
#if 0
int m, e;
#endif
DesFunc *f;
static char * expect[] = {
"57 99 F7 2A D2 3F AE 4C", "9C C6 2D F4 3B 6E ED 74",
"90 E6 96 A2 AD 56 50 0D", "A3 80 E0 2A 6B E5 46 96",
"43 5C FF C5 68 B3 70 1D", "25 DD AC 3E 96 17 64 67",
"80 B5 07 E1 E6 A7 47 3D", "3F A4 0E 8A 98 4D 48 15",
};
static DesFunc *funcs[] = {
DesQuickCoreEncrypt, DesQuickFipsEncrypt,
DesSmallCoreEncrypt, DesSmallFipsEncrypt,
DesQuickCoreDecrypt, DesQuickFipsDecrypt,
DesSmallCoreDecrypt, DesSmallFipsDecrypt };
#if 0
static char * names[] = {
"QuickCore", "QuickFips",
"SmallCore", "SmallFips" };
#endif
n = 0;
DesQuickInit();
/* do timing info first */
j = 10000;
#if 0
m = now(0);
#endif
do
DesMethod(keys, keyt);
while ( --j );
#if 0
m = now(1) - m;
#endif
do {
DesCryptFuncs[0] = funcs[n+4];
f = DesCryptFuncs[1] = funcs[n ];
j = 100000;
#if 0
e = now(0);
#endif
do
(*f)(cipher, keys, textt);