Score:0

How to use Argon2 with salt from binary file?

br flag

In the Linux program Argon2, we need to supply the salt in the command line. This limits the salt to be printable characters. How can we use a binary string as the salt?

# argon2 -h

Usage:  argon2 [-h] salt [-i|-d|-id] [-t iterations] [-m log2(memory in KiB) | -k memory in KiB] [-p parallelism] [-l hash length] [-e|-r] [-v (10|13)]
        Password is read from stdin
Parameters:
        salt            The salt to use, at least 8 characters
        -i              Use Argon2i (this is the default)
        -d              Use Argon2d instead of Argon2i
        -id             Use Argon2id instead of Argon2i
        -t N            Sets the number of iterations to N (default = 3)
        -m N            Sets the memory usage of 2^N KiB (default 12)
        -k N            Sets the memory usage of N KiB (default 4096)
        -p N            Sets parallelism to N threads (default 1)
        -l N            Sets hash output length to N bytes (default 32)
        -e              Output only encoded hash
        -r              Output only the raw bytes of the hash
        -v (10|13)      Argon2 version (defaults to the most recent version, currently 13)
        -h              Print argon2 usage

I tried using \x0A notation does not work. As see below, \x0A and \x0a produce different hashes.

# cat /tmp/keyfile | argon2 "\x0A\x0B\x0C\x0D\x1A\x1B\x1C\x1D" -id -t 4 -m 5 -p 1 -l 64 -r

6694bba14b3955a77beea3fb4c6018bd86953627949df2bc7e57bc7597519d2fed64a24380757bf6d963115656ce0ddcf59b2504b736036c239101c3e069849b

# cat /tmp/keyfile | argon2 "\x0a\x0B\x0C\x0D\x1A\x1B\x1C\x1D" -id -t 4 -m 5 -p 1 -l 64 -r 

3e97b90537a9ecdceaee638aee2b122c89a2cc3e03630bac31cf72c9b7e3e0565a4c3945eb7fc2a04922bb1453cc5fdafc3303327097749b0ceb87111cd1349c

For extra information, I would like to use Argon to simulate LUKS's PBKDF.

br flag
I found a partial solution: `eval 'cat /tmp/keyfile | argon2 '$(printf "\xab\xbc\x1b\x5b\xd9\x19\x2b\xce\x04\x59\x1c\x31\x97\xcc\x03\xd9\x13\x5a\x6f\x54\x6a\x1b\x81\xb8\xc6\x93\x0e\x19\xd1\xa0\x0c\x15")' -id -t 4 -m 5 -p 1 -l 64'`. But if the hex is `` " ' ( )` it will break. So I have to `grep` to check if it contains those hex, by `grep -e ' 60 ' -e ' 27 ' -e ' 22 ' -e ' 28 ' -e ' 29 '`.
SAI Peregrinus avatar
si flag
POSIX Shell escape sequences are octal, not hex.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.