Browse Source

Adjusted key/iv generation to GNUnet 0.12

Bernd Fix 2 months ago
parent
commit
4c4bb0010b
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      src/gnunet/crypto/gns.go

+ 5
- 3
src/gnunet/crypto/gns.go View File

@@ -11,13 +11,15 @@ import (
11 11
 // DeriveBlockKey returns a symmetric key and initialization vector to decipher a GNS block.
12 12
 func DeriveBlockKey(label string, pub *ed25519.PublicKey) (iv *SymmetricIV, skey *SymmetricKey) {
13 13
 	// generate symmetric key
14
-	prk := hkdf.Extract(sha512.New, []byte(label), pub.Bytes())
15
-	rdr := hkdf.Expand(sha256.New, prk, []byte("gns-aes-ctx-key"))
14
+	prk := hkdf.Extract(sha512.New, []byte("gns-aes-ctx-key"), pub.Bytes())
15
+	rdr := hkdf.Expand(sha256.New, prk, []byte(label))
16 16
 	skey = NewSymmetricKey()
17 17
 	rdr.Read(skey.AESKey)
18 18
 	rdr.Read(skey.TwofishKey)
19
+
19 20
 	// generate initialization vector
20
-	rdr = hkdf.Expand(sha256.New, prk, []byte("gns-aes-ctx-iv"))
21
+	prk = hkdf.Extract(sha512.New, []byte("gns-aes-ctx-iv"), pub.Bytes())
22
+	rdr = hkdf.Expand(sha256.New, prk, []byte(label))
21 23
 	iv = NewSymmetricIV()
22 24
 	rdr.Read(iv.AESIv)
23 25
 	rdr.Read(iv.TwofishIv)

Loading…
Cancel
Save