Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorMaurice Aarts <maurice@aarts.info>2014-05-14 19:50:11 +0400
committerMaurice Aarts <maurice@aarts.info>2014-05-14 19:50:11 +0400
commitdcc80faed5c210c4bef54cf38cb327d18b554269 (patch)
treeb22bff4180bfa3e52fe331a23cf97b1171c63111 /core/src
parent813e41d1e555fd69135cdfcd63bce2366a6a9e5c (diff)
Updated KDF Counter Generator Test to support new version of KDF Counter Generator
New KDF Counter Generator Test now supports all three variants of the NIST SP800-108 KDF Counter-based scheme.
Diffstat (limited to 'core/src')
-rw-r--r--core/src/test/java/org/bouncycastle/crypto/test/cavp/KDFCounterTests.java35
1 files changed, 26 insertions, 9 deletions
diff --git a/core/src/test/java/org/bouncycastle/crypto/test/cavp/KDFCounterTests.java b/core/src/test/java/org/bouncycastle/crypto/test/cavp/KDFCounterTests.java
index 868fdc8d..81f10824 100644
--- a/core/src/test/java/org/bouncycastle/crypto/test/cavp/KDFCounterTests.java
+++ b/core/src/test/java/org/bouncycastle/crypto/test/cavp/KDFCounterTests.java
@@ -23,12 +23,6 @@ public final class KDFCounterTests
Properties vectors)
{
- // always skip AFTER_FIXED, not included in SP 800-108
- if (config.getProperty("CTRLOCATION").matches("AFTER_FIXED"))
- {
- return;
- }
-
// create Mac based PRF from PRF property, create the KDF
final Mac prf = CAVPReader.createPRF(config);
final KDFCounterBytesGenerator gen = new KDFCounterBytesGenerator(prf);
@@ -44,9 +38,32 @@ public final class KDFCounterTests
final int count = Integer.parseInt(vectors.getProperty("COUNT"));
final int l = Integer.parseInt(vectors.getProperty("L"));
final byte[] ki = Hex.decode(vectors.getProperty("KI"));
- final byte[] fixedInputData = Hex.decode(vectors.getProperty("FixedInputData"));
- final KDFCounterParameters params = new KDFCounterParameters(ki, fixedInputData, r);
- gen.init(params);
+
+ //Three variants of this KDF are possible, with the counter before the fixed data, after the fixed data, or in the middle of the fixed data.
+ if (config.getProperty("CTRLOCATION").matches("BEFORE_FIXED"))
+ {
+ final byte[] fixedInputData = Hex.decode(vectors.getProperty("FixedInputData"));
+ final KDFCounterParameters params = new KDFCounterParameters(ki, null, fixedInputData, r);
+ gen.init(params);
+ }
+ else if (config.getProperty("CTRLOCATION").matches("AFTER_FIXED"))
+ {
+ final byte[] fixedInputData = Hex.decode(vectors.getProperty("FixedInputData"));
+ final KDFCounterParameters params = new KDFCounterParameters(ki, fixedInputData, null, r);
+ gen.init(params);
+ }
+ else if (config.getProperty("CTRLOCATION").matches("MIDDLE_FIXED"))
+ {
+ final byte[] DataBeforeCtrData = Hex.decode(vectors.getProperty("DataBeforeCtrData"));
+ final byte[] DataAfterCtrData = Hex.decode(vectors.getProperty("DataAfterCtrData"));
+ final KDFCounterParameters params = new KDFCounterParameters(ki, DataBeforeCtrData, DataAfterCtrData, r);
+ gen.init(params);
+ }
+ else
+ {
+ return; // Unknown CTRLOCATION
+ }
+
final byte[] koGenerated = new byte[l / 8];
gen.generateBytes(koGenerated, 0, koGenerated.length);