cleanup.
This commit is contained in:
parent
395df2fe30
commit
edb93ae643
@ -32,15 +32,15 @@ LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
|
|||||||
fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
|
fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
|
||||||
qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
|
qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
|
||||||
des_enc.c fcrypt_b.c read2pwd.c \
|
des_enc.c fcrypt_b.c read2pwd.c \
|
||||||
fcrypt.c xcbc_enc.c \
|
xcbc_enc.c \
|
||||||
str2key.c cfb64ede.c ofb64ede.c supp.c ede_cbcm_enc.c
|
str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c
|
||||||
|
|
||||||
LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
|
LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
|
||||||
ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
|
ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
|
||||||
enc_read.o enc_writ.o ofb64enc.o \
|
enc_read.o enc_writ.o ofb64enc.o \
|
||||||
ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
|
ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
|
||||||
${DES_ENC} read2pwd.o \
|
${DES_ENC} read2pwd.o \
|
||||||
fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o \
|
fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o \
|
||||||
ede_cbcm_enc.o
|
ede_cbcm_enc.o
|
||||||
|
|
||||||
SRC= $(LIBSRC)
|
SRC= $(LIBSRC)
|
||||||
|
@ -78,10 +78,7 @@ extern "C" {
|
|||||||
typedef unsigned char des_cblock[8];
|
typedef unsigned char des_cblock[8];
|
||||||
typedef /* const */ unsigned char const_des_cblock[8];
|
typedef /* const */ unsigned char const_des_cblock[8];
|
||||||
/* With "const", gcc 2.8.1 on Solaris thinks that des_cblock *
|
/* With "const", gcc 2.8.1 on Solaris thinks that des_cblock *
|
||||||
* and const_des_cblock * are incompatible pointer types.
|
* and const_des_cblock * are incompatible pointer types. */
|
||||||
* I haven't seen that warning on other systems ... I'll look
|
|
||||||
* what the standard says. */
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct des_ks_struct
|
typedef struct des_ks_struct
|
||||||
{
|
{
|
||||||
@ -141,8 +138,26 @@ void des_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
|
|||||||
int enc);
|
int enc);
|
||||||
void des_ecb_encrypt(const_des_cblock *input,des_cblock *output,
|
void des_ecb_encrypt(const_des_cblock *input,des_cblock *output,
|
||||||
des_key_schedule ks,int enc);
|
des_key_schedule ks,int enc);
|
||||||
|
|
||||||
|
/* This is the DES encryption function that gets called by just about
|
||||||
|
every other DES routine in the library. You should not use this
|
||||||
|
function except to implement 'modes' of DES. I say this because the
|
||||||
|
functions that call this routine do the conversion from 'char *' to
|
||||||
|
long, and this needs to be done to make sure 'non-aligned' memory
|
||||||
|
access do not occur. The characters are loaded 'little endian'.
|
||||||
|
Data is a pointer to 2 unsigned long's and ks is the
|
||||||
|
des_key_schedule to use. enc, is non zero specifies encryption,
|
||||||
|
zero if decryption. */
|
||||||
void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
|
void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
|
||||||
|
|
||||||
|
/* This functions is the same as des_encrypt() except that the DES
|
||||||
|
initial permutation (IP) and final permutation (FP) have been left
|
||||||
|
out. As for des_encrypt(), you should not use this function.
|
||||||
|
It is used by the routines in the library that implement triple DES.
|
||||||
|
IP() des_encrypt2() des_encrypt2() des_encrypt2() FP() is the same
|
||||||
|
as des_encrypt() des_encrypt() des_encrypt() except faster :-). */
|
||||||
void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
|
void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
|
||||||
|
|
||||||
void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
|
void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||||
des_key_schedule ks2, des_key_schedule ks3);
|
des_key_schedule ks2, des_key_schedule ks3);
|
||||||
void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
|
void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
|
||||||
@ -192,6 +207,7 @@ int des_read_2passwords(des_cblock *key1,des_cblock *key2,
|
|||||||
const char *prompt,int verify);
|
const char *prompt,int verify);
|
||||||
int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
|
int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
|
||||||
void des_set_odd_parity(des_cblock *key);
|
void des_set_odd_parity(des_cblock *key);
|
||||||
|
int des_check_key_parity(const_des_cblock *key);
|
||||||
int des_is_weak_key(const_des_cblock *key);
|
int des_is_weak_key(const_des_cblock *key);
|
||||||
/* des_set_key (= set_key = des_key_sched = key_sched) calls
|
/* des_set_key (= set_key = des_key_sched = key_sched) calls
|
||||||
* des_set_key_checked if global variable des_check_key is set,
|
* des_set_key_checked if global variable des_check_key is set,
|
||||||
@ -209,9 +225,6 @@ void des_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
|
|||||||
des_key_schedule schedule,des_cblock *ivec,int *num);
|
des_key_schedule schedule,des_cblock *ivec,int *num);
|
||||||
int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
|
int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
|
||||||
|
|
||||||
/* Extra functions from Mark Murray <mark@grondar.za> */
|
|
||||||
void des_cblock_print_file(const_des_cblock *cb, FILE *fp);
|
|
||||||
|
|
||||||
/* The following definitions provide compatibility with the MIT Kerberos
|
/* The following definitions provide compatibility with the MIT Kerberos
|
||||||
* library. The des_key_schedule structure is not binary compatible. */
|
* library. The des_key_schedule structure is not binary compatible. */
|
||||||
|
|
||||||
@ -241,11 +254,11 @@ void des_cblock_print_file(const_des_cblock *cb, FILE *fp);
|
|||||||
# define xcbc_encrypt des_xcbc_encrypt
|
# define xcbc_encrypt des_xcbc_encrypt
|
||||||
# define cbc_cksum des_cbc_cksum
|
# define cbc_cksum des_cbc_cksum
|
||||||
# define quad_cksum des_quad_cksum
|
# define quad_cksum des_quad_cksum
|
||||||
|
# define check_parity des_check_key_parity
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef des_key_schedule bit_64;
|
typedef des_key_schedule bit_64;
|
||||||
#define des_fixup_key_parity des_set_odd_parity
|
#define des_fixup_key_parity des_set_odd_parity
|
||||||
#define des_check_key_parity check_parity
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
/* This version of crypt has been developed from my MIT compatible
|
/* This version of crypt has been developed from my MIT compatible
|
||||||
* DES library.
|
* DES library.
|
||||||
* The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au
|
|
||||||
* Eric Young (eay@cryptsoft.com)
|
* Eric Young (eay@cryptsoft.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -63,7 +63,11 @@ void des_random_seed(des_cblock *key)
|
|||||||
|
|
||||||
int des_random_key(des_cblock *ret)
|
int des_random_key(des_cblock *ret)
|
||||||
{
|
{
|
||||||
int r = RAND_bytes((unsigned char *)ret, sizeof(des_cblock));
|
do
|
||||||
|
{
|
||||||
|
if (RAND_bytes((unsigned char *)ret, sizeof(des_cblock)) != 1)
|
||||||
|
return (0);
|
||||||
|
} while (des_is_weak_key(ret));
|
||||||
des_set_odd_parity(ret);
|
des_set_odd_parity(ret);
|
||||||
return r;
|
return (1);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,6 @@
|
|||||||
#include "podd.h"
|
#include "podd.h"
|
||||||
#include "sk.h"
|
#include "sk.h"
|
||||||
|
|
||||||
static int check_parity(const_des_cblock *key);
|
|
||||||
OPENSSL_GLOBAL int des_check_key=0;
|
OPENSSL_GLOBAL int des_check_key=0;
|
||||||
|
|
||||||
void des_set_odd_parity(des_cblock *key)
|
void des_set_odd_parity(des_cblock *key)
|
||||||
@ -78,7 +77,7 @@ void des_set_odd_parity(des_cblock *key)
|
|||||||
(*key)[i]=odd_parity[(*key)[i]];
|
(*key)[i]=odd_parity[(*key)[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_parity(const_des_cblock *key)
|
int des_check_key_parity(const_des_cblock *key)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -164,7 +163,7 @@ int des_set_key(const_des_cblock *key, des_key_schedule schedule)
|
|||||||
*/
|
*/
|
||||||
int des_set_key_checked(const_des_cblock *key, des_key_schedule schedule)
|
int des_set_key_checked(const_des_cblock *key, des_key_schedule schedule)
|
||||||
{
|
{
|
||||||
if (!check_parity(key))
|
if (!des_check_key_parity(key))
|
||||||
return(-1);
|
return(-1);
|
||||||
if (des_is_weak_key(key))
|
if (des_is_weak_key(key))
|
||||||
return(-2);
|
return(-2);
|
||||||
@ -245,3 +244,9 @@ int des_key_sched(const_des_cblock *key, des_key_schedule schedule)
|
|||||||
{
|
{
|
||||||
return(des_set_key(key,schedule));
|
return(des_set_key(key,schedule));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef des_fixup_key_parity
|
||||||
|
void des_fixup_key_parity(des_cblock *key)
|
||||||
|
{
|
||||||
|
des_set_odd_parity(key);
|
||||||
|
}
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
/* crypto/des/supp.c */
|
|
||||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This package is an SSL implementation written
|
|
||||||
* by Eric Young (eay@cryptsoft.com).
|
|
||||||
* The implementation was written so as to conform with Netscapes SSL.
|
|
||||||
*
|
|
||||||
* This library is free for commercial and non-commercial use as long as
|
|
||||||
* the following conditions are aheared to. The following conditions
|
|
||||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
|
||||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
|
||||||
* included with this distribution is covered by the same copyright terms
|
|
||||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
|
||||||
*
|
|
||||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
|
||||||
* the code are not to be removed.
|
|
||||||
* If this package is used in a product, Eric Young should be given attribution
|
|
||||||
* as the author of the parts of the library used.
|
|
||||||
* This can be in the form of a textual message at program startup or
|
|
||||||
* in documentation (online or textual) provided with the package.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* "This product includes cryptographic software written by
|
|
||||||
* Eric Young (eay@cryptsoft.com)"
|
|
||||||
* The word 'cryptographic' can be left out if the rouines from the library
|
|
||||||
* being used are not cryptographic related :-).
|
|
||||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
|
||||||
* the apps directory (application code) you must include an acknowledgement:
|
|
||||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* The licence and distribution terms for any publically available version or
|
|
||||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
|
||||||
* copied and put under another distribution licence
|
|
||||||
* [including the GNU Public Licence.]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1995
|
|
||||||
* Mark Murray. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by Mark Murray
|
|
||||||
* 4. Neither the name of the author nor the names of any co-contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY MARK MURRAY AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $Id: supp.c,v 1.5 1999/05/16 12:25:45 bodo Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "des_locl.h"
|
|
||||||
|
|
||||||
void des_cblock_print_file(const_des_cblock *cb, FILE *fp)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
const unsigned int *p = (const unsigned int *)cb;
|
|
||||||
|
|
||||||
fprintf(fp, " 0x { ");
|
|
||||||
for (i = 0; i < 8; i++) {
|
|
||||||
fprintf(fp, "%x", p[i]);
|
|
||||||
if (i != 7) fprintf(fp, ", ");
|
|
||||||
}
|
|
||||||
fprintf(fp, " }");
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user