acvptool: support hybrid HKDF shared secrets

The SP800-56Cr2 ACVP KDA HKDF spec allows a hybrid shared secret Z ||
T by opting in to the usesHybridSharedSecret capability. To support
this, decode the optional t parameter and append it to z before invoking
the HKDF subcmd. An absent t preserves ordinary and revision-1
processing.

See the ACVP KAS-KDF spec for more information:
  https://pages.nist.gov/ACVP/draft-hammett-acvp-kas-kdf-hkdf.html#section-7.3

Change-Id: I011f3b077694bd388bc3b630211321908614f95f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/105530
Reviewed-by: David Benjamin <davidben@google.com>
Presubmit-BoringSSL-Verified: boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
diff --git a/util/fipstools/acvp/acvptool/subprocess/kda.go b/util/fipstools/acvp/acvptool/subprocess/kda.go
index c93a80b..44b4353 100644
--- a/util/fipstools/acvp/acvptool/subprocess/kda.go
+++ b/util/fipstools/acvp/acvptool/subprocess/kda.go
@@ -103,8 +103,9 @@
 }
 
 type hkdfParameters struct {
-	SaltHex string `json:"salt"`
-	KeyHex  string `json:"z"`
+	SaltHex   string `json:"salt"`
+	KeyHex    string `json:"z"`
+	AuxKeyHex string `json:"t"`
 }
 
 func (p *hkdfParameters) extract() (key, salt []byte, err error) {
@@ -118,6 +119,13 @@
 		return nil, nil, err
 	}
 
+	// For a hybrid shared secret, the input is Z || T (SP 800-56C Rev. 2).
+	auxKey, err := hex.DecodeString(p.AuxKeyHex)
+	if err != nil {
+		return nil, nil, err
+	}
+	key = append(key, auxKey...)
+
 	return key, salt, nil
 }
 
diff --git a/util/fipstools/acvp/acvptool/test/expected/HKDF-hybrid.bz2 b/util/fipstools/acvp/acvptool/test/expected/HKDF-hybrid.bz2
new file mode 100644
index 0000000..80dd912
--- /dev/null
+++ b/util/fipstools/acvp/acvptool/test/expected/HKDF-hybrid.bz2
Binary files differ
diff --git a/util/fipstools/acvp/acvptool/test/tests.json b/util/fipstools/acvp/acvptool/test/tests.json
index 92aa111..448c50d 100644
--- a/util/fipstools/acvp/acvptool/test/tests.json
+++ b/util/fipstools/acvp/acvptool/test/tests.json
@@ -21,6 +21,7 @@
 {"Wrapper": "modulewrapper", "In": "vectors/HMAC-SHA2-512.bz2", "Out": "expected/HMAC-SHA2-512.bz2"},
 {"Wrapper": "modulewrapper", "In": "vectors/HMAC-SHA2-512-256.bz2", "Out": "expected/HMAC-SHA2-512-256.bz2"},
 {"Wrapper": "modulewrapper", "In": "vectors/HKDF.bz2", "Out": "expected/HKDF.bz2"},
+{"Wrapper": "modulewrapper", "In": "vectors/HKDF-hybrid.bz2", "Out": "expected/HKDF-hybrid.bz2"},
 {"Wrapper": "testmodulewrapper", "In": "vectors/hmacDRBG.bz2", "Out": "expected/hmacDRBG.bz2"},
 {"Wrapper": "testmodulewrapper", "In": "vectors/KDA.bz2", "Out": "expected/KDA.bz2"},
 {"Wrapper": "modulewrapper", "In": "vectors/KAS-ECC-SSC.bz2"},
diff --git a/util/fipstools/acvp/acvptool/test/vectors/HKDF-hybrid.bz2 b/util/fipstools/acvp/acvptool/test/vectors/HKDF-hybrid.bz2
new file mode 100644
index 0000000..d74b1db
--- /dev/null
+++ b/util/fipstools/acvp/acvptool/test/vectors/HKDF-hybrid.bz2
Binary files differ