From 0325ffc0afb5798e1242f6c7da3c0f34d87dcb38 Mon Sep 17 00:00:00 2001 From: siddharth Date: Fri, 21 Jan 2022 19:30:26 -0500 Subject: challenge: update challenge 34 Use sha1 of the session key as the key for encryption/decryption instead of the session key itself. --- challenge/c34.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/challenge/c34.go b/challenge/c34.go index 86a40b8..130c437 100644 --- a/challenge/c34.go +++ b/challenge/c34.go @@ -63,7 +63,10 @@ func C34(args []string) { // Encipher using AES-CBC. encipher := func(skey *big.Int, msg string) (string, error) { // Make key out of DH sesssion key. - skeyb := skey.Bytes() + sha1 := lib.Sha1{} + sha1.Init([]uint32{}) + sha1.Message(skey.Bytes()) + skeyb := sha1.Hash() if len(skeyb) < 16 { // Pad it to 16 bytes. skeyb = append(skeyb, make([]byte, 16-len(skeyb))...) @@ -89,7 +92,10 @@ func C34(args []string) { // Decipher using AES-CBC. decipher := func(skey *big.Int, packet string) (string, error) { // Make key out of DH sesssion key. - skeyb := skey.Bytes() + sha1 := lib.Sha1{} + sha1.Init([]uint32{}) + sha1.Message(skey.Bytes()) + skeyb := sha1.Hash() if len(skeyb) < 16 { // Pad it to 16 bytes. skeyb = append(skeyb, make([]byte, 16-len(skeyb))...) -- cgit v1.2.3