~moody/libdp9ik

libdp9ik/crypt.go -rw-r--r-- 938 bytes
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package libdp9ik

import (
	"crypto/sha1"
	"math/big"

	"golang.org/x/crypto/pbkdf2"
)

func passtoaeskey(passwd string) []byte {
	return pbkdf2.Key([]byte(passwd), []byte("Plan 9 key derivation"), 9001, Aeskeylen, sha1.New)
}

type PAKCurve struct {
	P *big.Int
	A *big.Int
	D *big.Int
	X *big.Int
	Y *big.Int
}

const (
	//see drawterm/libauthsrv/ed448.mpc
	edP0 = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
	edA0 = 1
	edD0 = -39081
	edX0 = "297EA0EA2692FF1B4FAFF46098453A6A26ADF733245F065C3C59D0709CECFA96147EAAF3932D94C63D96C170033F4BA0C7F0DE840AED939F"
	edY0 = 13
)

//GPAKCurve is to be used as readonly
var GPAKCurve PAKCurve = func() PAKCurve {
	c := PAKCurve{
		&big.Int{},
		&big.Int{},
		&big.Int{},
		&big.Int{},
		&big.Int{},
	}
	c.P.SetString(edP0, 16)
	c.A.SetInt64(edA0)
	c.D.SetInt64(edD0)
	c.X.SetString(edX0, 16)
	c.Y.SetInt64(edY0)
	return c
}()