From 1642d378e61c0ceb1e92a1e50fda710584c4c633 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Sat, 12 Jul 2014 20:11:46 +0000 Subject: Remove private_{Camellia,RC4}_set_key FIPS indirection tentacles, as has been done for other symmetric algorithms recently. --- lib/libcrypto/crypto/Makefile | 5 +-- lib/libssl/src/crypto/camellia/cmll_locl.h | 4 +- lib/libssl/src/crypto/camellia/cmll_misc.c | 39 +++++++++--------- lib/libssl/src/crypto/camellia/cmll_utl.c | 61 ----------------------------- lib/libssl/src/crypto/rc4/asm/rc4-586.pl | 4 +- lib/libssl/src/crypto/rc4/asm/rc4-parisc.pl | 4 +- lib/libssl/src/crypto/rc4/asm/rc4-s390x.pl | 39 +++++++++++++++--- lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl | 8 ++-- lib/libssl/src/crypto/rc4/rc4_skey.c | 4 +- lib/libssl/src/crypto/rc4/rc4_utl.c | 59 ---------------------------- 10 files changed, 67 insertions(+), 160 deletions(-) delete mode 100644 lib/libssl/src/crypto/camellia/cmll_utl.c delete mode 100644 lib/libssl/src/crypto/rc4/rc4_utl.c (limited to 'lib') diff --git a/lib/libcrypto/crypto/Makefile b/lib/libcrypto/crypto/Makefile index 79fbd478b3c..fdbafba8528 100644 --- a/lib/libcrypto/crypto/Makefile +++ b/lib/libcrypto/crypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.44 2014/07/11 14:01:38 tedu Exp $ +# $OpenBSD: Makefile,v 1.45 2014/07/12 20:11:45 miod Exp $ LIB= crypto @@ -208,9 +208,6 @@ SRCS+= randfile.c rand_lib.c rand_err.c # rc2/ SRCS+= rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c -# rc4/ -SRCS+= rc4_utl.c - # rc5/ #SRCS+= rc5_skey.c rc5_ecb.c rc5cfb64.c rc5ofb64.c diff --git a/lib/libssl/src/crypto/camellia/cmll_locl.h b/lib/libssl/src/crypto/camellia/cmll_locl.h index 1ee144d4d08..60055b0d18e 100644 --- a/lib/libssl/src/crypto/camellia/cmll_locl.h +++ b/lib/libssl/src/crypto/camellia/cmll_locl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cmll_locl.h,v 1.3 2014/06/12 15:49:28 deraadt Exp $ */ +/* $OpenBSD: cmll_locl.h,v 1.4 2014/07/12 20:11:45 miod Exp $ */ /* ==================================================================== * Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) . * ALL RIGHTS RESERVED. @@ -81,6 +81,4 @@ void Camellia_EncryptBlock(int keyBitLength, const u8 plaintext[], const KEY_TABLE_TYPE keyTable, u8 ciphertext[]); void Camellia_DecryptBlock(int keyBitLength, const u8 ciphertext[], const KEY_TABLE_TYPE keyTable, u8 plaintext[]); -int private_Camellia_set_key(const unsigned char *userKey, const int bits, - CAMELLIA_KEY *key); #endif /* #ifndef HEADER_CAMELLIA_LOCL_H */ diff --git a/lib/libssl/src/crypto/camellia/cmll_misc.c b/lib/libssl/src/crypto/camellia/cmll_misc.c index 5caa7a98747..68b8dc44ff2 100644 --- a/lib/libssl/src/crypto/camellia/cmll_misc.c +++ b/lib/libssl/src/crypto/camellia/cmll_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmll_misc.c,v 1.4 2014/07/09 11:10:50 bcook Exp $ */ +/* $OpenBSD: cmll_misc.c,v 1.5 2014/07/12 20:11:45 miod Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * @@ -54,25 +54,28 @@ #include #include "cmll_locl.h" -int private_Camellia_set_key(const unsigned char *userKey, const int bits, - CAMELLIA_KEY *key) - { - if(!userKey || !key) +int +Camellia_set_key(const unsigned char *userKey, const int bits, + CAMELLIA_KEY *key) +{ + if (userKey == NULL || key == NULL) return -1; - if(bits != 128 && bits != 192 && bits != 256) + if (bits != 128 && bits != 192 && bits != 256) return -2; - key->grand_rounds = Camellia_Ekeygen(bits , userKey, key->u.rd_key); + key->grand_rounds = Camellia_Ekeygen(bits, userKey, key->u.rd_key); return 0; - } +} -void Camellia_encrypt(const unsigned char *in, unsigned char *out, - const CAMELLIA_KEY *key) - { - Camellia_EncryptBlock_Rounds(key->grand_rounds, in , key->u.rd_key , out); - } +void +Camellia_encrypt(const unsigned char *in, unsigned char *out, + const CAMELLIA_KEY *key) +{ + Camellia_EncryptBlock_Rounds(key->grand_rounds, in, key->u.rd_key, out); +} -void Camellia_decrypt(const unsigned char *in, unsigned char *out, - const CAMELLIA_KEY *key) - { - Camellia_DecryptBlock_Rounds(key->grand_rounds, in , key->u.rd_key , out); - } +void +Camellia_decrypt(const unsigned char *in, unsigned char *out, + const CAMELLIA_KEY *key) +{ + Camellia_DecryptBlock_Rounds(key->grand_rounds, in, key->u.rd_key, out); +} diff --git a/lib/libssl/src/crypto/camellia/cmll_utl.c b/lib/libssl/src/crypto/camellia/cmll_utl.c deleted file mode 100644 index 198ba8951ad..00000000000 --- a/lib/libssl/src/crypto/camellia/cmll_utl.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $OpenBSD: cmll_utl.c,v 1.4 2014/06/12 15:49:28 deraadt Exp $ */ -/* ==================================================================== - * 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 -#include "cmll_locl.h" - -int Camellia_set_key(const unsigned char *userKey, const int bits, - CAMELLIA_KEY *key) - { - return private_Camellia_set_key(userKey, bits, key); - } diff --git a/lib/libssl/src/crypto/rc4/asm/rc4-586.pl b/lib/libssl/src/crypto/rc4/asm/rc4-586.pl index 5c9ac6ad286..84f1a798cb8 100644 --- a/lib/libssl/src/crypto/rc4/asm/rc4-586.pl +++ b/lib/libssl/src/crypto/rc4/asm/rc4-586.pl @@ -300,7 +300,7 @@ $ido="ecx"; $idx="edx"; # void RC4_set_key(RC4_KEY *key,int len,const unsigned char *data); -&function_begin("private_RC4_set_key"); +&function_begin("RC4_set_key"); &mov ($out,&wparam(0)); # load key &mov ($idi,&wparam(1)); # load len &mov ($inp,&wparam(2)); # load data @@ -378,7 +378,7 @@ $idx="edx"; &xor ("eax","eax"); &mov (&DWP(-8,$out),"eax"); # key->x=0; &mov (&DWP(-4,$out),"eax"); # key->y=0; -&function_end("private_RC4_set_key"); +&function_end("RC4_set_key"); # const char *RC4_options(void); &function_begin_B("RC4_options"); diff --git a/lib/libssl/src/crypto/rc4/asm/rc4-parisc.pl b/lib/libssl/src/crypto/rc4/asm/rc4-parisc.pl index 9eca69902e1..7e7974430aa 100644 --- a/lib/libssl/src/crypto/rc4/asm/rc4-parisc.pl +++ b/lib/libssl/src/crypto/rc4/asm/rc4-parisc.pl @@ -247,9 +247,9 @@ ___ $code.=<<___; - .EXPORT private_RC4_set_key,ENTRY,ARGW0=GR,ARGW1=GR,ARGW2=GR + .EXPORT RC4_set_key,ENTRY,ARGW0=GR,ARGW1=GR,ARGW2=GR .ALIGN 8 -private_RC4_set_key +RC4_set_key .PROC .CALLINFO NO_CALLS .ENTRY diff --git a/lib/libssl/src/crypto/rc4/asm/rc4-s390x.pl b/lib/libssl/src/crypto/rc4/asm/rc4-s390x.pl index 96681fa05ec..1aa754820c6 100644 --- a/lib/libssl/src/crypto/rc4/asm/rc4-s390x.pl +++ b/lib/libssl/src/crypto/rc4/asm/rc4-s390x.pl @@ -13,6 +13,29 @@ # "cluster" Address Generation Interlocks, so that one pipeline stall # resolves several dependencies. +# November 2010. +# +# Adapt for -m31 build. If kernel supports what's called "highgprs" +# feature on Linux [see /proc/cpuinfo], it's possible to use 64-bit +# instructions and achieve "64-bit" performance even in 31-bit legacy +# application context. The feature is not specific to any particular +# processor, as long as it's "z-CPU". Latter implies that the code +# remains z/Architecture specific. On z990 it was measured to perform +# 50% better than code generated by gcc 4.3. + +$flavour = shift; + +if ($flavour =~ /3[12]/) { + $SIZE_T=4; + $g=""; +} else { + $SIZE_T=8; + $g="g"; +} + +while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {} +open STDOUT,">$output"; + $rp="%r14"; $sp="%r15"; $code=<<___; @@ -39,7 +62,12 @@ $code.=<<___; .type RC4,\@function .align 64 RC4: - stmg %r6,%r11,48($sp) + stm${g} %r6,%r11,6*$SIZE_T($sp) +___ +$code.=<<___ if ($flavour =~ /3[12]/); + llgfr $len,$len +___ +$code.=<<___; llgc $XX[0],0($key) llgc $YY,1($key) la $XX[0],1($XX[0]) @@ -90,7 +118,7 @@ $code.=<<___; xgr $acc,$TX[1] stg $acc,0($out) la $out,8($out) - brct $cnt,.Loop8 + brctg $cnt,.Loop8 .Lshort: lghi $acc,7 @@ -122,7 +150,7 @@ $code.=<<___; ahi $XX[0],-1 stc $XX[0],0($key) stc $YY,1($key) - lmg %r6,%r11,48($sp) + lm${g} %r6,%r11,6*$SIZE_T($sp) br $rp .size RC4,.-RC4 .string "RC4 for s390x, CRYPTOGAMS by " @@ -147,7 +175,7 @@ $code.=<<___; .type RC4_set_key,\@function .align 64 RC4_set_key: - stmg %r6,%r8,48($sp) + stm${g} %r6,%r8,6*$SIZE_T($sp) lhi $cnt,256 la $idx,0(%r0) sth $idx,0($key) @@ -180,7 +208,7 @@ RC4_set_key: la $iinp,0(%r0) j .L2ndloop .Ldone: - lmg %r6,%r8,48($sp) + lm${g} %r6,%r8,6*$SIZE_T($sp) br $rp .size RC4_set_key,.-RC4_set_key @@ -203,3 +231,4 @@ RC4_options: ___ print $code; +close STDOUT; # force flush diff --git a/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl b/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl index 2bed1e279fc..197749dda73 100755 --- a/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl +++ b/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl @@ -428,10 +428,10 @@ $idx="%r8"; $ido="%r9"; $code.=<<___; -.globl private_RC4_set_key -.type private_RC4_set_key,\@function,3 +.globl RC4_set_key +.type RC4_set_key,\@function,3 .align 16 -private_RC4_set_key: +RC4_set_key: lea 8($dat),$dat lea ($inp,$len),$inp neg $len @@ -498,7 +498,7 @@ private_RC4_set_key: mov %eax,-8($dat) mov %eax,-4($dat) ret -.size private_RC4_set_key,.-private_RC4_set_key +.size RC4_set_key,.-RC4_set_key .globl RC4_options .type RC4_options,\@abi-omnipotent diff --git a/lib/libssl/src/crypto/rc4/rc4_skey.c b/lib/libssl/src/crypto/rc4/rc4_skey.c index 282ed7cc1b5..455cd44d136 100644 --- a/lib/libssl/src/crypto/rc4/rc4_skey.c +++ b/lib/libssl/src/crypto/rc4/rc4_skey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc4_skey.c,v 1.11 2014/07/09 11:10:51 bcook Exp $ */ +/* $OpenBSD: rc4_skey.c,v 1.12 2014/07/12 20:11:45 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -83,7 +83,7 @@ const char *RC4_options(void) * Date: Wed, 14 Sep 1994 06:35:31 GMT */ -void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) +void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) { register RC4_INT tmp; register int id1,id2; diff --git a/lib/libssl/src/crypto/rc4/rc4_utl.c b/lib/libssl/src/crypto/rc4/rc4_utl.c deleted file mode 100644 index 0d02171a3ec..00000000000 --- a/lib/libssl/src/crypto/rc4/rc4_utl.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: rc4_utl.c,v 1.4 2014/06/12 15:49:30 deraadt Exp $ */ -/* ==================================================================== - * 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) - { - private_RC4_set_key(key, len, data); - } -- cgit v1.2.3