summaryrefslogtreecommitdiffstats
path: root/crypto/chacha
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-06-18 17:35:40 +0200
committerMatt Caswell <matt@openssl.org>2021-06-25 08:49:45 +0100
commit3d178db73b1ac13011e950baae5225837c587df1 (patch)
tree448200c4eb072c508064fa3da5dfac76a89829c9 /crypto/chacha
parent991519aeb99b41e2239b20a254535436cad39553 (diff)
ppccap.c: Split out algorithm-specific functions
Fixes #13336 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15828)
Diffstat (limited to 'crypto/chacha')
-rw-r--r--crypto/chacha/build.info2
-rw-r--r--crypto/chacha/chacha_ppc.c35
2 files changed, 36 insertions, 1 deletions
diff --git a/crypto/chacha/build.info b/crypto/chacha/build.info
index 9757739682..c12cb9c201 100644
--- a/crypto/chacha/build.info
+++ b/crypto/chacha/build.info
@@ -12,7 +12,7 @@ IF[{- !$disabled{asm} -}]
$CHACHAASM_armv4=chacha-armv4.S
$CHACHAASM_aarch64=chacha-armv8.S
- $CHACHAASM_ppc32=chacha-ppc.s
+ $CHACHAASM_ppc32=chacha_ppc.c chacha-ppc.s
$CHACHAASM_ppc64=$CHACHAASM_ppc32
$CHACHAASM_c64xplus=chacha-c64xplus.s
diff --git a/crypto/chacha/chacha_ppc.c b/crypto/chacha/chacha_ppc.c
new file mode 100644
index 0000000000..5319040cc1
--- /dev/null
+++ b/crypto/chacha/chacha_ppc.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2009-2021 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (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 <stdlib.h>
+#include <string.h>
+
+#include <openssl/opensslconf.h>
+#include "crypto/chacha.h"
+#include "crypto/ppc_arch.h"
+
+void ChaCha20_ctr32_int(unsigned char *out, const unsigned char *inp,
+ size_t len, const unsigned int key[8],
+ const unsigned int counter[4]);
+void ChaCha20_ctr32_vmx(unsigned char *out, const unsigned char *inp,
+ size_t len, const unsigned int key[8],
+ const unsigned int counter[4]);
+void ChaCha20_ctr32_vsx(unsigned char *out, const unsigned char *inp,
+ size_t len, const unsigned int key[8],
+ const unsigned int counter[4]);
+void ChaCha20_ctr32(unsigned char *out, const unsigned char *inp,
+ size_t len, const unsigned int key[8],
+ const unsigned int counter[4])
+{
+ OPENSSL_ppccap_P & PPC_CRYPTO207
+ ? ChaCha20_ctr32_vsx(out, inp, len, key, counter)
+ : OPENSSL_ppccap_P & PPC_ALTIVEC
+ ? ChaCha20_ctr32_vmx(out, inp, len, key, counter)
+ : ChaCha20_ctr32_int(out, inp, len, key, counter);
+}