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