1a079e38bSJohn Baldwin /* 2a079e38bSJohn Baldwin * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. 3a079e38bSJohn Baldwin * 4a079e38bSJohn Baldwin * Licensed under the OpenSSL license (the "License"). You may not use 5a079e38bSJohn Baldwin * this file except in compliance with the License. You can obtain a copy 6a079e38bSJohn Baldwin * in the file LICENSE in the source distribution or at 7a079e38bSJohn Baldwin * https://www.openssl.org/source/license.html 8a079e38bSJohn Baldwin */ 9a079e38bSJohn Baldwin 10a079e38bSJohn Baldwin /* From include/crypto/poly1305.h */ 11a079e38bSJohn Baldwin 12a079e38bSJohn Baldwin #define POLY1305_BLOCK_SIZE 16 13a079e38bSJohn Baldwin 14a079e38bSJohn Baldwin typedef struct poly1305_context POLY1305; 15a079e38bSJohn Baldwin 16a079e38bSJohn Baldwin /* From crypto/poly1305/poly1305_local.h */ 17a079e38bSJohn Baldwin 18a079e38bSJohn Baldwin typedef void (*poly1305_blocks_f) (void *ctx, const unsigned char *inp, 19a079e38bSJohn Baldwin size_t len, unsigned int padbit); 20a079e38bSJohn Baldwin typedef void (*poly1305_emit_f) (void *ctx, unsigned char mac[16], 21a079e38bSJohn Baldwin const unsigned int nonce[4]); 22a079e38bSJohn Baldwin 23a079e38bSJohn Baldwin struct poly1305_context { 24a079e38bSJohn Baldwin double opaque[24]; /* large enough to hold internal state, declared 25a079e38bSJohn Baldwin * 'double' to ensure at least 64-bit invariant 26a079e38bSJohn Baldwin * alignment across all platforms and 27a079e38bSJohn Baldwin * configurations */ 28a079e38bSJohn Baldwin unsigned int nonce[4]; 29a079e38bSJohn Baldwin unsigned char data[POLY1305_BLOCK_SIZE]; 30a079e38bSJohn Baldwin size_t num; 31a079e38bSJohn Baldwin struct { 32a079e38bSJohn Baldwin poly1305_blocks_f blocks; 33a079e38bSJohn Baldwin poly1305_emit_f emit; 34a079e38bSJohn Baldwin } func; 35a079e38bSJohn Baldwin }; 36*78991a93SJohn Baldwin 37*78991a93SJohn Baldwin int ossl_poly1305_update(void *vctx, const void *buf, u_int len); 38*78991a93SJohn Baldwin void Poly1305_Init(POLY1305 *ctx, const unsigned char key[32]); 39*78991a93SJohn Baldwin void Poly1305_Update(POLY1305 *ctx, const unsigned char *inp, size_t len); 40*78991a93SJohn Baldwin void Poly1305_Final(POLY1305 *ctx, unsigned char mac[16]); 41