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
7a46cf37
Commit
7a46cf37
authored
3 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Add function to generate session keys with DH and SIDH keys
parent
4d02e1d5
No related branches found
No related tags found
2 merge requests
!117
Release
,
!73
Quantum secure xx messenger key negotiation
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage/e2e/key.go
+36
-1
36 additions, 1 deletion
storage/e2e/key.go
with
36 additions
and
1 deletion
storage/e2e/key.go
+
36
−
1
View file @
7a46cf37
...
@@ -12,8 +12,42 @@ import (
...
@@ -12,8 +12,42 @@ import (
e2eCrypto
"gitlab.com/elixxir/crypto/e2e"
e2eCrypto
"gitlab.com/elixxir/crypto/e2e"
"gitlab.com/elixxir/crypto/hash"
"gitlab.com/elixxir/crypto/hash"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/elixxir/primitives/format"
"github.com/cloudflare/circl/dh/sidh"
"gitlab.com/elixxir/crypto/cyclic"
dh
"gitlab.com/elixxir/crypto/diffieHellman"
jww
"github.com/spf13/jwalterweatherman"
)
)
// GenerateE2ESessionBaseKey returns the baseKey symmetric encryption key root.
// The baseKey is created by hashing the results of the diffie-helman (DH) key
// exchange with the post-quantum secure Supersingular Isogeny DH exchange
// results.
func
GenerateE2ESessionBaseKey
(
myDHPrivKey
,
theirDHPubKey
*
cyclic
.
Int
,
dhGrp
*
cyclic
.
Group
,
mySIDHPrivKey
*
sidh
.
PrivateKey
,
theirSIDHPubKey
*
sidh
.
PublicKey
)
*
cyclic
.
Int
{
// DH Key Gen
dhKey
:=
dh
.
GenerateSessionKey
(
myDHPrivKey
,
theirDHPubKey
,
dhGrp
)
// SIDH Key Gen
sidhKey
:=
make
([]
byte
,
mySIDHPrivKey
.
SharedSecretSize
())
mySIDHPrivKey
.
DeriveSecret
(
sidhKey
,
theirSIDHPubKey
)
// Derive key
h
:=
hash
.
CMixHash
.
New
()
h
.
Write
(
dhKey
.
Bytes
())
h
.
Write
(
sidhKey
)
keyDigest
:=
h
.
Sum
(
nil
)
// NOTE: Sadly the baseKey was a full DH key, and that key was used
// to create an "IDF" as well as in key generation and potentially other
// downstream code. We use a KDF to limit scope of the change,'
// generating into the same group as DH to preserve any kind of
// downstream reliance on the size of the key for now.
baseKey
:=
hash
.
ExpandKey
(
hash
.
CMixHash
.
New
,
dhGrp
,
keyDigest
,
dhGrp
.
NewInt
(
1
))
return
baseKey
}
type
Key
struct
{
type
Key
struct
{
// Links
// Links
session
*
Session
session
*
Session
...
@@ -96,7 +130,8 @@ func (k *Key) denoteUse() {
...
@@ -96,7 +130,8 @@ func (k *Key) denoteUse() {
k
.
session
.
useKey
(
k
.
keyNum
)
k
.
session
.
useKey
(
k
.
keyNum
)
}
}
// Generates the key and returns it
// generateKey derives the current e2e key from the baseKey and the index
// keyNum and returns it
func
(
k
*
Key
)
generateKey
()
e2eCrypto
.
Key
{
func
(
k
*
Key
)
generateKey
()
e2eCrypto
.
Key
{
return
e2eCrypto
.
DeriveKey
(
k
.
session
.
baseKey
,
k
.
keyNum
,
return
e2eCrypto
.
DeriveKey
(
k
.
session
.
baseKey
,
k
.
keyNum
,
k
.
session
.
relationshipFingerprint
)
k
.
session
.
relationshipFingerprint
)
...
...
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