@@ -131,7 +131,7 @@ var (
131
131
// https://pages.nist.gov/ACVP/draft-hammett-acvp-kas-ssc-ecc.html#section-7.3
132
132
// HMAC DRBG and CTR DRBG algorithm capabilities:
133
133
// https://pages.nist.gov/ACVP/draft-vassilev-acvp-drbg.html#section-7.2
134
- // KDF-Counter algorithm capabilities:
134
+ // KDF-Counter and KDF-Feedback algorithm capabilities:
135
135
// https://pages.nist.gov/ACVP/draft-celi-acvp-kbkdf.html#section-7.3
136
136
// RSA algorithm capabilities:
137
137
// https://pages.nist.gov/ACVP/draft-celi-acvp-rsa.html#section-7.3
@@ -268,8 +268,6 @@ var (
268
268
"ctrDRBG/AES-256" : cmdCtrDrbgAft (),
269
269
"ctrDRBG-reseed/AES-256" : cmdCtrDrbgReseedAft (),
270
270
271
- "KDF-counter" : cmdKdfCounterAft (),
272
-
273
271
"RSA/keyGen" : cmdRsaKeyGenAft (),
274
272
275
273
"RSA/sigGen/SHA2-224/pkcs1v1.5" : cmdRsaSigGenAft (func () fips140.Hash { return sha256 .New224 () }, "SHA-224" , false ),
@@ -289,6 +287,9 @@ var (
289
287
"RSA/sigVer/SHA2-256/pss" : cmdRsaSigVerAft (func () fips140.Hash { return sha256 .New () }, "SHA-256" , true ),
290
288
"RSA/sigVer/SHA2-384/pss" : cmdRsaSigVerAft (func () fips140.Hash { return sha512 .New384 () }, "SHA-384" , true ),
291
289
"RSA/sigVer/SHA2-512/pss" : cmdRsaSigVerAft (func () fips140.Hash { return sha512 .New () }, "SHA-512" , true ),
290
+
291
+ "KDF-counter" : cmdKdfCounterAft (),
292
+ "KDF-feedback" : cmdKdfFeedbackAft (),
292
293
}
293
294
)
294
295
@@ -1651,6 +1652,57 @@ func cmdKdfCounterAft() command {
1651
1652
}
1652
1653
}
1653
1654
1655
+ func cmdKdfFeedbackAft () command {
1656
+ return command {
1657
+ requiredArgs : 5 , // Number output bytes, PRF name, counter location string, key, number of counter bits, IV
1658
+ handler : func (args [][]byte ) ([][]byte , error ) {
1659
+ // The max supported output len for the KDF algorithm type is 4096 bits, making an int cast
1660
+ // here safe.
1661
+ // See https://pages.nist.gov/ACVP/draft-celi-acvp-kbkdf.html#section-7.3.2
1662
+ outputBytes := int (binary .LittleEndian .Uint32 (args [0 ]))
1663
+ prf := string (args [1 ])
1664
+ counterLocation := args [2 ]
1665
+ key := args [3 ]
1666
+ counterBits := binary .LittleEndian .Uint32 (args [4 ])
1667
+
1668
+ if ! strings .HasPrefix (prf , "HMAC-" ) {
1669
+ return nil , fmt .Errorf ("feedback KDF received unsupported PRF %q" , prf )
1670
+ }
1671
+ prf = prf [len ("HMAC-" ):]
1672
+
1673
+ h , err := lookupHash (prf )
1674
+ if err != nil {
1675
+ return nil , fmt .Errorf ("feedback KDF received unsupported PRF %q: %w" , prf , err )
1676
+ }
1677
+
1678
+ if ! bytes .Equal (counterLocation , []byte ("after fixed data" )) {
1679
+ return nil , fmt .Errorf ("feedback KDF received unsupported counter location %q" , string (counterLocation ))
1680
+ }
1681
+
1682
+ // The spec doesn't describe the "deferred" property for a KDF counterMode test case.
1683
+ // BoringSSL's acvptool sends an empty key when deferred=true, but with the capabilities
1684
+ // we register all test cases have deferred=false and provide a key from the populated
1685
+ // keyIn property.
1686
+ if len (key ) == 0 {
1687
+ return nil , errors .New ("deferred test cases are not supported" )
1688
+ }
1689
+
1690
+ if counterBits != 8 {
1691
+ return nil , fmt .Errorf ("feedback KDF received unsupported counter length %d" , counterBits )
1692
+ }
1693
+
1694
+ var context [12 ]byte
1695
+ rand .Reader .Read (context [:])
1696
+ fixedData := make ([]byte , 1 + 1 + 12 ) // 1 byte label (we pick null), 1 null byte, 12 bytes context.
1697
+ copy (fixedData [2 :], context [:])
1698
+
1699
+ result := hkdf .Expand (h , key , string (fixedData [:]), outputBytes )
1700
+
1701
+ return [][]byte {key , fixedData [:], result [:]}, nil
1702
+ },
1703
+ }
1704
+ }
1705
+
1654
1706
func cmdRsaKeyGenAft () command {
1655
1707
return command {
1656
1708
requiredArgs : 1 , // Modulus bit-size
@@ -1775,7 +1827,7 @@ func TestACVP(t *testing.T) {
1775
1827
1776
1828
const (
1777
1829
bsslModule = "boringssl.googlesource.com/boringssl.git"
1778
- bsslVersion = "v0.0.0-20250116010235-21f54b2730ee "
1830
+ bsslVersion = "v0.0.0-20250123161947-ba24bde161f7 "
1779
1831
goAcvpModule = "github.com/cpu/go-acvp"
1780
1832
goAcvpVersion = "v0.0.0-20250110181646-e47fea3b5d7d"
1781
1833
)
0 commit comments