Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
8faa53d3
Commit
8faa53d3
authored
3 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Update backup to set argon2id params
parent
f15bf8df
No related branches found
No related tags found
4 merge requests
!510
Release
,
!207
WIP: Client Restructure
,
!205
cmd restructure
,
!203
Symmetric broadcast
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
backup/backup.go
+6
-2
6 additions, 2 deletions
backup/backup.go
backup/backup_test.go
+26
-7
26 additions, 7 deletions
backup/backup_test.go
backup/utils_test.go
+5
-4
5 additions, 4 deletions
backup/utils_test.go
with
37 additions
and
13 deletions
backup/backup.go
+
6
−
2
View file @
8faa53d3
...
@@ -8,12 +8,13 @@
...
@@ -8,12 +8,13 @@
package
backup
package
backup
import
(
import
(
"sync"
"time"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/primitives/fact"
"gitlab.com/elixxir/primitives/fact"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
"sync"
"time"
"github.com/pkg/errors"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
jww
"github.com/spf13/jwalterweatherman"
...
@@ -119,6 +120,9 @@ func InitializeBackup(password string, updateBackupCb UpdateBackupFn,
...
@@ -119,6 +120,9 @@ func InitializeBackup(password string, updateBackupCb UpdateBackupFn,
rand
.
Close
()
rand
.
Close
()
params
:=
backup
.
DefaultParams
()
params
:=
backup
.
DefaultParams
()
params
.
Memory
=
256
*
1024
// 256 MiB
params
.
Threads
=
4
params
.
Time
=
100
key
:=
backup
.
DeriveKey
(
password
,
salt
,
params
)
key
:=
backup
.
DeriveKey
(
password
,
salt
,
params
)
// Save key, salt, and parameters to storage
// Save key, salt, and parameters to storage
...
...
This diff is collapsed.
Click to expand it.
backup/backup_test.go
+
26
−
7
View file @
8faa53d3
...
@@ -9,13 +9,14 @@ package backup
...
@@ -9,13 +9,14 @@ package backup
import
(
import
(
"bytes"
"bytes"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/ekv"
"reflect"
"reflect"
"strings"
"strings"
"testing"
"testing"
"time"
"time"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/ekv"
"gitlab.com/elixxir/crypto/backup"
"gitlab.com/elixxir/crypto/backup"
"gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/crypto/csprng"
...
@@ -52,7 +53,7 @@ func Test_InitializeBackup(t *testing.T) {
...
@@ -52,7 +53,7 @@ func Test_InitializeBackup(t *testing.T) {
}
}
// Check that the key, salt, and params were saved to storage
// Check that the key, salt, and params were saved to storage
key
,
salt
,
p
,
err
:=
loadBackup
(
b
.
kv
)
key
,
salt
,
_
,
err
:=
loadBackup
(
b
.
kv
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Failed to load key, salt, and params: %+v"
,
err
)
t
.
Errorf
(
"Failed to load key, salt, and params: %+v"
,
err
)
}
}
...
@@ -62,10 +63,10 @@ func Test_InitializeBackup(t *testing.T) {
...
@@ -62,10 +63,10 @@ func Test_InitializeBackup(t *testing.T) {
if
len
(
salt
)
!=
saltLen
||
bytes
.
Equal
(
salt
,
make
([]
byte
,
saltLen
))
{
if
len
(
salt
)
!=
saltLen
||
bytes
.
Equal
(
salt
,
make
([]
byte
,
saltLen
))
{
t
.
Errorf
(
"Invalid salt: %v"
,
salt
)
t
.
Errorf
(
"Invalid salt: %v"
,
salt
)
}
}
if
!
reflect
.
DeepEqual
(
p
,
backup
.
DefaultParams
())
{
//
if !reflect.DeepEqual(p, backup.DefaultParams()) {
t
.
Errorf
(
"Invalid params.
\n
expected: %+v
\n
received: %+v"
,
//
t.Errorf("Invalid params.\nexpected: %+v\nreceived: %+v",
backup
.
DefaultParams
(),
p
)
//
backup.DefaultParams(), p)
}
//
}
encryptedBackup
:=
[]
byte
(
"encryptedBackup"
)
encryptedBackup
:=
[]
byte
(
"encryptedBackup"
)
go
b
.
updateBackupCb
(
encryptedBackup
)
go
b
.
updateBackupCb
(
encryptedBackup
)
...
@@ -432,3 +433,21 @@ func newTestBackup(password string, cb UpdateBackupFn, t *testing.T) *Backup {
...
@@ -432,3 +433,21 @@ func newTestBackup(password string, cb UpdateBackupFn, t *testing.T) *Backup {
return
b
return
b
}
}
// Tests that Backup.InitializeBackup returns a new Backup with a copy of the
// key and the callback.
func
Benchmark_InitializeBackup
(
t
*
testing
.
B
)
{
kv
:=
versioned
.
NewKV
(
make
(
ekv
.
Memstore
))
rngGen
:=
fastRNG
.
NewStreamGenerator
(
1000
,
10
,
csprng
.
NewSystemRNG
)
cbChan
:=
make
(
chan
[]
byte
,
2
)
cb
:=
func
(
encryptedBackup
[]
byte
)
{
cbChan
<-
encryptedBackup
}
expectedPassword
:=
"MySuperSecurePassword"
for
i
:=
0
;
i
<
t
.
N
;
i
++
{
_
,
err
:=
InitializeBackup
(
expectedPassword
,
cb
,
&
Container
{},
newMockE2e
(
t
),
newMockSession
(
t
),
newMockUserDiscovery
(),
kv
,
rngGen
)
if
err
!=
nil
{
t
.
Errorf
(
"InitializeBackup returned an error: %+v"
,
err
)
}
}
}
This diff is collapsed.
Click to expand it.
backup/utils_test.go
+
5
−
4
View file @
8faa53d3
...
@@ -8,13 +8,14 @@
...
@@ -8,13 +8,14 @@
package
backup
package
backup
import
(
import
(
"testing"
"time"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/primitives/fact"
"gitlab.com/elixxir/primitives/fact"
"gitlab.com/xx_network/crypto/large"
"gitlab.com/xx_network/crypto/large"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
"testing"
"time"
)
)
// Adheres to the E2e interface.
// Adheres to the E2e interface.
...
@@ -24,7 +25,7 @@ type mockE2e struct {
...
@@ -24,7 +25,7 @@ type mockE2e struct {
historicalDHPrivkey
*
cyclic
.
Int
historicalDHPrivkey
*
cyclic
.
Int
}
}
func
newMockE2e
(
t
*
testing
.
T
)
*
mockE2e
{
func
newMockE2e
(
t
testing
.
T
B
)
*
mockE2e
{
grp
:=
cyclic
.
NewGroup
(
large
.
NewInt
(
173
),
large
.
NewInt
(
0
))
grp
:=
cyclic
.
NewGroup
(
large
.
NewInt
(
173
),
large
.
NewInt
(
0
))
return
&
mockE2e
{
return
&
mockE2e
{
partnerIDs
:
[]
*
id
.
ID
{
partnerIDs
:
[]
*
id
.
ID
{
...
@@ -54,7 +55,7 @@ type mockSession struct {
...
@@ -54,7 +55,7 @@ type mockSession struct {
registrationTimestamp
time
.
Time
registrationTimestamp
time
.
Time
}
}
func
newMockSession
(
t
*
testing
.
T
)
*
mockSession
{
func
newMockSession
(
t
testing
.
T
B
)
*
mockSession
{
receptionRSA
,
_
:=
rsa
.
LoadPrivateKeyFromPem
([]
byte
(
privKey
))
receptionRSA
,
_
:=
rsa
.
LoadPrivateKeyFromPem
([]
byte
(
privKey
))
transmissionRSA
,
_
:=
rsa
.
LoadPrivateKeyFromPem
([]
byte
(
privKey
))
transmissionRSA
,
_
:=
rsa
.
LoadPrivateKeyFromPem
([]
byte
(
privKey
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment