@@ -29,11 +29,12 @@ import (
|
29 | 29 | "encoding/hex"
|
30 | 30 | "encoding/json"
|
31 | 31 | "fmt"
|
32 |
| -".com/cisco/go-hpke" |
33 | 32 | "io"
|
34 | 33 | "io/ioutil"
|
35 | 34 | "os"
|
36 | 35 | "testing"
|
| 36 | + |
| 37 | +".com/cisco/go-hpke" |
37 | 38 | )
|
38 | 39 |
|
39 | 40 | const (
|
@@ -683,7 +684,7 @@ type rawTestVector struct {
|
683 | 684 | KemID int `json:"kem_id"`
|
684 | 685 | KdfID int `json:"kdf_id"`
|
685 | 686 | AeadID int `json:"aead_id"`
|
686 |
| -Config string `json:"odohconfig"` |
| 687 | +Configs string `json:"odohconfigs"` |
687 | 688 | PublicKeySeed string `json:"public_key_seed"`
|
688 | 689 | KeyId string `json:"key_id"`
|
689 | 690 |
|
@@ -695,7 +696,7 @@ type testVector struct {
|
695 | 696 | kem_id hpke.KEMID
|
696 | 697 | kdf_id hpke.KDFID
|
697 | 698 | aead_id hpke.AEADID
|
698 |
| -odoh_config []byte |
| 699 | +odoh_configs []byte |
699 | 700 | public_key_seed []byte
|
700 | 701 | key_id []byte
|
701 | 702 |
|
@@ -707,7 +708,7 @@ func (tv testVector) MarshalJSON() ([]byte, error) {
|
707 | 708 | KemID: int(tv.kem_id),
|
708 | 709 | KdfID: int(tv.kdf_id),
|
709 | 710 | AeadID: int(tv.aead_id),
|
710 |
| -Config: mustHex(tv.odoh_config), |
| 711 | +Configs: mustHex(tv.odoh_configs), |
711 | 712 | PublicKeySeed: mustHex(tv.public_key_seed),
|
712 | 713 | KeyId: mustHex(tv.key_id),
|
713 | 714 | Transactions: tv.transactions,
|
@@ -725,7 +726,7 @@ func (tv *testVector) UnmarshalJSON(data []byte) error {
|
725 | 726 | tv.kdf_id = hpke.KDFID(raw.KdfID)
|
726 | 727 | tv.aead_id = hpke.AEADID(raw.AeadID)
|
727 | 728 | 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) |
729 | 730 | tv.key_id = mustUnhex(tv.t, raw.KeyId)
|
730 | 731 |
|
731 | 732 | tv.transactions = raw.Transactions
|
@@ -828,12 +829,13 @@ func generateTestVector(t *testing.T, kem_id hpke.KEMID, kdf_id hpke.KDFID, aead
|
828 | 829 | }
|
829 | 830 | }
|
830 | 831 |
|
| 832 | +configs := []ObliviousDoHConfig{kp.Config} |
831 | 833 | vector := testVector{
|
832 | 834 | t: t,
|
833 | 835 | kem_id: kem_id,
|
834 | 836 | kdf_id: kdf_id,
|
835 | 837 | aead_id: aead_id,
|
836 |
| -odoh_config: kp.Config.Marshal(), |
| 838 | +odoh_configs: CreateObliviousDoHConfigs(configs).Marshal(), |
837 | 839 | public_key_seed: kp.Seed,
|
838 | 840 | key_id: kp.Config.Contents.KeyID(),
|
839 | 841 | transactions: transactions,
|
@@ -843,8 +845,9 @@ func generateTestVector(t *testing.T, kem_id hpke.KEMID, kdf_id hpke.KDFID, aead
|
843 | 845 | }
|
844 | 846 |
|
845 | 847 | 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] |
848 | 851 |
|
849 | 852 | kp, err := CreateKeyPairFromSeed(config.Contents.KemID, config.Contents.KdfID, config.Contents.AeadID, tv.public_key_seed)
|
850 | 853 | assertNotError(t, "CreateKeyPairFromSeed failed", err)
|
@@ -892,7 +895,7 @@ func verifyTestVectors(t *testing.T, vectorString []byte, subtest bool) {
|
892 | 895 | if !subtest {
|
893 | 896 | test(t)
|
894 | 897 | } else {
|
895 |
| -label := fmt.Sprintf("config=%x", tv.odoh_config) |
| 898 | +label := fmt.Sprintf("odohconfigs=%x", tv.odoh_configs) |
896 | 899 | t.Run(label, test)
|
897 | 900 | }
|
898 | 901 | }
|
|
0 commit comments