summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>1998-08-10 18:33:08 +0000
committerNiels Provos <provos@cvs.openbsd.org>1998-08-10 18:33:08 +0000
commit7182e8c3cebdc3e69c012c12074dcc11f941924d (patch)
tree8b4de8b63c9a3f27e866ede961e579eabf007631 /lib/libc
parente214c45e4ca64f4c1a777d206123d6c06b6d2c49 (diff)
fix base64 encoding, this problem was reported by
Solar Designer <solar@false.com> some time ago.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/crypt/bcrypt.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/libc/crypt/bcrypt.c b/lib/libc/crypt/bcrypt.c
index 3c2934b4288..1b121fb28f7 100644
--- a/lib/libc/crypt/bcrypt.c
+++ b/lib/libc/crypt/bcrypt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcrypt.c,v 1.11 1998/02/18 16:10:53 provos Exp $ */
+/* $OpenBSD: bcrypt.c,v 1.12 1998/08/10 18:33:07 provos Exp $ */
/*
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@@ -45,7 +45,7 @@
*
*/
-#ifdef TEST
+#if 0
#include <stdio.h>
#endif
@@ -289,7 +289,7 @@ bcrypt(key, salt)
encode_base64((u_int8_t *) encrypted + i + 3, csalt, BCRYPT_MAXSALT);
encode_base64((u_int8_t *) encrypted + strlen(encrypted), ciphertext,
- 4 * BCRYPT_BLOCKS);
+ 4 * BCRYPT_BLOCKS - 1);
return encrypted;
}
@@ -311,26 +311,26 @@ encode_base64(buffer, data, len)
c1 = *p++;
*bp++ = Base64Code[(c1 >> 2)];
c1 = (c1 & 0x03) << 4;
- c2 = *p++;
if (p >= data + len) {
*bp++ = Base64Code[c1];
break;
}
+ c2 = *p++;
c1 |= (c2 >> 4) & 0x0f;
*bp++ = Base64Code[c1];
c1 = (c2 & 0x0f) << 2;
- c2 = *p++;
if (p >= data + len) {
*bp++ = Base64Code[c1];
break;
}
+ c2 = *p++;
c1 |= (c2 >> 6) & 0x03;
*bp++ = Base64Code[c1];
*bp++ = Base64Code[c2 & 0x3f];
}
*bp = '\0';
}
-#ifdef TEST
+#if 0
void
main()
{