Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CIRCL for X448 #57

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
_ "crypto/sha256"
_ "crypto/sha512"

"git.schwanenlied.me/yawning/x448.git"
"github.com/cloudflare/circl/dh/sidh"
"github.com/cloudflare/circl/dh/x448"
"golang.org/x/crypto/chacha20poly1305"
"golang.org/x/crypto/curve25519"
)
Expand Down Expand Up @@ -464,17 +464,17 @@ func (s x25519Scheme) PrivateKeySize() int {
// ECDH with X448

type x448PrivateKey struct {
val [56]byte
val x448.Key
}

func (priv x448PrivateKey) PublicKey() KEMPublicKey {
pub := &x448PublicKey{}
x448.ScalarBaseMult(&pub.val, &priv.val)
x448.KeyGen(&pub.val, &priv.val)
return pub
}

type x448PublicKey struct {
val [56]byte
val x448.Key
}

type x448Scheme struct {
Expand Down Expand Up @@ -552,8 +552,8 @@ func (s x448Scheme) DH(priv KEMPrivateKey, pub KEMPublicKey) ([]byte, error) {
return nil, fmt.Errorf("Public key not suitable for X448: %+v", pub)
}

var sharedSecret, zero [56]byte
x448.ScalarMult(&sharedSecret, &xPriv.val, &xPub.val)
var sharedSecret, zero x448.Key
x448.Shared(&sharedSecret, &xPriv.val, &xPub.val)
if subtle.ConstantTimeCompare(sharedSecret[:], zero[:]) == 1 {
return nil, fmt.Errorf("bad input point: low order point")
}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/cisco/go-hpke
go 1.14

require (
git.schwanenlied.me/yawning/x448.git v0.0.0-20170617130356-01b048fb03d6
github.com/cisco/go-tls-syntax v0.0.0-20200617162716-46b0cfb76b9b
github.com/cloudflare/circl v1.0.0
github.com/stretchr/testify v1.6.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
git.schwanenlied.me/yawning/x448.git v0.0.0-20170617130356-01b048fb03d6 h1:w8IZgCntCe0RuBJp+dENSMwEBl/k8saTgJ5hPca5IWw=
git.schwanenlied.me/yawning/x448.git v0.0.0-20170617130356-01b048fb03d6/go.mod h1:wQaGCqEu44ykB17jZHCevrgSVl3KJnwQBObUtrKU4uU=
github.com/cisco/go-tls-syntax v0.0.0-20200617162716-46b0cfb76b9b h1:Ves2turKTX7zruivAcUOQg155xggcbv3suVdbKCBQNM=
github.com/cisco/go-tls-syntax v0.0.0-20200617162716-46b0cfb76b9b/go.mod h1:0AZAV7lYvynZQ5ErHlGMKH+4QYMyNCFd+AiL9MlrCYA=
github.com/cloudflare/circl v1.0.0 h1:64b6pyfCFbYm623ncIkYGNZaOcmIbyd+CjyMi2L9vdI=
Expand Down