diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-07-10 22:53:38 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-07-10 22:53:38 +0000 |
commit | 2ec8c7489d9ac4f6eb544112b10bfae5a1f06913 (patch) | |
tree | 902cba3814dfa7b3256de57afca75fcc05aad5dd /lib/libskey | |
parent | 7f713d9ace4c5809f5dff75d423f0ba82b6b351e (diff) |
Use new SHA1* functions.
Diffstat (limited to 'lib/libskey')
-rw-r--r-- | lib/libskey/shlib_version | 2 | ||||
-rw-r--r-- | lib/libskey/skeysubr.c | 40 |
2 files changed, 24 insertions, 18 deletions
diff --git a/lib/libskey/shlib_version b/lib/libskey/shlib_version index dea2b62cafc..97247abae54 100644 --- a/lib/libskey/shlib_version +++ b/lib/libskey/shlib_version @@ -1,2 +1,2 @@ major=0 -minor=2 +minor=3 diff --git a/lib/libskey/skeysubr.c b/lib/libskey/skeysubr.c index 06a83aa4f7c..b93ac0793c3 100644 --- a/lib/libskey/skeysubr.c +++ b/lib/libskey/skeysubr.c @@ -10,7 +10,7 @@ * * S/KEY misc routines. * - * $Id: skeysubr.c,v 1.12 1996/11/03 18:57:30 millert Exp $ + * $Id: skeysubr.c,v 1.13 1997/07/10 22:53:37 millert Exp $ */ #include <stdio.h> @@ -149,7 +149,8 @@ keycrunch_sha1(result, seed, passwd) char *passwd; /* Password, any length */ { char *buf; - SHA1_INFO sha; + SHA1_CTX sha; + u_int32_t results[5]; unsigned int buflen; buflen = strlen(seed) + strlen(passwd); @@ -161,20 +162,22 @@ keycrunch_sha1(result, seed, passwd) /* Crunch the key through SHA1 */ sevenbit(buf); - sha1Init(&sha); - sha1Update(&sha, (unsigned char *)buf, buflen); - sha1Final(&sha); + SHA1Init(&sha); + SHA1Update(&sha, (unsigned char *)buf, buflen); + SHA1Final((unsigned char *)results, &sha); (void)free(buf); /* Fold 160 to 64 bits */ - sha.digest[0] ^= sha.digest[2]; - sha.digest[1] ^= sha.digest[3]; - sha.digest[0] ^= sha.digest[4]; + results[0] ^= results[2]; + results[1] ^= results[3]; + results[0] ^= results[4]; - (void)memcpy((void *)result, (void *)sha.digest, SKEY_BINKEY_SIZE); + (void)memcpy((void *)result, (void *)results, SKEY_BINKEY_SIZE); +#if 0 /* XXX */ #if BYTE_ORDER == LITTLE_ENDIAN sha1ByteReverse((u_int32_t *)result, SKEY_BINKEY_SIZE); #endif /* LITTLE_ENDIAN */ +#endif return 0; } @@ -230,21 +233,24 @@ static void f_sha1(x) char *x; { - SHA1_INFO sha; + SHA1_CTX sha; + u_int32_t results[5]; - sha1Init(&sha); - sha1Update(&sha, (unsigned char *)x, SKEY_BINKEY_SIZE); - sha1Final(&sha); + SHA1Init(&sha); + SHA1Update(&sha, (unsigned char *)x, SKEY_BINKEY_SIZE); + SHA1Final((unsigned char *)results, &sha); /* Fold 160 to 64 bits */ - sha.digest[0] ^= sha.digest[2]; - sha.digest[1] ^= sha.digest[3]; - sha.digest[0] ^= sha.digest[4]; + results[0] ^= results[2]; + results[1] ^= results[3]; + results[0] ^= results[4]; - (void)memcpy((void *)x, (void *)sha.digest, SKEY_BINKEY_SIZE); + (void)memcpy((void *)x, (void *)results, SKEY_BINKEY_SIZE); +#if 0 /* XXX */ #if BYTE_ORDER == LITTLE_ENDIAN sha1ByteReverse((u_int32_t *)x, SKEY_BINKEY_SIZE); #endif /* LITTLE_ENDIAN */ +#endif } /* Strip trailing cr/lf from a line of text */ |