X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=crypto%2Fbf%2Fbf_locl.h;h=cc7c3ec9922161636846abfe5ed20aecc16844af;hb=ec5add8784a2ffacd3391daae7937e04225da9da;hp=418ff04fdeb35941a9ed2365f41d6d419ace0c14;hpb=8e10f2b3ac1cb5ba9de832981ce32ac49c71fdee;p=openssl.git diff --git a/crypto/bf/bf_locl.h b/crypto/bf/bf_locl.h index 418ff04fde..cc7c3ec992 100644 --- a/crypto/bf/bf_locl.h +++ b/crypto/bf/bf_locl.h @@ -1,4 +1,4 @@ -/* crypto/bf/bf_locl.org */ +/* crypto/bf/bf_locl.h */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,9 +56,9 @@ * [including the GNU Public Licence.] */ -#ifndef _HEADER_BF_LOCL_H -#define _HEADER_BF_LOCL_H -#include "opensslconf.h" /* BF_PTR, BF_PTR2 */ +#ifndef HEADER_BF_LOCL_H +#define HEADER_BF_LOCL_H +#include /* BF_PTR, BF_PTR2 */ #undef c2l #define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ @@ -148,59 +148,72 @@ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) -/* This is actually a big endian algorithm, the most significate byte +/* This is actually a big endian algorithm, the most significant byte * is used to lookup array 0 */ -#define BF_M 0x3fc -#define BF_0 22L -#define BF_1 14L -#define BF_2 6L -#define BF_3 2L /* left shift */ - #if defined(BF_PTR2) -/* This is basically a special pentium verson */ -#define BF_ENC(LL,R,S,P) \ - { \ - BF_LONG t,u,v; \ - u=R>>BF_0; \ - v=R>>BF_1; \ - u&=BF_M; \ - v&=BF_M; \ - t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \ - u=R>>BF_2; \ - t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \ - v=R<>24)&0xFF)], \ + t+= KEY[BF_ROUNDS+2 + 256 + ((R>>16)&0xFF)], \ + t^= KEY[BF_ROUNDS+2 + 512 + ((R>>8 )&0xFF)], \ + t+= KEY[BF_ROUNDS+2 + 768 + ((R )&0xFF)], \ + LL^=t \ + ) #elif defined(BF_PTR) -/* This is normally very good */ +#ifndef BF_LONG_LOG2 +#define BF_LONG_LOG2 2 /* default to BF_LONG being 32 bits */ +#endif +#define BF_M (0xFF<>BF_i)&BF_M gets folded into a single instruction, namely + * rlwinm. So let'em double-check if their compiler does it. + */ -#define BF_ENC(LL,R,S,P) \ - LL^=P; \ +#define BF_ENC(LL,R,S,P) ( \ + LL^=P, \ LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \ *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \ - *(BF_LONG *)((unsigned char *)&(S[768])+((R<>24L) ] + \ - S[0x0100+((int)(R>>16L)&0xff)])^ \ - S[0x0200+((int)(R>> 8L)&0xff)])+ \ - S[0x0300+((int)(R )&0xff)])&0xffffffffL; +#define BF_ENC(LL,R,S,P) ( \ + LL^=P, \ + LL^=((( S[ ((int)(R>>24)&0xff)] + \ + S[0x0100+((int)(R>>16)&0xff)])^ \ + S[0x0200+((int)(R>> 8)&0xff)])+ \ + S[0x0300+((int)(R )&0xff)])&0xffffffffL \ + ) #endif #endif