Skip to content

Commit

Permalink
Rename variables representing algorithm names
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhosv committed Aug 28, 2024
1 parent 65892ec commit 764a8ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import static com.amazon.corretto.crypto.provider.ConcatenationKdfSpi.CKDF_WITH_SHA256;
import static com.amazon.corretto.crypto.provider.ConcatenationKdfSpi.CKDF_WITH_SHA384;
import static com.amazon.corretto.crypto.provider.ConcatenationKdfSpi.CKDF_WITH_SHA512;
import static com.amazon.corretto.crypto.provider.CounterKdfSpi.CNTRKDF_WITH_SHA256;
import static com.amazon.corretto.crypto.provider.CounterKdfSpi.CNTRKDF_WITH_SHA384;
import static com.amazon.corretto.crypto.provider.CounterKdfSpi.CNTRKDF_WITH_SHA512;
import static com.amazon.corretto.crypto.provider.CounterKdfSpi.CTR_KDF_WITH_HMAC_SHA256;
import static com.amazon.corretto.crypto.provider.CounterKdfSpi.CTR_KDF_WITH_HMAC_SHA384;
import static com.amazon.corretto.crypto.provider.CounterKdfSpi.CTR_KDF_WITH_HMAC_SHA512;
import static com.amazon.corretto.crypto.provider.HkdfSecretKeyFactorySpi.HKDF_WITH_SHA1;
import static com.amazon.corretto.crypto.provider.HkdfSecretKeyFactorySpi.HKDF_WITH_SHA256;
import static com.amazon.corretto.crypto.provider.HkdfSecretKeyFactorySpi.HKDF_WITH_SHA384;
Expand Down Expand Up @@ -105,9 +105,9 @@ private void buildServiceMap() {
addService("SecretKeyFactory", CKDF_WITH_HMAC_SHA512, concatenationKdfSpi, false);

final String counterKdfSpi = "CounterKdfSpi";
addService("SecretKeyFactory", CNTRKDF_WITH_SHA256, counterKdfSpi, false);
addService("SecretKeyFactory", CNTRKDF_WITH_SHA384, counterKdfSpi, false);
addService("SecretKeyFactory", CNTRKDF_WITH_SHA512, counterKdfSpi, false);
addService("SecretKeyFactory", CTR_KDF_WITH_HMAC_SHA256, counterKdfSpi, false);
addService("SecretKeyFactory", CTR_KDF_WITH_HMAC_SHA384, counterKdfSpi, false);
addService("SecretKeyFactory", CTR_KDF_WITH_HMAC_SHA512, counterKdfSpi, false);
}

addService("KeyPairGenerator", "RSA", "RsaGen");
Expand Down
17 changes: 9 additions & 8 deletions src/com/amazon/corretto/crypto/provider/CounterKdfSpi.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@ private static native void nKdf(

static final Map<String, CounterKdfSpi> INSTANCES = getInstances();

private static final String CNTR_KDF = "CounterKdf";
private static final String WITH_HMAC = "WithHmac";
static final String CNTRKDF_WITH_SHA256 = CNTR_KDF + WITH_HMAC + "SHA256";
static final String CNTRKDF_WITH_SHA384 = CNTR_KDF + WITH_HMAC + "SHA384";
static final String CNTRKDF_WITH_SHA512 = CNTR_KDF + WITH_HMAC + "SHA512";
static final String CTR_KDF_WITH_HMAC_SHA256 = "CounterKdfWithHmacSHA256";
static final String CTR_KDF_WITH_HMAC_SHA384 = "CounterKdfWithHmacSHA384";
static final String CTR_KDF_WITH_HMAC_SHA512 = "CounterKdfWithHmacSHA512";

private static Map<String, CounterKdfSpi> getInstances() {
final Map<String, CounterKdfSpi> kdfs = new HashMap<>();
kdfs.put(getSpiFactoryForAlgName(CNTRKDF_WITH_SHA256), new CounterKdfSpi(Utils.SHA256_CODE));
kdfs.put(getSpiFactoryForAlgName(CNTRKDF_WITH_SHA384), new CounterKdfSpi(Utils.SHA384_CODE));
kdfs.put(getSpiFactoryForAlgName(CNTRKDF_WITH_SHA512), new CounterKdfSpi(Utils.SHA512_CODE));
kdfs.put(
getSpiFactoryForAlgName(CTR_KDF_WITH_HMAC_SHA256), new CounterKdfSpi(Utils.SHA256_CODE));
kdfs.put(
getSpiFactoryForAlgName(CTR_KDF_WITH_HMAC_SHA384), new CounterKdfSpi(Utils.SHA384_CODE));
kdfs.put(
getSpiFactoryForAlgName(CTR_KDF_WITH_HMAC_SHA512), new CounterKdfSpi(Utils.SHA512_CODE));
return Collections.unmodifiableMap(kdfs);
}

Expand Down

0 comments on commit 764a8ff

Please sign in to comment.