1 /* hmac.h -- hashed message authentication codes 2 Copyright (C) 2005, 2009-2021 Free Software Foundation, Inc. 3 4 This file is free software: you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 2.1 of the 7 License, or (at your option) any later version. 8 9 This file is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public License 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 17 /* Written by Simon Josefsson. */ 18 19 #ifndef HMAC_H 20 # define HMAC_H 1 21 22 #include <stddef.h> 23 24 /* Compute Hashed Message Authentication Code with MD5, as described 25 in RFC 2104, over BUFFER data of BUFLEN bytes using the KEY of 26 KEYLEN bytes, writing the output to pre-allocated 16 byte minimum 27 RESBUF buffer. Return 0 on success. */ 28 int 29 hmac_md5 (const void *key, size_t keylen, 30 const void *buffer, size_t buflen, void *restrict resbuf); 31 32 /* Compute Hashed Message Authentication Code with SHA-1, over BUFFER 33 data of BUFLEN bytes using the KEY of KEYLEN bytes, writing the 34 output to pre-allocated 20 byte minimum RESBUF buffer. Return 0 on 35 success. */ 36 int 37 hmac_sha1 (const void *key, size_t keylen, 38 const void *in, size_t inlen, void *restrict resbuf); 39 40 /* Compute Hashed Message Authentication Code with SHA-256, over BUFFER 41 data of BUFLEN bytes using the KEY of KEYLEN bytes, writing the 42 output to pre-allocated 32 byte minimum RESBUF buffer. Return 0 on 43 success. */ 44 int 45 hmac_sha256 (const void *key, size_t keylen, 46 const void *in, size_t inlen, void *restrict resbuf); 47 48 /* Compute Hashed Message Authentication Code with SHA-512, over BUFFER 49 data of BUFLEN bytes using the KEY of KEYLEN bytes, writing the 50 output to pre-allocated 64 byte minimum RESBUF buffer. Return 0 on 51 success. */ 52 int 53 hmac_sha512 (const void *key, size_t keylen, 54 const void *in, size_t inlen, void *restrict resbuf); 55 56 #endif /* HMAC_H */