1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

Add implementation of the Argon2 password hash.

This is going to be used in the new version of the PPK file format. It
was the winner of the Password Hashing Context, which I think makes it
a reasonable choice.

Argon2 comes in three flavours: one with no data dependency in its
memory addressing, one with _deliberate_ data dependency (intended to
serialise computation, to hinder parallel brute-forcing), and a hybrid
form that starts off data-independent and then switches over to the
dependent version once the sensitive input data has been adequately
mixed around. I test all three in the test suite; the side-channel
tester can only expect Argon2i to pass; and, following the spec's
recommendation, I'll be using Argon2id for the actual key file
encryption.
This commit is contained in:
Simon Tatham
2021-02-13 17:30:12 +00:00
parent 5c8f3bf924
commit 0faeb82ccd
8 changed files with 882 additions and 2 deletions

12
ssh.h
View File

@ -930,6 +930,18 @@ struct ssh2_userkey {
char *comment; /* the key comment */
};
/* Argon2 password hashing function */
typedef enum { Argon2d = 0, Argon2i = 1, Argon2id = 2 } Argon2Flavour;
void argon2(Argon2Flavour, uint32_t mem, uint32_t passes,
uint32_t parallel, uint32_t taglen,
ptrlen P, ptrlen S, ptrlen K, ptrlen X, strbuf *out);
void argon2_choose_passes(
Argon2Flavour, uint32_t mem, uint32_t milliseconds, uint32_t *passes,
uint32_t parallel, uint32_t taglen, ptrlen P, ptrlen S, ptrlen K, ptrlen X,
strbuf *out);
/* The H' hash defined in Argon2, exposed just for testcrypt */
strbuf *argon2_long_hash(unsigned length, ptrlen data);
/* The maximum length of any hash algorithm. (bytes) */
#define MAX_HASH_LEN (114) /* longest is SHAKE256 with 114-byte output */