1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 2009-2021 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci#include <openssl/opensslconf.h> 11e1051a39Sopenharmony_ci#include <openssl/types.h> 12e1051a39Sopenharmony_ci#include "crypto/poly1305.h" 13e1051a39Sopenharmony_ci#include "crypto/ppc_arch.h" 14e1051a39Sopenharmony_ci 15e1051a39Sopenharmony_civoid poly1305_init_int(void *ctx, const unsigned char key[16]); 16e1051a39Sopenharmony_civoid poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, 17e1051a39Sopenharmony_ci unsigned int padbit); 18e1051a39Sopenharmony_civoid poly1305_emit(void *ctx, unsigned char mac[16], 19e1051a39Sopenharmony_ci const unsigned int nonce[4]); 20e1051a39Sopenharmony_civoid poly1305_init_fpu(void *ctx, const unsigned char key[16]); 21e1051a39Sopenharmony_civoid poly1305_blocks_fpu(void *ctx, const unsigned char *inp, size_t len, 22e1051a39Sopenharmony_ci unsigned int padbit); 23e1051a39Sopenharmony_civoid poly1305_emit_fpu(void *ctx, unsigned char mac[16], 24e1051a39Sopenharmony_ci const unsigned int nonce[4]); 25e1051a39Sopenharmony_civoid poly1305_init_vsx(void *ctx, const unsigned char key[16]); 26e1051a39Sopenharmony_civoid poly1305_blocks_vsx(void *ctx, const unsigned char *inp, size_t len, 27e1051a39Sopenharmony_ci unsigned int padbit); 28e1051a39Sopenharmony_civoid poly1305_emit_vsx(void *ctx, unsigned char mac[16], 29e1051a39Sopenharmony_ci const unsigned int nonce[4]); 30e1051a39Sopenharmony_ciint poly1305_init(void *ctx, const unsigned char key[16], void *func[2]); 31e1051a39Sopenharmony_ciint poly1305_init(void *ctx, const unsigned char key[16], void *func[2]) 32e1051a39Sopenharmony_ci{ 33e1051a39Sopenharmony_ci if (OPENSSL_ppccap_P & PPC_CRYPTO207) { 34e1051a39Sopenharmony_ci poly1305_init_int(ctx, key); 35e1051a39Sopenharmony_ci func[0] = (void*)(uintptr_t)poly1305_blocks_vsx; 36e1051a39Sopenharmony_ci func[1] = (void*)(uintptr_t)poly1305_emit; 37e1051a39Sopenharmony_ci } else if (sizeof(size_t) == 4 && (OPENSSL_ppccap_P & PPC_FPU)) { 38e1051a39Sopenharmony_ci poly1305_init_fpu(ctx, key); 39e1051a39Sopenharmony_ci func[0] = (void*)(uintptr_t)poly1305_blocks_fpu; 40e1051a39Sopenharmony_ci func[1] = (void*)(uintptr_t)poly1305_emit_fpu; 41e1051a39Sopenharmony_ci } else { 42e1051a39Sopenharmony_ci poly1305_init_int(ctx, key); 43e1051a39Sopenharmony_ci func[0] = (void*)(uintptr_t)poly1305_blocks; 44e1051a39Sopenharmony_ci func[1] = (void*)(uintptr_t)poly1305_emit; 45e1051a39Sopenharmony_ci } 46e1051a39Sopenharmony_ci return 1; 47e1051a39Sopenharmony_ci} 48