diff options
| author | provos <> | 1998-08-10 18:33:07 +0000 | 
|---|---|---|
| committer | provos <> | 1998-08-10 18:33:07 +0000 | 
| commit | 4b7e5519b6321af405d7c2e537dd087cd98d41af (patch) | |
| tree | 3447285d13f7744df2b0458952ed08a98e5743df /src/lib/libc/crypt/bcrypt.c | |
| parent | ecc79d719061ba72b6b8ed3b970f87bd0d75f431 (diff) | |
| download | openbsd-4b7e5519b6321af405d7c2e537dd087cd98d41af.tar.gz openbsd-4b7e5519b6321af405d7c2e537dd087cd98d41af.tar.bz2 openbsd-4b7e5519b6321af405d7c2e537dd087cd98d41af.zip | |
fix base64 encoding, this problem was reported by
Solar Designer <solar@false.com> some time ago.
Diffstat (limited to 'src/lib/libc/crypt/bcrypt.c')
| -rw-r--r-- | src/lib/libc/crypt/bcrypt.c | 12 | 
1 files changed, 6 insertions, 6 deletions
| 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 @@ | |||
| 1 | /* $OpenBSD: bcrypt.c,v 1.11 1998/02/18 16:10:53 provos Exp $ */ | 1 | /* $OpenBSD: bcrypt.c,v 1.12 1998/08/10 18:33:07 provos Exp $ */ | 
| 2 | 2 | ||
| 3 | /* | 3 | /* | 
| 4 | * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> | 4 | * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> | 
| @@ -45,7 +45,7 @@ | |||
| 45 | * | 45 | * | 
| 46 | */ | 46 | */ | 
| 47 | 47 | ||
| 48 | #ifdef TEST | 48 | #if 0 | 
| 49 | #include <stdio.h> | 49 | #include <stdio.h> | 
| 50 | #endif | 50 | #endif | 
| 51 | 51 | ||
| @@ -289,7 +289,7 @@ bcrypt(key, salt) | |||
| 289 | 289 | ||
| 290 | encode_base64((u_int8_t *) encrypted + i + 3, csalt, BCRYPT_MAXSALT); | 290 | encode_base64((u_int8_t *) encrypted + i + 3, csalt, BCRYPT_MAXSALT); | 
| 291 | encode_base64((u_int8_t *) encrypted + strlen(encrypted), ciphertext, | 291 | encode_base64((u_int8_t *) encrypted + strlen(encrypted), ciphertext, | 
| 292 | 4 * BCRYPT_BLOCKS); | 292 | 4 * BCRYPT_BLOCKS - 1); | 
| 293 | return encrypted; | 293 | return encrypted; | 
| 294 | } | 294 | } | 
| 295 | 295 | ||
| @@ -311,26 +311,26 @@ encode_base64(buffer, data, len) | |||
| 311 | c1 = *p++; | 311 | c1 = *p++; | 
| 312 | *bp++ = Base64Code[(c1 >> 2)]; | 312 | *bp++ = Base64Code[(c1 >> 2)]; | 
| 313 | c1 = (c1 & 0x03) << 4; | 313 | c1 = (c1 & 0x03) << 4; | 
| 314 | c2 = *p++; | ||
| 315 | if (p >= data + len) { | 314 | if (p >= data + len) { | 
| 316 | *bp++ = Base64Code[c1]; | 315 | *bp++ = Base64Code[c1]; | 
| 317 | break; | 316 | break; | 
| 318 | } | 317 | } | 
| 318 | c2 = *p++; | ||
| 319 | c1 |= (c2 >> 4) & 0x0f; | 319 | c1 |= (c2 >> 4) & 0x0f; | 
| 320 | *bp++ = Base64Code[c1]; | 320 | *bp++ = Base64Code[c1]; | 
| 321 | c1 = (c2 & 0x0f) << 2; | 321 | c1 = (c2 & 0x0f) << 2; | 
| 322 | c2 = *p++; | ||
| 323 | if (p >= data + len) { | 322 | if (p >= data + len) { | 
| 324 | *bp++ = Base64Code[c1]; | 323 | *bp++ = Base64Code[c1]; | 
| 325 | break; | 324 | break; | 
| 326 | } | 325 | } | 
| 326 | c2 = *p++; | ||
| 327 | c1 |= (c2 >> 6) & 0x03; | 327 | c1 |= (c2 >> 6) & 0x03; | 
| 328 | *bp++ = Base64Code[c1]; | 328 | *bp++ = Base64Code[c1]; | 
| 329 | *bp++ = Base64Code[c2 & 0x3f]; | 329 | *bp++ = Base64Code[c2 & 0x3f]; | 
| 330 | } | 330 | } | 
| 331 | *bp = '\0'; | 331 | *bp = '\0'; | 
| 332 | } | 332 | } | 
| 333 | #ifdef TEST | 333 | #if 0 | 
| 334 | void | 334 | void | 
| 335 | main() | 335 | main() | 
| 336 | { | 336 | { | 
