blob: cefe2b1c7bbd90242be13c566d600e8f7c045f6f [file] [log] [blame]
Adam Langleyd9e397b2015-01-22 14:27:53 -08001/* 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
21extern "C" {
22#endif
23
24
Kenny Rootb8494592015-09-25 02:29:14 +000025typedef uint8_t poly1305_state[512];
Adam Langleyd9e397b2015-01-22 14:27:53 -080026
Robert Sloan8f860b12017-08-28 07:37:06 -070027// CRYPTO_poly1305_init sets up |state| so that it can be used to calculate an
28// authentication tag with the one-time key |key|. Note that |key| is a
29// one-time key and therefore there is no `reset' method because that would
30// enable several messages to be authenticated with the same key.
Kenny Rootb8494592015-09-25 02:29:14 +000031OPENSSL_EXPORT void CRYPTO_poly1305_init(poly1305_state* state,
32 const uint8_t key[32]);
Adam Langleyd9e397b2015-01-22 14:27:53 -080033
Robert Sloan8f860b12017-08-28 07:37:06 -070034// CRYPTO_poly1305_update processes |in_len| bytes from |in|. It can be called
35// zero or more times after poly1305_init.
Kenny Rootb8494592015-09-25 02:29:14 +000036OPENSSL_EXPORT void CRYPTO_poly1305_update(poly1305_state* state,
37 const uint8_t* in,
38 size_t in_len);
Adam Langleyd9e397b2015-01-22 14:27:53 -080039
Robert Sloan8f860b12017-08-28 07:37:06 -070040// CRYPTO_poly1305_finish completes the poly1305 calculation and writes a 16
41// byte authentication tag to |mac|. The |mac| address must be 16-byte
42// aligned.
Kenny Rootb8494592015-09-25 02:29:14 +000043OPENSSL_EXPORT void CRYPTO_poly1305_finish(poly1305_state* state,
44 uint8_t mac[16]);
Adam Langleyd9e397b2015-01-22 14:27:53 -080045
46
47#if defined(__cplusplus)
Robert Sloan8f860b12017-08-28 07:37:06 -070048} // extern C
Adam Langleyd9e397b2015-01-22 14:27:53 -080049#endif
50
Robert Sloan8f860b12017-08-28 07:37:06 -070051#endif // OPENSSL_HEADER_POLY1305_H