mirror of https://github.com/waku-org/noise.git
vectorgen: generate psk test vectors
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
1b34a57a83
commit
3bc46b50a9
|
@ -31,13 +31,15 @@ func main() {
|
||||||
HandshakeX,
|
HandshakeX,
|
||||||
HandshakeXR,
|
HandshakeXR,
|
||||||
} {
|
} {
|
||||||
for _, psk := range []bool{false, true} {
|
for pskPlacement := -1; pskPlacement <= len(handshake.Messages); pskPlacement++ {
|
||||||
|
psk := pskPlacement >= 0
|
||||||
payloads := (psk && hi%2 == 0) || (!psk && hi%2 != 0)
|
payloads := (psk && hi%2 == 0) || (!psk && hi%2 != 0)
|
||||||
prologue := ci == 0
|
prologue := ci == 0
|
||||||
writeHandshake(
|
writeHandshake(
|
||||||
os.Stdout,
|
os.Stdout,
|
||||||
NewCipherSuite(DH25519, cipher, hash),
|
NewCipherSuite(DH25519, cipher, hash),
|
||||||
handshake, psk, prologue, payloads,
|
handshake, pskPlacement,
|
||||||
|
psk, prologue, payloads,
|
||||||
)
|
)
|
||||||
fmt.Fprintln(os.Stdout)
|
fmt.Fprintln(os.Stdout)
|
||||||
}
|
}
|
||||||
|
@ -62,7 +64,7 @@ const (
|
||||||
key4 = "4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60"
|
key4 = "4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60"
|
||||||
)
|
)
|
||||||
|
|
||||||
func writeHandshake(out io.Writer, cs CipherSuite, h HandshakePattern, hasPSK, hasPrologue, payloads bool) {
|
func writeHandshake(out io.Writer, cs CipherSuite, h HandshakePattern, pskPlacement int, hasPSK, hasPrologue, payloads bool) {
|
||||||
var prologue, psk []byte
|
var prologue, psk []byte
|
||||||
if hasPrologue {
|
if hasPrologue {
|
||||||
prologue = []byte("notsecret")
|
prologue = []byte("notsecret")
|
||||||
|
@ -82,6 +84,7 @@ func writeHandshake(out io.Writer, cs CipherSuite, h HandshakePattern, hasPSK, h
|
||||||
Initiator: true,
|
Initiator: true,
|
||||||
Prologue: prologue,
|
Prologue: prologue,
|
||||||
PresharedKey: psk,
|
PresharedKey: psk,
|
||||||
|
PresharedKeyPlacement: pskPlacement,
|
||||||
}
|
}
|
||||||
configR := configI
|
configR := configI
|
||||||
configR.Random = hexReader(key4)
|
configR.Random = hexReader(key4)
|
||||||
|
@ -89,10 +92,10 @@ func writeHandshake(out io.Writer, cs CipherSuite, h HandshakePattern, hasPSK, h
|
||||||
|
|
||||||
var pskName string
|
var pskName string
|
||||||
if hasPSK {
|
if hasPSK {
|
||||||
pskName = "PSK"
|
pskName = fmt.Sprintf("psk%d", pskPlacement)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(out, "handshake=Noise%s_%s_%s\n", pskName, h.Name, cs.Name())
|
fmt.Fprintf(out, "handshake=Noise_%s%s_%s\n", h.Name, pskName, cs.Name())
|
||||||
|
|
||||||
if len(h.Name) == 1 {
|
if len(h.Name) == 1 {
|
||||||
switch h.Name {
|
switch h.Name {
|
||||||
|
|
6050
vectors.txt
6050
vectors.txt
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue