summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des
diff options
context:
space:
mode:
authormarkus <>2003-05-11 21:36:59 +0000
committermarkus <>2003-05-11 21:36:59 +0000
commit9cea7b85baecb1a02a3ea617de73d9693a9792eb (patch)
treeb0ca83a03e35572831c5818cd2011868d462a5d1 /src/lib/libcrypto/des
parentf8f1d7fabf136ce9810602509c477d2c42bf6d1c (diff)
downloadopenbsd-9cea7b85baecb1a02a3ea617de73d9693a9792eb.tar.gz
openbsd-9cea7b85baecb1a02a3ea617de73d9693a9792eb.tar.bz2
openbsd-9cea7b85baecb1a02a3ea617de73d9693a9792eb.zip
import 0.9.7b (without idea and rc5)
Diffstat (limited to 'src/lib/libcrypto/des')
-rw-r--r--src/lib/libcrypto/des/FILES096
-rw-r--r--src/lib/libcrypto/des/des.c32
-rw-r--r--src/lib/libcrypto/des/des_old.h10
-rw-r--r--src/lib/libcrypto/des/destest.c6
-rw-r--r--src/lib/libcrypto/des/read2pwd.c8
-rw-r--r--src/lib/libcrypto/des/read_pwd.c44
6 files changed, 154 insertions, 42 deletions
diff --git a/src/lib/libcrypto/des/FILES0 b/src/lib/libcrypto/des/FILES0
new file mode 100644
index 0000000000..4c7ea2de7a
--- /dev/null
+++ b/src/lib/libcrypto/des/FILES0
@@ -0,0 +1,96 @@
1/* General stuff */
2COPYRIGHT - Copyright info.
3MODES.DES - A description of the features of the different modes of DES.
4FILES - This file.
5INSTALL - How to make things compile.
6Imakefile - For use with kerberos.
7README - What this package is.
8VERSION - Which version this is and what was changed.
9KERBEROS - Kerberos version 4 notes.
10Makefile.PL - An old makefile to build with perl5, not current.
11Makefile.ssl - The SSLeay makefile
12Makefile.uni - The normal unix makefile.
13GNUmakefile - The makefile for use with glibc.
14makefile.bc - A Borland C makefile
15times - Some outputs from 'speed' on some machines.
16vms.com - For use when compiling under VMS
17
18/* My SunOS des(1) replacement */
19des.c - des(1) source code.
20des.man - des(1) manual.
21
22/* Testing and timing programs. */
23destest.c - Source for libdes.a test program.
24speed.c - Source for libdes.a timing program.
25rpw.c - Source for libdes.a testing password reading routines.
26
27/* libdes.a source code */
28des_crypt.man - libdes.a manual page.
29des.h - Public libdes.a header file.
30ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code.
31ecb3_enc.c - des_ecb3_encrypt() source.
32cbc_ckm.c - des_cbc_cksum() source.
33cbc_enc.c - des_cbc_encrypt() source.
34ncbc_enc.c - des_cbc_encrypt() that is 'normal' in that it copies
35 the new iv values back in the passed iv vector.
36ede_enc.c - des_ede3_cbc_encrypt() cbc mode des using triple DES.
37cbc3_enc.c - des_3cbc_encrypt() source, don't use this function.
38cfb_enc.c - des_cfb_encrypt() source.
39cfb64enc.c - des_cfb64_encrypt() cfb in 64 bit mode but setup to be
40 used as a stream cipher.
41cfb64ede.c - des_ede3_cfb64_encrypt() cfb in 64 bit mode but setup to be
42 used as a stream cipher and using triple DES.
43ofb_enc.c - des_cfb_encrypt() source.
44ofb64_enc.c - des_ofb_encrypt() ofb in 64 bit mode but setup to be
45 used as a stream cipher.
46ofb64ede.c - des_ede3_ofb64_encrypt() ofb in 64 bit mode but setup to be
47 used as a stream cipher and using triple DES.
48enc_read.c - des_enc_read() source.
49enc_writ.c - des_enc_write() source.
50pcbc_enc.c - des_pcbc_encrypt() source.
51qud_cksm.c - quad_cksum() source.
52rand_key.c - des_random_key() source.
53read_pwd.c - Source for des_read_password() plus related functions.
54set_key.c - Source for des_set_key().
55str2key.c - Covert a string of any length into a key.
56fcrypt.c - A small, fast version of crypt(3).
57des_locl.h - Internal libdes.a header file.
58podd.h - Odd parity tables - used in des_set_key().
59sk.h - Lookup tables used in des_set_key().
60spr.h - What is left of the S tables - used in ecb_encrypt().
61des_ver.h - header file for the external definition of the
62 version string.
63des.doc - SSLeay documentation for the library.
64
65/* The perl scripts - you can ignore these files they are only
66 * included for the curious */
67des.pl - des in perl anyone? des_set_key and des_ecb_encrypt
68 both done in a perl library.
69testdes.pl - Testing program for des.pl
70doIP - Perl script used to develop IP xor/shift code.
71doPC1 - Perl script used to develop PC1 xor/shift code.
72doPC2 - Generates sk.h.
73PC1 - Output of doPC1 should be the same as output from PC1.
74PC2 - used in development of doPC2.
75shifts.pl - Perl library used by my perl scripts.
76
77/* I started making a perl5 dynamic library for libdes
78 * but did not fully finish, these files are part of that effort. */
79DES.pm
80DES.pod
81DES.xs
82t
83typemap
84
85/* The following are for use with sun RPC implementaions. */
86rpc_des.h
87rpc_enc.c
88
89/* The following are contibuted by Mark Murray <mark@grondar.za>. They
90 * are not normally built into libdes due to machine specific routines
91 * contained in them. They are for use in the most recent incarnation of
92 * export kerberos v 4 (eBones). */
93supp.c
94new_rkey.c
95
96
diff --git a/src/lib/libcrypto/des/des.c b/src/lib/libcrypto/des/des.c
index d8c846b23d..343135ff9e 100644
--- a/src/lib/libcrypto/des/des.c
+++ b/src/lib/libcrypto/des/des.c
@@ -427,7 +427,7 @@ void doencryption(void)
427 k2[i-8]=k; 427 k2[i-8]=k;
428 } 428 }
429 DES_set_key_unchecked(&k2,&ks2); 429 DES_set_key_unchecked(&k2,&ks2);
430 memset(k2,0,sizeof(k2)); 430 OPENSSL_cleanse(k2,sizeof(k2));
431 } 431 }
432 else if (longk || flag3) 432 else if (longk || flag3)
433 { 433 {
@@ -435,7 +435,7 @@ void doencryption(void)
435 { 435 {
436 DES_string_to_2keys(key,&kk,&k2); 436 DES_string_to_2keys(key,&kk,&k2);
437 DES_set_key_unchecked(&k2,&ks2); 437 DES_set_key_unchecked(&k2,&ks2);
438 memset(k2,0,sizeof(k2)); 438 OPENSSL_cleanse(k2,sizeof(k2));
439 } 439 }
440 else 440 else
441 DES_string_to_key(key,&kk); 441 DES_string_to_key(key,&kk);
@@ -457,8 +457,8 @@ void doencryption(void)
457 } 457 }
458 458
459 DES_set_key_unchecked(&kk,&ks); 459 DES_set_key_unchecked(&kk,&ks);
460 memset(key,0,sizeof(key)); 460 OPENSSL_cleanse(key,sizeof(key));
461 memset(kk,0,sizeof(kk)); 461 OPENSSL_cleanse(kk,sizeof(kk));
462 /* woops - A bug that does not showup under unix :-( */ 462 /* woops - A bug that does not showup under unix :-( */
463 memset(iv,0,sizeof(iv)); 463 memset(iv,0,sizeof(iv));
464 memset(iv2,0,sizeof(iv2)); 464 memset(iv2,0,sizeof(iv2));
@@ -666,18 +666,18 @@ void doencryption(void)
666 if (l) fclose(CKSUM_OUT); 666 if (l) fclose(CKSUM_OUT);
667 } 667 }
668problems: 668problems:
669 memset(buf,0,sizeof(buf)); 669 OPENSSL_cleanse(buf,sizeof(buf));
670 memset(obuf,0,sizeof(obuf)); 670 OPENSSL_cleanse(obuf,sizeof(obuf));
671 memset(&ks,0,sizeof(ks)); 671 OPENSSL_cleanse(&ks,sizeof(ks));
672 memset(&ks2,0,sizeof(ks2)); 672 OPENSSL_cleanse(&ks2,sizeof(ks2));
673 memset(iv,0,sizeof(iv)); 673 OPENSSL_cleanse(iv,sizeof(iv));
674 memset(iv2,0,sizeof(iv2)); 674 OPENSSL_cleanse(iv2,sizeof(iv2));
675 memset(kk,0,sizeof(kk)); 675 OPENSSL_cleanse(kk,sizeof(kk));
676 memset(k2,0,sizeof(k2)); 676 OPENSSL_cleanse(k2,sizeof(k2));
677 memset(uubuf,0,sizeof(uubuf)); 677 OPENSSL_cleanse(uubuf,sizeof(uubuf));
678 memset(b,0,sizeof(b)); 678 OPENSSL_cleanse(b,sizeof(b));
679 memset(bb,0,sizeof(bb)); 679 OPENSSL_cleanse(bb,sizeof(bb));
680 memset(cksum,0,sizeof(cksum)); 680 OPENSSL_cleanse(cksum,sizeof(cksum));
681 if (Exit) EXIT(Exit); 681 if (Exit) EXIT(Exit);
682 } 682 }
683 683
diff --git a/src/lib/libcrypto/des/des_old.h b/src/lib/libcrypto/des/des_old.h
index 51b987422a..1d840b474a 100644
--- a/src/lib/libcrypto/des/des_old.h
+++ b/src/lib/libcrypto/des/des_old.h
@@ -88,14 +88,14 @@
88 * 88 *
89 */ 89 */
90 90
91#ifndef HEADER_DES_OLD_H 91#ifndef HEADER_DES_H
92#define HEADER_DES_OLD_H 92#define HEADER_DES_H
93 93
94#ifdef OPENSSL_NO_DES 94#ifdef OPENSSL_NO_DES
95#error DES is disabled. 95#error DES is disabled.
96#endif 96#endif
97 97
98#ifndef HEADER_DES_H 98#ifndef HEADER_NEW_DES_H
99#error You must include des.h, not des_old.h directly. 99#error You must include des.h, not des_old.h directly.
100#endif 100#endif
101 101
@@ -173,10 +173,12 @@ typedef struct _ossl_old_des_ks_struct
173 DES_fcrypt((b),(s),(r)) 173 DES_fcrypt((b),(s),(r))
174#define des_crypt(b,s)\ 174#define des_crypt(b,s)\
175 DES_crypt((b),(s)) 175 DES_crypt((b),(s))
176#if 0
176#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) 177#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
177#define crypt(b,s)\ 178#define crypt(b,s)\
178 DES_crypt((b),(s)) 179 DES_crypt((b),(s))
179#endif 180#endif
181#endif
180#define des_ofb_encrypt(i,o,n,l,k,iv)\ 182#define des_ofb_encrypt(i,o,n,l,k,iv)\
181 DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv)) 183 DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))
182#define des_pcbc_encrypt(i,o,l,k,iv,e)\ 184#define des_pcbc_encrypt(i,o,l,k,iv,e)\
@@ -274,8 +276,10 @@ typedef struct _ossl_old_des_ks_struct
274 _ossl_old_des_fcrypt((b),(s),(r)) 276 _ossl_old_des_fcrypt((b),(s),(r))
275#define des_crypt(b,s)\ 277#define des_crypt(b,s)\
276 _ossl_old_des_crypt((b),(s)) 278 _ossl_old_des_crypt((b),(s))
279#if 0
277#define crypt(b,s)\ 280#define crypt(b,s)\
278 _ossl_old_crypt((b),(s)) 281 _ossl_old_crypt((b),(s))
282#endif
279#define des_ofb_encrypt(i,o,n,l,k,iv)\ 283#define des_ofb_encrypt(i,o,n,l,k,iv)\
280 _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv)) 284 _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))
281#define des_pcbc_encrypt(i,o,l,k,iv,e)\ 285#define des_pcbc_encrypt(i,o,l,k,iv,e)\
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c
index 58e8c35dcb..687c00c792 100644
--- a/src/lib/libcrypto/des/destest.c
+++ b/src/lib/libcrypto/des/destest.c
@@ -84,9 +84,7 @@ int main(int argc, char *argv[])
84#else 84#else
85#include <openssl/des.h> 85#include <openssl/des.h>
86 86
87#if defined(PERL5) || defined(__FreeBSD__) || defined(NeXT)
88#define crypt(c,s) (des_crypt((c),(s))) 87#define crypt(c,s) (des_crypt((c),(s)))
89#endif
90 88
91/* tisk tisk - the test keys don't all have odd parity :-( */ 89/* tisk tisk - the test keys don't all have odd parity :-( */
92/* test data */ 90/* test data */
@@ -322,7 +320,11 @@ static unsigned char ofb_cipher[24]=
322 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3 320 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3
323 }; 321 };
324 322
323#if 0
325static DES_LONG cbc_cksum_ret=0xB462FEF7L; 324static DES_LONG cbc_cksum_ret=0xB462FEF7L;
325#else
326static DES_LONG cbc_cksum_ret=0xF7FE62B4L;
327#endif
326static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4}; 328static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
327 329
328static char *pt(unsigned char *p); 330static char *pt(unsigned char *p);
diff --git a/src/lib/libcrypto/des/read2pwd.c b/src/lib/libcrypto/des/read2pwd.c
index b4720c3a98..3a63c4016c 100644
--- a/src/lib/libcrypto/des/read2pwd.c
+++ b/src/lib/libcrypto/des/read2pwd.c
@@ -120,8 +120,8 @@ int DES_read_password(DES_cblock *key, const char *prompt, int verify)
120 120
121 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) 121 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
122 DES_string_to_key(buf,key); 122 DES_string_to_key(buf,key);
123 memset(buf,0,BUFSIZ); 123 OPENSSL_cleanse(buf,BUFSIZ);
124 memset(buff,0,BUFSIZ); 124 OPENSSL_cleanse(buff,BUFSIZ);
125 return(ok); 125 return(ok);
126 } 126 }
127 127
@@ -133,7 +133,7 @@ int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt,
133 133
134 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) 134 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
135 DES_string_to_2keys(buf,key1,key2); 135 DES_string_to_2keys(buf,key1,key2);
136 memset(buf,0,BUFSIZ); 136 OPENSSL_cleanse(buf,BUFSIZ);
137 memset(buff,0,BUFSIZ); 137 OPENSSL_cleanse(buff,BUFSIZ);
138 return(ok); 138 return(ok);
139 } 139 }
diff --git a/src/lib/libcrypto/des/read_pwd.c b/src/lib/libcrypto/des/read_pwd.c
index 9061935f21..ce5fa00a37 100644
--- a/src/lib/libcrypto/des/read_pwd.c
+++ b/src/lib/libcrypto/des/read_pwd.c
@@ -101,8 +101,10 @@
101 101
102#ifdef WIN_CONSOLE_BUG 102#ifdef WIN_CONSOLE_BUG
103#include <windows.h> 103#include <windows.h>
104#ifndef OPENSSL_SYS_WINCE
104#include <wincon.h> 105#include <wincon.h>
105#endif 106#endif
107#endif
106 108
107 109
108/* There are 5 types of terminal interface supported, 110/* There are 5 types of terminal interface supported,
@@ -133,7 +135,7 @@
133#define SGTTY 135#define SGTTY
134#endif 136#endif
135 137
136#if defined(OPENSSL_SYS_VSWORKS) 138#if defined(OPENSSL_SYS_VXWORKS)
137#undef TERMIOS 139#undef TERMIOS
138#undef TERMIO 140#undef TERMIO
139#undef SGTTY 141#undef SGTTY
@@ -167,7 +169,7 @@
167#include <sys/ioctl.h> 169#include <sys/ioctl.h>
168#endif 170#endif
169 171
170#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) 172#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) && !defined(OPENSSL_SYS_WINCE)
171#include <conio.h> 173#include <conio.h>
172#define fgets(a,b,c) noecho_fgets(a,b,c) 174#define fgets(a,b,c) noecho_fgets(a,b,c)
173#endif 175#endif
@@ -218,11 +220,29 @@ int des_read_pw_string(char *buf, int length, const char *prompt,
218 int ret; 220 int ret;
219 221
220 ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify); 222 ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
221 memset(buff,0,BUFSIZ); 223 OPENSSL_cleanse(buff,BUFSIZ);
222 return(ret); 224 return(ret);
223 } 225 }
224 226
225#ifndef OPENSSL_SYS_WIN16 227#ifdef OPENSSL_SYS_WINCE
228
229int des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
230 {
231 memset(buf,0,size);
232 memset(buff,0,size);
233 return(0);
234 }
235
236#elif defined(OPENSSL_SYS_WIN16)
237
238int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
239 {
240 memset(buf,0,size);
241 memset(buff,0,size);
242 return(0);
243 }
244
245#else /* !OPENSSL_SYS_WINCE && !OPENSSL_SYS_WIN16 */
226 246
227static void read_till_nl(FILE *in) 247static void read_till_nl(FILE *in)
228 { 248 {
@@ -274,7 +294,7 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
274#ifdef OPENSSL_SYS_MSDOS 294#ifdef OPENSSL_SYS_MSDOS
275 if ((tty=fopen("con","r")) == NULL) 295 if ((tty=fopen("con","r")) == NULL)
276 tty=stdin; 296 tty=stdin;
277#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VSWORKS) 297#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VXWORKS)
278 tty=stdin; 298 tty=stdin;
279#else 299#else
280#ifndef OPENSSL_SYS_MPE 300#ifndef OPENSSL_SYS_MPE
@@ -393,17 +413,6 @@ error:
393 return(!ok); 413 return(!ok);
394 } 414 }
395 415
396#else /* OPENSSL_SYS_WIN16 */
397
398int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
399 {
400 memset(buf,0,size);
401 memset(buff,0,size);
402 return(0);
403 }
404
405#endif
406
407static void pushsig(void) 416static void pushsig(void)
408 { 417 {
409 int i; 418 int i;
@@ -466,7 +475,7 @@ static void recsig(int i)
466#endif 475#endif
467 } 476 }
468 477
469#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) 478#ifdef OPENSSL_SYS_MSDOS
470static int noecho_fgets(char *buf, int size, FILE *tty) 479static int noecho_fgets(char *buf, int size, FILE *tty)
471 { 480 {
472 int i; 481 int i;
@@ -509,3 +518,4 @@ static int noecho_fgets(char *buf, int size, FILE *tty)
509 return(strlen(buf)); 518 return(strlen(buf));
510 } 519 }
511#endif 520#endif
521#endif /* !OPENSSL_SYS_WINCE && !WIN16 */