poly1305.h (1819B)
1 // Copyright 2014 The BoringSSL Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef OPENSSL_HEADER_POLY1305_H 16 #define OPENSSL_HEADER_POLY1305_H 17 18 #include <openssl/base.h> // IWYU pragma: export 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 25 typedef uint8_t poly1305_state[512]; 26 27 // 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. 31 OPENSSL_EXPORT void CRYPTO_poly1305_init(poly1305_state *state, 32 const uint8_t key[32]); 33 34 // CRYPTO_poly1305_update processes |in_len| bytes from |in|. It can be called 35 // zero or more times after poly1305_init. 36 OPENSSL_EXPORT void CRYPTO_poly1305_update(poly1305_state *state, 37 const uint8_t *in, size_t in_len); 38 39 // CRYPTO_poly1305_finish completes the poly1305 calculation and writes a 16 40 // byte authentication tag to |mac|. 41 OPENSSL_EXPORT void CRYPTO_poly1305_finish(poly1305_state *state, 42 uint8_t mac[16]); 43 44 45 #if defined(__cplusplus) 46 } // extern C 47 #endif 48 49 #endif // OPENSSL_HEADER_POLY1305_H