(enc []byte)
| 68 | } |
| 69 | |
| 70 | func parseECHConfig(enc []byte) (skip bool, ec EchConfig, err error) { |
| 71 | s := cryptobyte.String(enc) |
| 72 | ec.raw = []byte(enc) |
| 73 | if !s.ReadUint16(&ec.Version) { |
| 74 | return false, EchConfig{}, &echConfigErr{"version"} |
| 75 | } |
| 76 | if !s.ReadUint16(&ec.Length) { |
| 77 | return false, EchConfig{}, &echConfigErr{"length"} |
| 78 | } |
| 79 | if len(ec.raw) < int(ec.Length)+4 { |
| 80 | return false, EchConfig{}, &echConfigErr{"length"} |
| 81 | } |
| 82 | ec.raw = ec.raw[:ec.Length+4] |
| 83 | if ec.Version != extensionEncryptedClientHello { |
| 84 | s.Skip(int(ec.Length)) |
| 85 | return true, EchConfig{}, nil |
| 86 | } |
| 87 | if !s.ReadUint8(&ec.ConfigID) { |
| 88 | return false, EchConfig{}, &echConfigErr{"config_id"} |
| 89 | } |
| 90 | if !s.ReadUint16(&ec.KemID) { |
| 91 | return false, EchConfig{}, &echConfigErr{"kem_id"} |
| 92 | } |
| 93 | if !readUint16LengthPrefixed(&s, &ec.PublicKey) { |
| 94 | return false, EchConfig{}, &echConfigErr{"public_key"} |
| 95 | } |
| 96 | var cipherSuites cryptobyte.String |
| 97 | if !s.ReadUint16LengthPrefixed(&cipherSuites) { |
| 98 | return false, EchConfig{}, &echConfigErr{"cipher_suites"} |
| 99 | } |
| 100 | for !cipherSuites.Empty() { |
| 101 | var c EchCipher |
| 102 | if !cipherSuites.ReadUint16(&c.KDFID) { |
| 103 | return false, EchConfig{}, &echConfigErr{"cipher_suites kdf_id"} |
| 104 | } |
| 105 | if !cipherSuites.ReadUint16(&c.AEADID) { |
| 106 | return false, EchConfig{}, &echConfigErr{"cipher_suites aead_id"} |
| 107 | } |
| 108 | ec.SymmetricCipherSuite = append(ec.SymmetricCipherSuite, c) |
| 109 | } |
| 110 | if !s.ReadUint8(&ec.MaxNameLength) { |
| 111 | return false, EchConfig{}, &echConfigErr{"maximum_name_length"} |
| 112 | } |
| 113 | var publicName cryptobyte.String |
| 114 | if !s.ReadUint8LengthPrefixed(&publicName) { |
| 115 | return false, EchConfig{}, &echConfigErr{"public_name"} |
| 116 | } |
| 117 | ec.PublicName = publicName |
| 118 | var extensions cryptobyte.String |
| 119 | if !s.ReadUint16LengthPrefixed(&extensions) { |
| 120 | return false, EchConfig{}, &echConfigErr{"extensions"} |
| 121 | } |
| 122 | for !extensions.Empty() { |
| 123 | var e echExtension |
| 124 | if !extensions.ReadUint16(&e.Type) { |
| 125 | return false, EchConfig{}, &echConfigErr{"extensions type"} |
| 126 | } |
| 127 | if !extensions.ReadUint16LengthPrefixed((*cryptobyte.String)(&e.Data)) { |
no test coverage detected
searching dependent graphs…