mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2025-01-05 15:12:13 +00:00
Add test testing that whitespaces are used by kdf wrapper
Adds a new test that assures that spaces are part of the passwords
This commit is contained in:
parent
3440a32839
commit
bce58cae3e
36
extras/kdf-keys/test.sh
Normal file → Executable file
36
extras/kdf-keys/test.sh
Normal file → Executable file
@ -1,7 +1,9 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
error=0
|
error=0
|
||||||
while read line; do
|
|
||||||
|
check_kdf() {
|
||||||
|
while read line; do
|
||||||
pass=`cut -f1 <<<$line`
|
pass=`cut -f1 <<<$line`
|
||||||
salt=`cut -f2 <<<$line`
|
salt=`cut -f2 <<<$line`
|
||||||
iter=`cut -f3 <<<$line`
|
iter=`cut -f3 <<<$line`
|
||||||
@ -9,13 +11,39 @@ while read line; do
|
|||||||
expected=`cut -f5 <<<$line`
|
expected=`cut -f5 <<<$line`
|
||||||
hexsalt=`cut -f6 <<<$line`
|
hexsalt=`cut -f6 <<<$line`
|
||||||
#TODO: check!
|
#TODO: check!
|
||||||
derived=`./pbkdf2 $hexsalt $iter $keylen <<<$pass`
|
derived=`./tomb-kdb-pbkdf2 $hexsalt $iter $keylen <<<$pass`
|
||||||
if [[ $derived != $expected ]]; then
|
if [[ $derived != $expected ]]; then
|
||||||
echo ./pbkdf2 $hexsalt $iter $keylen "<<<$pass"
|
|
||||||
echo "Expected $expected, got $derived" >&2
|
echo "Expected $expected, got $derived" >&2
|
||||||
error=$((error + 1))
|
error=$((error + 1))
|
||||||
fi
|
fi
|
||||||
done < test.txt
|
done < test.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
check_white_spaces() {
|
||||||
|
hexsalt="73616c74"
|
||||||
|
iter=4096
|
||||||
|
keylen=20
|
||||||
|
typeset -a results
|
||||||
|
passwords=('one two three' 'one two' 'one')
|
||||||
|
for pwd in $passwords; do
|
||||||
|
results+=`./tomb-kdb-pbkdf2 $hexsalt $iter $keylen <<<$pwd`
|
||||||
|
done
|
||||||
|
for ((i=1;i<=3;i++)); do
|
||||||
|
d1=$results[$i]
|
||||||
|
i1=$passwords[$i]
|
||||||
|
for ((j=(($i+1));j<=3;j++)); do
|
||||||
|
d2=$results[$j]
|
||||||
|
i2=$passwords[$j]
|
||||||
|
if [[ $d1 == $d2 ]]; then
|
||||||
|
echo "Inputs \"$i1\" and \"$i2\" produce the same output $d1" >&2
|
||||||
|
error=$((error + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
check_kdf
|
||||||
|
check_white_spaces
|
||||||
|
|
||||||
if [[ $error == 1 ]]; then
|
if [[ $error == 1 ]]; then
|
||||||
exit $error
|
exit $error
|
||||||
|
Loading…
Reference in New Issue
Block a user