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

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
const (
35-
ODOH_VERSION = uint16(0xff02)
35+
ODOH_VERSION = uint16(0xff03)
3636
ODOH_SECRET_LENGTH = 32
3737
ODOH_PADDING_BYTE = uint8(0)
3838
ODOH_LABEL_KEY_ID = "odoh key id"
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ import (
2929
"encoding/hex"
3030
"encoding/json"
3131
"fmt"
32-
".com/cisco/go-hpke"
3332
"io"
3433
"io/ioutil"
3534
"os"
3635
"testing"
36+
37+
".com/cisco/go-hpke"
3738
)
3839

3940
const (
@@ -683,7 +684,7 @@ type rawTestVector struct {
683684
KemID int `json:"kem_id"`
684685
KdfID int `json:"kdf_id"`
685686
AeadID int `json:"aead_id"`
686-
Config string `json:"odohconfig"`
687+
Configs string `json:"odohconfigs"`
687688
PublicKeySeed string `json:"public_key_seed"`
688689
KeyId string `json:"key_id"`
689690

@@ -695,7 +696,7 @@ type testVector struct {
695696
kem_id hpke.KEMID
696697
kdf_id hpke.KDFID
697698
aead_id hpke.AEADID
698-
odoh_config []byte
699+
odoh_configs []byte
699700
public_key_seed []byte
700701
key_id []byte
701702

@@ -707,7 +708,7 @@ func (tv testVector) MarshalJSON() ([]byte, error) {
707708
KemID: int(tv.kem_id),
708709
KdfID: int(tv.kdf_id),
709710
AeadID: int(tv.aead_id),
710-
Config: mustHex(tv.odoh_config),
711+
Configs: mustHex(tv.odoh_configs),
711712
PublicKeySeed: mustHex(tv.public_key_seed),
712713
KeyId: mustHex(tv.key_id),
713714
Transactions: tv.transactions,
@@ -725,7 +726,7 @@ func (tv *testVector) UnmarshalJSON(data []byte) error {
725726
tv.kdf_id = hpke.KDFID(raw.KdfID)
726727
tv.aead_id = hpke.AEADID(raw.AeadID)
727728
tv.public_key_seed = mustUnhex(tv.t, raw.PublicKeySeed)
728-
tv.odoh_config = mustUnhex(tv.t, raw.Config)
729+
tv.odoh_configs = mustUnhex(tv.t, raw.Configs)
729730
tv.key_id = mustUnhex(tv.t, raw.KeyId)
730731

731732
tv.transactions = raw.Transactions
@@ -828,12 +829,13 @@ func generateTestVector(t *testing.T, kem_id hpke.KEMID, kdf_id hpke.KDFID, aead
828829
}
829830
}
830831

832+
configs := []ObliviousDoHConfig{kp.Config}
831833
vector := testVector{
832834
t: t,
833835
kem_id: kem_id,
834836
kdf_id: kdf_id,
835837
aead_id: aead_id,
836-
odoh_config: kp.Config.Marshal(),
838+
odoh_configs: CreateObliviousDoHConfigs(configs).Marshal(),
837839
public_key_seed: kp.Seed,
838840
key_id: kp.Config.Contents.KeyID(),
839841
transactions: transactions,
@@ -843,8 +845,9 @@ func generateTestVector(t *testing.T, kem_id hpke.KEMID, kdf_id hpke.KDFID, aead
843845
}
844846

845847
func verifyTestVector(t *testing.T, tv testVector) {
846-
config, err := UnmarshalObliviousDoHConfig(tv.odoh_config)
847-
assertNotError(t, "UnmarshalObliviousDoHConfigContents failed", err)
848+
configs, err := UnmarshalObliviousDoHConfigs(tv.odoh_configs)
849+
assertNotError(t, "UnmarshalObliviousDoHConfigs failed", err)
850+
config := configs.Configs[0]
848851

849852
kp, err := CreateKeyPairFromSeed(config.Contents.KemID, config.Contents.KdfID, config.Contents.AeadID, tv.public_key_seed)
850853
assertNotError(t, "CreateKeyPairFromSeed failed", err)
@@ -892,7 +895,7 @@ func verifyTestVectors(t *testing.T, vectorString []byte, subtest bool) {
892895
if !subtest {
893896
test(t)
894897
} else {
895-
label := fmt.Sprintf("config=%x", tv.odoh_config)
898+
label := fmt.Sprintf("odohconfigs=%x", tv.odoh_configs)
896899
t.Run(label, test)
897900
}
898901
}

0 commit comments

Comments
 (0)