NAME=rahash2 -a entropy
FILE=-
CMDS=!rahash2 -a entropy bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 entropy: 3.27819072
EOF
RUN

NAME=rahash2 -a ssdeep
FILE=-
CMDS=!rahash2 -a ssdeep bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 ssdeep: 96:aPsZ7JSRX4hHmfSz/XWwZpxI9LGr5lar87cZGbbgb:aPeJiam6zWQpxKLElZE
EOF
RUN

NAME=rahash2 -a md5
FILE=-
CMDS=!rahash2 -a md5 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 md5: c957bd5bd6204470256bc15248ccafd4
EOF
RUN

NAME=rahash2 -a sha1
FILE=-
CMDS=!rahash2 -a sha1 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 sha1: 687c82d13cb27f0600d8e57edc784282c1732f56
EOF
RUN

NAME=rahash2 -a sha256
FILE=-
CMDS=!rahash2 -a sha256 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 sha256: 7bdbf25324af1946ec0b16dbf928875a588a786f7c279cd115729c5a3a297a55
EOF
RUN

NAME=rahash2 -a sha384
FILE=-
CMDS=!rahash2 -a sha384 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 sha384: a6fed224b0b5892ab44839b5ae6a12e54fb3393b5f1e1ca174fb5a0032c994f1c492c5b3a090518d8a60875223977ba4
EOF
RUN

NAME=rahash2 -a sha512
FILE=-
CMDS=!rahash2 -a sha512 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 sha512: 2640b1ff96870fb78a3d8ae6b51595ca86c37e25443b2e8c5441e77d11cdb3830ece8d791561c22788d37d7f22c99cdabf8f798826c0ff441901e6157890fee6
EOF
RUN

NAME=rahash2 -a md5,sha1,sha256 -r
FILE=-
CMDS=!rahash2 -a md5,sha1,sha256 -r bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: CC file md5:c957bd5bd6204470256bc15248ccafd4
bins/elf/analysis/hello-linux-x86_64: CC file sha1:687c82d13cb27f0600d8e57edc784282c1732f56
bins/elf/analysis/hello-linux-x86_64: CC file sha256:7bdbf25324af1946ec0b16dbf928875a588a786f7c279cd115729c5a3a297a55
EOF
RUN

NAME=rahash2 -b10 -a md5,sha1,sha256 -r
FILE=-
CMDS=!rahash2 -b10 -a md5,sha1,sha256 -r bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: CC file md5:c957bd5bd6204470256bc15248ccafd4
bins/elf/analysis/hello-linux-x86_64: CC file sha1:687c82d13cb27f0600d8e57edc784282c1732f56
bins/elf/analysis/hello-linux-x86_64: CC file sha256:7bdbf25324af1946ec0b16dbf928875a588a786f7c279cd115729c5a3a297a55
EOF
RUN

NAME=rahash2 -h
FILE=-
CMDS=!rahash2~Usage
EXPECT=<<EOF
Usage: rahash2 [-BehjkLqrvX] [-b S] [-a A] [-c H] [-E A] [-s S] [-f O] [-t O] [file] ...
EOF
RUN

NAME=rahash2 -a md5 -s "admin"
FILE=-
CMDS=!rahash2 -a md5 -s "admin"
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -a md5 -e -s "admin"
FILE=-
CMDS=!rahash2 -a md5 -e -s "admin"
EXPECT=<<EOF
0x00000000-0x00000004 md5: c31f804a0e4a8943a7a5577a292f2321
EOF
RUN

NAME=rahash2 -a sha1,sha256 -s "admin"
FILE=-
CMDS=!rahash2 -a sha1,sha256 -s "admin"
EXPECT=<<EOF
0x00000000-0x00000004 sha1: d033e22ae348aeb5660fc2140aec35850c4da997
0x00000000-0x00000004 sha256: 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
EOF
RUN

NAME=rahash2 -D base64 -s "YWRtaW4="
FILE=-
CMDS=!rahash2 -D base64 -s "YWRtaW4="
EXPECT=admin
RUN

NAME=rahash2 -E base64 -s "admin"
FILE=-
CMDS=!rahash2 -E base64 -s "admin"
EXPECT=YWRtaW4=
RUN

NAME=rahash2 -E base64 -x "61646d696e"
FILE=-
CMDS=!rahash2 -E base64 -x "61646d696e"
EXPECT=YWRtaW4=
RUN

NAME=rahash2 -a md5 -x "61646d696e"
FILE=-
CMDS=!rahash2 -a md5 -x "61646d696e"
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -a md5 -x "61646d696e" -s "admin"
FILE=-
CMDS=!rahash2 -a md5 -x "61646d696e" -s "admin"
EXPECT=
EXPECT_ERR=<<EOF
WARN: Hashstring already defined
EOF
RUN

NAME=rahash2 -a luhn -s "5105105105105100"
FILE=-
CMDS=!rahash2 -a luhn -s "5105105105105100"
EXPECT=<<EOF
0x00000000-0x0000000f luhn: 00
EOF
RUN

NAME=rahash2 -a luhn -s "4408041234567890"
FILE=-
CMDS=!rahash2 -a luhn -s "4408041234567890"
EXPECT=<<EOF
0x00000000-0x0000000f luhn: 07
EOF
RUN

NAME=rahash2 -L
FILE=-
CMDS=!rahash2 -L
EXPECT=<<EOF
hash          add  Add checksum used by Tar (sum all bytes into ut32)
cryp      aes-ecb  Rijndael block cipher with Electronic Code Book mode
cryp      aes-cbc  Rijndael block cipher with Cipher Block Chaining mode
cryp     aes-wrap  Rijndael block cipher with Key Wrap Algorithm (RFC 3394)
cryp       base64  Binary to text encoding scheme using 64 ascii characters
base       base91  Binary to text encoding scheme using 91 ascii characters
base       bech32  
cryp     blowfish  Bruce Schneier's symetric-key block cipher
char      pokemon  Transcode from/to Pokémon charset used in Gen 1 games
cryp         cps2  Capcom Play System 2
cryp      des-ecb  DES with with Electronic Code Book mode
sign      ed25519  Elliptic curve pubkey cryptographic algorithm used for signing and verification
hash      entropy  Shannon entropy
hash         null  mutate nothing
char     punycode  Unicoded represented in plain ascii
cryp          rc2  Ron Rivest's Code symmetric key encryption also known as ARC2
cryp          rc4  Rivest Cipher 4
cryp          rc6  Rivest's Cipher 6
cryp          rol  Rotate Left N bits
cryp          ror  Rotate Right N bits
cryp          rot  Rotate Encryption
cryp  serpent-ecb  Serpent block cipher with Electronic Code Book mode
hash          sip  SipHash-2-4
cryp      sm4-ecb  ShāngMì4 block cipher with Electronic Code Book mode
hash      strhash  String hash using a modified DJB2 xor
cryp          xor  Byte level Exclusive Or
hash          md5
hash         sha1
hash       sha256
hash       sha384
hash       sha512
hash          md4
hash          xor
hash      xorpair
hash       parity
hash      entropy
hash      hamdist
hash      pcprint
hash       mod255
hash       xxhash
hash      adler32
hash         luhn
hash       ssdeep
hash    crc8smbus
hash     crc15can
hash        crc16
hash    crc16hdlc
hash     crc16usb
hash    crc16citt
hash        crc24
hash        crc32
hash       crc32c
hash crc32ecma267
hash   crc32bzip2
hash       crc32d
hash   crc32mpeg2
hash   crc32posix
hash       crc32q
hash  crc32jamcrc
hash    crc32xfer
hash        crc64
hash    crc64ecma
hash      crc64we
hash      crc64xz
hash     crc64iso
hash    fletcher8
hash   fletcher16
hash   fletcher32
hash   fletcher64
hash          elf
EOF
RUN

NAME=rahash2 -a md5 -t0x4 -x "61646d696eaa"
FILE=-
CMDS=!rahash2 -a md5 -t0x4 -x "61646d696eaa"
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -q -a md5 -t0x4 -x "61646d696eaa"
FILE=-
CMDS=!rahash2 -q -a md5 -t0x4 -x "61646d696eaa"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -q -a md5 -f0x1 -x "aa61646d696e"
FILE=-
CMDS=!rahash2 -q -a md5 -f0x1 -x "aa61646d696e"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -q -a md5 -i1 -x "61646d696e"
FILE=-
CMDS=!rahash2 -q -a md5 -i1 -x "61646d696e"
EXPECT=<<EOF
43442676c74ae59f219c2d87fd6bad52
EOF
RUN

NAME=rahash2 -q -a md5 -i2 -x "61646d696e"
FILE=-
CMDS=!rahash2 -q -a md5 -i2 -x "61646d696e"
EXPECT=<<EOF
9fec80fbcee7632ce78d1586332b299e
EOF
RUN

NAME=rahash2 -a md5 -t0x4 -s "admina"
FILE=-
CMDS=!rahash2 -a md5 -t0x4 -s "admina"
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -q -a md5 -t0x4 -s "admina"
FILE=-
CMDS=!rahash2 -q -a md5 -t0x4 -s "admina"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -q -a md5 -f0x1 -s "aadmin"
FILE=-
CMDS=!rahash2 -q -a md5 -f0x1 -s "aadmin"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -q -a md5 -i1 -s "admin"
FILE=-
CMDS=!rahash2 -q -a md5 -i1 -s "admin"
EXPECT=<<EOF
43442676c74ae59f219c2d87fd6bad52
EOF
RUN

NAME=rahash2 -q -a md5 -i2 -s "admin"
FILE=-
CMDS=!rahash2 -q -a md5 -i2 -s "admin"
EXPECT=<<EOF
9fec80fbcee7632ce78d1586332b299e
EOF
RUN

NAME=rahash2 -q -a md5 -f0x1 -t0x5 -s "aadmina"
FILE=-
CMDS=!rahash2 -q -a md5 -f0x1 -t0x5 -s "aadmina"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -q -a md5 -f0x1 -t0x5 -x "aa61646d696eaa"
FILE=-
CMDS=!rahash2 -q -a md5 -f0x1 -t0x5 -x "aa61646d696eaa"
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=printf "admin" | rahash2 -q -a md5 -s -
FILE=-
CMDS=!printf "admin" | rahash2 -q -a md5 -s -
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=printf "aadmina" | rahash2 -f0x1 -t0x5 -q -a md5 -s -
FILE=-
CMDS=!printf "aadmina" | rahash2 -f0x1 -t0x5 -q -a md5 -s -
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=printf "aa61646d696eaa" | rahash2 -f0x1 -t0x5 -q -a md5 -x -
FILE=-
CMDS=!printf "aa61646d696eaa" | rahash2 -f0x1 -t0x5 -q -a md5 -x -
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -f0x1 -t0x5 -q -a md5 admin.txt
FILE=bins/other/admin.txt
CMDS=!rahash2 -f0x1 -t0x5 -q -a md5 bins/other/admin.txt
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3 bins/other/admin.txt
EOF
RUN

NAME=rahash2 -f0x1 -t0x5 -qq -a md5 admin.txt
FILE=bins/other/admin.txt
CMDS=!rahash2 -f0x1 -t0x5 -qq -a md5 bins/other/admin.txt
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -Bb 1 -a md5 admin.txt
FILE=bins/other/admin.txt
CMDS=!rahash2 -Bb 1 -a md5 bins/other/admin.txt
EXPECT=<<EOF
0x00000000-0x00000000 md5: 0cc175b9c0f1b6a831c399e269772661
0x00000001-0x00000001 md5: 0cc175b9c0f1b6a831c399e269772661
0x00000002-0x00000002 md5: 8277e0910d750195b448797616e091ad
0x00000003-0x00000003 md5: 6f8f57715090da2632453988d9a1501b
0x00000004-0x00000004 md5: 865c0c0b4ab0e063e5caa3387c1a8741
0x00000005-0x00000005 md5: 7b8b965ad4bca0e41ab51de7b31363a1
0x00000006-0x00000006 md5: 0cc175b9c0f1b6a831c399e269772661
EOF
RUN

NAME=rahash2 -v~commit?"
FILE=-
CMDS=!!rahash2 -v~commit?
EXPECT=<<EOF
1
EOF
RUN

NAME=rahash2 -s hello1
FILE=-
CMDS=!rahash2 -qa md5 -s hello1
EXPECT=<<EOF
203ad5ffa1d7c650ad681fdff3965cd2
EOF
RUN

NAME=rahash2 -s hello\x31
FILE=-
CMDS=!rahash2 -qa md5 -s "hello\x31"
EXPECT=<<EOF
203ad5ffa1d7c650ad681fdff3965cd2
EOF
RUN

NAME=rahash2 zero length hashes md5
FILE=-
CMDS=!rahash2 -a md5 -s ""
EXPECT=<<EOF
0x00000000-0x00000000 md5: d41d8cd98f00b204e9800998ecf8427e
EOF
RUN

NAME=rahash2 zero length hashes sha1
FILE=-
CMDS=!rahash2 -a sha1 -s ""
EXPECT=<<EOF
0x00000000-0x00000000 sha1: da39a3ee5e6b4b0d3255bfef95601890afd80709
EOF
RUN

NAME=rahash2 -c with correct expected hash
FILE=-
CMDS=!rahash2 -a md5 -s "admin" -c 21232f297a57a5a743894a0e4a801fc3
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -c with incorrect expected hash
FILE=-
CMDS=!rahash2 -a md5 -s "admin" -c 21232f297a57a5a743894a0e4a801fc4
EXPECT=<<EOF
0x00000000-0x00000004 md5: 21232f297a57a5a743894a0e4a801fc3
EOF
EXPECT_ERR=<<EOF
WARN: Computed hash doesn't match the expected one
EOF
RUN

NAME=rahash2 -c with correct expected hash and quiet
FILE=-
CMDS=!rahash2 -q -a md5 -s "admin" -c 21232f297a57a5a743894a0e4a801fc3
EXPECT=<<EOF
21232f297a57a5a743894a0e4a801fc3
EOF
RUN

NAME=rahash2 -c with missing nibble
FILE=-
CMDS=!rahash2 -a md5 -s "admin" -c 21232f297a57a5a743894a0e4a801fc
EXPECT=
EXPECT_ERR=<<EOF
ERROR: Invalid -c hex hash
EOF
RUN

NAME=rahash2 -c with incorrect md5 hash length
FILE=-
CMDS=!rahash2 -a md5 -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=
EXPECT_ERR=<<EOF
ERROR: Given -c hash has 15 byte(s) but the selected algorithm returns 16 byte(s)
EOF
RUN

NAME=rahash2 -c with incorrect sha1 hash length
FILE=-
CMDS=!rahash2 -a sha1 -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=
EXPECT_ERR=<<EOF
ERROR: Given -c hash has 15 byte(s) but the selected algorithm returns 20 byte(s)
EOF
RUN

NAME=rahash2 -c with 2 hash algorithms
FILE=-
CMDS=!rahash2 -a md5,sha1 -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=
EXPECT_ERR=<<EOF
ERROR: Option -c incompatible with multiple algorithms in -a
EOF
RUN

NAME=rahash2 -c with all hash algorithms
FILE=-
CMDS=!rahash2 -a all -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=
EXPECT_ERR=<<EOF
ERROR: Option -c incompatible with multiple algorithms in -a
EOF
RUN

NAME=rahash2 -c with custom block size and per-block hash
FILE=-
CMDS=!rahash2 -b 1 -B -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=
EXPECT_ERR=<<EOF
ERROR: Option -c incompatible with -b and -B options
EOF
RUN

NAME=rahash2 -c with base64 encoding
FILE=-
CMDS=!rahash2 -E base64 -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=
EXPECT_ERR=<<EOF
ERROR: Option -c incompatible with -E base64, -E base91, -D base64 or -D base91 options
EOF
RUN

NAME=rahash2 -c with base64 decoding
FILE=-
CMDS=!rahash2 -D base64 -s "admin" -c 21232f297a57a5a743894a0e4a801f
EXPECT=
EXPECT_ERR=<<EOF
ERROR: Option -c incompatible with -E base64, -E base91, -D base64 or -D base91 options
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST
NAME=rahash2 of "abc" using sha256
FILE=-
CMDS=!rahash2 -a sha256 -s "abc"
EXPECT=<<EOF
0x00000000-0x00000002 sha256: ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST
NAME=rahash2 of "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" using sha256
FILE=-
CMDS=!rahash2 -a sha256 -s "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
EXPECT=<<EOF
0x00000000-0x00000037 sha256: 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST
NAME=rahash2 of "abc" using sha512
FILE=-
CMDS=!rahash2 -a sha512 -s "abc"
EXPECT=<<EOF
0x00000000-0x00000002 sha512: ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST
NAME=rahash2 of "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" using sha512
FILE=-
CMDS=!rahash2 -a sha512 -s "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
EXPECT=<<EOF
0x00000000-0x0000006f sha512: 8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST3
NAME=rahash2 of "abc" using sha384
FILE=-
CMDS=!rahash2 -a sha384 -s "abc"
EXPECT=<<EOF
0x00000000-0x00000002 sha384: cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7
EOF
RUN

# Taken from "Descriptions of SHA-256, SHA-384, and SHA-512" by NIST
NAME=rahash2 of "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" using sha384
FILE=-
CMDS=!rahash2 -a sha384 -s "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
EXPECT=<<EOF
0x00000000-0x0000006f sha384: 09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039
EOF
RUN

NAME=rahash2 of empty string using sha256
FILE=-
CMDS=!rahash2 -a sha256 -s ""
EXPECT=<<EOF
0x00000000-0x00000000 sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
EOF
RUN

NAME=rahash2 of empty string using sha384
FILE=-
CMDS=!rahash2 -a sha384 -s ""
EXPECT=<<EOF
0x00000000-0x00000000 sha384: 38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b
EOF
RUN

NAME=rahash2 of empty string using sha512
FILE=-
CMDS=!rahash2 -a sha512 -s ""
EXPECT=<<EOF
0x00000000-0x00000000 sha512: cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
EOF
RUN

NAME=rahash2 -E RC4
FILE=-
CMDS=!rahash2 -S key -E rc4 -s hello" world\n" | rahash2 -S key -E rc4 -s -
EXPECT=<<EOF
hello world
EOF
RUN

NAME=rahash2 -E xor
FILE=-
CMDS=!rahash2 -S key -E xor -s hello" world\n" | rahash2 -S key -E xor -s -
EXPECT=<<EOF
hello world
EOF
RUN

NAME=rahash2 -E blowfish
FILE=-
CMDS=!rahash2 -S key -E blowfish -s hello" world 123\n" | rax2 -S
EXPECT=<<EOF
6ceced43fb2a72c9aa9447d193b00763
EOF
RUN

NAME=rahash2 -D blowfish
FILE=-
CMDS=!rahash2 -S key -E blowfish -s hello" world 123\n" | rahash2 -S key -D blowfish -s -
EXPECT=<<EOF
hello world 123
EOF
RUN

NAME=rahash2 -E aes-ecb 128 bit
FILE=-
CMDS=!rahash2 -E aes-ecb -S "11111111111111111111111111111111" -s "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") <(echo -en "\xff\x6f\xb5\xd9\x27\x6d\xe8\x38\x8e\x4b\x82\xa7\x73\xd0\xb5\x21\xff\x6f\xb5\xd9\x27\x6d\xe8\x38\x8e\x4b\x82\xa7\x73\xd0\xb5\x21\xff\x6f\xb5\xd9\x27\x6d\xe8\x38\x8e\x4b\x82\xa7\x73\xd0\xb5\x21\xff\x6f\xb5\xd9\x27\x6d\xe8\x38\x8e\x4b\x82\xa7\x73\xd0\xb5\x21")"
EXPECT=<<EOF
EOF
RUN

NAME=rahash2 -D aes-ecb 128 bit
FILE=-
CMDS=!rahash2 -E aes-ecb -S "11111111111111111111111111111111" -s "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" | rahash2 -D aes-ecb -S "11111111111111111111111111111111" -s -
EXPECT=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
RUN

NAME=rahash2 -E aes-ecb 192 bit
FILE=-
CMDS=!rahash2 -E aes-ecb -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -x "6bc1bee22e409f96e93d7e117393172a" | rax2 -S
EXPECT=<<EOF
bd334f1d6e45f25ff712a214571fa5cc
EOF
RUN

NAME=rahash2 -D aes-ecb 192 bit
FILE=-
CMDS=!rahash2 -E aes-ecb -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -x "6bc1bee22e409f96e93d7e117393172a" | rahash2 -D aes-ecb -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -s - | rax2 -S
EXPECT=<<EOF
6bc1bee22e409f96e93d7e117393172a
EOF
RUN

NAME=rahash2 -E aes-ecb 256 bit
FILE=-
CMDS=!rahash2 -E aes-ecb -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -x "6bc1bee22e409f96e93d7e117393172a" | rax2 -S
EXPECT=<<EOF
f3eed1bdb5d2a03c064b5a7e3db181f8
EOF
RUN

NAME=rahash2 -D aes-ecb 256 bit
FILE=-
CMDS=!rahash2 -E aes-ecb -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -x "6bc1bee22e409f96e93d7e117393172a" | rahash2 -D aes-ecb -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -s - | rax2 -S
EXPECT=<<EOF
6bc1bee22e409f96e93d7e117393172a
EOF
RUN

NAME=rahash2 -E aes-cbc 128 bit
FILE=-
CMDS=!rahash2 -E aes-cbc -S "2b7e151628aed2a6abf7158809cf4f3c" -I "7649ABAC8119B246CEE98E9B12E9197D"  -x "ae2d8a571e03ac9c9eb76fac45af8e51" | rax2 -S
EXPECT=<<EOF
5086cb9b507219ee95db113a917678b2
EOF
RUN

NAME=rahash2 -D aes-cbc 128 bit
FILE=-
CMDS=!rahash2 -E aes-cbc -S "2b7e151628aed2a6abf7158809cf4f3c" -I "7649ABAC8119B246CEE98E9B12E9197D"  -x "ae2d8a571e03ac9c9eb76fac45af8e51" | rahash2 -D aes-cbc -S "2b7e151628aed2a6abf7158809cf4f3c" -I "7649ABAC8119B246CEE98E9B12E9197D" -s - | rax2 -S
EXPECT=<<EOF
ae2d8a571e03ac9c9eb76fac45af8e51
EOF
RUN

NAME=rahash2 -E aes-cbc 192 bit
FILE=-
CMDS=!rahash2 -E aes-cbc -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -x "6bc1bee22e409f96e93d7e117393172a" -I "000102030405060708090A0B0C0D0E0F" | rax2 -S
EXPECT=<<EOF
4f021db243bc633d7178183a9fa071e8
EOF
RUN

NAME=rahash2 -D aes-cbc 192 bit
FILE=-
CMDS=!rahash2 -E aes-cbc -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -x "6bc1bee22e409f96e93d7e117393172a" -I "000102030405060708090A0B0C0D0E0F" | rahash2 -D aes-cbc -S 8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -I "000102030405060708090A0B0C0D0E0F" -s - | rax2 -S
EXPECT=<<EOF
6bc1bee22e409f96e93d7e117393172a
EOF
RUN

NAME=rahash2 -E aes-cbc 256 bit
FILE=-
CMDS=!rahash2 -E aes-cbc -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -x "f69f2445df4f9b17ad2b417be66c3710" -I "39F23369A9D9BACFA530E26304231461" | rax2 -S
EXPECT=<<EOF
b2eb05e2c39be9fcda6c19078c6a9d1b
EOF
RUN

NAME=rahash2 -D aes-cbc 256 bit
FILE=-
CMDS=!rahash2 -E aes-cbc -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -x "f69f2445df4f9b17ad2b417be66c3710" -I "39F23369A9D9BACFA530E26304231461" | rahash2 -D aes-cbc -S 603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 -I "39F23369A9D9BACFA530E26304231461" -s - | rax2 -S
EXPECT=<<EOF
f69f2445df4f9b17ad2b417be66c3710
EOF
RUN

NAME=rahash2 -E aes-wrap 128 bit
FILE=-
CMDS=!rahash2 -E aes-wrap -S 000102030405060708090A0B0C0D0E0F -x "00112233445566778899AABBCCDDEEFF" | rax2 -S
EXPECT=<<EOF
1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5
EOF
RUN

NAME=rahash2 -E aes-wrap 128 bit custom IV
FILE=-
CMDS=!rahash2 -E aes-wrap -S 000102030405060708090A0B0C0D0E0F -x "00112233445566778899AABBCCDDEEFF" -I "0011223344556677" | rahash2 -D aes-wrap -S 000102030405060708090A0B0C0D0E0F -I "0011223344556677" -s - | rax2 -S
EXPECT=<<EOF
00112233445566778899aabbccddeeff
EOF
RUN

NAME=rahash2 -D aes-wrap 128 bit
FILE=-
CMDS=!rahash2 -D aes-wrap -S 000102030405060708090A0B0C0D0E0F -x "1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5" | rax2 -S
EXPECT=<<EOF
00112233445566778899aabbccddeeff
EOF
RUN

NAME=rahash2 -D aes-wrap 128 bit invalid
FILE=-
CMDS=!rahash2 -D aes-wrap -S 000102030405060708090A0B0C0D0E0F -x "1FA68B0A8112B447AE934BD8FB5A7B829D3E862371D2CFE5" | rax2 -S
EXPECT=<<EOF
EOF
RUN

NAME=rahash2 -D aes-wrap 192 bit
FILE=-
CMDS=!rahash2 -D aes-wrap -S 000102030405060708090A0B0C0D0E0F1011121314151617 -x "96778B25AE6CA435F92B5B97C050AED2468AB8A17AD84E5D" | rax2 -S
EXPECT=<<EOF
00112233445566778899aabbccddeeff
EOF
RUN

NAME=rahash2 -E aes-wrap 256 bit
FILE=-
CMDS=!rahash2 -E aes-wrap -S 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F -x "00112233445566778899AABBCCDDEEFF000102030405060708090A0B0C0D0E0F" | rax2 -S
EXPECT=<<EOF
28c9f404c4b810f4cbccb35cfb87f8263f5786e2d80ed326cbc7f0e71a99f43bfb988b9b7a02dd21
EOF
RUN

NAME=rahash2 -E rot
FILE=-
CMDS=!rahash2 -E rot -S s:13 -s hello" world\n"
EXPECT=<<EOF
uryyb jbeyq
EOF
RUN

NAME=rahash2 -E rot negative key
FILE=-
CMDS=!rahash2 -E rot -S s:14 -s hello" world\n" | rahash2 -E rot -S s:-14 -s -
EXPECT=<<EOF
hello world
EOF
RUN

NAME=rahash2 -E rol
FILE=-
CMDS=!rahash2 -E rol -S 03 -x "31ed4989" | rax2 -S
EXPECT=<<EOF
896f4a4c
EOF
RUN

NAME=rahash2 -E ror
FILE=-
CMDS=!rahash2 -E ror -S 04 -x "62da9212" | rax2 -S
EXPECT=<<EOF
26ad2921
EOF
RUN

NAME=rahash2 -E base91
FILE=-
CMDS=!rahash2 -E base91 -s "hello world\n"
EXPECT=TPwJh>Io2Tv!^aB
RUN

NAME=rahash2 -D base91
FILE=-
CMDS=!rahash2 -E base91 -s "hello world" | rahash2 -D base91 -s -
EXPECT=hello world
RUN

NAME=rahash2 -E rc2
FILE=-
CMDS=!rahash2 -E rc2 -S key -s "helloworld123456" | rax2 -S 
EXPECT=<<EOF
a9c85c7650456d8f5f369704ad1e339f
EOF
RUN

NAME=rahash2 -D rc2
FILE=-
CMDS=!rahash2 -E rc2 -S key -s "helloworld123456" | rahash2 -D rc2 -S key -s -
EXPECT=helloworld123456
RUN

NAME=rahash2 -E punycode
FILE=-
CMDS=!rahash2 -E punycode -x 57696c6c73742064752064696520426cc3bc74686520646573206672c3bc68656e2c20646965204672c3bc6368746520646573207370c3a4746572656e204a6168726573
EXPECT=Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal
RUN

NAME=rahash2 -D punycode
FILE=-
CMDS=!rahash2 -D punycode -s "Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal" | rax2 -S
EXPECT=<<EOF
57696c6c73742064752064696520426cc3bc74686520646573206672c3bc68656e2c20646965204672c3bc6368746520646573207370c3a4746572656e204a6168726573
EOF
RUN

NAME=rahash2 -E punycode[1]
FILE=-
CMDS=!rahash2 -E punycode -x f09f918d
EXPECT=yp8h
RUN

NAME=rahash2 -D punycode[1]
FILE=-
CMDS=!rahash2 -D punycode -s yp8h | rax2 -S
EXPECT=<<EOF
f09f918d
EOF
RUN

NAME=rahash2 -E rc6 128 bit
FILE=-
CMDS=!rahash2 -E rc6 -S 0123456789abcdef0112233445566778 -x 02132435465768798a9bacbdcedfe0f1 | rax2 -S
EXPECT=<<EOF
524e192f4715c6231f51f6367ea43f18
EOF
RUN

NAME=rahash2 -D rc6 128 bit
FILE=-
CMDS=!rahash2 -D rc6 -S 0123456789abcdef0112233445566778 -x 524e192f4715c6231f51f6367ea43f18 | rax2 -S
EXPECT=<<EOF
02132435465768798a9bacbdcedfe0f1
EOF
RUN

NAME=rahash2 -E rc6 192 bit
FILE=-
CMDS=!rahash2 -E rc6 -S 0123456789abcdef0112233445566778899aabbccddeeff0 -x 02132435465768798a9bacbdcedfe0f1 | rax2 -S
EXPECT=<<EOF
688329d019e505041e52e92af95291d4
EOF
RUN

NAME=rahash2 -D rc6 192 bit
FILE=-
CMDS=!rahash2 -D rc6 -S 0123456789abcdef0112233445566778899aabbccddeeff0 -x 688329d019e505041e52e92af95291d4 | rax2 -S
EXPECT=<<EOF
02132435465768798a9bacbdcedfe0f1
EOF
RUN

NAME=rahash2 -E rc6 256 bit
FILE=-
CMDS=!rahash2 -E rc6 -S 0123456789abcdef0112233445566778899aabbccddeeff01032547698badcfe -x 02132435465768798a9bacbdcedfe0f1 | rax2 -S
EXPECT=<<EOF
c8241816f0d7e48920ad16a1674e5d48
EOF
RUN

NAME=rahash2 -D rc6 256 bit
FILE=-
CMDS=!rahash2 -D rc6 -S 0123456789abcdef0112233445566778899aabbccddeeff01032547698badcfe -x c8241816f0d7e48920ad16a1674e5d48 | rax2 -S
EXPECT=<<EOF
02132435465768798a9bacbdcedfe0f1
EOF
RUN

NAME=rahash2 -E cps2 8 byte
FILE=-
CMDS=!rahash2 -E cps2 -S "0x942a5702 0x05ac140e" -x 000000000000033244d31b9deba90ac1 | rax2 -S
EXPECT=<<EOF
d5642832bc24ac560000fe020000fe02
EOF
RUN

NAME=rahash2 -D cps2 8 byte
FILE=-
CMDS=!rahash2 -D cps2 -S "0x942a5702 0x05ac140e" -x d5642832bc24ac560000fe020000fe02 | rax2 -S
EXPECT=<<EOF
000000000000033244d31b9deba90ac1
EOF
RUN

NAME=rahash2 -E cps2 20 byte
FILE=-
CMDS=!rahash2 -E cps2 -S "0x010002400008704380000011C0A0D68103A950A4" -x 000000000000033244d31b9deba90ac1 | rax2 -S
EXPECT=<<EOF
d5642832bc24ac560000fe020000fe02
EOF
RUN

NAME=rahash2 -D cps2 20 byte
FILE=-
CMDS=!rahash2 -D cps2 -S "0x010002400008704380000011C0A0D68103A950A4" -x d5642832bc24ac560000fe020000fe02 | rax2 -S
EXPECT=<<EOF
000000000000033244d31b9deba90ac1
EOF
RUN

NAME=rahash2 -E des-ecb
FILE=-
CMDS=!rahash2 -E "des-ecb" -S "4545454545454545" -x "CC3368EE3DD10A86" | rax2 -S
EXPECT=<<EOF
4545454545454545
EOF
RUN

NAME=rahash2 -D des-ecb
FILE=-
CMDS=!rahash2 -D "des-ecb" -S "0101010101010101" -x "41AD068548809D02994D4DC157B96C52" | rax2 -S
EXPECT=<<EOF
b01c29502b59ff4a0101010101010101
EOF
RUN

NAME=rahash2 -E des-ecb STRING
FILE=-
CMDS=!rahash2 -E "des-ecb" -S s:"doom bin" -s "A password storms below a laid singer." | rax2 -S
EXPECT=<<EOF
8d244873a8e0de1287f65d712419cb937ff318a5352682e0c31d3e7a72c7e35f40c06d63fb5f2e5f
EOF
RUN

NAME=rahash2 -D des-ecb STRING
FILE=-
CMDS=!rahash2 -D "des-ecb" -S s:"savethat" -x "c3868da6e3d787c88e5a61a7c333cd802e5cee17d7b09555572a35e120fb8e36dc9f0722976934b9453a3a4e741f27c8"
EXPECT=How does a passionate magic wipe a reactionary?.
RUN

NAME=rahash2 -E serpent-ecb 128 bit
FILE=-
CMDS=!rahash2 -E serpent-ecb -S "BFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBF" -x "BFBFBFBFBFBFBFBFBFBFBFBFBFBFBFBF" | rax2 -S
EXPECT=<<EOF
af39614e747b9331c38b797f527ebea6
EOF
RUN

NAME=rahash2 -D serpent-ecb 128 bit
FILE=-
CMDS=!rahash2 -D serpent-ecb -S "2BD6459F82C5B300952C49104881FF48" -x "EA024714AD5C4D84EA024714AD5C4D84" | rax2 -S
EXPECT=<<EOF
beb6c069393822d3be73ff30525ec43e
EOF
RUN

NAME=rahash2 -E serpent-ecb 192 bit
FILE=-
CMDS=!rahash2 -E serpent-ecb -S "C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C7" -x "C6C6C6C6C6C6C6C6C6C6C6C6C6C6C6C7" | rax2 -S
EXPECT=<<EOF
844a4ef08b4354c52593d3e907a163f7
EOF
RUN

NAME=rahash2 -D serpent-ecb 192 bit
FILE=-
CMDS=!rahash2 -D serpent-ecb -S "2BD6459F82C5B300952C49104881FF482BD6459F82C5B300" -x "EA024714AD5C4D84EA024714AD5C4D84" | rax2 -S
EXPECT=<<EOF
e0208be278e21420c4b1b9747788a954
EOF
RUN

NAME=rahash2 -E serpent-ecb 256 bit
FILE=-
CMDS=!rahash2 -E serpent-ecb -S "5757575757575757575757575757575757575757575757575757575757575756" -x "57575757575757575757575757575756" | rax2 -S
EXPECT=<<EOF
d35588cf3d2e74f2a0df437ffa0073b3
EOF
RUN

NAME=rahash2 -D serpent-ecb 256 bit
FILE=-
CMDS=!rahash2 -D serpent-ecb -S "2BD6459F82C5B300952C49104881FF482BD6459F82C5B300952C49104881FF48" -x "EA024714AD5C4D84EA024714AD5C4D84" | rax2 -S
EXPECT=<<EOF
677c8dfaa08071743fd2b415d1b28af2
EOF
RUN

NAME=rahash2 -E serpent-ecb zero padding
FILE=-
CMDS=!rahash2 -E serpent-ecb -S "1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe" -x "101231" | rax2 -S
EXPECT=<<EOF
417dfc518e8146ea81b089731b56fefa
EOF
RUN

NAME=rahash2 -E sm4-ecb
FILE=-
CMDS=!rahash2 -E sm4-ecb -S "0123456789abcdeffedcba9876543210" -x "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeffffffffaaaaaaaabbbbbbbb" | rax2 -S
EXPECT=<<EOF
5ec8143de509cff7b5179f8f474b86192f1d305a7fb17df985f81c8482192304
EOF
RUN

NAME=rahash2 -a fletcher8 -s hello-world
FILE=-
CMDS=!rahash2 -a fletcher8 -s hello-world
EXPECT=<<EOF
0x00000000-0x0000000a fletcher8: 6d
EOF
RUN

NAME=rahash2 -a fletcher16 -s hello-world
FILE=-
CMDS=!rahash2 -a fletcher16 -s hello-world
EXPECT=<<EOF
0x00000000-0x0000000a fletcher16: 6d68
EOF
RUN

NAME=rahash2 -a fletcher32 -s hello-world
FILE=-
CMDS=!rahash2 -a fletcher32 -s hello-world
EXPECT=<<EOF
0x00000000-0x0000000a fletcher32: 91dbfc5b
EOF
RUN

NAME=rahash2 -a fletcher64 -s hello-world
FILE=-
CMDS=!rahash2 -a fletcher64 -s hello-world
EXPECT=<<EOF
0x00000000-0x0000000a fletcher64: 49ff47dc88f79724
EOF
RUN

NAME=rahash2 empty single path
FILE=-
CMDS=!rahash2 -a md5 ""
EXPECT_ERR=<<EOF
ERROR: Cannot open empty path
EOF
RUN

NAME=rahash2 empty second path
FILE=-
CMDS=!rahash2 -a md5 bins/elf/analysis/hello-linux-x86_64 ""
EXPECT=<<EOF
bins/elf/analysis/hello-linux-x86_64: 0x00000000-0x00001a35 md5: c957bd5bd6204470256bc15248ccafd4
EOF
EXPECT_ERR=<<EOF
ERROR: Cannot open empty path
EOF
RUN

NAME=rahash2 empty first file
FILE=-
CMDS=!rahash2 -a md5 "" bins/elf/analysis/hello-linux-x86_64
EXPECT_ERR=<<EOF
ERROR: Cannot open empty path
EOF
RUN

NAME=rahash2 -j file
FILE=-
CMDS=!rahash2 -j -a md4,md5 bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
[{"name":"md5","hash":"c957bd5bd6204470256bc15248ccafd4"},{"name":"md4","hash":"d4d61472a12d59be3a85e07ff9065658"}]
EOF
RUN

NAME=rahash2 -j file ssdeep
FILE=-
CMDS=!rahash2 -j -a ssdeep bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
[{"name":"ssdeep","hash":"96:aPsZ7JSRX4hHmfSz/XWwZpxI9LGr5lar87cZGbbgb:aPeJiam6zWQpxKLElZE"}]
EOF
RUN

NAME=rahash2 -j string
FILE=-
CMDS=!rahash2 -j -a sha1,sha256 -s 233
EXPECT=<<EOF
[{"name":"sha1","hash":"52fdb9f68c503e11d168fe52035901864c0a4861"},{"name":"sha256","hash":"c0509a487a18b003ba05e505419ebb63e57a29158073e381f57160b5c5b86426"}]
EOF
RUN
