[898] in Kerberos-V5-bugs
des425 library doesn't have a make check....
daemon@ATHENA.MIT.EDU (epeisach@MIT.EDU)
Tue Oct 25 15:28:39 1994
From: epeisach@MIT.EDU
Date: Tue, 25 Oct 1994 15:28:28 -0400
To: krb5-bugs@MIT.EDU
Two patches:
Makefile.in - for check, make verify and run it...
verify.c:
Don't check for sizeof(long) - if library is broken, you
will know.
Add (a la crypto/des/verify.c) the results of the
encryption - so that verify can tell you if
everything worked - without having to be
visually checked.
===================================================================
RCS file: /mit/krb5/.cvsroot/src/lib/des425/Makefile.in,v
retrieving revision 1.12
diff -c -r1.12 Makefile.in
*** 1.12 1994/10/19 16:21:30
--- Makefile.in 1994/10/25 19:26:02
***************
*** 30,40 ****
$(srcdir)/weak_key.c
! EXT_LIB= $(TOPDIR)/lib/cryptoconf.o $(TOPDIR)/lib/crypto/libcrypto.a libdes425.a $(COMERRLIB)
! verify: verify.o libdes425.o
! $(RM) verify.o
$(CC) -o $@ verify.o $(LDFLAGS) $(EXT_LIB)
clean::
$(RM) verify
--- 30,45 ----
$(srcdir)/weak_key.c
! EXT_LIB= libdes425.a $(TOPLIBD)/libcrypto.a
! DEPKLIB= $(TOPLIBD)/libcrypto.a
! verify: verify.o libdes425.a $(DEPKLIB)
$(CC) -o $@ verify.o $(LDFLAGS) $(EXT_LIB)
+
+ check:: verify
+ ./verify -z
+ ./verify -m
+ ./verify
clean::
$(RM) verify
===================================================================
RCS file: /mit/krb5/.cvsroot/src/lib/des425/verify.c,v
retrieving revision 5.3
diff -c -r5.3 verify.c
*** 5.3 1994/08/18 21:56:10
--- verify.c 1994/10/19 13:31:57
***************
*** 71,76 ****
--- 71,100 ----
unsigned char zero_key[8] = {1,1,1,1,1,1,1,1}; /* just parity bits */
int i,j;
+ unsigned char cipher1[8] = {
+ 0x25,0xdd,0xac,0x3e,0x96,0x17,0x64,0x67
+ };
+ unsigned char cipher2[8] = {
+ 0x3f,0xa4,0x0e,0x8a,0x98,0x4d,0x48,0x15
+ };
+ unsigned char cipher3[64] = {
+ 0xe5,0xc7,0xcd,0xde,0x87,0x2b,0xf2,0x7c,
+ 0x43,0xe9,0x34,0x00,0x8c,0x38,0x9c,0x0f,
+ 0x68,0x37,0x88,0x49,0x9a,0x7c,0x05,0xf6
+ };
+ unsigned char checksum[8] = {
+ 0x58,0xd2,0xe7,0x7e,0x86,0x06,0x27,0x33
+ };
+
+ unsigned char zresult[8] = {
+ 0x8c, 0xa6, 0x4d, 0xe9, 0xc1, 0xb1, 0x23, 0xa7
+ };
+
+ unsigned char mresult[8] = {
+ 0xa3, 0x80, 0xe0, 0x2a, 0x6b, 0xe5, 0x46, 0x96
+ };
+
+
/*
* Can also add :
* plaintext = 0, key = 0, cipher = 0x8ca64de9c1b123a7 (or is it a 1?)
***************
*** 85,96 ****
progname=argv[0]; /* salt away invoking program */
- /* Assume a long is four bytes */
- if (sizeof(long) != 4) {
- printf("\nERROR, size of long is %d",sizeof(long));
- exit(-1);
- }
-
while (--argc > 0 && (*++argv)[0] == '-')
for (i=1; argv[0][i] != '\0'; i++) {
switch (argv[0][i]) {
--- 109,114 ----
***************
*** 133,139 ****
printf("%02x ",cipher_text[j]);
printf("\n");
do_decrypt(output,cipher_text);
! return(0);
}
if (mflag) {
--- 151,161 ----
printf("%02x ",cipher_text[j]);
printf("\n");
do_decrypt(output,cipher_text);
! if ( memcmp((char *)cipher_text, (char *)zresult, 8) ) {
! printf("verify: error in zero key test\n");
! exit(-1);
! }
! exit(0);
}
if (mflag) {
***************
*** 148,154 ****
}
printf("\n");
do_decrypt(output,cipher_text);
! return(0);
}
/* ECB mode Davies and Price */
--- 170,180 ----
}
printf("\n");
do_decrypt(output,cipher_text);
! if ( memcmp((char *)cipher_text, (char *)mresult, 8) ) {
! printf("verify: error in msb test\n");
! exit(-1);
! }
! exit(0);
}
/* ECB mode Davies and Price */
***************
*** 170,175 ****
--- 196,207 ----
printf("%02x ",cipher_text[j]);
printf("\n\n");
do_decrypt(output,cipher_text);
+ if ( memcmp((char *)cipher_text, (char *)cipher1, 8) ) {
+ printf("verify: error in ECB encryption\n");
+ exit(-1);
+ }
+ else
+ printf("verify: ECB encription is correct\n\n");
}
/* ECB mode */
***************
*** 188,193 ****
--- 220,231 ----
}
printf("\n\n");
do_decrypt(output,cipher_text);
+ if ( memcmp((char *)cipher_text, (char *)cipher2, 8) ) {
+ printf("verify: error in ECB encryption\n");
+ exit(-1);
+ }
+ else
+ printf("verify: ECB encription is correct\n\n");
}
/* CBC mode */
***************
*** 212,217 ****
--- 250,262 ----
des_cbc_encrypt(cipher_text,clear_text,(long) in_length,KS,ivec,0);
printf("\tdecrypted clear_text = \"%s\"\n",clear_text);
+ if ( memcmp((char *)cipher_text, (char *)cipher3, in_length) ) {
+ printf("verify: error in CBC encryption\n");
+ exit(-1);
+ }
+ else
+ printf("verify: CBC encription is correct\n\n");
+
printf("EXAMPLE CBC checksum");
printf("\tkey = 0123456789abcdef\tiv = 1234567890abcdef\n");
printf("\tclear =\t\t\"7654321 Now is the time for \"\n");
***************
*** 224,229 ****
--- 269,280 ----
for (j = 0; j<=7; j++)
printf("%02x ",cipher_text[j]);
printf("\n\n");
+ if ( memcmp((char *)cipher_text, (char *)checksum, 8) ) {
+ printf("verify: error in CBC cheksum\n");
+ exit(-1);
+ }
+ else
+ printf("verify: CBC checksum is correct\n\n");
exit(0);
}