Skip to content
Snippets Groups Projects
Commit d10a8e57 authored by Jake Taylor's avatar Jake Taylor
Browse files

fix salt generation

parent f70d9ac7
No related branches found
No related tags found
3 merge requests!510Release,!267Make BuildReceptionIdentity public, and make backup restore function return a...,!263Hotfix/refactor cmd
......@@ -39,7 +39,7 @@ func createNewUser(rng *fastRNG.StreamGenerator, e2eGroup *cyclic.Group) user.In
var transmissionSalt, receptionSalt []byte
e2eKeyBytes, transmissionSalt, receptionSalt,
transmissionRsaKey, receptionRsaKey := createDhKeys(rng, e2eGroup)
transmissionRsaKey, receptionRsaKey := createKeys(rng, e2eGroup)
transmissionID, err := xx.NewID(transmissionRsaKey.GetPublic(),
transmissionSalt, id.User)
......@@ -67,7 +67,7 @@ func createNewUser(rng *fastRNG.StreamGenerator, e2eGroup *cyclic.Group) user.In
}
}
func createDhKeys(rng *fastRNG.StreamGenerator,
func createKeys(rng *fastRNG.StreamGenerator,
e2e *cyclic.Group) (e2eKeyBytes,
transmissionSalt, receptionSalt []byte,
transmissionRsaKey, receptionRsaKey *rsa.PrivateKey) {
......@@ -96,6 +96,11 @@ func createDhKeys(rng *fastRNG.StreamGenerator,
var err error
stream := rng.GetStream()
transmissionRsaKey, err = rsa.GenerateKey(stream, rsa.DefaultRSABitLen)
if err != nil {
jww.FATAL.Panicf(err.Error())
}
transmissionSalt = make([]byte, SaltSize)
_, err = stream.Read(transmissionSalt)
stream.Close()
if err != nil {
jww.FATAL.Panicf(err.Error())
......@@ -107,6 +112,11 @@ func createDhKeys(rng *fastRNG.StreamGenerator,
var err error
stream := rng.GetStream()
receptionRsaKey, err = rsa.GenerateKey(stream, rsa.DefaultRSABitLen)
if err != nil {
jww.FATAL.Panicf(err.Error())
}
receptionSalt = make([]byte, SaltSize)
_, err = stream.Read(receptionSalt)
stream.Close()
if err != nil {
jww.FATAL.Panicf(err.Error())
......@@ -206,17 +216,17 @@ func createNewVanityUser(rng csprng.Source,
if err != nil {
jww.FATAL.Panicf(err.Error())
}
id := rID.String()
rid := rID.String()
if ignoreCase {
id = strings.ToLower(id)
rid = strings.ToLower(rid)
}
if strings.HasPrefix(id, pref) {
if strings.HasPrefix(rid, pref) {
mu.Lock()
receptionID = rID
receptionSalt = rSalt
mu.Unlock()
found <- true
defer wg.Done()
wg.Done()
return
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment