diff options
author | Ulf Möller <ulf@openssl.org> | 1999-04-27 21:17:18 +0000 |
---|---|---|
committer | Ulf Möller <ulf@openssl.org> | 1999-04-27 21:17:18 +0000 |
commit | 8cd8a7b7a2cb2b69cd1ede5c525e3dbbee138a0c (patch) | |
tree | 30d450a439b3356fbb29b84189dd93bed2d10656 /crypto/bf/bf_enc.c | |
parent | 67a4728511cad54b22b871aa2674944d111f30d2 (diff) | |
download | openssl-8cd8a7b7a2cb2b69cd1ede5c525e3dbbee138a0c.tar.gz |
More portable blowfish macros.
Submitted by: Andy Polyakov <appro@fy.chalmers.se>
Diffstat (limited to 'crypto/bf/bf_enc.c')
-rw-r--r-- | crypto/bf/bf_enc.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/crypto/bf/bf_enc.c b/crypto/bf/bf_enc.c index f8a95e2142..ee01834561 100644 --- a/crypto/bf/bf_enc.c +++ b/crypto/bf/bf_enc.c @@ -71,6 +71,7 @@ to modify the code. void BF_encrypt(BF_LONG *data, BF_KEY *key) { +#ifndef BF_PTR2 register BF_LONG l,r,*p,*s; p=key->P; @@ -105,12 +106,48 @@ void BF_encrypt(BF_LONG *data, BF_KEY *key) data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; +#else + register BF_LONG l,r,t,*k; + + l=data[0]; + r=data[1]; + k=(BF_LONG*)key; + + l^=k[0]; + BF_ENC(r,l,k, 1); + BF_ENC(l,r,k, 2); + BF_ENC(r,l,k, 3); + BF_ENC(l,r,k, 4); + BF_ENC(r,l,k, 5); + BF_ENC(l,r,k, 6); + BF_ENC(r,l,k, 7); + BF_ENC(l,r,k, 8); + BF_ENC(r,l,k, 9); + BF_ENC(l,r,k,10); + BF_ENC(r,l,k,11); + BF_ENC(l,r,k,12); + BF_ENC(r,l,k,13); + BF_ENC(l,r,k,14); + BF_ENC(r,l,k,15); + BF_ENC(l,r,k,16); +#if BF_ROUNDS == 20 + BF_ENC(r,l,k,17); + BF_ENC(l,r,k,18); + BF_ENC(r,l,k,19); + BF_ENC(l,r,k,20); +#endif + r^=k[BF_ROUNDS+1]; + + data[1]=l&0xffffffffL; + data[0]=r&0xffffffffL; +#endif } #ifndef BF_DEFAULT_OPTIONS void BF_decrypt(BF_LONG *data, BF_KEY *key) { +#ifndef BF_PTR2 register BF_LONG l,r,*p,*s; p=key->P; @@ -145,6 +182,41 @@ void BF_decrypt(BF_LONG *data, BF_KEY *key) data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; +#else + register BF_LONG l,r,t,*k; + + l=data[0]; + r=data[1]; + k=(BF_LONG *)key; + + l^=k[BF_ROUNDS+1]; +#if BF_ROUNDS == 20 + BF_ENC(r,l,k,20); + BF_ENC(l,r,k,19); + BF_ENC(r,l,k,18); + BF_ENC(l,r,k,17); +#endif + BF_ENC(r,l,k,16); + BF_ENC(l,r,k,15); + BF_ENC(r,l,k,14); + BF_ENC(l,r,k,13); + BF_ENC(r,l,k,12); + BF_ENC(l,r,k,11); + BF_ENC(r,l,k,10); + BF_ENC(l,r,k, 9); + BF_ENC(r,l,k, 8); + BF_ENC(l,r,k, 7); + BF_ENC(r,l,k, 6); + BF_ENC(l,r,k, 5); + BF_ENC(r,l,k, 4); + BF_ENC(l,r,k, 3); + BF_ENC(r,l,k, 2); + BF_ENC(l,r,k, 1); + r^=k[0]; + + data[1]=l&0xffffffffL; + data[0]=r&0xffffffffL; +#endif } void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, |