Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ctidh_cgo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
ctidh_cgo
Commits
bc3f946a
Commit
bc3f946a
authored
Sep 16, 2022
by
David Stainton
Browse files
Options
Downloads
Patches
Plain Diff
Add constant time key comparison methods
parent
c765b86b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
binding.go
+11
-0
11 additions, 0 deletions
binding.go
with
11 additions
and
0 deletions
binding.go
+
11
−
0
View file @
bc3f946a
...
@@ -5,6 +5,7 @@ package ctidh
...
@@ -5,6 +5,7 @@ package ctidh
import
"C"
import
"C"
import
(
import
(
"bytes"
"bytes"
"crypto/hmac"
"encoding/pem"
"encoding/pem"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
...
@@ -137,6 +138,11 @@ func (p *PublicKey) FromBytes(data []byte) error {
...
@@ -137,6 +138,11 @@ func (p *PublicKey) FromBytes(data []byte) error {
return
nil
return
nil
}
}
// Equal is a constant time comparison of the two public keys.
func
(
p
*
PublicKey
)
Equal
(
publicKey
*
PublicKey
)
bool
{
return
hmac
.
Equal
(
p
.
Bytes
(),
publicKey
.
Bytes
())
}
// Blind performs a blinding operation
// Blind performs a blinding operation
// and mutates the public key.
// and mutates the public key.
// See notes below about blinding operation with CTIDH.
// See notes below about blinding operation with CTIDH.
...
@@ -196,6 +202,11 @@ func (p *PrivateKey) FromBytes(data []byte) error {
...
@@ -196,6 +202,11 @@ func (p *PrivateKey) FromBytes(data []byte) error {
return
nil
return
nil
}
}
// Equal is a constant time comparison of the two private keys.
func
(
p
*
PrivateKey
)
Equal
(
privateKey
*
PrivateKey
)
bool
{
return
hmac
.
Equal
(
p
.
Bytes
(),
privateKey
.
Bytes
())
}
// ToPEMFile writes out the PrivateKey to a PEM file at path f.
// ToPEMFile writes out the PrivateKey to a PEM file at path f.
func
(
p
*
PrivateKey
)
ToPEMFile
(
f
string
)
error
{
func
(
p
*
PrivateKey
)
ToPEMFile
(
f
string
)
error
{
keyType
:=
Name
()
+
" PRIVATE KEY"
keyType
:=
Name
()
+
" PRIVATE KEY"
...
...
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