summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des/des.h
diff options
context:
space:
mode:
authorbeck <>2023-07-08 07:11:07 +0000
committerbeck <>2023-07-08 07:11:07 +0000
commit690a2d7bb2ae49af3eba452cabf6daa1c05c5468 (patch)
tree893e40f2d049c1ae16b1df1305f2bb885508c93f /src/lib/libcrypto/des/des.h
parented40d3cca6345815b45a8b09197f9d7d29369445 (diff)
downloadopenbsd-690a2d7bb2ae49af3eba452cabf6daa1c05c5468.tar.gz
openbsd-690a2d7bb2ae49af3eba452cabf6daa1c05c5468.tar.bz2
openbsd-690a2d7bb2ae49af3eba452cabf6daa1c05c5468.zip
Hit the des directory with the loving mallet of knfmt
ok tb@
Diffstat (limited to 'src/lib/libcrypto/des/des.h')
-rw-r--r--src/lib/libcrypto/des/des.h165
1 files changed, 81 insertions, 84 deletions
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h
index e1331d3fa2..ef2ecb4d03 100644
--- a/src/lib/libcrypto/des/des.h
+++ b/src/lib/libcrypto/des/des.h
@@ -1,25 +1,25 @@
1/* $OpenBSD: des.h,v 1.19 2015/02/07 13:19:15 doug Exp $ */ 1/* $OpenBSD: des.h,v 1.20 2023/07/08 07:11:07 beck 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 *
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
@@ -65,7 +65,6 @@
65#error DES is disabled. 65#error DES is disabled.
66#endif 66#endif
67 67
68
69#ifdef __cplusplus 68#ifdef __cplusplus
70extern "C" { 69extern "C" {
71#endif 70#endif
@@ -75,16 +74,14 @@ typedef /* const */ unsigned char const_DES_cblock[8];
75/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * 74/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock *
76 * and const_DES_cblock * are incompatible pointer types. */ 75 * and const_DES_cblock * are incompatible pointer types. */
77 76
78typedef struct DES_ks 77typedef struct DES_ks {
79 { 78 union {
80 union 79 DES_cblock cblock;
81 {
82 DES_cblock cblock;
83 /* make sure things are correct size on machines with 80 /* make sure things are correct size on machines with
84 * 8 byte longs */ 81 * 8 byte longs */
85 DES_LONG deslong[2]; 82 DES_LONG deslong[2];
86 } ks[16]; 83 } ks[16];
87 } DES_key_schedule; 84} DES_key_schedule;
88 85
89#define DES_KEY_SZ (sizeof(DES_cblock)) 86#define DES_KEY_SZ (sizeof(DES_cblock))
90#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) 87#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))
@@ -112,26 +109,26 @@ extern int DES_rw_mode; /* defaults to DES_PCBC_MODE */
112 109
113const char *DES_options(void); 110const char *DES_options(void);
114void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, 111void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
115 DES_key_schedule *ks1,DES_key_schedule *ks2, 112 DES_key_schedule *ks1, DES_key_schedule *ks2,
116 DES_key_schedule *ks3, int enc); 113 DES_key_schedule *ks3, int enc);
117DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, 114DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,
118 long length,DES_key_schedule *schedule, 115 long length, DES_key_schedule *schedule,
119 const_DES_cblock *ivec); 116 const_DES_cblock *ivec);
120/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ 117/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */
121void DES_cbc_encrypt(const unsigned char *input,unsigned char *output, 118void DES_cbc_encrypt(const unsigned char *input, unsigned char *output,
122 long length,DES_key_schedule *schedule,DES_cblock *ivec, 119 long length, DES_key_schedule *schedule, DES_cblock *ivec,
123 int enc); 120 int enc);
124void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output, 121void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,
125 long length,DES_key_schedule *schedule,DES_cblock *ivec, 122 long length, DES_key_schedule *schedule, DES_cblock *ivec,
126 int enc); 123 int enc);
127void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output, 124void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,
128 long length,DES_key_schedule *schedule,DES_cblock *ivec, 125 long length, DES_key_schedule *schedule, DES_cblock *ivec,
129 const_DES_cblock *inw,const_DES_cblock *outw,int enc); 126 const_DES_cblock *inw, const_DES_cblock *outw, int enc);
130void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, 127void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
131 long length,DES_key_schedule *schedule,DES_cblock *ivec, 128 long length, DES_key_schedule *schedule, DES_cblock *ivec,
132 int enc); 129 int enc);
133void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output, 130void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
134 DES_key_schedule *ks,int enc); 131 DES_key_schedule *ks, int enc);
135 132
136/* This is the DES encryption function that gets called by just about 133/* This is the DES encryption function that gets called by just about
137 every other DES routine in the library. You should not use this 134 every other DES routine in the library. You should not use this
@@ -142,7 +139,7 @@ void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output,
142 Data is a pointer to 2 unsigned long's and ks is the 139 Data is a pointer to 2 unsigned long's and ks is the
143 DES_key_schedule to use. enc, is non zero specifies encryption, 140 DES_key_schedule to use. enc, is non zero specifies encryption,
144 zero if decryption. */ 141 zero if decryption. */
145void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc); 142void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);
146 143
147/* This functions is the same as DES_encrypt1() except that the DES 144/* This functions is the same as DES_encrypt1() except that the DES
148 initial permutation (IP) and final permutation (FP) have been left 145 initial permutation (IP) and final permutation (FP) have been left
@@ -150,47 +147,47 @@ void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc);
150 It is used by the routines in the library that implement triple DES. 147 It is used by the routines in the library that implement triple DES.
151 IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same 148 IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same
152 as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */ 149 as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */
153void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc); 150void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);
154 151
155void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, 152void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
156 DES_key_schedule *ks2, DES_key_schedule *ks3); 153 DES_key_schedule *ks2, DES_key_schedule *ks3);
157void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, 154void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
158 DES_key_schedule *ks2, DES_key_schedule *ks3); 155 DES_key_schedule *ks2, DES_key_schedule *ks3);
159void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, 156void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
160 long length, 157 long length,
161 DES_key_schedule *ks1,DES_key_schedule *ks2, 158 DES_key_schedule *ks1, DES_key_schedule *ks2,
162 DES_key_schedule *ks3,DES_cblock *ivec,int enc); 159 DES_key_schedule *ks3, DES_cblock *ivec, int enc);
163void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out, 160void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
164 long length, 161 long length,
165 DES_key_schedule *ks1,DES_key_schedule *ks2, 162 DES_key_schedule *ks1, DES_key_schedule *ks2,
166 DES_key_schedule *ks3, 163 DES_key_schedule *ks3,
167 DES_cblock *ivec1,DES_cblock *ivec2, 164 DES_cblock *ivec1, DES_cblock *ivec2,
168 int enc); 165 int enc);
169void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, 166void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
170 long length,DES_key_schedule *ks1, 167 long length, DES_key_schedule *ks1,
171 DES_key_schedule *ks2,DES_key_schedule *ks3, 168 DES_key_schedule *ks2, DES_key_schedule *ks3,
172 DES_cblock *ivec,int *num,int enc); 169 DES_cblock *ivec, int *num, int enc);
173void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, 170void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,
174 int numbits,long length,DES_key_schedule *ks1, 171 int numbits, long length, DES_key_schedule *ks1,
175 DES_key_schedule *ks2,DES_key_schedule *ks3, 172 DES_key_schedule *ks2, DES_key_schedule *ks3,
176 DES_cblock *ivec,int enc); 173 DES_cblock *ivec, int enc);
177void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, 174void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,
178 long length,DES_key_schedule *ks1, 175 long length, DES_key_schedule *ks1,
179 DES_key_schedule *ks2,DES_key_schedule *ks3, 176 DES_key_schedule *ks2, DES_key_schedule *ks3,
180 DES_cblock *ivec,int *num); 177 DES_cblock *ivec, int *num);
181int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, 178int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
182 DES_cblock *iv); 179 DES_cblock *iv);
183int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched, 180int DES_enc_write(int fd, const void *buf, int len, DES_key_schedule *sched,
184 DES_cblock *iv); 181 DES_cblock *iv);
185char *DES_fcrypt(const char *buf,const char *salt, char *ret); 182char *DES_fcrypt(const char *buf, const char *salt, char *ret);
186char *DES_crypt(const char *buf,const char *salt); 183char *DES_crypt(const char *buf, const char *salt);
187void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, 184void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
188 long length,DES_key_schedule *schedule,DES_cblock *ivec); 185 long length, DES_key_schedule *schedule, DES_cblock *ivec);
189void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output, 186void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
190 long length,DES_key_schedule *schedule,DES_cblock *ivec, 187 long length, DES_key_schedule *schedule, DES_cblock *ivec,
191 int enc); 188 int enc);
192DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[], 189DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
193 long length,int out_count,DES_cblock *seed); 190 long length, int out_count, DES_cblock *seed);
194int DES_random_key(DES_cblock *ret); 191int DES_random_key(DES_cblock *ret);
195void DES_set_odd_parity(DES_cblock *key); 192void DES_set_odd_parity(DES_cblock *key);
196int DES_check_key_parity(const_DES_cblock *key); 193int DES_check_key_parity(const_DES_cblock *key);
@@ -198,17 +195,17 @@ int DES_is_weak_key(const_DES_cblock *key);
198/* DES_set_key (= set_key = DES_key_sched = key_sched) calls 195/* DES_set_key (= set_key = DES_key_sched = key_sched) calls
199 * DES_set_key_checked if global variable DES_check_key is set, 196 * DES_set_key_checked if global variable DES_check_key is set,
200 * DES_set_key_unchecked otherwise. */ 197 * DES_set_key_unchecked otherwise. */
201int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule); 198int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);
202int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule); 199int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);
203int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule); 200int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);
204void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule); 201void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);
205void DES_string_to_key(const char *str,DES_cblock *key); 202void DES_string_to_key(const char *str, DES_cblock *key);
206void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2); 203void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);
207void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, 204void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length,
208 DES_key_schedule *schedule,DES_cblock *ivec,int *num, 205 DES_key_schedule *schedule, DES_cblock *ivec, int *num,
209 int enc); 206 int enc);
210void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, 207void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length,
211 DES_key_schedule *schedule,DES_cblock *ivec,int *num); 208 DES_key_schedule *schedule, DES_cblock *ivec, int *num);
212 209
213#define DES_fixup_key_parity DES_set_odd_parity 210#define DES_fixup_key_parity DES_set_odd_parity
214 211