This repository was archived by the owner on Oct 26, 2023. It is now read-only.

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Coverage Status](https://coveralls.io/repos//cloudflare/odoh-go/badge.svg?branch=master)](https://coveralls.io//cloudflare/odoh-go?branch=master)
44
[![GoDoc](https://godoc.org/.com/cloudflare/odoh-go?status.svg)](https://godoc.org/.com/cloudflare/odoh-go)
55

6-
This library implements draft -03 of [Oblivious DoH](https://tools.ietf.org/html/draft-pauly-dprive-oblivious-doh-03). It is based on the original implementation [available here](https://.com/chris-wood/odoh).
6+
This library implements draft -04 of [Oblivious DoH](https://tools.ietf.org/html/draft-pauly-dprive-oblivious-doh-04). It is based on the original implementation [available here](https://.com/chris-wood/odoh).
77

88
![protocol overview](odoh-flow.png)
99

Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module .com/cloudflare/odoh-go
22

33
go 1.14
44

5-
require .com/cisco/go-hpke v0.0.0-20201023221920-2866d2aa0603
5+
require .com/cisco/go-hpke v0.0.0-20201215202025-9cebdf8f33d4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ import (
2828
"encoding/binary"
2929
"errors"
3030
"fmt"
31+
3132
".com/cisco/go-hpke"
3233
)
3334

3435
const (
35-
ODOH_VERSION = uint16(0xff03)
36+
ODOH_VERSION = uint16(0xff04)
3637
ODOH_SECRET_LENGTH = 32
3738
ODOH_PADDING_BYTE = uint8(0)
3839
ODOH_LABEL_KEY_ID = "odoh key id"
@@ -58,7 +59,7 @@ func CreateObliviousDoHConfigContents(kemID hpke.KEMID, kdfID hpke.KDFID, aeadID
5859
return ObliviousDoHConfigContents{}, err
5960
}
6061

61-
_, err = suite.KEM.Deserialize(publicKeyBytes)
62+
_, err = suite.KEM.DeserializePublicKey(publicKeyBytes)
6263
if err != nil {
6364
return ObliviousDoHConfigContents{}, err
6465
}
@@ -177,7 +178,7 @@ func UnmarshalObliviousDoHConfigContents(buffer []byte) (ObliviousDoHConfigConte
177178
return ObliviousDoHConfigContents{}, errors.New(fmt.Sprintf("Unsupported HPKE ciphersuite"))
178179
}
179180

180-
_, err = suite.KEM.Deserialize(publicKeyBytes)
181+
_, err = suite.KEM.DeserializePublicKey(publicKeyBytes)
181182
if err != nil {
182183
return ObliviousDoHConfigContents{}, errors.New(fmt.Sprintf("Invalid HPKE public key bytes"))
183184
}
@@ -338,7 +339,7 @@ func CreateKeyPairFromSeed(kemID hpke.KEMID, kdfID hpke.KDFID, aeadID hpke.AEADI
338339
return ObliviousDoHKeyPair{}, err
339340
}
340341

341-
configContents, err := CreateObliviousDoHConfigContents(kemID, kdfID, aeadID, suite.KEM.Serialize(pk))
342+
configContents, err := CreateObliviousDoHConfigContents(kemID, kdfID, aeadID, suite.KEM.SerializePublicKey(pk))
342343
if err != nil {
343344
return ObliviousDoHKeyPair{}, err
344345
}
@@ -369,7 +370,7 @@ func CreateKeyPair(kemID hpke.KEMID, kdfID hpke.KDFID, aeadID hpke.AEADID) (Obli
369370
return ObliviousDoHKeyPair{}, err
370371
}
371372

372-
configContents, err := CreateObliviousDoHConfigContents(kemID, kdfID, aeadID, suite.KEM.Serialize(pk))
373+
configContents, err := CreateObliviousDoHConfigContents(kemID, kdfID, aeadID, suite.KEM.SerializePublicKey(pk))
373374
if err != nil {
374375
return ObliviousDoHKeyPair{}, err
375376
}
@@ -444,7 +445,7 @@ func (targetKey ObliviousDoHConfigContents) EncryptQuery(query *ObliviousDNSQuer
444445
return ObliviousDNSMessage{}, QueryContext{}, err
445446
}
446447

447-
pkR, err := suite.KEM.Deserialize(targetKey.PublicKeyBytes)
448+
pkR, err := suite.KEM.DeserializePublicKey(targetKey.PublicKeyBytes)
448449
if err != nil {
449450
return ObliviousDNSMessage{}, QueryContext{}, err
450451
}
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func createDefaultSerializedPublicKey(t *testing.T) []byte {
214214
t.Fatalf("Failed generating public key")
215215
}
216216

217-
return suite.KEM.Serialize(publicKey)
217+
return suite.KEM.SerializePublicKey(publicKey)
218218
}
219219

220220
func validateSerializedContents(t *testing.T, configContents ObliviousDoHConfigContents, serializedContents []byte) {
@@ -368,7 +368,7 @@ func TestQueryEncryption(t *testing.T) {
368368
KemID: kemID,
369369
KdfID: kdfID,
370370
AeadID: aeadID,
371-
PublicKeyBytes: suite.KEM.Serialize(pkR),
371+
PublicKeyBytes: suite.KEM.SerializePublicKey(pkR),
372372
}
373373

374374
targetConfig := ObliviousDoHConfig{
@@ -423,7 +423,7 @@ func Test_Sender_ODOHQueryEncryption(t *testing.T) {
423423
KemID: kemID,
424424
KdfID: kdfID,
425425
AeadID: aeadID,
426-
PublicKeyBytes: suite.KEM.Serialize(pkR),
426+
PublicKeyBytes: suite.KEM.SerializePublicKey(pkR),
427427
}
428428

429429
targetConfig := ObliviousDoHConfig{
@@ -486,7 +486,7 @@ func TestOdohPublicKeyMarshalUnmarshal(t *testing.T) {
486486
KemID: kemID,
487487
KdfID: kdfID,
488488
AeadID: aeadID,
489-
PublicKeyBytes: suite.KEM.Serialize(pkR),
489+
PublicKeyBytes: suite.KEM.SerializePublicKey(pkR),
490490
}
491491

492492
serializedPublicKey := targetKey.Marshal()
@@ -611,15 +611,15 @@ func mustHex(d []byte) string {
611611

612612
func mustDeserializePub(t *testing.T, suite hpke.CipherSuite, h string, required bool) hpke.KEMPublicKey {
613613
pkm := mustUnhex(t, h)
614-
pk, err := suite.KEM.Deserialize(pkm)
614+
pk, err := suite.KEM.DeserializePublicKey(pkm)
615615
if required {
616616
fatalOnError(t, err, "Deserialize failed")
617617
}
618618
return pk
619619
}
620620

621621
func mustSerializePub(suite hpke.CipherSuite, pub hpke.KEMPublicKey) string {
622-
return mustHex(suite.KEM.Serialize(pub))
622+
return mustHex(suite.KEM.SerializePublicKey(pub))
623623
}
624624

625625
///////

0 commit comments

Comments
 (0)