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
fa6aa4d9
Commit
fa6aa4d9
authored
3 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Add GenerateE2ESessionBaseKey function
parent
7a46cf37
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!117
Release
,
!73
Quantum secure xx messenger key negotiation
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
storage/e2e/key.go
+0
-1
0 additions, 1 deletion
storage/e2e/key.go
storage/e2e/key_test.go
+56
-1
56 additions, 1 deletion
storage/e2e/key_test.go
with
56 additions
and
2 deletions
storage/e2e/key.go
+
0
−
1
View file @
fa6aa4d9
...
@@ -15,7 +15,6 @@ import (
...
@@ -15,7 +15,6 @@ import (
"github.com/cloudflare/circl/dh/sidh"
"github.com/cloudflare/circl/dh/sidh"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/cyclic"
dh
"gitlab.com/elixxir/crypto/diffieHellman"
dh
"gitlab.com/elixxir/crypto/diffieHellman"
jww
"github.com/spf13/jwalterweatherman"
)
)
// GenerateE2ESessionBaseKey returns the baseKey symmetric encryption key root.
// GenerateE2ESessionBaseKey returns the baseKey symmetric encryption key root.
...
...
This diff is collapsed.
Click to expand it.
storage/e2e/key_test.go
+
56
−
1
View file @
fa6aa4d9
...
@@ -22,8 +22,51 @@ import (
...
@@ -22,8 +22,51 @@ import (
"math/rand"
"math/rand"
"reflect"
"reflect"
"testing"
"testing"
"gitlab.com/elixxir/crypto/fastRNG"
"github.com/cloudflare/circl/dh/sidh"
)
)
// TestGenerateE2ESessionBaseKey smoke tests the GenerateE2ESessionBaseKey
// function to ensure that it produces the correct key on both sides of the
// connection.
func
TestGenerateE2ESessionBaseKey
(
t
*
testing
.
T
)
{
rng
:=
fastRNG
.
NewStreamGenerator
(
1
,
3
,
csprng
.
NewSystemRNG
)
myRng
:=
rng
.
GetStream
()
// DH Keys
grp
:=
getGroup
()
dhPrivateKeyA
:=
dh
.
GeneratePrivateKey
(
dh
.
DefaultPrivateKeyLength
,
grp
,
myRng
)
dhPublicKeyA
:=
dh
.
GeneratePublicKey
(
dhPrivateKeyA
,
grp
)
dhPrivateKeyB
:=
dh
.
GeneratePrivateKey
(
dh
.
DefaultPrivateKeyLength
,
grp
,
myRng
)
dhPublicKeyB
:=
dh
.
GeneratePublicKey
(
dhPrivateKeyB
,
grp
)
// SIDH keys
pubA
:=
sidh
.
NewPublicKey
(
sidh
.
Fp434
,
sidh
.
KeyVariantSidhA
)
privA
:=
sidh
.
NewPrivateKey
(
sidh
.
Fp434
,
sidh
.
KeyVariantSidhA
)
privA
.
Generate
(
myRng
)
privA
.
GeneratePublicKey
(
pubA
)
pubB
:=
sidh
.
NewPublicKey
(
sidh
.
Fp434
,
sidh
.
KeyVariantSidhB
)
privB
:=
sidh
.
NewPrivateKey
(
sidh
.
Fp434
,
sidh
.
KeyVariantSidhB
)
privB
.
Generate
(
myRng
)
privB
.
GeneratePublicKey
(
pubB
)
myRng
.
Close
()
baseKey1
:=
GenerateE2ESessionBaseKey
(
dhPrivateKeyA
,
dhPublicKeyB
,
grp
,
privA
,
pubB
)
baseKey2
:=
GenerateE2ESessionBaseKey
(
dhPrivateKeyB
,
dhPublicKeyA
,
grp
,
privB
,
pubA
)
if
!
reflect
.
DeepEqual
(
baseKey1
,
baseKey2
)
{
t
.
Errorf
(
"Cannot produce the same session key:
\n
%v
\n
%v"
,
baseKey1
,
baseKey2
)
}
}
// Happy path of newKey().
// Happy path of newKey().
func
Test_newKey
(
t
*
testing
.
T
)
{
func
Test_newKey
(
t
*
testing
.
T
)
{
expectedKey
:=
&
Key
{
expectedKey
:=
&
Key
{
...
@@ -190,7 +233,19 @@ func getSession(t *testing.T) *Session {
...
@@ -190,7 +233,19 @@ func getSession(t *testing.T) *Session {
// generate the baseKey and session
// generate the baseKey and session
privateKey
:=
dh
.
GeneratePrivateKey
(
dh
.
DefaultPrivateKeyLength
,
grp
,
rng
)
privateKey
:=
dh
.
GeneratePrivateKey
(
dh
.
DefaultPrivateKeyLength
,
grp
,
rng
)
publicKey
:=
dh
.
GeneratePublicKey
(
privateKey
,
grp
)
publicKey
:=
dh
.
GeneratePublicKey
(
privateKey
,
grp
)
baseKey
:=
dh
.
GenerateSessionKey
(
privateKey
,
publicKey
,
grp
)
// SIDH keys
pubA
:=
sidh
.
NewPublicKey
(
sidh
.
Fp434
,
sidh
.
KeyVariantSidhA
)
privA
:=
sidh
.
NewPrivateKey
(
sidh
.
Fp434
,
sidh
.
KeyVariantSidhA
)
privA
.
Generate
(
rng
)
privA
.
GeneratePublicKey
(
pubA
)
pubB
:=
sidh
.
NewPublicKey
(
sidh
.
Fp434
,
sidh
.
KeyVariantSidhB
)
privB
:=
sidh
.
NewPrivateKey
(
sidh
.
Fp434
,
sidh
.
KeyVariantSidhB
)
privB
.
Generate
(
rng
)
privB
.
GeneratePublicKey
(
pubB
)
baseKey
:=
GenerateE2ESessionBaseKey
(
privateKey
,
publicKey
,
grp
,
privA
,
pubB
)
fps
:=
newFingerprints
()
fps
:=
newFingerprints
()
ctx
:=
&
context
{
ctx
:=
&
context
{
...
...
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