diff options
author | David Hook <dgh@cryptoworkshop.com> | 2021-05-02 12:02:16 +1000 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2021-05-02 12:02:16 +1000 |
commit | 6b2a3a7eeef943f73140c36e9eaca6bc213b62eb (patch) | |
tree | 72303461c2fde1aacb048b7efc1a6d6908bc5d60 | |
parent | updates for working tests for FPE, TupleHash, ParallelHash (diff) | |
download | BouncyCastle.NET-ed25519-6b2a3a7eeef943f73140c36e9eaca6bc213b62eb.tar.xz |
minor refactor of Hkdf to HKdf
-rw-r--r-- | crypto/src/crypto/generators/HKdfBytesGenerator.cs (renamed from crypto/src/crypto/generators/HKDFBytesGenerator.cs) | 10 | ||||
-rw-r--r-- | crypto/src/crypto/parameters/HKdfParameters.cs (renamed from crypto/src/crypto/parameters/HKDFParameters.cs) | 16 |
2 files changed, 13 insertions, 13 deletions
diff --git a/crypto/src/crypto/generators/HKDFBytesGenerator.cs b/crypto/src/crypto/generators/HKdfBytesGenerator.cs index 6f36a6faa..9672f5ba3 100644 --- a/crypto/src/crypto/generators/HKDFBytesGenerator.cs +++ b/crypto/src/crypto/generators/HKdfBytesGenerator.cs @@ -13,7 +13,7 @@ namespace Org.BouncyCastle.Crypto.Generators * (output keying material) and is likely to have better security properties * than KDF's based on just a hash function. */ - public class HkdfBytesGenerator + public class HKdfBytesGenerator : IDerivationFunction { private HMac hMacHash; @@ -29,7 +29,7 @@ namespace Org.BouncyCastle.Crypto.Generators * * @param hash the digest to be used as the source of generatedBytes bytes */ - public HkdfBytesGenerator(IDigest hash) + public HKdfBytesGenerator(IDigest hash) { this.hMacHash = new HMac(hash); this.hashLen = hash.GetDigestSize(); @@ -37,10 +37,10 @@ namespace Org.BouncyCastle.Crypto.Generators public virtual void Init(IDerivationParameters parameters) { - if (!(parameters is HkdfParameters)) - throw new ArgumentException("HKDF parameters required for HkdfBytesGenerator", "parameters"); + if (!(parameters is HKdfParameters)) + throw new ArgumentException("HKDF parameters required for HKdfBytesGenerator", "parameters"); - HkdfParameters hkdfParameters = (HkdfParameters)parameters; + HKdfParameters hkdfParameters = (HKdfParameters)parameters; if (hkdfParameters.SkipExtract) { // use IKM directly as PRK diff --git a/crypto/src/crypto/parameters/HKDFParameters.cs b/crypto/src/crypto/parameters/HKdfParameters.cs index 6d1465e4c..348b1148a 100644 --- a/crypto/src/crypto/parameters/HKDFParameters.cs +++ b/crypto/src/crypto/parameters/HKdfParameters.cs @@ -6,9 +6,9 @@ using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Crypto.Parameters { /** - * Parameter class for the HkdfBytesGenerator class. + * Parameter class for the HKdfBytesGenerator class. */ - public class HkdfParameters + public class HKdfParameters : IDerivationParameters { private readonly byte[] ikm; @@ -16,7 +16,7 @@ namespace Org.BouncyCastle.Crypto.Parameters private readonly byte[] salt; private readonly byte[] info; - private HkdfParameters(byte[] ikm, bool skip, byte[] salt, byte[] info) + private HKdfParameters(byte[] ikm, bool skip, byte[] salt, byte[] info) { if (ikm == null) throw new ArgumentNullException("ikm"); @@ -51,7 +51,7 @@ namespace Org.BouncyCastle.Crypto.Parameters * @param salt the salt to use, may be null for a salt for hashLen zeros * @param info the info to use, may be null for an info field of zero bytes */ - public HkdfParameters(byte[] ikm, byte[] salt, byte[] info) + public HKdfParameters(byte[] ikm, byte[] salt, byte[] info) : this(ikm, false, salt, info) { } @@ -65,14 +65,14 @@ namespace Org.BouncyCastle.Crypto.Parameters * @param info the info to use, may be null for an info field of zero bytes * @return HKDFParameters that makes the implementation skip step 1 */ - public static HkdfParameters SkipExtractParameters(byte[] ikm, byte[] info) + public static HKdfParameters SkipExtractParameters(byte[] ikm, byte[] info) { - return new HkdfParameters(ikm, true, null, info); + return new HKdfParameters(ikm, true, null, info); } - public static HkdfParameters DefaultParameters(byte[] ikm) + public static HKdfParameters DefaultParameters(byte[] ikm) { - return new HkdfParameters(ikm, false, null, null); + return new HKdfParameters(ikm, false, null, null); } /** |