summaryrefslogtreecommitdiff
path: root/handshake_ntor.go
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2014-05-21 00:26:25 +0000
committerYawning Angel <yawning@schwanenlied.me>2014-05-21 00:26:25 +0000
commitb50a8bdf244c9d62aa1d13a966c877945ed9cf47 (patch)
tree38e1898b179ff8ab1592dddb9d2916b930ef329c /handshake_ntor.go
parent676e0428e75a7808e3fac81d777b8cc69e81b712 (diff)
Finish adding godoc comments to all public interfaces.
Diffstat (limited to 'handshake_ntor.go')
-rw-r--r--handshake_ntor.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/handshake_ntor.go b/handshake_ntor.go
index 1aa00bc..bff500c 100644
--- a/handshake_ntor.go
+++ b/handshake_ntor.go
@@ -63,10 +63,22 @@ const (
inlineSeedFrameLength = framing.FrameOverhead + packetOverhead + seedPacketPayloadLength
)
+// ErrMarkNotFoundYet is the error returned when the obfs4 handshake is
+// incomplete and requires more data to continue. This error is non-fatal and
+// is the equivalent to EAGAIN/EWOULDBLOCK.
var ErrMarkNotFoundYet = errors.New("handshake: M_[C,S] not found yet")
+
+// ErrInvalidHandshake is the error returned when the obfs4 handshake fails due
+// to the peer not sending the correct mark. This error is fatal and the
+// connection MUST be dropped.
var ErrInvalidHandshake = errors.New("handshake: Failed to find M_[C,S]")
+
+// ErrNtorFailed is the error returned when the ntor handshake fails. This
+// error is fatal and the connection MUST be dropped.
var ErrNtorFailed = errors.New("handshake: ntor handshake failure")
+// InvalidMacError is the error returned when the handshake MACs do not match.
+// This error is fatal and the connection MUST be dropped.
type InvalidMacError struct {
Derived []byte
Received []byte
@@ -77,6 +89,8 @@ func (e *InvalidMacError) Error() string {
hex.EncodeToString(e.Derived), hex.EncodeToString(e.Received))
}
+// InvalidAuthError is the error returned when the ntor AUTH tags do not match.
+// This error is fatal and the connection MUST be dropped.
type InvalidAuthError struct {
Derived *ntor.Auth
Received *ntor.Auth
@@ -363,7 +377,7 @@ func findMarkMac(mark, buf []byte, startPos, maxPos int, fromTail bool) (pos int
if endPos > maxPos {
endPos = maxPos
}
- if endPos - startPos < markLength + macLength {
+ if endPos-startPos < markLength+macLength {
return -1
}
@@ -389,7 +403,7 @@ func findMarkMac(mark, buf []byte, startPos, maxPos int, fromTail bool) (pos int
}
// Ensure that there is enough trailing data for the MAC.
- if startPos + pos + markLength + macLength > endPos {
+ if startPos+pos+markLength+macLength > endPos {
return -1
}