~moody/libdp9ik

libdp9ik/auth_test.go -rw-r--r-- 2.6 KiB
4efa26b9 — Jacob Moody Progress made towards authpak_new and authpak_finish 9 months ago
                                                                                
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
30
package libdp9ik_test

import (
	"bytes"
	"testing"

	auth "git.sr.ht/~moody/libdp9ik"
)

func TestPasstokey(t *testing.T) {
	a := &auth.AuthKey{}
	a.Passtokey("password")
	correct := []byte{21, 209, 50, 86, 52, 66, 17, 229, 108, 82, 245, 12, 83, 157, 226, 35}
	if bytes.Compare(a.Aes[:], correct) != 0 {
		t.Fatalf("Expected %v\nGot %v\n", correct, a.Aes)
	}
}

func TestAuthPakHash(t *testing.T) {
	a := &auth.AuthKey{}
	a.Passtokey("password")
	err := a.AuthpakHash([]byte("user"))
	if err != nil {
		t.Fatal(err)
	}
	correct := []byte{158, 20, 24, 41, 20, 191, 182, 174, 93, 77, 203, 21, 104, 75, 81, 147, 102, 204, 17, 35, 142, 237, 82, 202, 73, 59, 59, 48, 147, 197, 206, 191, 164, 38, 7, 243, 132, 15, 66, 26, 168, 181, 216, 197, 63, 142, 56, 0, 5, 127, 179, 42, 252, 236, 154, 194, 253, 169, 161, 111, 16, 254, 116, 191, 63, 167, 22, 241, 72, 56, 43, 180, 226, 98, 195, 142, 137, 74, 152, 114, 231, 240, 50, 154, 227, 78, 175, 182, 12, 189, 53, 109, 73, 131, 25, 247, 183, 15, 161, 161, 40, 192, 148, 194, 45, 127, 98, 101, 99, 159, 188, 24, 106, 114, 106, 131, 87, 101, 200, 67, 88, 39, 195, 66, 123, 216, 167, 39, 69, 78, 61, 114, 26, 112, 250, 104, 54, 60, 7, 205, 18, 74, 61, 72, 203, 83, 161, 176, 211, 228, 14, 232, 87, 90, 110, 110, 10, 171, 205, 185, 207, 46, 105, 197, 242, 177, 39, 119, 22, 196, 252, 34, 26, 10, 98, 84, 166, 255, 152, 223, 236, 234, 170, 226, 42, 247, 92, 15, 111, 112, 108, 156, 67, 209, 251, 102, 215, 195, 119, 128, 151, 51, 234, 213, 9, 112, 96, 38, 109, 192, 59, 55, 209, 128, 209, 92, 63, 197, 27, 235, 163, 182, 179, 128, 93, 159, 158, 245, 128, 1, 35, 145, 103, 149, 127, 216, 0, 75, 5, 112, 126, 29, 120, 56, 48, 114, 152, 159, 119, 190, 212, 221, 201, 239, 183, 12, 227, 156, 176, 224, 238, 187, 151, 15, 183, 241, 103, 147, 190, 98, 146, 249, 184, 112, 245, 149, 197, 41, 190, 120, 13, 79, 201, 81, 17, 158, 193, 255, 168, 200, 179, 158, 151, 110, 6, 224, 22, 134, 100, 115, 177, 49, 113, 172, 181, 137, 143, 82, 220, 157, 89, 47, 224, 82, 60, 193, 196, 51, 158, 24, 51, 57, 0, 173, 48, 41, 194, 249, 2, 9, 182, 11, 201, 110, 139, 213, 240, 134, 40, 138, 99, 242, 89, 96, 22, 156, 250, 99, 147, 157, 0, 124, 199, 83, 224, 184, 97, 134, 59, 66, 49, 215, 128, 42, 211, 58, 235, 131, 176, 184, 201, 3, 16, 72, 17, 96, 221, 89, 1, 61, 104, 104, 153, 222, 25, 230, 106, 228, 124, 136, 108, 108, 12, 66, 100, 35, 193, 198, 5, 186, 50, 139, 171, 53, 89, 58, 126, 206, 62, 113, 241, 36, 46, 243, 28, 175, 180, 90, 219, 214, 178, 104, 197, 21, 56, 183, 162, 211, 205, 26, 79, 1, 54, 147, 189, 23, 188, 232, 82, 240, 184, 41, 245, 124, 18, 71, 44, 177}
	if bytes.Compare(correct, a.Pakhash[:]) != 0 {
		t.Fatalf("Expected %v\nGot %v\n", correct, a.Pakhash)
	}
}