Skip to content
Snippets Groups Projects
Commit 6db7df70 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

Merge branch 'hotfix/sentRequest' into 'release'

Fix bug with SentRequest

See merge request !639
parents 9a8efb99 9a398006
Branches
Tags
1 merge request!23Release
......@@ -91,12 +91,16 @@ func (m *Manager) handleRequest(cmixMsg format.Message,
jww.TRACE.Printf("handleRequest PARTNERPUBKEY: %v", partnerPubKey.Bytes())
//decrypt the message
jww.TRACE.Printf("handleRequest SALT: %v", baseFmt.GetSalt())
jww.TRACE.Printf("handleRequest ECRPAYLOAD: %v", baseFmt.GetEcrPayload())
jww.TRACE.Printf("handleRequest MAC: %v", cmixMsg.GetMac())
success, payload := cAuth.Decrypt(myHistoricalPrivKey,
partnerPubKey, baseFmt.GetSalt(), baseFmt.GetEcrPayload(),
cmixMsg.GetMac(), grp)
if !success {
jww.WARN.Printf("Recieved auth request failed " +
jww.WARN.Printf("Received auth request failed " +
"its mac check")
return
}
......@@ -151,7 +155,7 @@ func (m *Manager) handleRequest(cmixMsg format.Message,
switch rType {
// if this is a duplicate, ignore the message
case auth.Receive:
jww.WARN.Printf("Recieved new Auth request for %s, "+
jww.WARN.Printf("Received new Auth request for %s, "+
"is a duplicate", partnerID)
return
// if we sent a request, then automatically confirm
......@@ -230,12 +234,15 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest,
jww.TRACE.Printf("handleConfirm SRMYPUBKEY: %v", sr.GetMyPubKey().Bytes())
// decrypt the payload
jww.TRACE.Printf("handleConfirm SALT: %v", baseFmt.GetSalt())
jww.TRACE.Printf("handleConfirm ECRPAYLOAD: %v", baseFmt.GetEcrPayload())
jww.TRACE.Printf("handleConfirm MAC: %v", cmixMsg.GetMac())
success, payload := cAuth.Decrypt(sr.GetMyPrivKey(),
partnerPubKey, baseFmt.GetSalt(), baseFmt.GetEcrPayload(),
cmixMsg.GetMac(), grp)
if !success {
jww.WARN.Printf("Recieved auth confirmation failed its mac " +
jww.WARN.Printf("Received auth confirmation failed its mac " +
"check")
m.storage.Auth().Done(sr.GetPartner())
return
......
......@@ -140,12 +140,16 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader,
cmixMsg.SetMac(mac)
cmixMsg.SetContents(baseFmt.Marshal())
jww.TRACE.Printf("RequestAuth SALT: %v", salt)
jww.TRACE.Printf("RequestAuth ECRPAYLOAD: %v", baseFmt.GetEcrPayload())
jww.TRACE.Printf("RequestAuth MAC: %v", mac)
/*store state*/
//fixme: channel is bricked if the first store succedes but the second fails
//store the in progress auth
if !resend {
err = storage.Auth().AddSent(partner.ID, partner.DhPubKey, newPrivKey,
newPrivKey, confirmFp)
newPubKey, confirmFp)
if err != nil {
return 0, errors.Errorf("Failed to store auth request: %s", err)
}
......
......@@ -8,8 +8,10 @@
package auth
import (
"encoding/hex"
"encoding/json"
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/primitives/format"
......@@ -51,8 +53,8 @@ func loadSentRequest(kv *versioned.KV, partner *id.ID, grp *cyclic.Group) (*Sent
"SentRequest Auth with %s", partner)
}
historicalPrivKey := grp.NewInt(1)
if err = historicalPrivKey.GobDecode(srd.PartnerHistoricalPubKey); err != nil {
historicalPubKey := grp.NewInt(1)
if err = historicalPubKey.GobDecode(srd.PartnerHistoricalPubKey); err != nil {
return nil, errors.WithMessagef(err, "Failed to decode historical "+
"private key with %s for SentRequest Auth", partner)
}
......@@ -72,10 +74,21 @@ func loadSentRequest(kv *versioned.KV, partner *id.ID, grp *cyclic.Group) (*Sent
fp := format.Fingerprint{}
copy(fp[:], srd.Fingerprint)
jww.INFO.Printf("loadSentRequest partner: %s",
hex.EncodeToString(partner[:]))
jww.INFO.Printf("loadSentRequest historicalPubKey: %s",
hex.EncodeToString(historicalPubKey.Bytes()))
jww.INFO.Printf("loadSentRequest myPrivKey: %s",
hex.EncodeToString(myPrivKey.Bytes()))
jww.INFO.Printf("loadSentRequest myPubKey: %s",
hex.EncodeToString(myPubKey.Bytes()))
jww.INFO.Printf("loadSentRequest fingerprint: %s",
hex.EncodeToString(fp[:]))
return &SentRequest{
kv: kv,
partner: partner,
partnerHistoricalPubKey: historicalPrivKey,
partnerHistoricalPubKey: historicalPubKey,
myPrivKey: myPrivKey,
myPubKey: myPubKey,
fingerprint: fp,
......@@ -93,13 +106,24 @@ func (sr *SentRequest) save() error {
return err
}
historicalPrivKey, err := sr.partnerHistoricalPubKey.GobEncode()
historicalPubKey, err := sr.partnerHistoricalPubKey.GobEncode()
if err != nil {
return err
}
jww.INFO.Printf("saveSentRequest partner: %s",
hex.EncodeToString(sr.partner[:]))
jww.INFO.Printf("saveSentRequest historicalPubKey: %s",
hex.EncodeToString(sr.partnerHistoricalPubKey.Bytes()))
jww.INFO.Printf("saveSentRequest myPrivKey: %s",
hex.EncodeToString(sr.myPrivKey.Bytes()))
jww.INFO.Printf("saveSentRequest myPubKey: %s",
hex.EncodeToString(sr.myPubKey.Bytes()))
jww.INFO.Printf("saveSentRequest fingerprint: %s",
hex.EncodeToString(sr.fingerprint[:]))
ipd := sentRequestDisk{
PartnerHistoricalPubKey: historicalPrivKey,
PartnerHistoricalPubKey: historicalPubKey,
MyPrivKey: privKey,
MyPubKey: pubKey,
Fingerprint: sr.fingerprint[:],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment