diff options
Diffstat (limited to 'src/lib/libcrypto/bf/bf_cbc.c')
| -rw-r--r-- | src/lib/libcrypto/bf/bf_cbc.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/lib/libcrypto/bf/bf_cbc.c b/src/lib/libcrypto/bf/bf_cbc.c index e0fa9ad763..f949629dc6 100644 --- a/src/lib/libcrypto/bf/bf_cbc.c +++ b/src/lib/libcrypto/bf/bf_cbc.c | |||
| @@ -56,16 +56,11 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include "blowfish.h" | 59 | #include <openssl/blowfish.h> |
| 60 | #include "bf_locl.h" | 60 | #include "bf_locl.h" |
| 61 | 61 | ||
| 62 | void BF_cbc_encrypt(in, out, length, ks, iv, encrypt) | 62 | void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, |
| 63 | unsigned char *in; | 63 | const BF_KEY *schedule, unsigned char *ivec, int encrypt) |
| 64 | unsigned char *out; | ||
| 65 | long length; | ||
| 66 | BF_KEY *ks; | ||
| 67 | unsigned char *iv; | ||
| 68 | int encrypt; | ||
| 69 | { | 64 | { |
| 70 | register BF_LONG tin0,tin1; | 65 | register BF_LONG tin0,tin1; |
| 71 | register BF_LONG tout0,tout1,xor0,xor1; | 66 | register BF_LONG tout0,tout1,xor0,xor1; |
| @@ -74,9 +69,9 @@ int encrypt; | |||
| 74 | 69 | ||
| 75 | if (encrypt) | 70 | if (encrypt) |
| 76 | { | 71 | { |
| 77 | n2l(iv,tout0); | 72 | n2l(ivec,tout0); |
| 78 | n2l(iv,tout1); | 73 | n2l(ivec,tout1); |
| 79 | iv-=8; | 74 | ivec-=8; |
| 80 | for (l-=8; l>=0; l-=8) | 75 | for (l-=8; l>=0; l-=8) |
| 81 | { | 76 | { |
| 82 | n2l(in,tin0); | 77 | n2l(in,tin0); |
| @@ -85,7 +80,7 @@ int encrypt; | |||
| 85 | tin1^=tout1; | 80 | tin1^=tout1; |
| 86 | tin[0]=tin0; | 81 | tin[0]=tin0; |
| 87 | tin[1]=tin1; | 82 | tin[1]=tin1; |
| 88 | BF_encrypt(tin,ks); | 83 | BF_encrypt(tin,schedule); |
| 89 | tout0=tin[0]; | 84 | tout0=tin[0]; |
| 90 | tout1=tin[1]; | 85 | tout1=tin[1]; |
| 91 | l2n(tout0,out); | 86 | l2n(tout0,out); |
| @@ -98,27 +93,27 @@ int encrypt; | |||
| 98 | tin1^=tout1; | 93 | tin1^=tout1; |
| 99 | tin[0]=tin0; | 94 | tin[0]=tin0; |
| 100 | tin[1]=tin1; | 95 | tin[1]=tin1; |
| 101 | BF_encrypt(tin,ks); | 96 | BF_encrypt(tin,schedule); |
| 102 | tout0=tin[0]; | 97 | tout0=tin[0]; |
| 103 | tout1=tin[1]; | 98 | tout1=tin[1]; |
| 104 | l2n(tout0,out); | 99 | l2n(tout0,out); |
| 105 | l2n(tout1,out); | 100 | l2n(tout1,out); |
| 106 | } | 101 | } |
| 107 | l2n(tout0,iv); | 102 | l2n(tout0,ivec); |
| 108 | l2n(tout1,iv); | 103 | l2n(tout1,ivec); |
| 109 | } | 104 | } |
| 110 | else | 105 | else |
| 111 | { | 106 | { |
| 112 | n2l(iv,xor0); | 107 | n2l(ivec,xor0); |
| 113 | n2l(iv,xor1); | 108 | n2l(ivec,xor1); |
| 114 | iv-=8; | 109 | ivec-=8; |
| 115 | for (l-=8; l>=0; l-=8) | 110 | for (l-=8; l>=0; l-=8) |
| 116 | { | 111 | { |
| 117 | n2l(in,tin0); | 112 | n2l(in,tin0); |
| 118 | n2l(in,tin1); | 113 | n2l(in,tin1); |
| 119 | tin[0]=tin0; | 114 | tin[0]=tin0; |
| 120 | tin[1]=tin1; | 115 | tin[1]=tin1; |
| 121 | BF_decrypt(tin,ks); | 116 | BF_decrypt(tin,schedule); |
| 122 | tout0=tin[0]^xor0; | 117 | tout0=tin[0]^xor0; |
| 123 | tout1=tin[1]^xor1; | 118 | tout1=tin[1]^xor1; |
| 124 | l2n(tout0,out); | 119 | l2n(tout0,out); |
| @@ -132,15 +127,15 @@ int encrypt; | |||
| 132 | n2l(in,tin1); | 127 | n2l(in,tin1); |
| 133 | tin[0]=tin0; | 128 | tin[0]=tin0; |
| 134 | tin[1]=tin1; | 129 | tin[1]=tin1; |
| 135 | BF_decrypt(tin,ks); | 130 | BF_decrypt(tin,schedule); |
| 136 | tout0=tin[0]^xor0; | 131 | tout0=tin[0]^xor0; |
| 137 | tout1=tin[1]^xor1; | 132 | tout1=tin[1]^xor1; |
| 138 | l2nn(tout0,tout1,out,l+8); | 133 | l2nn(tout0,tout1,out,l+8); |
| 139 | xor0=tin0; | 134 | xor0=tin0; |
| 140 | xor1=tin1; | 135 | xor1=tin1; |
| 141 | } | 136 | } |
| 142 | l2n(xor0,iv); | 137 | l2n(xor0,ivec); |
| 143 | l2n(xor1,iv); | 138 | l2n(xor1,ivec); |
| 144 | } | 139 | } |
| 145 | tin0=tin1=tout0=tout1=xor0=xor1=0; | 140 | tin0=tin1=tout0=tout1=xor0=xor1=0; |
| 146 | tin[0]=tin[1]=0; | 141 | tin[0]=tin[1]=0; |
