diff options
author | jsing <> | 2022-11-11 12:08:29 +0000 |
---|---|---|
committer | jsing <> | 2022-11-11 12:08:29 +0000 |
commit | 57b70d7ba6ec6499567b2f281f47b636282a2ecd (patch) | |
tree | 5b400e8c145bf12274317967d2b18caee9914a21 /src/lib/libcrypto/bf/bf_cfb64.c | |
parent | 8162acf7813e6b117517a092921aebf84fb21de9 (diff) | |
download | openbsd-57b70d7ba6ec6499567b2f281f47b636282a2ecd.tar.gz openbsd-57b70d7ba6ec6499567b2f281f47b636282a2ecd.tar.bz2 openbsd-57b70d7ba6ec6499567b2f281f47b636282a2ecd.zip |
Whack blowfish with a style(9) bat.
Diffstat (limited to 'src/lib/libcrypto/bf/bf_cfb64.c')
-rw-r--r-- | src/lib/libcrypto/bf/bf_cfb64.c | 108 |
1 files changed, 55 insertions, 53 deletions
diff --git a/src/lib/libcrypto/bf/bf_cfb64.c b/src/lib/libcrypto/bf/bf_cfb64.c index 6cc0bb999b..4ef15b94c6 100644 --- a/src/lib/libcrypto/bf/bf_cfb64.c +++ b/src/lib/libcrypto/bf/bf_cfb64.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* $OpenBSD: bf_cfb64.c,v 1.5 2014/10/28 07:35:58 jsg Exp $ */ | 1 | /* $OpenBSD: bf_cfb64.c,v 1.6 2022/11/11 12:08: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 | * |
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -64,58 +64,60 @@ | |||
64 | * 64bit block we have used is contained in *num; | 64 | * 64bit block we have used is contained in *num; |
65 | */ | 65 | */ |
66 | 66 | ||
67 | void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, | 67 | void |
68 | const BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt) | 68 | BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, |
69 | { | 69 | const BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt) |
70 | BF_LONG v0,v1,t; | 70 | { |
71 | BF_LONG v0, v1, t; | ||
71 | int n= *num; | 72 | int n= *num; |
72 | long l=length; | 73 | long l = length; |
73 | BF_LONG ti[2]; | 74 | BF_LONG ti[2]; |
74 | unsigned char *iv,c,cc; | 75 | unsigned char *iv, c, cc; |
75 | 76 | ||
76 | iv=(unsigned char *)ivec; | 77 | iv = (unsigned char *)ivec; |
77 | if (encrypt) | 78 | if (encrypt) { |
78 | { | 79 | while (l--) { |
79 | while (l--) | 80 | if (n == 0) { |
80 | { | 81 | n2l(iv, v0); |
81 | if (n == 0) | 82 | ti[0] = v0; |
82 | { | 83 | n2l(iv, v1); |
83 | n2l(iv,v0); ti[0]=v0; | 84 | ti[1] = v1; |
84 | n2l(iv,v1); ti[1]=v1; | 85 | BF_encrypt((BF_LONG *)ti, schedule); |
85 | BF_encrypt((BF_LONG *)ti,schedule); | 86 | iv = (unsigned char *)ivec; |
86 | iv=(unsigned char *)ivec; | 87 | t = ti[0]; |
87 | t=ti[0]; l2n(t,iv); | 88 | l2n(t, iv); |
88 | t=ti[1]; l2n(t,iv); | 89 | t = ti[1]; |
89 | iv=(unsigned char *)ivec; | 90 | l2n(t, iv); |
90 | } | 91 | iv = (unsigned char *)ivec; |
91 | c= *(in++)^iv[n]; | ||
92 | *(out++)=c; | ||
93 | iv[n]=c; | ||
94 | n=(n+1)&0x07; | ||
95 | } | 92 | } |
93 | c= *(in++)^iv[n]; | ||
94 | *(out++) = c; | ||
95 | iv[n] = c; | ||
96 | n = (n + 1)&0x07; | ||
96 | } | 97 | } |
97 | else | 98 | } else { |
98 | { | 99 | while (l--) { |
99 | while (l--) | 100 | if (n == 0) { |
100 | { | 101 | n2l(iv, v0); |
101 | if (n == 0) | 102 | ti[0] = v0; |
102 | { | 103 | n2l(iv, v1); |
103 | n2l(iv,v0); ti[0]=v0; | 104 | ti[1] = v1; |
104 | n2l(iv,v1); ti[1]=v1; | 105 | BF_encrypt((BF_LONG *)ti, schedule); |
105 | BF_encrypt((BF_LONG *)ti,schedule); | 106 | iv = (unsigned char *)ivec; |
106 | iv=(unsigned char *)ivec; | 107 | t = ti[0]; |
107 | t=ti[0]; l2n(t,iv); | 108 | l2n(t, iv); |
108 | t=ti[1]; l2n(t,iv); | 109 | t = ti[1]; |
109 | iv=(unsigned char *)ivec; | 110 | l2n(t, iv); |
110 | } | 111 | iv = (unsigned char *)ivec; |
111 | cc= *(in++); | ||
112 | c=iv[n]; | ||
113 | iv[n]=cc; | ||
114 | *(out++)=c^cc; | ||
115 | n=(n+1)&0x07; | ||
116 | } | 112 | } |
113 | cc= *(in++); | ||
114 | c = iv[n]; | ||
115 | iv[n] = cc; | ||
116 | *(out++) = c^cc; | ||
117 | n = (n + 1)&0x07; | ||
117 | } | 118 | } |
118 | v0=v1=ti[0]=ti[1]=t=c=cc=0; | ||
119 | *num=n; | ||
120 | } | 119 | } |
120 | v0 = v1 = ti[0] = ti[1] = t=c = cc = 0; | ||
121 | *num = n; | ||
122 | } | ||
121 | 123 | ||