OpenSSL 1.1.1-pre2
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
# The inner loop instruction sequence and the IP/FP modifications are from
|
||||
# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
|
||||
# Svend Olaf Mikkelsen
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
@@ -16,7 +16,7 @@ require "x86asm.pl";
|
||||
$output=pop;
|
||||
open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],"crypt586.pl");
|
||||
&asm_init($ARGV[0]);
|
||||
|
||||
$L="edi";
|
||||
$R="esi";
|
||||
@@ -111,7 +111,7 @@ sub D_ENCRYPT
|
||||
&and( $u, "0xfcfcfcfc" ); # 2
|
||||
&xor( $tmp1, $tmp1); # 1
|
||||
&and( $t, "0xcfcfcfcf" ); # 2
|
||||
&xor( $tmp2, $tmp2);
|
||||
&xor( $tmp2, $tmp2);
|
||||
&movb( &LB($tmp1), &LB($u) );
|
||||
&movb( &LB($tmp2), &HB($u) );
|
||||
&rotr( $t, 4 );
|
||||
@@ -175,7 +175,7 @@ sub IP_new
|
||||
&R_PERM_OP($l,$tt,$r,14,"0x33333333",$r);
|
||||
&R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r);
|
||||
|
||||
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
# The inner loop instruction sequence and the IP/FP modifications are from
|
||||
# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
|
||||
# Svend Olaf Mikkelsen.
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
@@ -15,7 +15,7 @@ require "x86asm.pl";
|
||||
require "cbc.pl";
|
||||
require "desboth.pl";
|
||||
|
||||
# base code is in microsft
|
||||
# base code is in Microsoft
|
||||
# op dest, source
|
||||
# format.
|
||||
#
|
||||
@@ -23,7 +23,7 @@ require "desboth.pl";
|
||||
$output=pop;
|
||||
open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],"des-586.pl");
|
||||
&asm_init($ARGV[0]);
|
||||
|
||||
$L="edi";
|
||||
$R="esi";
|
||||
@@ -85,7 +85,7 @@ sub DES_encrypt_internal()
|
||||
|
||||
&function_end_B("_x86_DES_encrypt");
|
||||
}
|
||||
|
||||
|
||||
sub DES_decrypt_internal()
|
||||
{
|
||||
&function_begin_B("_x86_DES_decrypt");
|
||||
@@ -122,7 +122,7 @@ sub DES_decrypt_internal()
|
||||
|
||||
&function_end_B("_x86_DES_decrypt");
|
||||
}
|
||||
|
||||
|
||||
sub DES_encrypt
|
||||
{
|
||||
local($name,$do_ip)=@_;
|
||||
@@ -283,7 +283,7 @@ sub IP_new
|
||||
&R_PERM_OP($l,$tt,$r,14,"0x33333333",$r);
|
||||
&R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r);
|
||||
&R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r);
|
||||
|
||||
|
||||
if ($lr != 3)
|
||||
{
|
||||
if (($lr-3) < 0)
|
||||
|
||||
+11
-15
@@ -1,4 +1,4 @@
|
||||
! Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
! Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
!
|
||||
! Licensed under the OpenSSL license (the "License"). You may not use
|
||||
! this file except in compliance with the License. You can obtain a copy
|
||||
@@ -31,10 +31,6 @@
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#ifdef OPENSSL_FIPSCANISTER
|
||||
#include <openssl/fipssyms.h>
|
||||
#endif
|
||||
|
||||
#if defined(__SUNPRO_C) && defined(__sparcv9)
|
||||
# define ABI64 /* They've said -xarch=v9 at command line */
|
||||
#elif defined(__GNUC__) && defined(__arch64__)
|
||||
@@ -116,7 +112,7 @@ changequote({,})
|
||||
!
|
||||
! Loads key first round from address in parameter 5 to out0, out1.
|
||||
!
|
||||
! After the the original LibDES initial permutation, the resulting left
|
||||
! After the original LibDES initial permutation, the resulting left
|
||||
! is in the variable initially used for right and vice versa. The macro
|
||||
! implements the possibility to keep the halfs in the original registers.
|
||||
!
|
||||
@@ -532,8 +528,8 @@ $4:
|
||||
! parameter 3 1 for optional store to [in0]
|
||||
! parameter 4 1 for load input/output address to local5/7
|
||||
!
|
||||
! The final permutation logic switches the halfes, meaning that
|
||||
! left and right ends up the the registers originally used.
|
||||
! The final permutation logic switches the halves, meaning that
|
||||
! left and right ends up the registers originally used.
|
||||
|
||||
define(fp_macro, {
|
||||
|
||||
@@ -735,7 +731,7 @@ define(fp_ip_macro, {
|
||||
sll $4, 3, local2
|
||||
xor local4, temp2, $2
|
||||
|
||||
! reload since used as temporar:
|
||||
! reload since used as temporary:
|
||||
|
||||
ld [out2+280], out4 ! loop counter
|
||||
|
||||
@@ -757,7 +753,7 @@ define(fp_ip_macro, {
|
||||
! parameter 1 address
|
||||
! parameter 2 destination left
|
||||
! parameter 3 destination right
|
||||
! parameter 4 temporar
|
||||
! parameter 4 temporary
|
||||
! parameter 5 label
|
||||
|
||||
define(load_little_endian, {
|
||||
@@ -806,7 +802,7 @@ $5a:
|
||||
! parameter 1 address
|
||||
! parameter 2 destination left
|
||||
! parameter 3 destination right
|
||||
! parameter 4 temporar
|
||||
! parameter 4 temporary
|
||||
! parameter 4 label
|
||||
!
|
||||
! adds 8 to address
|
||||
@@ -931,7 +927,7 @@ $7.jmp.table:
|
||||
! parameter 1 address
|
||||
! parameter 2 source left
|
||||
! parameter 3 source right
|
||||
! parameter 4 temporar
|
||||
! parameter 4 temporary
|
||||
|
||||
define(store_little_endian, {
|
||||
|
||||
@@ -1521,7 +1517,7 @@ DES_ncbc_encrypt:
|
||||
! parameter 7 1 for mov in1 to in3
|
||||
! parameter 8 1 for mov in3 to in4
|
||||
|
||||
ip_macro(in5, out5, out5, in5, in4, 2, 0, 1) ! include decryprion ks in4
|
||||
ip_macro(in5, out5, out5, in5, in4, 2, 0, 1) ! include decryption ks in4
|
||||
|
||||
fp_macro(out5, in5, 0, 1) ! 1 for input and output address to local5/7
|
||||
|
||||
@@ -1567,7 +1563,7 @@ DES_ncbc_encrypt:
|
||||
.size DES_ncbc_encrypt, .DES_ncbc_encrypt.end-DES_ncbc_encrypt
|
||||
|
||||
|
||||
! void DES_ede3_cbc_encrypt(input, output, lenght, ks1, ks2, ks3, ivec, enc)
|
||||
! void DES_ede3_cbc_encrypt(input, output, length, ks1, ks2, ks3, ivec, enc)
|
||||
! **************************************************************************
|
||||
|
||||
|
||||
@@ -1815,7 +1811,7 @@ DES_ede3_cbc_encrypt:
|
||||
.byte 240, 240, 240, 240, 244, 244, 244, 244
|
||||
.byte 248, 248, 248, 248, 252, 252, 252, 252
|
||||
|
||||
! 5 numbers for initil/final permutation
|
||||
! 5 numbers for initial/final permutation
|
||||
|
||||
.word 0x0f0f0f0f ! offset 256
|
||||
.word 0x0000ffff ! 260
|
||||
|
||||
@@ -34,7 +34,7 @@ sub DES_encrypt3
|
||||
&IP_new($L,$R,"edx",0);
|
||||
|
||||
# put them back
|
||||
|
||||
|
||||
if ($enc)
|
||||
{
|
||||
&mov(&DWP(4,"ebx","",0),$R);
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
|
||||
# ====================================================================
|
||||
# Written by David S. Miller <davem@devemloft.net> and Andy Polyakov
|
||||
# <appro@openssl.org>. The module is licensed under 2-clause BSD
|
||||
# Written by David S. Miller and Andy Polyakov.
|
||||
# The module is licensed under 2-clause BSD
|
||||
# license. March 2013. All rights reserved.
|
||||
# ====================================================================
|
||||
|
||||
|
||||
@@ -5,13 +5,15 @@ SOURCE[../../libcrypto]=\
|
||||
ofb64ede.c ofb64enc.c ofb_enc.c \
|
||||
str2key.c pcbc_enc.c qud_cksm.c rand_key.c \
|
||||
{- $target{des_asm_src} -} \
|
||||
fcrypt.c xcbc_enc.c rpc_enc.c cbc_cksm.c
|
||||
fcrypt.c xcbc_enc.c cbc_cksm.c
|
||||
|
||||
GENERATE[des_enc-sparc.S]=asm/des_enc.m4
|
||||
GENERATE[dest4-sparcv9.S]=asm/dest4-sparcv9.pl $(PERLASM_SCHEME)
|
||||
INCLUDE[dest4-sparcv9.o]=..
|
||||
|
||||
GENERATE[des-586.s]=asm/des-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(LIB_CFLAGS)
|
||||
GENERATE[des-586.s]=asm/des-586.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS)
|
||||
DEPEND[des-586.s]=../perlasm/x86asm.pl ../perlasm/cbc.pl
|
||||
GENERATE[crypt586.s]=asm/crypt586.pl $(PERLASM_SCHEME) $(CFLAGS) $(LIB_CFLAGS)
|
||||
GENERATE[crypt586.s]=asm/crypt586.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS)
|
||||
DEPEND[crypt586.s]=../perlasm/x86asm.pl ../perlasm/cbc.pl
|
||||
@@ -33,7 +33,6 @@ DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output,
|
||||
tin1 ^= tout1;
|
||||
tin[1] = tin1;
|
||||
DES_encrypt1((DES_LONG *)tin, schedule, DES_ENCRYPT);
|
||||
/* fix 15/10/91 eay - thanks to keithr@sco.COM */
|
||||
tout0 = tin[0];
|
||||
tout1 = tin[1];
|
||||
}
|
||||
@@ -50,5 +49,5 @@ DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output,
|
||||
| ((tout1 >> 8L) & 0x0000FF00)
|
||||
| ((tout1 << 8L) & 0x00FF0000)
|
||||
| ((tout1 << 24L) & 0xFF000000);
|
||||
return (tout1);
|
||||
return tout1;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "des_locl.h"
|
||||
#include "e_os.h"
|
||||
|
||||
/*
|
||||
* The input and output encrypted as though 64bit cfb mode is being used.
|
||||
|
||||
@@ -37,7 +37,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
|
||||
unsigned int sh[4];
|
||||
unsigned char *ovec = (unsigned char *)sh;
|
||||
|
||||
/* I kind of count that compiler optimizes away this assertioni, */
|
||||
/* I kind of count that compiler optimizes away this assertion, */
|
||||
assert(sizeof(sh[0]) == 4); /* as this holds true for all, */
|
||||
/* but 16-bit platforms... */
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
|
||||
* Things have been modified so that the initial rotate is done outside
|
||||
* the loop. This required the DES_SPtrans values in sp.h to be rotated
|
||||
* 1 bit to the right. One perl script later and things have a 5% speed
|
||||
* up on a sparc2. Thanks to Richard Outerbridge
|
||||
* <71755.204@CompuServe.COM> for pointing this out.
|
||||
* up on a sparc2. Thanks to Richard Outerbridge for pointing this out.
|
||||
*/
|
||||
/* clear the top bits on machines with 8byte longs */
|
||||
/* shift left by 2 */
|
||||
@@ -95,8 +94,7 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
|
||||
* Things have been modified so that the initial rotate is done outside
|
||||
* the loop. This required the DES_SPtrans values in sp.h to be rotated
|
||||
* 1 bit to the right. One perl script later and things have a 5% speed
|
||||
* up on a sparc2. Thanks to Richard Outerbridge
|
||||
* <71755.204@CompuServe.COM> for pointing this out.
|
||||
* up on a sparc2. Thanks to Richard Outerbridge for pointing this out.
|
||||
*/
|
||||
/* clear the top bits on machines with 8byte longs */
|
||||
r = ROTATE(r, 29) & 0xffffffffL;
|
||||
|
||||
@@ -26,10 +26,6 @@
|
||||
# define ITERATIONS 16
|
||||
# define HALF_ITERATIONS 8
|
||||
|
||||
/* used in des_read and des_write */
|
||||
# define MAXWRITE (1024*16)
|
||||
# define BSIZE (MAXWRITE+4)
|
||||
|
||||
# define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
|
||||
l|=((DES_LONG)(*((c)++)))<< 8L, \
|
||||
l|=((DES_LONG)(*((c)++)))<<16L, \
|
||||
@@ -67,7 +63,6 @@
|
||||
* replacements for htonl and ntohl since I have no idea what to do when
|
||||
* faced with machines with 8 byte longs.
|
||||
*/
|
||||
# define HDRSIZE 4
|
||||
|
||||
# define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \
|
||||
l|=((DES_LONG)(*((c)++)))<<16L, \
|
||||
@@ -101,7 +96,7 @@
|
||||
} \
|
||||
}
|
||||
|
||||
# if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER))
|
||||
# if defined(_MSC_VER)
|
||||
# define ROTATE(a,n) (_lrotr(a,n))
|
||||
# elif defined(__ICC)
|
||||
# define ROTATE(a,n) (_rotr(a,n))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -15,19 +15,16 @@
|
||||
const char *DES_options(void)
|
||||
{
|
||||
static int init = 1;
|
||||
static char buf[32];
|
||||
static char buf[12];
|
||||
|
||||
if (init) {
|
||||
const char *size;
|
||||
|
||||
if (sizeof(DES_LONG) != sizeof(long))
|
||||
size = "int";
|
||||
OPENSSL_strlcpy(buf, "des(int)", sizeof(buf));
|
||||
else
|
||||
size = "long";
|
||||
BIO_snprintf(buf, sizeof(buf), "des(%s)", size);
|
||||
OPENSSL_strlcpy(buf, "des(long)", sizeof(buf));
|
||||
init = 0;
|
||||
}
|
||||
return (buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* Added more values to handle illegal salt values the way normal crypt()
|
||||
* implementations do. The patch was sent by Bjorn Gronvall <bg@sics.se>
|
||||
* implementations do.
|
||||
*/
|
||||
static unsigned const char con_salt[128] = {
|
||||
0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9,
|
||||
@@ -60,7 +60,7 @@ char *DES_crypt(const char *buf, const char *salt)
|
||||
static char buff[14];
|
||||
|
||||
#ifndef CHARSET_EBCDIC
|
||||
return (DES_fcrypt(buf, salt, buff));
|
||||
return DES_fcrypt(buf, salt, buff);
|
||||
#else
|
||||
char e_salt[2 + 1];
|
||||
char e_buf[32 + 1]; /* replace 32 by 8 ? */
|
||||
@@ -145,5 +145,5 @@ char *DES_fcrypt(const char *buf, const char *salt, char *ret)
|
||||
ret[i] = cov_2char[c];
|
||||
}
|
||||
ret[13] = '\0';
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
#include "des_locl.h"
|
||||
|
||||
/* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */
|
||||
#define Q_B0(a) (((DES_LONG)(a)))
|
||||
#define Q_B1(a) (((DES_LONG)(a))<<8)
|
||||
#define Q_B2(a) (((DES_LONG)(a))<<16)
|
||||
@@ -73,5 +72,5 @@ DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
|
||||
*lp++ = z1;
|
||||
}
|
||||
}
|
||||
return (z0);
|
||||
return z0;
|
||||
}
|
||||
@@ -14,8 +14,8 @@ int DES_random_key(DES_cblock *ret)
|
||||
{
|
||||
do {
|
||||
if (RAND_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1)
|
||||
return (0);
|
||||
return 0;
|
||||
} while (DES_is_weak_key(ret));
|
||||
DES_set_odd_parity(ret);
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */
|
||||
/*-
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
* unrestricted use provided that this legend is included on all tape
|
||||
* media and as a part of the software program in whole or part. Users
|
||||
* may copy or modify Sun RPC without charge, but are not authorized
|
||||
* to license or distribute it to anyone else except as part of a product or
|
||||
* program developed by the user.
|
||||
*
|
||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
||||
*
|
||||
* Sun RPC is provided with no support and without any obligation on the
|
||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||
* modification or enhancement.
|
||||
*
|
||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||
* OR ANY PART THEREOF.
|
||||
*
|
||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||
* or profits or other special, indirect and consequential damages, even if
|
||||
* Sun has been advised of the possibility of such damages.
|
||||
*
|
||||
* Sun Microsystems, Inc.
|
||||
* 2550 Garcia Avenue
|
||||
* Mountain View, California 94043
|
||||
*/
|
||||
/*
|
||||
* Generic DES driver interface
|
||||
* Keep this file hardware independent!
|
||||
* Copyright (c) 1986 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */
|
||||
#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */
|
||||
|
||||
enum desdir { ENCRYPT, DECRYPT };
|
||||
enum desmode { CBC, ECB };
|
||||
|
||||
/*
|
||||
* parameters to ioctl call
|
||||
*/
|
||||
struct desparams {
|
||||
unsigned char des_key[8]; /* key (with low bit parity) */
|
||||
enum desdir des_dir; /* direction */
|
||||
enum desmode des_mode; /* mode */
|
||||
unsigned char des_ivec[8]; /* input vector */
|
||||
unsigned des_len; /* number of bytes to crypt */
|
||||
union {
|
||||
unsigned char UDES_data[DES_QUICKLEN];
|
||||
unsigned char *UDES_buf;
|
||||
} UDES;
|
||||
#define des_data UDES.UDES_data /* direct data here if quick */
|
||||
#define des_buf UDES.UDES_buf /* otherwise, pointer to data */
|
||||
};
|
||||
|
||||
/*
|
||||
* Encrypt an arbitrary sized buffer
|
||||
*/
|
||||
#define DESIOCBLOCK _IOWR('d', 6, struct desparams)
|
||||
|
||||
/*
|
||||
* Encrypt of small amount of data, quickly
|
||||
*/
|
||||
#define DESIOCQUICK _IOWR('d', 7, struct desparams)
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "rpc_des.h"
|
||||
#include "des_locl.h"
|
||||
|
||||
int _des_crypt(char *buf, int len, struct desparams *desp);
|
||||
int _des_crypt(char *buf, int len, struct desparams *desp)
|
||||
{
|
||||
DES_key_schedule ks;
|
||||
int enc;
|
||||
|
||||
DES_set_key_unchecked(&desp->des_key, &ks);
|
||||
enc = (desp->des_dir == ENCRYPT) ? DES_ENCRYPT : DES_DECRYPT;
|
||||
|
||||
if (desp->des_mode == CBC)
|
||||
DES_ecb_encrypt((const_DES_cblock *)desp->UDES.UDES_buf,
|
||||
(DES_cblock *)desp->UDES.UDES_buf, &ks, enc);
|
||||
else {
|
||||
DES_ncbc_encrypt(desp->UDES.UDES_buf, desp->UDES.UDES_buf,
|
||||
len, &ks, &desp->des_ivec, enc);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
+11
-28
@@ -18,10 +18,9 @@
|
||||
#include <openssl/crypto.h>
|
||||
#include "des_locl.h"
|
||||
|
||||
/* defaults to false */
|
||||
OPENSSL_IMPLEMENT_GLOBAL(int, DES_check_key, 0)
|
||||
/*
|
||||
* defaults to false
|
||||
*/
|
||||
|
||||
static const unsigned char odd_parity[256] = {
|
||||
1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
|
||||
16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31,
|
||||
@@ -65,9 +64,9 @@ int DES_check_key_parity(const_DES_cblock *key)
|
||||
|
||||
for (i = 0; i < DES_KEY_SZ; i++) {
|
||||
if ((*key)[i] != odd_parity[(*key)[i]])
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -77,8 +76,6 @@ int DES_check_key_parity(const_DES_cblock *key)
|
||||
* %T Security for Computer Networks
|
||||
* %I John Wiley & Sons
|
||||
* %D 1984
|
||||
* Many thanks to smb@ulysses.att.com (Steven Bellovin) for the reference
|
||||
* (and actual cblock values).
|
||||
*/
|
||||
#define NUM_WEAK_KEY 16
|
||||
static const DES_cblock weak_keys[NUM_WEAK_KEY] = {
|
||||
@@ -107,15 +104,9 @@ int DES_is_weak_key(const_DES_cblock *key)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_WEAK_KEY; i++)
|
||||
/*
|
||||
* Added == 0 to comparison, I obviously don't run this section very
|
||||
* often :-(, thanks to engineering@MorningStar.Com for the fix eay
|
||||
* 93/06/29 Another problem, I was comparing only the first 4 bytes,
|
||||
* 97/03/18
|
||||
*/
|
||||
if (memcmp(weak_keys[i], key, sizeof(DES_cblock)) == 0)
|
||||
return (1);
|
||||
return (0);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -302,9 +293,9 @@ 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)
|
||||
{
|
||||
if (!DES_check_key_parity(key))
|
||||
return (-1);
|
||||
return -1;
|
||||
if (DES_is_weak_key(key))
|
||||
return (-2);
|
||||
return -2;
|
||||
DES_set_key_unchecked(key, schedule);
|
||||
return 0;
|
||||
}
|
||||
@@ -329,8 +320,8 @@ void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
|
||||
c2l(in, d);
|
||||
|
||||
/*
|
||||
* do PC1 in 47 simple operations :-) Thanks to John Fletcher
|
||||
* (john_fletcher@lccmail.ocf.llnl.gov) for the inspiration. :-)
|
||||
* do PC1 in 47 simple operations. Thanks to John Fletcher
|
||||
* for the inspiration.
|
||||
*/
|
||||
PERM_OP(d, c, t, 4, 0x0f0f0f0fL);
|
||||
HPERM_OP(c, t, -2, 0xcccc0000L);
|
||||
@@ -377,13 +368,5 @@ void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
|
||||
|
||||
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
-1
@@ -7,7 +7,7 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
OPENSSL_GLOBAL const DES_LONG DES_SPtrans[8][64] = {
|
||||
const DES_LONG DES_SPtrans[8][64] = {
|
||||
{
|
||||
/* nibble 0 */
|
||||
0x02080800L, 0x00080000L, 0x02000002L, 0x02080802L,
|
||||
|
||||
@@ -17,10 +17,6 @@ void DES_string_to_key(const char *str, DES_cblock *key)
|
||||
|
||||
memset(key, 0, 8);
|
||||
length = strlen(str);
|
||||
#ifdef OLD_STR_TO_KEY
|
||||
for (i = 0; i < length; i++)
|
||||
(*key)[i % 8] ^= (str[i] << 1);
|
||||
#else /* MIT COMPATIBLE */
|
||||
for (i = 0; i < length; i++) {
|
||||
register unsigned char j = str[i];
|
||||
|
||||
@@ -34,7 +30,6 @@ void DES_string_to_key(const char *str, DES_cblock *key)
|
||||
(*key)[7 - (i % 8)] ^= j;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
DES_set_odd_parity(key);
|
||||
DES_set_key_unchecked(key, &ks);
|
||||
DES_cbc_cksum((const unsigned char *)str, key, length, &ks, key);
|
||||
@@ -50,20 +45,6 @@ void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2)
|
||||
memset(key1, 0, 8);
|
||||
memset(key2, 0, 8);
|
||||
length = strlen(str);
|
||||
#ifdef OLD_STR_TO_KEY
|
||||
if (length <= 8) {
|
||||
for (i = 0; i < length; i++) {
|
||||
(*key2)[i] = (*key1)[i] = (str[i] << 1);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < length; i++) {
|
||||
if ((i / 8) & 1)
|
||||
(*key2)[i % 8] ^= (str[i] << 1);
|
||||
else
|
||||
(*key1)[i % 8] ^= (str[i] << 1);
|
||||
}
|
||||
}
|
||||
#else /* MIT COMPATIBLE */
|
||||
for (i = 0; i < length; i++) {
|
||||
register unsigned char j = str[i];
|
||||
|
||||
@@ -84,7 +65,6 @@ void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2)
|
||||
}
|
||||
if (length <= 8)
|
||||
memcpy(key2, key1, 8);
|
||||
#endif
|
||||
DES_set_odd_parity(key1);
|
||||
DES_set_odd_parity(key2);
|
||||
DES_set_key_unchecked(key1, &ks);
|
||||
|
||||
Reference in New Issue
Block a user