]> git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/poly1305/poly1305_ppccap.c
Move algorithm specific ppccap code from crypto/ppccap.c
[thirdparty/openssl.git] / crypto / poly1305 / poly1305_ppccap.c
1 /*
2 * Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (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 <stdlib.h>
11 #include <openssl/opensslconf.h>
12 #include "../ppc_arch.h"
13
14 #ifdef OPENSSL_NO_POLY1305
15 NON_EMPTY_TRANSLATION_UNIT
16 #else
17 void poly1305_init_int(void *ctx, const unsigned char key[16]);
18 void poly1305_blocks(void *ctx, const unsigned char *inp, size_t len,
19 unsigned int padbit);
20 void poly1305_emit(void *ctx, unsigned char mac[16],
21 const unsigned int nonce[4]);
22 void poly1305_init_fpu(void *ctx, const unsigned char key[16]);
23 void poly1305_blocks_fpu(void *ctx, const unsigned char *inp, size_t len,
24 unsigned int padbit);
25 void poly1305_emit_fpu(void *ctx, unsigned char mac[16],
26 const unsigned int nonce[4]);
27 int poly1305_init(void *ctx, const unsigned char key[16], void *func[2])
28 {
29 if (sizeof(size_t) == 4 && (OPENSSL_ppccap_P & PPC_FPU)) {
30 poly1305_init_fpu(ctx, key);
31 func[0] = poly1305_blocks_fpu;
32 func[1] = poly1305_emit_fpu;
33 } else {
34 poly1305_init_int(ctx, key);
35 func[0] = poly1305_blocks;
36 func[1] = poly1305_emit;
37 }
38 return 1;
39 }
40 #endif
41