Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:14

0001 /* balloon.h
0002 
0003    Balloon password-hashing algorithm.
0004 
0005    Copyright (C) 2022 Zoltan Fridrich
0006    Copyright (C) 2022 Red Hat, Inc.
0007 
0008    This file is part of GNU Nettle.
0009 
0010    GNU Nettle is free software: you can redistribute it and/or
0011    modify it under the terms of either:
0012 
0013      * the GNU Lesser General Public License as published by the Free
0014        Software Foundation; either version 3 of the License, or (at your
0015        option) any later version.
0016 
0017    or
0018 
0019      * the GNU General Public License as published by the Free
0020        Software Foundation; either version 2 of the License, or (at your
0021        option) any later version.
0022 
0023    or both in parallel, as here.
0024 
0025    GNU Nettle is distributed in the hope that it will be useful,
0026    but WITHOUT ANY WARRANTY; without even the implied warranty of
0027    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0028    General Public License for more details.
0029 
0030    You should have received copies of the GNU General Public License and
0031    the GNU Lesser General Public License along with this program.  If
0032    not, see http://www.gnu.org/licenses/.
0033 */
0034 
0035 /* For a description of the algorithm, see:
0036  * Boneh, D., Corrigan-Gibbs, H., Schechter, S. (2017, May 12). Balloon Hashing:
0037  * A Memory-Hard Function Providing Provable Protection Against Sequential Attacks.
0038  * Retrieved Sep 1, 2022, from https://eprint.iacr.org/2016/027.pdf
0039  */
0040 
0041 #ifndef NETTLE_BALLOON_H_INCLUDED
0042 #define NETTLE_BALLOON_H_INCLUDED
0043 
0044 #include "nettle-types.h"
0045 
0046 #ifdef __cplusplus
0047 extern "C" {
0048 #endif
0049 
0050 /* Name mangling */
0051 #define balloon nettle_balloon
0052 #define balloon_itch nettle_balloon_itch
0053 #define balloon_sha1 nettle_balloon_sha1
0054 #define balloon_sha256 nettle_balloon_sha256
0055 #define balloon_sha384 nettle_balloon_sha384
0056 #define balloon_sha512 nettle_balloon_sha512
0057 
0058 void
0059 balloon(void *hash_ctx,
0060         nettle_hash_update_func *update,
0061         nettle_hash_digest_func *digest,
0062         size_t digest_size, size_t s_cost, size_t t_cost,
0063         size_t passwd_length, const uint8_t *passwd,
0064         size_t salt_length, const uint8_t *salt,
0065         uint8_t *scratch, uint8_t *dst);
0066 
0067 size_t
0068 balloon_itch(size_t digest_size, size_t s_cost);
0069 
0070 void
0071 balloon_sha1(size_t s_cost, size_t t_cost,
0072              size_t passwd_length, const uint8_t *passwd,
0073              size_t salt_length, const uint8_t *salt,
0074              uint8_t *scratch, uint8_t *dst);
0075 
0076 void
0077 balloon_sha256(size_t s_cost, size_t t_cost,
0078                size_t passwd_length, const uint8_t *passwd,
0079                size_t salt_length, const uint8_t *salt,
0080                uint8_t *scratch, uint8_t *dst);
0081 
0082 void
0083 balloon_sha384(size_t s_cost, size_t t_cost,
0084                size_t passwd_length, const uint8_t *passwd,
0085                size_t salt_length, const uint8_t *salt,
0086                uint8_t *scratch, uint8_t *dst);
0087 
0088 void
0089 balloon_sha512(size_t s_cost, size_t t_cost,
0090                size_t passwd_length, const uint8_t *passwd,
0091                size_t salt_length, const uint8_t *salt,
0092                uint8_t *scratch, uint8_t *dst);
0093 
0094 #ifdef __cplusplus
0095 }
0096 #endif
0097 
0098 #endif /* NETTLE_BALLOON_H_INCLUDED */