summaryrefslogtreecommitdiff
path: root/ntor/ntor.go
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2014-05-12 04:51:06 +0000
committerYawning Angel <yawning@schwanenlied.me>2014-05-12 04:51:06 +0000
commit9712aec73b2b483a4426ca670ee208b44ad1bc25 (patch)
tree9f46805aa32166d627e8038ddfd308b2f078bf99 /ntor/ntor.go
parent8a1f58cd5a1e2345b7321259c074c044a0ecbefd (diff)
Preliminary support padding, log on panic.
This adds preliminary support for data padding by adding another layer of encapsulation inside each AEAD frame containing a type and length. For now, data is still sent unpadded, but the infrastructure for supporting it is mostly there. Additionally, use log.Panic[f]() instead of panic through out the code so that some panics are logged.
Diffstat (limited to 'ntor/ntor.go')
-rw-r--r--ntor/ntor.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/ntor/ntor.go b/ntor/ntor.go
index 9dbed7f..b19c4a1 100644
--- a/ntor/ntor.go
+++ b/ntor/ntor.go
@@ -45,6 +45,7 @@ import (
"encoding/base64"
"fmt"
"io"
+ "log"
"code.google.com/p/go.crypto/curve25519"
"code.google.com/p/go.crypto/hkdf"
@@ -421,9 +422,9 @@ func Kdf(keySeed []byte, okmLen int) []byte {
okm := make([]byte, okmLen)
n, err := io.ReadFull(kdf, okm)
if err != nil {
- panic(fmt.Sprintf("BUG: Failed HKDF: %s", err.Error()))
+ log.Panicf("BUG: Failed HKDF: %s", err.Error())
} else if n != len(okm) {
- panic(fmt.Sprintf("BUG: Got truncated HKDF output: %d", n))
+ log.Panicf("BUG: Got truncated HKDF output: %d", n)
}
return okm