From 4b7e5519b6321af405d7c2e537dd087cd98d41af Mon Sep 17 00:00:00 2001 From: provos <> Date: Mon, 10 Aug 1998 18:33:07 +0000 Subject: fix base64 encoding, this problem was reported by Solar Designer some time ago. --- src/lib/libc/crypt/bcrypt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/lib/libc/crypt/bcrypt.c') diff --git a/src/lib/libc/crypt/bcrypt.c b/src/lib/libc/crypt/bcrypt.c index 3c2934b428..1b121fb28f 100644 --- a/src/lib/libc/crypt/bcrypt.c +++ b/src/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 @@ -45,7 +45,7 @@ * */ -#ifdef TEST +#if 0 #include #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() { -- cgit v1.2.3-55-g6feb