diff options
author | csgr <csgr@FreeBSD.org> | 1994-08-08 17:29:04 +0000 |
---|---|---|
committer | csgr <csgr@FreeBSD.org> | 1994-08-08 17:29:04 +0000 |
commit | 1f61f296f8d8bd9ef1bf86dc0394cc86811aad95 (patch) | |
tree | 0812b61f89ad397b2b4237faf54aca46be9cc905 /secure/lib/libcrypt/test | |
parent | a0c8b1611ca0b2e6fe43067f59fef9b949efb389 (diff) | |
download | FreeBSD-src-1f61f296f8d8bd9ef1bf86dc0394cc86811aad95.zip FreeBSD-src-1f61f296f8d8bd9ef1bf86dc0394cc86811aad95.tar.gz |
Modify libcrypt so that the only exported symbol is _crypt().
Submitted by: Geoff Rehmet
Diffstat (limited to 'secure/lib/libcrypt/test')
-rw-r--r-- | secure/lib/libcrypt/test/Makefile | 33 | ||||
-rw-r--r-- | secure/lib/libcrypt/test/cert.c | 138 |
2 files changed, 14 insertions, 157 deletions
diff --git a/secure/lib/libcrypt/test/Makefile b/secure/lib/libcrypt/test/Makefile index 53b0ec1..e02ae87 100644 --- a/secure/lib/libcrypt/test/Makefile +++ b/secure/lib/libcrypt/test/Makefile @@ -4,27 +4,26 @@ # # $Id: Makefile,v 1.1.1.1 1994/04/04 14:57:18 g89r4222 Exp $ # -LIBCRYPT!=cd $(.CURDIR)/..; \ - printf "xxx:\n\techo \$${.OBJDIR}/libcrypt.a\n" | make -r -s -f - xxx +.if exists (../obj) +OBJDIR = obj +.else +OBJDIR = +.endif + +LIBCRYPT= $(.CURDIR)/../$(OBJDIR)/libcrypt.a #CFLAGS+= -DHAVE_CRYPT16 -TARGETS=cert speedcrypt speeddes +TARGETS=cert speedcrypt all: ${TARGETS} -test: all testcrypt testencrypt testdes testspeed +test: all testcrypt testspeed testcrypt: cert @./cert -c -testencrypt: cert - @./cert -e < ${.CURDIR}/cert.input - -testdes: cert - @./cert -d < ${.CURDIR}/cert.input - -testspeed: cryptspeed desspeed +testspeed: cryptspeed cryptspeed: speedcrypt @./speedcrypt 30 1 @@ -32,24 +31,18 @@ cryptspeed: speedcrypt @./speedcrypt 30 0 @./speedcrypt 30 0 -desspeed: speeddes - @./speeddes 30 1 - @./speeddes 30 1 - @./speeddes 40 25 - @./speeddes 40 25 - cert: cert.c ${LIBCRYPT} $(CC) $(CFLAGS) -o cert ${.CURDIR}/cert.c ${LIBCRYPT} speedcrypt: speedcrypt.c ${LIBCRYPT} $(CC) $(CFLAGS) -o speedcrypt ${.CURDIR}/speedcrypt.c ${LIBCRYPT} -speeddes: speeddes.c ${LIBCRYPT} - $(CC) $(CFLAGS) -o speeddes ${.CURDIR}/speeddes.c ${LIBCRYPT} clean: rm -f ${TARGETS} install: -.include <bsd.obj.mk> +obj: + +.include <bsd.prog.mk> diff --git a/secure/lib/libcrypt/test/cert.c b/secure/lib/libcrypt/test/cert.c index fe0d0bc..4a9c088 100644 --- a/secure/lib/libcrypt/test/cert.c +++ b/secure/lib/libcrypt/test/cert.c @@ -144,72 +144,6 @@ char *key, *plain, *answer; return(0); } -/* - * Test the setkey and encrypt functions - */ -void test_encrypt() -{ - char key[64],plain[64],cipher[64],answer[64]; - char buff[BUFSIZ]; - unsigned long salt; - int i; - int test; - int fail; - - printf("Testing setkey/encrypt\n"); - - for(test=0;fgets(buff, BUFSIZ, stdin);test++){ - - /* - * Allow comments. - */ - if (*buff == '#') - continue; - - if ((fail = parse_line(buff, &salt, key, plain, answer)) < 0){ - printf("test %d garbled (%d)\n", test, fail); - continue; - } - - if (salt) - continue; /* encrypt has no salt support */ - - printf(" K: "); put8(key); - printf(" P: "); put8(plain); - printf(" C: "); put8(answer); - - setkey(key); - for(i = 0; i < 64; i++) - cipher[i] = plain[i]; - encrypt(cipher, 0); - - for(i=0;i<64;i++) - if(cipher[i] != answer[i]) - break; - fail = 0; - if(i != 64){ - printf(" Enc FAIL "); - put8(cipher); - fail++; totfails++; - } - - encrypt(cipher, 1); - - for(i=0;i<64;i++) - if(cipher[i] != plain[i]) - break; - if(i != 64){ - printf(" Dec FAIL"); - fail++; totfails++; - } - - if(fail == 0) - printf(" OK"); - printf("\n"); - } -} - - void bytes_to_bits(bytes, bits) char *bytes; unsigned char *bits; @@ -225,71 +159,6 @@ unsigned char *bits; } -/* - * Test the des_setkey and des_cipher functions - */ -void test_des() -{ - char ckey[64], cplain[64], canswer[64]; - unsigned char key[8], plain[8], cipher[8], answer[8]; - char buff[BUFSIZ]; - unsigned long salt; - int i; - int test; - int fail; - - printf("Testing des_setkey/des_cipher\n"); - - for(test=0;fgets(buff, BUFSIZ, stdin);test++){ - - /* - * Allow comments. - */ - if (*buff == '#') - continue; - - if ((fail = parse_line(buff, &salt, ckey, cplain, canswer)) <0){ - printf("test %d garbled (%d)\n", test, fail); - continue; - } - - printf(" S: %06x", salt); - printf(" K: "); put8(ckey); - printf(" P: "); put8(cplain); - printf(" C: "); put8(canswer); - - bytes_to_bits(ckey, key); - bytes_to_bits(cplain, plain); - bytes_to_bits(canswer, answer); - des_setkey(key); - des_cipher(plain, cipher, salt, 1); - - for(i = 0; i < 8; i++) - if(cipher[i] != answer[i]) - break; - fail = 0; - if(i != 8){ - printf(" Enc FAIL "); - print_bits(cipher); - fail++; totfails++; - } - - des_cipher(cipher, cipher, salt, -1); - - for(i = 0; i < 8; i++) - if(cipher[i] != plain[i]) - break; - if(i != 8){ - printf(" Dec FAIL"); - fail++; totfails++; - } - - if(fail == 0) - printf(" OK"); - printf("\n"); - } -} - /* * Test the old-style crypt(), the new-style crypt(), and crypt16(). @@ -334,11 +203,6 @@ main(argc, argv) int argc; char *argv[]; { - if(argc < 1 || !strcmp(argv[1], "-e")) - test_encrypt(); - else if(!strcmp(argv[1], "-d")) - test_des(); - else if(!strcmp(argv[1], "-c")) - test_crypt(); + test_crypt(); good_bye(); } |