summaryrefslogtreecommitdiff
path: root/testsuite/nettle-pbkdf2-test
blob: a1e26380e2fa762980433b66aaaa7ebe8e770bc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/sh

if [ -z "$srcdir" ] ; then
  srcdir=`pwd`
fi

test_pbkdf2 () {
    password="$1"
    salt="$2"
    iters="$3"
    expected="$4"
    length=`expr ${#expected} / 2`

    printf "%s" "$password" | $EMULATOR ../tools/nettle-pbkdf2 \
	-i "$iters" -l "$length" "$salt" > test1.out
    echo "$expected" > test2.out

    if cmp test1.out test2.out ; then
	true
    else
	exit 1;
    fi
}

test_pbkdf2 passwd salt 1 "55ac046e56e3089f ec1691c22544b605"
test_pbkdf2 Password NaCl 80000 "4ddcd8f60b98be21 830cee5ef22701f9"

exit 0