aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2014-07-20 14:16:31 +0200
committerAndy Polyakov <appro@openssl.org>2014-07-20 14:16:31 +0200
commit0e716d9207e00c9d967492b3b8bb89efad16bd06 (patch)
tree90f31bde709857570c9f7c4203b816bd6ae870ff
parentf5b798f50c83bed58d90f940e427552b97eddcb7 (diff)
downloadopenssl-0e716d9207e00c9d967492b3b8bb89efad16bd06.zip
openssl-0e716d9207e00c9d967492b3b8bb89efad16bd06.tar.gz
openssl-0e716d9207e00c9d967492b3b8bb89efad16bd06.tar.bz2
Engage GHASH for PowerISA 2.0.7.
[and split ppccap.c to ppccap.c and ppc_arch.h] Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org>
-rwxr-xr-xConfigure2
-rw-r--r--TABLE20
-rw-r--r--crypto/evp/e_aes.c6
-rw-r--r--crypto/modes/Makefile2
-rw-r--r--crypto/modes/gcm128.c17
-rw-r--r--crypto/ppc_arch.h10
-rw-r--r--crypto/ppccap.c4
7 files changed, 44 insertions, 17 deletions
diff --git a/Configure b/Configure
index 429eaed..7a4730f 100755
--- a/Configure
+++ b/Configure
@@ -140,7 +140,7 @@ my $armv4_asm="armcap.o armv4cpuid.o:bn_asm.o armv4-mont.o armv4-gf2m.o::aes_cbc
my $aarch64_asm="armcap.o arm64cpuid.o mem_clr.o:::aes_core.o aes_cbc.o aesv8-armx.o:::sha1-armv8.o sha256-armv8.o sha512-armv8.o:::::::ghashv8-armx.o:";
my $parisc11_asm="pariscid.o:bn_asm.o parisc-mont.o::aes_core.o aes_cbc.o aes-parisc.o:::sha1-parisc.o sha256-parisc.o sha512-parisc.o::rc4-parisc.o:::::ghash-parisc.o::32";
my $parisc20_asm="pariscid.o:pa-risc2W.o parisc-mont.o::aes_core.o aes_cbc.o aes-parisc.o:::sha1-parisc.o sha256-parisc.o sha512-parisc.o::rc4-parisc.o:::::ghash-parisc.o::64";
-my $ppc64_asm="ppccpuid.o ppccap.o:bn-ppc.o ppc-mont.o ppc64-mont.o::aes_core.o aes_cbc.o aes-ppc.o vpaes-ppc.o aesp8-ppc.o:::sha1-ppc.o sha256-ppc.o sha512-ppc.o sha256p8-ppc.o sha512p8-ppc.o::::::::";
+my $ppc64_asm="ppccpuid.o ppccap.o:bn-ppc.o ppc-mont.o ppc64-mont.o::aes_core.o aes_cbc.o aes-ppc.o vpaes-ppc.o aesp8-ppc.o:::sha1-ppc.o sha256-ppc.o sha512-ppc.o sha256p8-ppc.o sha512p8-ppc.o:::::::ghashp8-ppc.o:";
my $ppc32_asm=$ppc64_asm;
my $no_asm=":::::::::::::::void";
diff --git a/TABLE b/TABLE
index 1920cb2..0cbfcb5 100644
--- a/TABLE
+++ b/TABLE
@@ -912,7 +912,7 @@ $rmd160_obj =
$rc5_obj =
$wp_obj =
$cmll_obj =
-$modes_obj =
+$modes_obj = ghashp8-ppc.o
$engines_obj =
$perlasm_scheme = aix32
$dso_scheme = dlfcn
@@ -945,7 +945,7 @@ $rmd160_obj =
$rc5_obj =
$wp_obj =
$cmll_obj =
-$modes_obj =
+$modes_obj = ghashp8-ppc.o
$engines_obj =
$perlasm_scheme = aix32
$dso_scheme = dlfcn
@@ -1011,7 +1011,7 @@ $rmd160_obj =
$rc5_obj =
$wp_obj =
$cmll_obj =
-$modes_obj =
+$modes_obj = ghashp8-ppc.o
$engines_obj =
$perlasm_scheme = aix64
$dso_scheme = dlfcn
@@ -1044,7 +1044,7 @@ $rmd160_obj =
$rc5_obj =
$wp_obj =
$cmll_obj =
-$modes_obj =
+$modes_obj = ghashp8-ppc.o
$engines_obj =
$perlasm_scheme = aix64
$dso_scheme = dlfcn
@@ -1473,7 +1473,7 @@ $rmd160_obj =
$rc5_obj =
$wp_obj =
$cmll_obj =
-$modes_obj =
+$modes_obj = ghashp8-ppc.o
$engines_obj =
$perlasm_scheme = osx32
$dso_scheme = dlfcn
@@ -1506,7 +1506,7 @@ $rmd160_obj =
$rc5_obj =
$wp_obj =
$cmll_obj =
-$modes_obj =
+$modes_obj = ghashp8-ppc.o
$engines_obj =
$perlasm_scheme = osx64
$dso_scheme = dlfcn
@@ -2199,7 +2199,7 @@ $rmd160_obj =
$rc5_obj =
$wp_obj =
$cmll_obj =
-$modes_obj =
+$modes_obj = ghashp8-ppc.o
$engines_obj =
$perlasm_scheme = osx32
$dso_scheme = dlfcn
@@ -4542,7 +4542,7 @@ $rmd160_obj =
$rc5_obj =
$wp_obj =
$cmll_obj =
-$modes_obj =
+$modes_obj = ghashp8-ppc.o
$engines_obj =
$perlasm_scheme = linux32
$dso_scheme = dlfcn
@@ -4575,7 +4575,7 @@ $rmd160_obj =
$rc5_obj =
$wp_obj =
$cmll_obj =
-$modes_obj =
+$modes_obj = ghashp8-ppc.o
$engines_obj =
$perlasm_scheme = linux64
$dso_scheme = dlfcn
@@ -4608,7 +4608,7 @@ $rmd160_obj =
$rc5_obj =
$wp_obj =
$cmll_obj =
-$modes_obj =
+$modes_obj = ghashp8-ppc.o
$engines_obj =
$perlasm_scheme = linux64le
$dso_scheme = dlfcn
diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c
index 89178bc..8ab4349 100644
--- a/crypto/evp/e_aes.c
+++ b/crypto/evp/e_aes.c
@@ -155,11 +155,11 @@ void AES_xts_decrypt(const char *inp,char *out,size_t len,
#endif
#if defined(OPENSSL_CPUID_OBJ) && (defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC))
-extern unsigned int OPENSSL_ppccap_P;
+# include "ppc_arch.h"
# ifdef VPAES_ASM
-# define VPAES_CAPABLE (OPENSSL_ppccap_P&(1<<1))
+# define VPAES_CAPABLE (OPENSSL_ppccap_P & PPC_ALTIVEC)
# endif
-# define HWAES_CAPABLE (OPENSSL_ppccap_P&(1<<2))
+# define HWAES_CAPABLE (OPENSSL_ppccap_P & PPC_CRYPTO207)
# define HWAES_set_encrypt_key aes_p8_set_encrypt_key
# define HWAES_set_decrypt_key aes_p8_set_decrypt_key
# define HWAES_encrypt aes_p8_encrypt
diff --git a/crypto/modes/Makefile b/crypto/modes/Makefile
index d03284e..ba0b094 100644
--- a/crypto/modes/Makefile
+++ b/crypto/modes/Makefile
@@ -62,6 +62,8 @@ ghash-parisc.s: asm/ghash-parisc.pl
$(PERL) asm/ghash-parisc.pl $(PERLASM_SCHEME) $@
ghashv8-armx.S: asm/ghashv8-armx.pl
$(PERL) asm/ghashv8-armx.pl $(PERLASM_SCHEME) $@
+ghashp8-ppc.s: asm/ghashp8-ppc.pl
+ $(PERL) asm/ghashp8-ppc.pl $(PERLASM_SCHEME) $@
# GNU make "catch all"
ghash-%.S: asm/ghash-%.pl; $(PERL) $< $(PERLASM_SCHEME) $@
diff --git a/crypto/modes/gcm128.c b/crypto/modes/gcm128.c
index 19cbcf5..484142a 100644
--- a/crypto/modes/gcm128.c
+++ b/crypto/modes/gcm128.c
@@ -700,6 +700,13 @@ extern unsigned int OPENSSL_sparcv9cap_P[];
void gcm_init_vis3(u128 Htable[16],const u64 Xi[2]);
void gcm_gmult_vis3(u64 Xi[2],const u128 Htable[16]);
void gcm_ghash_vis3(u64 Xi[2],const u128 Htable[16],const u8 *inp,size_t len);
+#elif defined(OPENSSL_CPUID_OBJ) && (defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC))
+# include "ppc_arch.h"
+# define GHASH_ASM_PPC
+# define GCM_FUNCREF_4BIT
+void gcm_init_p8(u128 Htable[16],const u64 Xi[2]);
+void gcm_gmult_p8(u64 Xi[2],const u128 Htable[16]);
+void gcm_ghash_p8(u64 Xi[2],const u128 Htable[16],const u8 *inp,size_t len);
# endif
#endif
@@ -803,6 +810,16 @@ void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx,void *key,block128_f block)
ctx->gmult = gcm_gmult_4bit;
ctx->ghash = gcm_ghash_4bit;
}
+# elif defined(GHASH_ASM_PPC)
+ if (OPENSSL_ppccap_P & PPC_CRYPTO207) {
+ gcm_init_p8(ctx->Htable,ctx->H.u);
+ ctx->gmult = gcm_gmult_p8;
+ ctx->ghash = gcm_ghash_p8;
+ } else {
+ gcm_init_4bit(ctx->Htable,ctx->H.u);
+ ctx->gmult = gcm_gmult_4bit;
+ ctx->ghash = gcm_ghash_4bit;
+ }
# else
gcm_init_4bit(ctx->Htable,ctx->H.u);
# endif
diff --git a/crypto/ppc_arch.h b/crypto/ppc_arch.h
new file mode 100644
index 0000000..1192edf
--- /dev/null
+++ b/crypto/ppc_arch.h
@@ -0,0 +1,10 @@
+#ifndef __PPC_ARCH_H__
+#define __PPC_ARCH_H__
+
+extern unsigned int OPENSSL_ppccap_P;
+
+#define PPC_FPU64 (1<<0)
+#define PPC_ALTIVEC (1<<1)
+#define PPC_CRYPTO207 (1<<2)
+
+#endif
diff --git a/crypto/ppccap.c b/crypto/ppccap.c
index cad14fd..13c2ca5 100644
--- a/crypto/ppccap.c
+++ b/crypto/ppccap.c
@@ -10,9 +10,7 @@
#include <crypto.h>
#include <openssl/bn.h>
-#define PPC_FPU64 (1<<0)
-#define PPC_ALTIVEC (1<<1)
-#define PPC_CRYPTO207 (1<<2)
+#include "ppc_arch.h"
unsigned int OPENSSL_ppccap_P = 0;