Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemare authored and bytemare committed Feb 17, 2021
1 parent 33639ef commit d3e7027
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/bytemare/opaque
go 1.15

require (
github.com/bytemare/cryptotools v0.0.0-20210208085821-9a824b7823bd
github.com/bytemare/voprf v0.0.0-20210208182605-37bf3e4f9e97
github.com/bytemare/cryptotools v0.0.0-20210217001400-aaae176edbfa
github.com/bytemare/voprf v0.0.0-20210217012622-bd71007551db
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
github.com/armfazh/h2c-go-ref v0.0.0-20201127170158-0b2291cd2684 h1:SBUPc1kJPlP3p90otzMe3arEWjmSQPl/rGIPNTFfpcs=
github.com/armfazh/h2c-go-ref v0.0.0-20201127170158-0b2291cd2684/go.mod h1:8fwPDRbWg9lh+s+iVv/7yAthCGHoGLTpeXnHf/J5EXs=
github.com/armfazh/h2c-go-ref v0.0.0-20210215173008-07e12a6f8e0d h1:0YBiQ+rXap26i6apP7AldB+h50fAP7XSzpbio4ElXQo=
github.com/armfazh/h2c-go-ref v0.0.0-20210215173008-07e12a6f8e0d/go.mod h1:8fwPDRbWg9lh+s+iVv/7yAthCGHoGLTpeXnHf/J5EXs=
github.com/armfazh/tozan-ecc v0.1.3 h1:g3OKE0KR4L/GZaoQYzsOUdg97Ey5lZRl1i1fD/QkUUw=
github.com/armfazh/tozan-ecc v0.1.3/go.mod h1:u25eZC5Z8uJFQxJxGBz1Blfii/7m3DfmwX0vFnwtG9I=
github.com/bytemare/cryptotools v0.0.0-20210208085821-9a824b7823bd h1:Om007KKqtk42pbPNhl9Lrx3WI9P2cX7ESX/PA9/FkSs=
github.com/bytemare/cryptotools v0.0.0-20210208085821-9a824b7823bd/go.mod h1:CKpsDERRG5MbUDJUl6xUDAuL228QndGKNabkx/E+Qug=
github.com/bytemare/cryptotools v0.0.0-20210216235952-8eafbd6934da h1:53sGefiWHBx2A9jxzqUPOn8h+9/x8fPjaoUdZKSTpTw=
github.com/bytemare/cryptotools v0.0.0-20210216235952-8eafbd6934da/go.mod h1:CKpsDERRG5MbUDJUl6xUDAuL228QndGKNabkx/E+Qug=
github.com/bytemare/cryptotools v0.0.0-20210217001400-aaae176edbfa h1:s5dgC/Cf9vkICks1x+7oWUFVhOcCQmmx5t+5veQISYo=
github.com/bytemare/cryptotools v0.0.0-20210217001400-aaae176edbfa/go.mod h1:CKpsDERRG5MbUDJUl6xUDAuL228QndGKNabkx/E+Qug=
github.com/bytemare/voprf v0.0.0-20210208181840-130a80cb1fdc h1:mqqR7AeRuOOjM0B0aFq1TvxupXU4OSngx0hkxtzX/sc=
github.com/bytemare/voprf v0.0.0-20210208181840-130a80cb1fdc/go.mod h1:ic+ItHJ7xFqglDArLQu7mFmo4SoKRUBOKMyWFSGKwpo=
github.com/bytemare/voprf v0.0.0-20210208182605-37bf3e4f9e97 h1:+RdE+SPQM9btDpcDEKTjv9BbrE6qN+RC6YaojYTokyo=
github.com/bytemare/voprf v0.0.0-20210208182605-37bf3e4f9e97/go.mod h1:ic+ItHJ7xFqglDArLQu7mFmo4SoKRUBOKMyWFSGKwpo=
github.com/bytemare/voprf v0.0.0-20210217012622-bd71007551db h1:Y22+p2fs+G98t0JHK4tL+q1d3TUkP8aydjLF7rqJm6I=
github.com/bytemare/voprf v0.0.0-20210217012622-bd71007551db/go.mod h1:IXvneXhNv+uODbDxwEZCq6rietIv0/y5H9SfzxkRtGA=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc=
Expand Down Expand Up @@ -38,6 +46,8 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210216224549-f992740a1bac h1:9glrpwtNjBYgRpb67AZJKHfzj1stG/8BL5H7In2oTC4=
golang.org/x/sys v0.0.0-20210216224549-f992740a1bac/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
37 changes: 11 additions & 26 deletions vectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ import (
)

var (
OprfSuites = []voprf.Ciphersuite{voprf.RistrettoSha512, voprf.P256Sha256}
Hashes = []hash.Identifier{hash.SHA256, hash.SHA512}
MHF = []mhf.MHF{mhf.Argon2id}
SigmaSignatures = []signature.Identifier{signature.Ed25519}
Modes = []envelope.Mode{envelope.Base, envelope.CustomIdentifier}
OprfSuites = []voprf.Ciphersuite{voprf.RistrettoSha512, voprf.P256Sha256}
Hashes = []hash.Hashing{hash.SHA256, hash.SHA512}
MHF = []mhf.MHF{mhf.Argon2id}
Modes = []envelope.Mode{envelope.Base, envelope.CustomIdentifier}
)

type ByteToHex []byte
Expand Down Expand Up @@ -269,14 +268,13 @@ func GenerateTestVector(p *Parameters, m *mhf.Parameters, s signature.Identifier
}

func GenerateAllVectors(t *testing.T) []*testVector {
v := len(OprfSuites) * len(Hashes) * len(MHF) * len(SigmaSignatures) * len(Modes)
v := len(OprfSuites) * len(Hashes) * len(MHF) * len(Modes)
log.Printf("v := %v", v)
vectors := make([]*testVector, v)
w := 0
for _, s := range OprfSuites {
for _, h := range Hashes {
for _, m := range MHF {
// for _, sig := range SigmaSignatures {
for _, mode := range Modes {
name := fmt.Sprintf("%d : %v-%v-%v-%v-%v", w, s, h, "3DH", m, mode)

Expand All @@ -297,7 +295,6 @@ func GenerateAllVectors(t *testing.T) []*testVector {
// return vectors
//}
}
//}
}
}
}
Expand Down Expand Up @@ -506,7 +503,7 @@ func (v *draftVector) test(t *testing.T) {
t.Fatal(err)
}

if !bytes.Equal(v.Intermediates.ClientMacKey, client.Ake.ClientMac) {
if !bytes.Equal(v.Intermediates.ClientMacKey, client.Ake.ClientMacKey) {
t.Fatal("client mac keys do not match")
}

Expand Down Expand Up @@ -544,19 +541,19 @@ func (v *draftVector) loginResponse(t *testing.T, s *Server, ke1 *message.KE1, c
t.Fatalf("HandshakeSecrets do not match : %v", s.Ake.HandshakeSecret)
}

if !bytes.Equal(v.Intermediates.ServerMacKey, s.Ake.ServerMac) {
if !bytes.Equal(v.Intermediates.ServerMacKey, s.Ake.ServerMacKey) {
t.Fatal("ServerMacs do not match")
}

if !bytes.Equal(v.Intermediates.ClientMacKey, s.Ake.ClientMacKey) {
if !bytes.Equal(v.Intermediates.ClientMacKey, s.Ake.Keys.ClientMacKey) {
t.Fatal("ClientMacs do not match")
}

if !bytes.Equal(v.Intermediates.HandshakeEncryptKey, s.Ake.HandshakeEncryptKey) {
t.Fatal("HandshakeEncryptKeys do not match")
}

draftKE2, err := message.DeserializeKE2(v.Outputs.KE2, 32, s.Ake.Group.ElementLength(), s.Ake.Hash.OutputSize())
draftKE2, err := message.DeserializeKE2(v.Outputs.KE2, 32, s.Ake.Group.ElementLength(), s.Ake.Hashing.OutputSize())
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -621,24 +618,12 @@ func buildOPRFClient(cs voprf.Ciphersuite, blind []byte) *voprf.Client {
return c
}

func hashToHash(h string) hash.Identifier {
func hashToHash(h string) hash.Hashing {
switch h {
case "SHA256":
return hash.SHA256
case "SHA512":
return hash.SHA512
case "SHA3-256":
return hash.SHA3_256
case "SHA3-512":
return hash.SHA3_512
case "SHAKE128":
return hash.SHAKE128
case "SHAKE256":
return hash.SHAKE256
case "BLAKE2XB":
return hash.BLAKE2XB
case "BLAKE2XS":
return hash.BLAKE2XS
default:
return 0
}
Expand All @@ -647,7 +632,7 @@ func hashToHash(h string) hash.Identifier {
type draftVectors []*draftVector

func TestOpaqueVectors(t *testing.T) {
if err := filepath.Walk("./tests/new.json",
if err := filepath.Walk("./tests/newVectors2.json",
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
Expand Down

0 comments on commit d3e7027

Please sign in to comment.