Skip to content

Commit

Permalink
Merge pull request #57 from cisco/cf-x448
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-wood authored Oct 26, 2022
2 parents aec2021 + 2ec0c96 commit 406e91b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
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

0 comments on commit 406e91b

Please sign in to comment.