blob: a38ef21788529635172c885f03de270fd80abc6b [file] [log] [blame]
Adam Langleyde0b2022014-06-20 12:00:00 -07001/* 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
David Benjamin3c4a5cb2016-03-29 17:43:31 -040025typedef uint8_t poly1305_state[512];
Adam Langleyde0b2022014-06-20 12:00:00 -070026
David Benjamin4512b792017-08-18 19:21:50 -040027// 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.
David Benjamin056035e2020-01-02 16:07:28 -050031OPENSSL_EXPORT void CRYPTO_poly1305_init(poly1305_state *state,
David Benjamin723f3532015-07-10 14:52:20 -040032 const uint8_t key[32]);
Adam Langleyde0b2022014-06-20 12:00:00 -070033
David Benjamin4512b792017-08-18 19:21:50 -040034// CRYPTO_poly1305_update processes |in_len| bytes from |in|. It can be called
35// zero or more times after poly1305_init.
David Benjamin056035e2020-01-02 16:07:28 -050036OPENSSL_EXPORT void CRYPTO_poly1305_update(poly1305_state *state,
37 const uint8_t *in, size_t in_len);
Adam Langleyde0b2022014-06-20 12:00:00 -070038
David Benjamin4512b792017-08-18 19:21:50 -040039// CRYPTO_poly1305_finish completes the poly1305 calculation and writes a 16
David Benjamin056035e2020-01-02 16:07:28 -050040// byte authentication tag to |mac|.
41OPENSSL_EXPORT void CRYPTO_poly1305_finish(poly1305_state *state,
David Benjamin723f3532015-07-10 14:52:20 -040042 uint8_t mac[16]);
Adam Langleyde0b2022014-06-20 12:00:00 -070043
44
45#if defined(__cplusplus)
David Benjamin4512b792017-08-18 19:21:50 -040046} // extern C
Adam Langleyde0b2022014-06-20 12:00:00 -070047#endif
48
David Benjamin4512b792017-08-18 19:21:50 -040049#endif // OPENSSL_HEADER_POLY1305_H