From 5ce38c90cf43ee79cd999716ea83a5a44eeb819e Mon Sep 17 00:00:00 2001 From: Gary Ching-Pang Lin Date: Tue, 28 Jul 2015 11:46:38 -0400 Subject: Update openssl to 1.0.2d Also update Cryptlib to edk2 r17731 Signed-off-by: Gary Ching-Pang Lin --- Cryptlib/OpenSSL/crypto/rc4/rc4_enc.c | 18 ++++---- Cryptlib/OpenSSL/crypto/rc4/rc4_fblk.c | 75 ---------------------------------- Cryptlib/OpenSSL/crypto/rc4/rc4_locl.h | 6 +-- Cryptlib/OpenSSL/crypto/rc4/rc4_skey.c | 50 ----------------------- Cryptlib/OpenSSL/crypto/rc4/rc4_utl.c | 62 ++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 137 deletions(-) delete mode 100644 Cryptlib/OpenSSL/crypto/rc4/rc4_fblk.c create mode 100644 Cryptlib/OpenSSL/crypto/rc4/rc4_utl.c (limited to 'Cryptlib/OpenSSL/crypto/rc4') diff --git a/Cryptlib/OpenSSL/crypto/rc4/rc4_enc.c b/Cryptlib/OpenSSL/crypto/rc4/rc4_enc.c index 72cc8f65..0f0a2487 100644 --- a/Cryptlib/OpenSSL/crypto/rc4/rc4_enc.c +++ b/Cryptlib/OpenSSL/crypto/rc4/rc4_enc.c @@ -68,18 +68,18 @@ * Date: Wed, 14 Sep 1994 06:35:31 GMT */ -void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, +void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, unsigned char *outdata) { register RC4_INT *d; register RC4_INT x, y, tx, ty; - int i; + size_t i; x = key->x; y = key->y; d = key->data; -#if defined(RC4_CHUNK) +#if defined(RC4_CHUNK) && !defined(PEDANTIC) /*- * The original reason for implementing this(*) was the fact that * pre-21164a Alpha CPUs don't have byte load/store instructions @@ -121,8 +121,8 @@ void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, (RC4_CHUNK)d[(tx+ty)&0xff]\ ) - if ((((unsigned long)indata & (sizeof(RC4_CHUNK) - 1)) | - ((unsigned long)outdata & (sizeof(RC4_CHUNK) - 1))) == 0) { + if ((((size_t)indata & (sizeof(RC4_CHUNK) - 1)) | + ((size_t)outdata & (sizeof(RC4_CHUNK) - 1))) == 0) { RC4_CHUNK ichunk, otp; const union { long one; @@ -161,7 +161,7 @@ void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, */ if (!is_endian.little) { /* BIG-ENDIAN CASE */ # define BESHFT(c) (((sizeof(RC4_CHUNK)-(c)-1)*8)&(sizeof(RC4_CHUNK)*8-1)) - for (; len & ~(sizeof(RC4_CHUNK) - 1); len -= sizeof(RC4_CHUNK)) { + for (; len & (0 - sizeof(RC4_CHUNK)); len -= sizeof(RC4_CHUNK)) { ichunk = *(RC4_CHUNK *) indata; otp = RC4_STEP << BESHFT(0); otp |= RC4_STEP << BESHFT(1); @@ -215,7 +215,7 @@ void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, return; } else { /* LITTLE-ENDIAN CASE */ # define LESHFT(c) (((c)*8)&(sizeof(RC4_CHUNK)*8-1)) - for (; len & ~(sizeof(RC4_CHUNK) - 1); len -= sizeof(RC4_CHUNK)) { + for (; len & (0 - sizeof(RC4_CHUNK)); len -= sizeof(RC4_CHUNK)) { ichunk = *(RC4_CHUNK *) indata; otp = RC4_STEP; otp |= RC4_STEP << 8; @@ -284,7 +284,7 @@ void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, # define RC4_LOOP(a,b,i) LOOP(a[i],b[i]) #endif - i = (int)(len >> 3L); + i = len >> 3; if (i) { for (;;) { RC4_LOOP(indata, outdata, 0); @@ -303,7 +303,7 @@ void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata, break; } } - i = (int)len & 0x07; + i = len & 0x07; if (i) { for (;;) { RC4_LOOP(indata, outdata, 0); diff --git a/Cryptlib/OpenSSL/crypto/rc4/rc4_fblk.c b/Cryptlib/OpenSSL/crypto/rc4/rc4_fblk.c deleted file mode 100644 index f2366851..00000000 --- a/Cryptlib/OpenSSL/crypto/rc4/rc4_fblk.c +++ /dev/null @@ -1,75 +0,0 @@ -/* crypto/rc4/rc4_fblk.c */ -/* - * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL - * project. - */ -/* ==================================================================== - * Copyright (c) 2008 The OpenSSL Project. 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 acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED 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 OpenSSL PROJECT OR - * ITS 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. - * ==================================================================== - */ - -#include -#include "rc4_locl.h" -#include -#include -#ifdef OPENSSL_FIPS -# include -#endif - -/* - * FIPS mode blocking for RC4 has to be done separately since RC4_set_key may - * be implemented in an assembly language file. - */ - -#ifdef OPENSSL_FIPS -void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) -{ - if (FIPS_mode()) - FIPS_BAD_ABORT(RC4) - private_RC4_set_key(key, len, data); -} -#endif diff --git a/Cryptlib/OpenSSL/crypto/rc4/rc4_locl.h b/Cryptlib/OpenSSL/crypto/rc4/rc4_locl.h index c712e163..faf8742f 100644 --- a/Cryptlib/OpenSSL/crypto/rc4/rc4_locl.h +++ b/Cryptlib/OpenSSL/crypto/rc4/rc4_locl.h @@ -1,5 +1,5 @@ #ifndef HEADER_RC4_LOCL_H -#define HEADER_RC4_LOCL_H -#include -#include +# define HEADER_RC4_LOCL_H +# include +# include #endif diff --git a/Cryptlib/OpenSSL/crypto/rc4/rc4_skey.c b/Cryptlib/OpenSSL/crypto/rc4/rc4_skey.c index 62121d90..06890d16 100644 --- a/Cryptlib/OpenSSL/crypto/rc4/rc4_skey.c +++ b/Cryptlib/OpenSSL/crypto/rc4/rc4_skey.c @@ -59,10 +59,6 @@ #include #include "rc4_locl.h" #include -#include -#ifdef OPENSSL_FIPS -# include -#endif const char RC4_version[] = "RC4" OPENSSL_VERSION_PTEXT; @@ -90,11 +86,7 @@ const char *RC4_options(void) * Date: Wed, 14 Sep 1994 06:35:31 GMT */ -#ifdef OPENSSL_FIPS void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) -#else -void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) -#endif { register RC4_INT tmp; register int id1, id2; @@ -113,48 +105,6 @@ void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) d[(n)]=d[id2]; \ d[id2]=tmp; } -#if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) -# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ - defined(__INTEL__) || \ - defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) - if (sizeof(RC4_INT) > 1) { - /* - * Unlike all other x86 [and x86_64] implementations, - * Intel P4 core [including EM64T] was found to perform - * poorly with wider RC4_INT. Performance improvement - * for IA-32 hand-coded assembler turned out to be 2.8x - * if re-coded for RC4_CHAR! It's however inappropriate - * to just switch to RC4_CHAR for x86[_64], as non-P4 - * implementations suffer from significant performance - * losses then, e.g. PIII exhibits >2x deterioration, - * and so does Opteron. In order to assure optimal - * all-round performance, we detect P4 at run-time by - * checking upon reserved bit 20 in CPU capability - * vector and set up compressed key schedule, which is - * recognized by correspondingly updated assembler - * module... Bit 20 is set up by OPENSSL_ia32_cpuid. - * - * - */ -# ifdef OPENSSL_FIPS - unsigned long *ia32cap_ptr = OPENSSL_ia32cap_loc(); - if (ia32cap_ptr && (*ia32cap_ptr & (1 << 20))) { -# else - if (OPENSSL_ia32cap_P & (1 << 20)) { -# endif - unsigned char *cp = (unsigned char *)d; - - for (i = 0; i < 256; i++) - cp[i] = i; - for (i = 0; i < 256; i++) - SK_LOOP(cp, i); - /* mark schedule as compressed! */ - d[256 / sizeof(RC4_INT)] = -1; - return; - } - } -# endif -#endif for (i = 0; i < 256; i++) d[i] = i; for (i = 0; i < 256; i += 4) { diff --git a/Cryptlib/OpenSSL/crypto/rc4/rc4_utl.c b/Cryptlib/OpenSSL/crypto/rc4/rc4_utl.c new file mode 100644 index 00000000..7c6a15f1 --- /dev/null +++ b/Cryptlib/OpenSSL/crypto/rc4/rc4_utl.c @@ -0,0 +1,62 @@ +/* crypto/rc4/rc4_utl.c -*- mode:C; c-file-style: "eay" -*- */ +/* ==================================================================== + * Copyright (c) 2011 The OpenSSL Project. 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 acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED 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 OpenSSL PROJECT OR + * ITS 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. + * ==================================================================== + * + */ + +#include +#include +#include + +void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) +{ +#ifdef OPENSSL_FIPS + fips_cipher_abort(RC4); +#endif + private_RC4_set_key(key, len, data); +} -- cgit v1.2.3