Skip to content
Snippets Groups Projects
Commit fed23e15 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

SIDH Fixes and passing tests

parent 8c6701ff
No related branches found
No related tags found
2 merge requests!117Release,!73Quantum secure xx messenger key negotiation
...@@ -180,8 +180,11 @@ func (m *Manager) handleRequest(cmixMsg format.Message, ...@@ -180,8 +180,11 @@ func (m *Manager) handleRequest(cmixMsg format.Message,
" msgDigest: %s which has been requested, auto-confirming", " msgDigest: %s which has been requested, auto-confirming",
partnerID, cmixMsg.Digest()) partnerID, cmixMsg.Digest())
// do the confirmation // do the confirmation
if err := m.doConfirm(sr2, grp, partnerPubKey, m.storage.E2e().GetDHPrivateKey(), if err := m.doConfirm(sr2, grp, partnerPubKey,
sr2.GetPartnerHistoricalPubKey(), ecrFmt.GetOwnership()); err != nil { m.storage.E2e().GetDHPrivateKey(),
sr2.GetPartnerHistoricalPubKey(),
ecrFmt.GetOwnership(),
partnerSIDHPubKey); err != nil {
em := fmt.Sprintf("Auto Confirmation with %s failed: %s", em := fmt.Sprintf("Auto Confirmation with %s failed: %s",
partnerID, err) partnerID, err)
jww.WARN.Print(em) jww.WARN.Print(em)
...@@ -293,7 +296,8 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest, ...@@ -293,7 +296,8 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest,
// finalize the confirmation // finalize the confirmation
if err := m.doConfirm(sr, grp, partnerPubKey, sr.GetMyPrivKey(), if err := m.doConfirm(sr, grp, partnerPubKey, sr.GetMyPrivKey(),
sr.GetPartnerHistoricalPubKey(), sr.GetPartnerHistoricalPubKey(),
ecrFmt.GetOwnership()); err != nil { ecrFmt.GetOwnership(),
partnerSIDHPubKey); err != nil {
em := fmt.Sprintf("Confirmation failed: %s", err) em := fmt.Sprintf("Confirmation failed: %s", err)
jww.WARN.Print(em) jww.WARN.Print(em)
events.Report(10, "Auth", "ConfirmError", em) events.Report(10, "Auth", "ConfirmError", em)
...@@ -303,7 +307,8 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest, ...@@ -303,7 +307,8 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest,
} }
func (m *Manager) doConfirm(sr *auth.SentRequest, grp *cyclic.Group, func (m *Manager) doConfirm(sr *auth.SentRequest, grp *cyclic.Group,
partnerPubKey, myPrivateKeyOwnershipProof, partnerPubKeyOwnershipProof *cyclic.Int, ownershipProof []byte) error { partnerPubKey, myPrivateKeyOwnershipProof, partnerPubKeyOwnershipProof *cyclic.Int,
ownershipProof []byte, partnerSIDHPubKey *sidh.PublicKey) error {
// verify the message came from the intended recipient // verify the message came from the intended recipient
if !cAuth.VerifyOwnershipProof(myPrivateKeyOwnershipProof, if !cAuth.VerifyOwnershipProof(myPrivateKeyOwnershipProof,
partnerPubKeyOwnershipProof, grp, ownershipProof) { partnerPubKeyOwnershipProof, grp, ownershipProof) {
...@@ -315,7 +320,8 @@ func (m *Manager) doConfirm(sr *auth.SentRequest, grp *cyclic.Group, ...@@ -315,7 +320,8 @@ func (m *Manager) doConfirm(sr *auth.SentRequest, grp *cyclic.Group,
// the second does not // the second does not
p := m.storage.E2e().GetE2ESessionParams() p := m.storage.E2e().GetE2ESessionParams()
if err := m.storage.E2e().AddPartner(sr.GetPartner(), if err := m.storage.E2e().AddPartner(sr.GetPartner(),
partnerPubKey, sr.GetMyPrivKey(), p, p); err != nil { partnerPubKey, sr.GetMyPrivKey(), partnerSIDHPubKey,
sr.GetMySIDHPrivKey(), p, p); err != nil {
return errors.Errorf("Failed to create channel with partner (%s) "+ return errors.Errorf("Failed to create channel with partner (%s) "+
"after confirmation: %+v", "after confirmation: %+v",
sr.GetPartner(), err) sr.GetPartner(), err)
...@@ -392,7 +398,7 @@ func handleBaseFormat(cmixMsg format.Message, grp *cyclic.Group) (baseFormat, ...@@ -392,7 +398,7 @@ func handleBaseFormat(cmixMsg format.Message, grp *cyclic.Group) (baseFormat,
*cyclic.Int, *sidh.PublicKey, error) { *cyclic.Int, *sidh.PublicKey, error) {
baseFmt, err := unmarshalBaseFormat(cmixMsg.GetContents(), baseFmt, err := unmarshalBaseFormat(cmixMsg.GetContents(),
grp.GetP().ByteLen(), sidhinterface.SidHPubKeyByteSize) grp.GetP().ByteLen(), sidhinterface.PubKeyByteSize)
if err != nil { if err != nil {
return baseFormat{}, nil, nil, errors.WithMessage(err, "Failed to"+ return baseFormat{}, nil, nil, errors.WithMessage(err, "Failed to"+
" unmarshal auth") " unmarshal auth")
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
sidhinterface "gitlab.com/elixxir/client/interfaces/sidh" sidhinterface "gitlab.com/elixxir/client/interfaces/sidh"
"io" "io"
util "gitlab.com/elixxir/client/storage/utility"
) )
func ConfirmRequestAuth(partner contact.Contact, rng io.Reader, func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
...@@ -37,11 +38,13 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader, ...@@ -37,11 +38,13 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
} }
// check if the partner has an auth in progress // check if the partner has an auth in progress
// this takes the lock, from this point forward any errors need to release // this takes the lock, from this point forward any errors need to
// the lock // release the lock
storedContact, _, err := storage.Auth().GetReceivedRequest(partner.ID) storedContact, theirSidhKey, err := storage.Auth().GetReceivedRequest(
partner.ID)
if err != nil { if err != nil {
return 0, errors.Errorf("failed to find a pending Auth Request: %s", return 0, errors.Errorf(
"failed to find a pending Auth Request: %s",
err) err)
} }
defer storage.Auth().Done(partner.ID) defer storage.Auth().Done(partner.ID)
...@@ -49,8 +52,8 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader, ...@@ -49,8 +52,8 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
// verify the passed contact matches what is stored // verify the passed contact matches what is stored
if storedContact.DhPubKey.Cmp(partner.DhPubKey) != 0 { if storedContact.DhPubKey.Cmp(partner.DhPubKey) != 0 {
storage.Auth().Done(partner.ID) storage.Auth().Done(partner.ID)
return 0, errors.WithMessage(err, "Pending Auth Request has different "+ return 0, errors.WithMessage(err,
"pubkey than stored") "Pending Auth Request has different pubkey than stored")
} }
grp := storage.E2e().GetGroup() grp := storage.E2e().GetGroup()
...@@ -65,6 +68,10 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader, ...@@ -65,6 +68,10 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
newPrivKey := diffieHellman.GeneratePrivateKey(256, grp, rng) newPrivKey := diffieHellman.GeneratePrivateKey(256, grp, rng)
newPubKey := diffieHellman.GeneratePublicKey(newPrivKey, grp) newPubKey := diffieHellman.GeneratePublicKey(newPrivKey, grp)
sidhVariant := util.GetSIDHVariant(theirSidhKey.Variant())
newSIDHPrivKey := util.NewSIDHPrivateKey(sidhVariant)
newSIDHPubKey := util.NewSIDHPublicKey(sidhVariant)
//generate salt //generate salt
salt := make([]byte, saltSize) salt := make([]byte, saltSize)
_, err = rng.Read(salt) _, err = rng.Read(salt)
...@@ -77,7 +84,8 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader, ...@@ -77,7 +84,8 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
// we build the payload before we save because it is technically fallible // we build the payload before we save because it is technically fallible
// which can get into a bricked state if it fails // which can get into a bricked state if it fails
cmixMsg := format.NewMessage(storage.Cmix().GetGroup().GetP().ByteLen()) cmixMsg := format.NewMessage(storage.Cmix().GetGroup().GetP().ByteLen())
baseFmt := newBaseFormat(cmixMsg.ContentsSize(), grp.GetP().ByteLen(), sidhinterface.SidHPubKeyByteSize) baseFmt := newBaseFormat(cmixMsg.ContentsSize(), grp.GetP().ByteLen(),
sidhinterface.PubKeyByteSize)
ecrFmt := newEcrFormat(baseFmt.GetEcrPayloadLen()) ecrFmt := newEcrFormat(baseFmt.GetEcrPayloadLen())
// setup the encrypted payload // setup the encrypted payload
...@@ -96,6 +104,7 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader, ...@@ -96,6 +104,7 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
baseFmt.SetEcrPayload(ecrPayload) baseFmt.SetEcrPayload(ecrPayload)
baseFmt.SetSalt(salt) baseFmt.SetSalt(salt)
baseFmt.SetPubKey(newPubKey) baseFmt.SetPubKey(newPubKey)
baseFmt.SetSidHPubKey(newSIDHPubKey)
cmixMsg.SetKeyFP(fp) cmixMsg.SetKeyFP(fp)
cmixMsg.SetMac(mac) cmixMsg.SetMac(mac)
...@@ -109,7 +118,8 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader, ...@@ -109,7 +118,8 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
//create local relationship //create local relationship
p := storage.E2e().GetE2ESessionParams() p := storage.E2e().GetE2ESessionParams()
if err := storage.E2e().AddPartner(partner.ID, partner.DhPubKey, newPrivKey, if err := storage.E2e().AddPartner(partner.ID, partner.DhPubKey,
newPrivKey, theirSidhKey, newSIDHPrivKey,
p, p); err != nil { p, p); err != nil {
em := fmt.Sprintf("Failed to create channel with partner (%s) "+ em := fmt.Sprintf("Failed to create channel with partner (%s) "+
"on confirmation, this is likley a replay: %s", "on confirmation, this is likley a replay: %s",
......
...@@ -80,7 +80,7 @@ func (f baseFormat) SetSidHPubKey(pubKey *sidh.PublicKey) { ...@@ -80,7 +80,7 @@ func (f baseFormat) SetSidHPubKey(pubKey *sidh.PublicKey) {
} }
func (f baseFormat) GetSidhPubKey() (*sidh.PublicKey, error) { func (f baseFormat) GetSidhPubKey() (*sidh.PublicKey, error) {
pubKey := sidh.NewPublicKey(sidhinterface.SidHKeyId, pubKey := sidh.NewPublicKey(sidhinterface.KeyId,
sidh.KeyVariantSidhA) sidh.KeyVariantSidhA)
err := pubKey.Import(f.sidHpubkey) err := pubKey.Import(f.sidHpubkey)
return pubKey, err return pubKey, err
......
...@@ -20,9 +20,9 @@ import ( ...@@ -20,9 +20,9 @@ import (
func TestNewBaseFormat(t *testing.T) { func TestNewBaseFormat(t *testing.T) {
// Construct message // Construct message
pubKeySize := 256 pubKeySize := 256
payloadSize := saltSize + pubKeySize + sidhinterface.SidHPubKeyByteSize payloadSize := saltSize + pubKeySize + sidhinterface.PubKeyByteSize
baseMsg := newBaseFormat(payloadSize, pubKeySize, baseMsg := newBaseFormat(payloadSize, pubKeySize,
sidhinterface.SidHPubKeyByteSize) sidhinterface.PubKeyByteSize)
// Check that the base format was constructed properly // Check that the base format was constructed properly
if !bytes.Equal(baseMsg.pubkey, make([]byte, pubKeySize)) { if !bytes.Equal(baseMsg.pubkey, make([]byte, pubKeySize)) {
...@@ -40,7 +40,7 @@ func TestNewBaseFormat(t *testing.T) { ...@@ -40,7 +40,7 @@ func TestNewBaseFormat(t *testing.T) {
} }
expectedEcrPayloadSize := payloadSize - (pubKeySize + expectedEcrPayloadSize := payloadSize - (pubKeySize +
sidhinterface.SidHPubKeyByteSize + saltSize) sidhinterface.PubKeyByteSize + saltSize)
if !bytes.Equal(baseMsg.ecrPayload, make([]byte, expectedEcrPayloadSize)) { if !bytes.Equal(baseMsg.ecrPayload, make([]byte, expectedEcrPayloadSize)) {
t.Errorf("NewBaseFormat error: "+ t.Errorf("NewBaseFormat error: "+
"Unexpected payload field in base format."+ "Unexpected payload field in base format."+
...@@ -56,7 +56,7 @@ func TestNewBaseFormat(t *testing.T) { ...@@ -56,7 +56,7 @@ func TestNewBaseFormat(t *testing.T) {
} }
}() }()
newBaseFormat(0, pubKeySize, sidhinterface.SidHPubKeyByteSize) newBaseFormat(0, pubKeySize, sidhinterface.PubKeyByteSize)
} }
/* Tests the setter/getter methods for baseFormat */ /* Tests the setter/getter methods for baseFormat */
...@@ -65,9 +65,9 @@ func TestNewBaseFormat(t *testing.T) { ...@@ -65,9 +65,9 @@ func TestNewBaseFormat(t *testing.T) {
func TestBaseFormat_SetGetPubKey(t *testing.T) { func TestBaseFormat_SetGetPubKey(t *testing.T) {
// Construct message // Construct message
pubKeySize := 256 pubKeySize := 256
payloadSize := saltSize + pubKeySize + sidhinterface.SidHPubKeyByteSize payloadSize := saltSize + pubKeySize + sidhinterface.PubKeyByteSize
baseMsg := newBaseFormat(payloadSize, pubKeySize, baseMsg := newBaseFormat(payloadSize, pubKeySize,
sidhinterface.SidHPubKeyByteSize) sidhinterface.PubKeyByteSize)
// Test setter // Test setter
grp := getGroup() grp := getGroup()
...@@ -94,9 +94,9 @@ func TestBaseFormat_SetGetPubKey(t *testing.T) { ...@@ -94,9 +94,9 @@ func TestBaseFormat_SetGetPubKey(t *testing.T) {
func TestBaseFormat_SetGetSalt(t *testing.T) { func TestBaseFormat_SetGetSalt(t *testing.T) {
// Construct message // Construct message
pubKeySize := 256 pubKeySize := 256
payloadSize := saltSize + pubKeySize + sidhinterface.SidHPubKeyByteSize payloadSize := saltSize + pubKeySize + sidhinterface.PubKeyByteSize
baseMsg := newBaseFormat(payloadSize, pubKeySize, baseMsg := newBaseFormat(payloadSize, pubKeySize,
sidhinterface.SidHPubKeyByteSize) sidhinterface.PubKeyByteSize)
// Test setter // Test setter
salt := newSalt("salt") salt := newSalt("salt")
...@@ -130,13 +130,13 @@ func TestBaseFormat_SetGetSalt(t *testing.T) { ...@@ -130,13 +130,13 @@ func TestBaseFormat_SetGetSalt(t *testing.T) {
func TestBaseFormat_SetGetEcrPayload(t *testing.T) { func TestBaseFormat_SetGetEcrPayload(t *testing.T) {
// Construct message // Construct message
pubKeySize := 256 pubKeySize := 256
payloadSize := (saltSize + pubKeySize + sidhinterface.SidHPubKeyByteSize) * 2 payloadSize := (saltSize + pubKeySize + sidhinterface.PubKeyByteSize) * 2
baseMsg := newBaseFormat(payloadSize, pubKeySize, baseMsg := newBaseFormat(payloadSize, pubKeySize,
sidhinterface.SidHPubKeyByteSize) sidhinterface.PubKeyByteSize)
// Test setter // Test setter
ecrPayloadSize := payloadSize - (pubKeySize + saltSize + ecrPayloadSize := payloadSize - (pubKeySize + saltSize +
sidhinterface.SidHPubKeyByteSize) sidhinterface.PubKeyByteSize)
ecrPayload := newPayload(ecrPayloadSize, "ecrPayload") ecrPayload := newPayload(ecrPayloadSize, "ecrPayload")
baseMsg.SetEcrPayload(ecrPayload) baseMsg.SetEcrPayload(ecrPayload)
if !bytes.Equal(ecrPayload, baseMsg.ecrPayload) { if !bytes.Equal(ecrPayload, baseMsg.ecrPayload) {
...@@ -169,11 +169,11 @@ func TestBaseFormat_SetGetEcrPayload(t *testing.T) { ...@@ -169,11 +169,11 @@ func TestBaseFormat_SetGetEcrPayload(t *testing.T) {
func TestBaseFormat_MarshalUnmarshal(t *testing.T) { func TestBaseFormat_MarshalUnmarshal(t *testing.T) {
// Construct a fully populated message // Construct a fully populated message
pubKeySize := 256 pubKeySize := 256
payloadSize := (saltSize + pubKeySize + sidhinterface.SidHPubKeyByteSize) * 2 payloadSize := (saltSize + pubKeySize + sidhinterface.PubKeyByteSize) * 2
baseMsg := newBaseFormat(payloadSize, pubKeySize, baseMsg := newBaseFormat(payloadSize, pubKeySize,
sidhinterface.SidHPubKeyByteSize) sidhinterface.PubKeyByteSize)
ecrPayloadSize := payloadSize - (pubKeySize + saltSize + ecrPayloadSize := payloadSize - (pubKeySize + saltSize +
sidhinterface.SidHPubKeyByteSize) sidhinterface.PubKeyByteSize)
ecrPayload := newPayload(ecrPayloadSize, "ecrPayload") ecrPayload := newPayload(ecrPayloadSize, "ecrPayload")
baseMsg.SetEcrPayload(ecrPayload) baseMsg.SetEcrPayload(ecrPayload)
salt := newSalt("salt") salt := newSalt("salt")
...@@ -192,7 +192,7 @@ func TestBaseFormat_MarshalUnmarshal(t *testing.T) { ...@@ -192,7 +192,7 @@ func TestBaseFormat_MarshalUnmarshal(t *testing.T) {
// Test unmarshal // Test unmarshal
newMsg, err := unmarshalBaseFormat(data, pubKeySize, newMsg, err := unmarshalBaseFormat(data, pubKeySize,
sidhinterface.SidHPubKeyByteSize) sidhinterface.PubKeyByteSize)
if err != nil { if err != nil {
t.Errorf("unmarshalBaseFormat() error: "+ t.Errorf("unmarshalBaseFormat() error: "+
"Could not unmarshal into baseFormat: %v", err) "Could not unmarshal into baseFormat: %v", err)
...@@ -206,7 +206,7 @@ func TestBaseFormat_MarshalUnmarshal(t *testing.T) { ...@@ -206,7 +206,7 @@ func TestBaseFormat_MarshalUnmarshal(t *testing.T) {
// Unmarshal error test: Invalid size parameter // Unmarshal error test: Invalid size parameter
_, err = unmarshalBaseFormat(make([]byte, 0), pubKeySize, _, err = unmarshalBaseFormat(make([]byte, 0), pubKeySize,
sidhinterface.SidHPubKeyByteSize) sidhinterface.PubKeyByteSize)
if err == nil { if err == nil {
t.Errorf("unmarshalBaseFormat() error: " + t.Errorf("unmarshalBaseFormat() error: " +
"Should not be able to unmarshal when baseFormat is too small") "Should not be able to unmarshal when baseFormat is too small")
...@@ -383,7 +383,7 @@ func TestNewRequestFormat(t *testing.T) { ...@@ -383,7 +383,7 @@ func TestNewRequestFormat(t *testing.T) {
// FIXME: Commented out for now.. it's not clear why this was necessary // FIXME: Commented out for now.. it's not clear why this was necessary
// if !bytes.Equal(reqMsg.GetPayload(), make([]byte, 0, // if !bytes.Equal(reqMsg.GetPayload(), make([]byte, 0,
// sidhinterface.SidHPubKeyByteSize)) { // sidhinterface.PubKeyByteSize)) {
// t.Errorf("newRequestFormat() error: "+ // t.Errorf("newRequestFormat() error: "+
// "Unexpected msgPayload field in requestFormat."+ // "Unexpected msgPayload field in requestFormat."+
// "\n\tExpected: %v"+ // "\n\tExpected: %v"+
...@@ -445,10 +445,10 @@ func TestRequestFormat_SetGetID(t *testing.T) { ...@@ -445,10 +445,10 @@ func TestRequestFormat_SetGetID(t *testing.T) {
// Unit test for Get/SetMsgPayload // Unit test for Get/SetMsgPayload
func TestRequestFormat_SetGetMsgPayload(t *testing.T) { func TestRequestFormat_SetGetMsgPayload(t *testing.T) {
// Construct message // Construct message
payloadSize := id.ArrIDLen*3 - 1 + sidhinterface.SidHPubKeyByteSize payloadSize := id.ArrIDLen*3 - 1 + sidhinterface.PubKeyByteSize
ecrMsg := newEcrFormat(payloadSize) ecrMsg := newEcrFormat(payloadSize)
expectedPayload := newPayload(id.ArrIDLen*2 + expectedPayload := newPayload(id.ArrIDLen*2 +
sidhinterface.SidHPubKeyByteSize, "ownership") sidhinterface.PubKeyByteSize, "ownership")
ecrMsg.SetPayload(expectedPayload) ecrMsg.SetPayload(expectedPayload)
reqMsg, err := newRequestFormat(ecrMsg) reqMsg, err := newRequestFormat(ecrMsg)
if err != nil { if err != nil {
...@@ -457,7 +457,7 @@ func TestRequestFormat_SetGetMsgPayload(t *testing.T) { ...@@ -457,7 +457,7 @@ func TestRequestFormat_SetGetMsgPayload(t *testing.T) {
} }
// Test SetMsgPayload // Test SetMsgPayload
msgPayload := newPayload(id.ArrIDLen*2 + sidhinterface.SidHPubKeyByteSize, msgPayload := newPayload(id.ArrIDLen*2 + sidhinterface.PubKeyByteSize,
"msgPayload") "msgPayload")
reqMsg.SetPayload(msgPayload) reqMsg.SetPayload(msgPayload)
if !bytes.Equal(reqMsg.GetPayload(), msgPayload) { if !bytes.Equal(reqMsg.GetPayload(), msgPayload) {
......
...@@ -17,6 +17,7 @@ import ( ...@@ -17,6 +17,7 @@ import (
"gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/interfaces/preimage" "gitlab.com/elixxir/client/interfaces/preimage"
"gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage"
util "gitlab.com/elixxir/client/storage/utility"
"gitlab.com/elixxir/client/storage/auth" "gitlab.com/elixxir/client/storage/auth"
"gitlab.com/elixxir/client/storage/e2e" "gitlab.com/elixxir/client/storage/e2e"
"gitlab.com/elixxir/client/storage/edge" "gitlab.com/elixxir/client/storage/edge"
...@@ -75,7 +76,8 @@ func RequestAuth(partner, me contact.Contact, rng io.Reader, ...@@ -75,7 +76,8 @@ func RequestAuth(partner, me contact.Contact, rng io.Reader,
/*generate embedded message structures and check payload*/ /*generate embedded message structures and check payload*/
cmixMsg := format.NewMessage(storage.Cmix().GetGroup().GetP().ByteLen()) cmixMsg := format.NewMessage(storage.Cmix().GetGroup().GetP().ByteLen())
baseFmt := newBaseFormat(cmixMsg.ContentsSize(), grp.GetP().ByteLen(), sidhinterface.SidHPubKeyByteSize) baseFmt := newBaseFormat(cmixMsg.ContentsSize(), grp.GetP().ByteLen(),
sidhinterface.PubKeyByteSize)
ecrFmt := newEcrFormat(baseFmt.GetEcrPayloadLen()) ecrFmt := newEcrFormat(baseFmt.GetEcrPayloadLen())
requestFmt, err := newRequestFormat(ecrFmt) requestFmt, err := newRequestFormat(ecrFmt)
if err != nil { if err != nil {
...@@ -99,16 +101,16 @@ func RequestAuth(partner, me contact.Contact, rng io.Reader, ...@@ -99,16 +101,16 @@ func RequestAuth(partner, me contact.Contact, rng io.Reader,
if resend { if resend {
newPrivKey = sr.GetMyPrivKey() newPrivKey = sr.GetMyPrivKey()
newPubKey = sr.GetMyPubKey() newPubKey = sr.GetMyPubKey()
sidHPrivKeyA = sr.GetMySidhPrivKeyA() sidHPrivKeyA = sr.GetMySIDHPrivKey()
sidHPubKeyA = sr.GetMySidhPubKeyA() sidHPubKeyA = sr.GetMySIDHPubKey()
//in this case it is a new request and we must generate new keys //in this case it is a new request and we must generate new keys
} else { } else {
//generate new keypair //generate new keypair
newPrivKey = diffieHellman.GeneratePrivateKey(256, grp, rng) newPrivKey = diffieHellman.GeneratePrivateKey(256, grp, rng)
newPubKey = diffieHellman.GeneratePublicKey(newPrivKey, grp) newPubKey = diffieHellman.GeneratePublicKey(newPrivKey, grp)
sidHPrivKeyA = sidh.NewPrivateKey(sidhinterface.SidHKeyId, sidh.KeyVariantSidhA) sidHPrivKeyA = util.NewSIDHPrivateKey(sidh.KeyVariantSidhA)
sidHPubKeyA = sidh.NewPublicKey(sidhinterface.SidHKeyId, sidh.KeyVariantSidhA) sidHPubKeyA = util.NewSIDHPublicKey(sidh.KeyVariantSidhA)
if err = sidHPrivKeyA.Generate(rng); err!=nil{ if err = sidHPrivKeyA.Generate(rng); err!=nil{
return 0, errors.WithMessagef(err, "Failed to send requrest due to " + return 0, errors.WithMessagef(err, "Failed to send requrest due to " +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment