blake2.h (1957B)
1 // Copyright 2021 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_BLAKE2_H 16 #define OPENSSL_HEADER_BLAKE2_H 17 18 #include <openssl/base.h> // IWYU pragma: export 19 20 #if defined(__cplusplus) 21 extern "C" { 22 #endif 23 24 25 #define BLAKE2B256_DIGEST_LENGTH (256 / 8) 26 #define BLAKE2B_CBLOCK 128 27 28 struct blake2b_state_st { 29 uint64_t h[8]; 30 uint64_t t_low, t_high; 31 uint8_t block[BLAKE2B_CBLOCK]; 32 size_t block_used; 33 }; 34 35 // BLAKE2B256_Init initialises |b2b| to perform a BLAKE2b-256 hash. There are no 36 // pointers inside |b2b| thus release of |b2b| is purely managed by the caller. 37 OPENSSL_EXPORT void BLAKE2B256_Init(BLAKE2B_CTX *b2b); 38 39 // BLAKE2B256_Update appends |len| bytes from |data| to the digest being 40 // calculated by |b2b|. 41 OPENSSL_EXPORT void BLAKE2B256_Update(BLAKE2B_CTX *b2b, const void *data, 42 size_t len); 43 44 // BLAKE2B256_Final completes the digest calculated by |b2b| and writes 45 // |BLAKE2B256_DIGEST_LENGTH| bytes to |out|. 46 OPENSSL_EXPORT void BLAKE2B256_Final(uint8_t out[BLAKE2B256_DIGEST_LENGTH], 47 BLAKE2B_CTX *b2b); 48 49 // BLAKE2B256 writes the BLAKE2b-256 digset of |len| bytes from |data| to 50 // |out|. 51 OPENSSL_EXPORT void BLAKE2B256(const uint8_t *data, size_t len, 52 uint8_t out[BLAKE2B256_DIGEST_LENGTH]); 53 54 55 #if defined(__cplusplus) 56 } // extern C 57 #endif 58 59 #endif // OPENSSL_HEADER_BLAKE2_H