diff options
author | Tomas Mraz <tomas@openssl.org> | 2021-06-18 17:35:40 +0200 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2021-06-25 08:49:45 +0100 |
commit | 3d178db73b1ac13011e950baae5225837c587df1 (patch) | |
tree | 448200c4eb072c508064fa3da5dfac76a89829c9 /crypto/poly1305 | |
parent | 991519aeb99b41e2239b20a254535436cad39553 (diff) | |
download | openssl-new-3d178db73b1ac13011e950baae5225837c587df1.tar.gz |
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/poly1305')
-rw-r--r-- | crypto/poly1305/build.info | 2 | ||||
-rw-r--r-- | crypto/poly1305/poly1305_ppc.c | 47 |
2 files changed, 48 insertions, 1 deletions
diff --git a/crypto/poly1305/build.info b/crypto/poly1305/build.info index 7e055ef338..7f13fdcf3b 100644 --- a/crypto/poly1305/build.info +++ b/crypto/poly1305/build.info @@ -16,7 +16,7 @@ IF[{- !$disabled{asm} -}] $POLY1305ASM_armv4=poly1305-armv4.S $POLY1305ASM_aarch64=poly1305-armv8.S - $POLY1305ASM_ppc32=poly1305-ppc.s poly1305-ppcfp.s + $POLY1305ASM_ppc32=poly1305_ppc.c poly1305-ppc.s poly1305-ppcfp.s $POLY1305ASM_ppc64=$POLY1305ASM_ppc32 $POLY1305ASM_c64xplus=poly1305-c64xplus.s diff --git a/crypto/poly1305/poly1305_ppc.c b/crypto/poly1305/poly1305_ppc.c new file mode 100644 index 0000000000..4e4e3d1994 --- /dev/null +++ b/crypto/poly1305/poly1305_ppc.c @@ -0,0 +1,47 @@ +/* + * 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 <openssl/opensslconf.h> +#include <openssl/types.h> +#include "crypto/poly1305.h" +#include "crypto/ppc_arch.h" + +void poly1305_init_int(void *ctx, const unsigned char key[16]); +void poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, + unsigned int padbit); +void poly1305_emit(void *ctx, unsigned char mac[16], + const unsigned int nonce[4]); +void poly1305_init_fpu(void *ctx, const unsigned char key[16]); +void poly1305_blocks_fpu(void *ctx, const unsigned char *inp, size_t len, + unsigned int padbit); +void poly1305_emit_fpu(void *ctx, unsigned char mac[16], + const unsigned int nonce[4]); +void poly1305_init_vsx(void *ctx, const unsigned char key[16]); +void poly1305_blocks_vsx(void *ctx, const unsigned char *inp, size_t len, + unsigned int padbit); +void poly1305_emit_vsx(void *ctx, unsigned char mac[16], + const unsigned int nonce[4]); +int poly1305_init(void *ctx, const unsigned char key[16], void *func[2]); +int poly1305_init(void *ctx, const unsigned char key[16], void *func[2]) +{ + if (OPENSSL_ppccap_P & PPC_CRYPTO207) { + poly1305_init_int(ctx, key); + func[0] = (void*)(uintptr_t)poly1305_blocks_vsx; + func[1] = (void*)(uintptr_t)poly1305_emit; + } else if (sizeof(size_t) == 4 && (OPENSSL_ppccap_P & PPC_FPU)) { + poly1305_init_fpu(ctx, key); + func[0] = (void*)(uintptr_t)poly1305_blocks_fpu; + func[1] = (void*)(uintptr_t)poly1305_emit_fpu; + } else { + poly1305_init_int(ctx, key); + func[0] = (void*)(uintptr_t)poly1305_blocks; + func[1] = (void*)(uintptr_t)poly1305_emit; + } + return 1; +} |