summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerardo Di Giacomo <19227040+gedigi@users.noreply.github.com>2018-03-26 14:13:16 -0700
committerJonathan Rudenberg <jonathan@titanous.com>2018-03-26 17:13:16 -0400
commitd1c47b35651a65fd9b64121e3c4c6d2d1d16894d (patch)
tree9054d471776c4018ed7953955e0cdcdb0abe0dda
parent953535c65f34da6d55db0662060775684af475e1 (diff)
downloadnoise-d1c47b35651a65fd9b64121e3c4c6d2d1d16894d.tar.xz
added XXfallback handshake, getters for local and peer ephemeral (#28)
-rw-r--r--patterns.go9
-rw-r--r--state.go13
2 files changed, 22 insertions, 0 deletions
diff --git a/patterns.go b/patterns.go
index 5fc17a8..d1a5a59 100644
--- a/patterns.go
+++ b/patterns.go
@@ -98,6 +98,15 @@ var HandshakeXX = HandshakePattern{
},
}
+var HandshakeXXfallback = HandshakePattern{
+ Name: "XXfallback",
+ Messages: [][]MessagePattern{
+ {MessagePatternE},
+ {MessagePatternE, MessagePatternDHEE, MessagePatternS, MessagePatternDHSE},
+ {MessagePatternS, MessagePatternDHES},
+ },
+}
+
var HandshakeIX = HandshakePattern{
Name: "IX",
Messages: [][]MessagePattern{
diff --git a/state.go b/state.go
index 723b368..8ce7c56 100644
--- a/state.go
+++ b/state.go
@@ -495,3 +495,16 @@ func (s *HandshakeState) PeerStatic() []byte {
func (s *HandshakeState) MessageIndex() int {
return s.msgIdx
}
+
+// PeerEphemeral returns the ephemeral key provided by the remote peer during
+// a handshake. It is an error to call this method if a handshake message
+// containing a static key has not been read.
+func (s *HandshakeState) PeerEphemeral() []byte {
+ return s.re
+}
+
+// LocalEphemeral returns the local ephemeral key pair generated during
+// a handshake.
+func (s *HandshakeState) LocalEphemeral() DHKey {
+ return s.e
+}