From d3e702706722a77fdf7dbcae918dd2a26b1caa3b Mon Sep 17 00:00:00 2001 From: bytemare <{ID}+{username}@users.noreply.github.com> Date: Wed, 17 Feb 2021 02:48:04 +0100 Subject: [PATCH] update --- go.mod | 4 ++-- go.sum | 10 ++++++++++ vectors_test.go | 37 +++++++++++-------------------------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/go.mod b/go.mod index c8ff4f2..16e0bec 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 5def009..625b385 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= diff --git a/vectors_test.go b/vectors_test.go index b255342..f4181de 100644 --- a/vectors_test.go +++ b/vectors_test.go @@ -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 @@ -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) @@ -297,7 +295,6 @@ func GenerateAllVectors(t *testing.T) []*testVector { // return vectors //} } - //} } } } @@ -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") } @@ -544,11 +541,11 @@ 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") } @@ -556,7 +553,7 @@ func (v *draftVector) loginResponse(t *testing.T, s *Server, ke1 *message.KE1, c 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) } @@ -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 } @@ -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