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

Integration fixes

parent f718f1a5
No related branches found
No related tags found
2 merge requests!117Release,!73Quantum secure xx messenger key negotiation
...@@ -26,6 +26,9 @@ import ( ...@@ -26,6 +26,9 @@ import (
"gitlab.com/elixxir/primitives/fact" "gitlab.com/elixxir/primitives/fact"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"strings" "strings"
util "gitlab.com/elixxir/client/storage/utility"
"gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/xx_network/crypto/csprng"
) )
func (m *Manager) StartProcesses() (stoppable.Stoppable, error) { func (m *Manager) StartProcesses() (stoppable.Stoppable, error) {
...@@ -179,6 +182,18 @@ func (m *Manager) handleRequest(cmixMsg format.Message, ...@@ -179,6 +182,18 @@ func (m *Manager) handleRequest(cmixMsg format.Message,
jww.INFO.Printf("Received AuthRequest from %s,"+ jww.INFO.Printf("Received AuthRequest from %s,"+
" msgDigest: %s which has been requested, auto-confirming", " msgDigest: %s which has been requested, auto-confirming",
partnerID, cmixMsg.Digest()) partnerID, cmixMsg.Digest())
// Note that our sent request SIDH key needs to
// change to be compatible
rngGen := fastRNG.NewStreamGenerator(1, 1,
csprng.NewSystemRNG)
rng := rngGen.GetStream()
myVariant := util.GetCompatibleSIDHVariant(
partnerSIDHPubKey.Variant())
myPriv, myPub := util.GenerateSIDHKeyPair(
myVariant, rng)
sr2.OverwriteSIDHKeys(myPriv, myPub)
rng.Close()
// do the confirmation // do the confirmation
if err := m.doConfirm(sr2, grp, partnerPubKey, if err := m.doConfirm(sr2, grp, partnerPubKey,
m.storage.E2e().GetDHPrivateKey(), m.storage.E2e().GetDHPrivateKey(),
...@@ -197,23 +212,12 @@ func (m *Manager) handleRequest(cmixMsg format.Message, ...@@ -197,23 +212,12 @@ func (m *Manager) handleRequest(cmixMsg format.Message,
} }
} }
//process the inner payload //create the contact, note that no facts are sent in the payload
facts, msg, err := fact.UnstringifyFactList(
string(requestFmt.GetPayload()))
if err != nil {
em := fmt.Sprintf("failed to parse facts and message "+
"from Auth Request: %s", err)
jww.WARN.Print(em)
events.Report(10, "Auth", "RequestError", em)
return
}
//create the contact
c := contact.Contact{ c := contact.Contact{
ID: partnerID, ID: partnerID,
DhPubKey: partnerPubKey, DhPubKey: partnerPubKey,
OwnershipProof: copySlice(ecrFmt.ownership), OwnershipProof: copySlice(ecrFmt.ownership),
Facts: facts, Facts: make([]fact.Fact, 0),
} }
// fixme: the client will never be notified of the channel creation if a // fixme: the client will never be notified of the channel creation if a
...@@ -232,7 +236,7 @@ func (m *Manager) handleRequest(cmixMsg format.Message, ...@@ -232,7 +236,7 @@ func (m *Manager) handleRequest(cmixMsg format.Message,
cbList := m.requestCallbacks.Get(c.ID) cbList := m.requestCallbacks.Get(c.ID)
for _, cb := range cbList { for _, cb := range cbList {
rcb := cb.(interfaces.RequestCallback) rcb := cb.(interfaces.RequestCallback)
go rcb(c, msg) go rcb(c, "")
} }
return return
} }
......
...@@ -68,7 +68,7 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader, ...@@ -68,7 +68,7 @@ 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()) sidhVariant := util.GetCompatibleSIDHVariant(theirSidhKey.Variant())
newSIDHPrivKey := util.NewSIDHPrivateKey(sidhVariant) newSIDHPrivKey := util.NewSIDHPrivateKey(sidhVariant)
newSIDHPubKey := util.NewSIDHPublicKey(sidhVariant) newSIDHPubKey := util.NewSIDHPublicKey(sidhVariant)
......
...@@ -205,6 +205,16 @@ func (sr *SentRequest) GetMySIDHPubKey() *sidh.PublicKey { ...@@ -205,6 +205,16 @@ func (sr *SentRequest) GetMySIDHPubKey() *sidh.PublicKey {
return sr.mySidHPubKeyA return sr.mySidHPubKeyA
} }
// OverwriteSIDHKeys is used to temporarily overwrite sidh keys
// to handle e.g., confirmation requests.
// FIXME: this is a code smell but was the cleanest solution at
// the time. Business logic should probably handle this better?
func (sr *SentRequest) OverwriteSIDHKeys(priv *sidh.PrivateKey,
pub *sidh.PublicKey) {
sr.mySidHPrivKeyA = priv
sr.mySidHPubKeyA = pub
}
func (sr *SentRequest) GetFingerprint() format.Fingerprint { func (sr *SentRequest) GetFingerprint() format.Fingerprint {
return sr.fingerprint return sr.fingerprint
} }
...@@ -613,7 +613,8 @@ func (s *Session) generate(kv *versioned.KV) *versioned.KV { ...@@ -613,7 +613,8 @@ func (s *Session) generate(kv *versioned.KV) *versioned.KV {
s.myPrivKey = dh.GeneratePrivateKey(dh.DefaultPrivateKeyLength, s.myPrivKey = dh.GeneratePrivateKey(dh.DefaultPrivateKeyLength,
grp, stream) grp, stream)
// Get the variant opposite my partners variant // Get the variant opposite my partners variant
sidhVariant := utility.GetSIDHVariant(s.partnerSIDHPubKey.Variant()) sidhVariant := utility.GetCompatibleSIDHVariant(
s.partnerSIDHPubKey.Variant())
s.mySIDHPrivKey = utility.NewSIDHPrivateKey(sidhVariant) s.mySIDHPrivKey = utility.NewSIDHPrivateKey(sidhVariant)
s.mySIDHPrivKey.Generate(stream) s.mySIDHPrivKey.Generate(stream)
stream.Close() stream.Close()
......
...@@ -15,6 +15,8 @@ import ( ...@@ -15,6 +15,8 @@ import (
sidhinterface "gitlab.com/elixxir/client/interfaces/sidh" sidhinterface "gitlab.com/elixxir/client/interfaces/sidh"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"fmt" "fmt"
jww "github.com/spf13/jwalterweatherman"
"io"
) )
const currentSIDHVersion = 0 const currentSIDHVersion = 0
...@@ -32,7 +34,7 @@ func NewSIDHPrivateKey(variant sidh.KeyVariant) *sidh.PrivateKey { ...@@ -32,7 +34,7 @@ func NewSIDHPrivateKey(variant sidh.KeyVariant) *sidh.PrivateKey {
} }
// GetSIDHVariant returns the variant opposite the otherVariant // GetSIDHVariant returns the variant opposite the otherVariant
func GetSIDHVariant(otherVariant sidh.KeyVariant) sidh.KeyVariant { func GetCompatibleSIDHVariant(otherVariant sidh.KeyVariant) sidh.KeyVariant {
// Note -- this is taken from inside the sidh lib to look for the A flag // Note -- this is taken from inside the sidh lib to look for the A flag
if (otherVariant & sidh.KeyVariantSidhA) == sidh.KeyVariantSidhA { if (otherVariant & sidh.KeyVariantSidhA) == sidh.KeyVariantSidhA {
return sidh.KeyVariantSidhB return sidh.KeyVariantSidhB
...@@ -40,6 +42,20 @@ func GetSIDHVariant(otherVariant sidh.KeyVariant) sidh.KeyVariant { ...@@ -40,6 +42,20 @@ func GetSIDHVariant(otherVariant sidh.KeyVariant) sidh.KeyVariant {
return sidh.KeyVariantSidhA return sidh.KeyVariantSidhA
} }
// GenerateSIDHKeyPair generates a SIDH keypair
func GenerateSIDHKeyPair(variant sidh.KeyVariant, rng io.Reader) (
*sidh.PrivateKey, *sidh.PublicKey) {
priv := NewSIDHPrivateKey(variant)
pub := NewSIDHPublicKey(variant)
if err := priv.Generate(rng); err!=nil {
jww.FATAL.Panicf("Unable to generate SIDH private key: %+v",
err)
}
priv.GeneratePublicKey(pub)
return priv, pub
}
// String interface impl to dump the contents of the public key as b64 string // String interface impl to dump the contents of the public key as b64 string
func StringSIDHPubKey(k *sidh.PublicKey) string { func StringSIDHPubKey(k *sidh.PublicKey) string {
kBytes := make([]byte, k.Size()) kBytes := make([]byte, k.Size())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment