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
        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


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


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.

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.