summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2024-03-27 11:54:29 +0000
committerjsing <>2024-03-27 11:54:29 +0000
commitb82df59d7eb9e971471210b81fa7a41f3d834638 (patch)
tree14ee39aaf143eed25a20e017c2614e6ddbd029eb /src
parentc2eb04ad52795aefaabc7e43e3bd7f7fe8b1802b (diff)
downloadopenbsd-b82df59d7eb9e971471210b81fa7a41f3d834638.tar.gz
openbsd-b82df59d7eb9e971471210b81fa7a41f3d834638.tar.bz2
openbsd-b82df59d7eb9e971471210b81fa7a41f3d834638.zip
Unifdef BF_PTR2.
This removes the unused Intel special version of BF_ENC(). ok tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bf/bf_local.h25
-rw-r--r--src/lib/libcrypto/bf/blowfish.c74
2 files changed, 4 insertions, 95 deletions
diff --git a/src/lib/libcrypto/bf/bf_local.h b/src/lib/libcrypto/bf/bf_local.h
index f463dda360..8fc5a5dbd8 100644
--- a/src/lib/libcrypto/bf/bf_local.h
+++ b/src/lib/libcrypto/bf/bf_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bf_local.h,v 1.2 2024/03/27 11:44:39 jsing Exp $ */ 1/* $OpenBSD: bf_local.h,v 1.3 2024/03/27 11:54:29 jsing Exp $ */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <openssl/opensslconf.h> /* BF_PTR, BF_PTR2 */ 59#include <openssl/opensslconf.h> /* BF_PTR */
60 60
61#ifndef HEADER_BF_LOCL_H 61#ifndef HEADER_BF_LOCL_H
62#define HEADER_BF_LOCL_H 62#define HEADER_BF_LOCL_H
@@ -107,26 +107,7 @@
107/* This is actually a big endian algorithm, the most significant byte 107/* This is actually a big endian algorithm, the most significant byte
108 * is used to lookup array 0 */ 108 * is used to lookup array 0 */
109 109
110#if defined(BF_PTR2) 110#if defined(BF_PTR)
111
112/*
113 * This is basically a special Intel version. Point is that Intel
114 * doesn't have many registers, but offers a reach choice of addressing
115 * modes. So we spare some registers by directly traversing BF_KEY
116 * structure and hiring the most decorated addressing mode. The code
117 * generated by EGCS is *perfectly* competitive with assembler
118 * implementation!
119 */
120#define BF_ENC(LL,R,KEY,Pi) (\
121 LL^=KEY[Pi], \
122 t= KEY[BF_ROUNDS+2 + 0 + ((R>>24)&0xFF)], \
123 t+= KEY[BF_ROUNDS+2 + 256 + ((R>>16)&0xFF)], \
124 t^= KEY[BF_ROUNDS+2 + 512 + ((R>>8 )&0xFF)], \
125 t+= KEY[BF_ROUNDS+2 + 768 + ((R )&0xFF)], \
126 LL^=t \
127 )
128
129#elif defined(BF_PTR)
130 111
131#ifndef BF_LONG_LOG2 112#ifndef BF_LONG_LOG2
132#define BF_LONG_LOG2 2 /* default to BF_LONG being 32 bits */ 113#define BF_LONG_LOG2 2 /* default to BF_LONG being 32 bits */
diff --git a/src/lib/libcrypto/bf/blowfish.c b/src/lib/libcrypto/bf/blowfish.c
index 4fa8a563f1..fa6d66fcea 100644
--- a/src/lib/libcrypto/bf/blowfish.c
+++ b/src/lib/libcrypto/bf/blowfish.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: blowfish.c,v 1.1 2024/03/27 11:24:15 jsing Exp $ */ 1/* $OpenBSD: blowfish.c,v 1.2 2024/03/27 11:54:29 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -344,7 +344,6 @@ static const BF_KEY bf_init = {
344void 344void
345BF_encrypt(BF_LONG *data, const BF_KEY *key) 345BF_encrypt(BF_LONG *data, const BF_KEY *key)
346{ 346{
347#ifndef BF_PTR2
348 BF_LONG l, r; 347 BF_LONG l, r;
349 const BF_LONG *p, *s; 348 const BF_LONG *p, *s;
350 349
@@ -380,41 +379,6 @@ BF_encrypt(BF_LONG *data, const BF_KEY *key)
380 379
381 data[1] = l&0xffffffffL; 380 data[1] = l&0xffffffffL;
382 data[0] = r&0xffffffffL; 381 data[0] = r&0xffffffffL;
383#else
384 BF_LONG l, r,t, *k;
385
386 l = data[0];
387 r = data[1];
388 k = (BF_LONG*)key;
389
390 l ^= k[0];
391 BF_ENC(r, l, k, 1);
392 BF_ENC(l, r, k, 2);
393 BF_ENC(r, l, k, 3);
394 BF_ENC(l, r, k, 4);
395 BF_ENC(r, l, k, 5);
396 BF_ENC(l, r, k, 6);
397 BF_ENC(r, l, k, 7);
398 BF_ENC(l, r, k, 8);
399 BF_ENC(r, l, k, 9);
400 BF_ENC(l, r,k, 10);
401 BF_ENC(r, l,k, 11);
402 BF_ENC(l, r,k, 12);
403 BF_ENC(r, l,k, 13);
404 BF_ENC(l, r,k, 14);
405 BF_ENC(r, l,k, 15);
406 BF_ENC(l, r,k, 16);
407#if BF_ROUNDS == 20
408 BF_ENC(r, l,k, 17);
409 BF_ENC(l, r,k, 18);
410 BF_ENC(r, l,k, 19);
411 BF_ENC(l, r,k, 20);
412#endif
413 r ^= k[BF_ROUNDS + 1];
414
415 data[1] = l&0xffffffffL;
416 data[0] = r&0xffffffffL;
417#endif
418} 382}
419 383
420#ifndef BF_DEFAULT_OPTIONS 384#ifndef BF_DEFAULT_OPTIONS
@@ -422,7 +386,6 @@ BF_encrypt(BF_LONG *data, const BF_KEY *key)
422void 386void
423BF_decrypt(BF_LONG *data, const BF_KEY *key) 387BF_decrypt(BF_LONG *data, const BF_KEY *key)
424{ 388{
425#ifndef BF_PTR2
426 BF_LONG l, r; 389 BF_LONG l, r;
427 const BF_LONG *p, *s; 390 const BF_LONG *p, *s;
428 391
@@ -458,41 +421,6 @@ BF_decrypt(BF_LONG *data, const BF_KEY *key)
458 421
459 data[1] = l&0xffffffffL; 422 data[1] = l&0xffffffffL;
460 data[0] = r&0xffffffffL; 423 data[0] = r&0xffffffffL;
461#else
462 BF_LONG l, r,t, *k;
463
464 l = data[0];
465 r = data[1];
466 k = (BF_LONG *)key;
467
468 l ^= k[BF_ROUNDS + 1];
469#if BF_ROUNDS == 20
470 BF_ENC(r, l,k, 20);
471 BF_ENC(l, r,k, 19);
472 BF_ENC(r, l,k, 18);
473 BF_ENC(l, r,k, 17);
474#endif
475 BF_ENC(r, l,k, 16);
476 BF_ENC(l, r,k, 15);
477 BF_ENC(r, l,k, 14);
478 BF_ENC(l, r,k, 13);
479 BF_ENC(r, l,k, 12);
480 BF_ENC(l, r,k, 11);
481 BF_ENC(r, l,k, 10);
482 BF_ENC(l, r, k, 9);
483 BF_ENC(r, l, k, 8);
484 BF_ENC(l, r, k, 7);
485 BF_ENC(r, l, k, 6);
486 BF_ENC(l, r, k, 5);
487 BF_ENC(r, l, k, 4);
488 BF_ENC(l, r, k, 3);
489 BF_ENC(r, l, k, 2);
490 BF_ENC(l, r, k, 1);
491 r ^= k[0];
492
493 data[1] = l&0xffffffffL;
494 data[0] = r&0xffffffffL;
495#endif
496} 424}
497 425
498void 426void