Adam Langley | de0b202 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2014, Google Inc. |
| 2 | * |
| 3 | * Permission to use, copy, modify, and/or distribute this software for any |
| 4 | * purpose with or without fee is hereby granted, provided that the above |
| 5 | * copyright notice and this permission notice appear in all copies. |
| 6 | * |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 14 | |
| 15 | #ifndef OPENSSL_HEADER_POLY1305_H |
| 16 | #define OPENSSL_HEADER_POLY1305_H |
| 17 | |
| 18 | #include <openssl/base.h> |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | |
David Benjamin | 6f0c4db | 2016-02-23 17:43:36 -0500 | [diff] [blame] | 25 | typedef union { |
| 26 | double align; |
| 27 | uint8_t bytes[512]; |
| 28 | } poly1305_state; |
Adam Langley | de0b202 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 29 | |
Adam Langley | c8e664b | 2015-09-24 14:48:32 -0700 | [diff] [blame] | 30 | /* CRYPTO_poly1305_init sets up |state| so that it can be used to calculate an |
Adam Langley | de0b202 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 31 | * authentication tag with the one-time key |key|. Note that |key| is a |
| 32 | * one-time key and therefore there is no `reset' method because that would |
| 33 | * enable several messages to be authenticated with the same key. */ |
David Benjamin | 723f353 | 2015-07-10 14:52:20 -0400 | [diff] [blame] | 34 | OPENSSL_EXPORT void CRYPTO_poly1305_init(poly1305_state* state, |
| 35 | const uint8_t key[32]); |
Adam Langley | de0b202 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 36 | |
Adam Langley | c8e664b | 2015-09-24 14:48:32 -0700 | [diff] [blame] | 37 | /* CRYPTO_poly1305_update processes |in_len| bytes from |in|. It can be called |
| 38 | * zero or more times after poly1305_init. */ |
David Benjamin | 723f353 | 2015-07-10 14:52:20 -0400 | [diff] [blame] | 39 | OPENSSL_EXPORT void CRYPTO_poly1305_update(poly1305_state* state, |
| 40 | const uint8_t* in, |
| 41 | size_t in_len); |
Adam Langley | de0b202 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 42 | |
Adam Langley | c8e664b | 2015-09-24 14:48:32 -0700 | [diff] [blame] | 43 | /* CRYPTO_poly1305_finish completes the poly1305 calculation and writes a 16 |
| 44 | * byte authentication tag to |mac|. The |mac| address must be 16-byte |
| 45 | * aligned. */ |
David Benjamin | 723f353 | 2015-07-10 14:52:20 -0400 | [diff] [blame] | 46 | OPENSSL_EXPORT void CRYPTO_poly1305_finish(poly1305_state* state, |
| 47 | uint8_t mac[16]); |
Adam Langley | de0b202 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 48 | |
| 49 | |
| 50 | #if defined(__cplusplus) |
| 51 | } /* extern C */ |
| 52 | #endif |
| 53 | |
| 54 | #endif /* OPENSSL_HEADER_POLY1305_H */ |