diff options
Diffstat (limited to 'src/gnunet/crypto/gns_test.go')
-rw-r--r-- | src/gnunet/crypto/gns_test.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/gnunet/crypto/gns_test.go b/src/gnunet/crypto/gns_test.go index 4ef64d4..12ab603 100644 --- a/src/gnunet/crypto/gns_test.go +++ b/src/gnunet/crypto/gns_test.go | |||
@@ -55,7 +55,9 @@ func TestDeriveBlockKey(t *testing.T) { | |||
55 | 55 | ||
56 | // create and initialize new public zone key (PKEY) | 56 | // create and initialize new public zone key (PKEY) |
57 | zkey := new(PKEYPublicImpl) | 57 | zkey := new(PKEYPublicImpl) |
58 | zkey.Init(PUB) | 58 | if err := zkey.Init(PUB); err != nil { |
59 | t.Fatal(err) | ||
60 | } | ||
59 | 61 | ||
60 | // derive and check a key for symmetric cipher | 62 | // derive and check a key for symmetric cipher |
61 | skey := zkey.BlockKey(LABEL, EXPIRE) | 63 | skey := zkey.BlockKey(LABEL, EXPIRE) |
@@ -267,7 +269,10 @@ func TestDeriveH(t *testing.T) { | |||
267 | } | 269 | } |
268 | 270 | ||
269 | // test key derivation | 271 | // test key derivation |
270 | dpub, h := pub.Derive(LABEL, CONTEXT) | 272 | dpub, h, err := pub.Derive(LABEL, CONTEXT) |
273 | if err != nil { | ||
274 | t.Fatal(err) | ||
275 | } | ||
271 | if !bytes.Equal(h.Bytes(), H) { | 276 | if !bytes.Equal(h.Bytes(), H) { |
272 | if testing.Verbose() { | 277 | if testing.Verbose() { |
273 | t.Logf("H(computed) = %s\n", hex.EncodeToString(h.Bytes())) | 278 | t.Logf("H(computed) = %s\n", hex.EncodeToString(h.Bytes())) |
@@ -297,7 +302,6 @@ func TestDeriveH(t *testing.T) { | |||
297 | } | 302 | } |
298 | 303 | ||
299 | func TestHKDF_gnunet(t *testing.T) { | 304 | func TestHKDF_gnunet(t *testing.T) { |
300 | |||
301 | var ( | 305 | var ( |
302 | // SALT as defined in GNUnet | 306 | // SALT as defined in GNUnet |
303 | salt = []byte("key-derivation") | 307 | salt = []byte("key-derivation") |
@@ -332,7 +336,9 @@ func TestHKDF_gnunet(t *testing.T) { | |||
332 | 336 | ||
333 | rdr := hkdf.Expand(sha256.New, prk, info) | 337 | rdr := hkdf.Expand(sha256.New, prk, info) |
334 | okm := make([]byte, len(OKM)) | 338 | okm := make([]byte, len(OKM)) |
335 | rdr.Read(okm) | 339 | if _, err := rdr.Read(okm); err != nil { |
340 | t.Fatal(err) | ||
341 | } | ||
336 | if testing.Verbose() { | 342 | if testing.Verbose() { |
337 | t.Log("OKM(computed) = " + hex.EncodeToString(okm)) | 343 | t.Log("OKM(computed) = " + hex.EncodeToString(okm)) |
338 | } | 344 | } |
@@ -387,7 +393,9 @@ func TestHDKF(t *testing.T) { | |||
387 | 393 | ||
388 | rdr := hkdf.Expand(sha512.New, prk, info) | 394 | rdr := hkdf.Expand(sha512.New, prk, info) |
389 | okm := make([]byte, len(OKM)) | 395 | okm := make([]byte, len(OKM)) |
390 | rdr.Read(okm) | 396 | if _, err := rdr.Read(okm); err != nil { |
397 | t.Fatal(err) | ||
398 | } | ||
391 | if testing.Verbose() { | 399 | if testing.Verbose() { |
392 | t.Log("OKM(computed) = " + hex.EncodeToString(okm)) | 400 | t.Log("OKM(computed) = " + hex.EncodeToString(okm)) |
393 | } | 401 | } |