Skip to content

Commit a7991ca

Browse files
committed
we do not need this
1 parent 12aa78b commit a7991ca

4 files changed

Lines changed: 7 additions & 9 deletions

File tree

sdk/src/main/java/io/opentdf/platform/sdk/ECKeyPair.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ public enum ECAlgorithm {
3434
private KeyPair keyPair;
3535

3636
public ECKeyPair() {
37-
this(ECCurve.SECP256R1, ECAlgorithm.ECDH);
37+
this(ECCurve.SECP256R1);
3838
}
3939

40-
public ECKeyPair(ECCurve curve, ECAlgorithm algorithm) {
40+
public ECKeyPair(ECCurve curve) {
4141
this.curve = Objects.requireNonNull(curve);
42-
Objects.requireNonNull(algorithm);
4342
try {
4443
KeyPairGenerator generator = KeyPairGenerator.getInstance(EC_ALGORITHM);
4544
generator.initialize(new ECGenParameterSpec(this.curve.getCurveName()));

sdk/src/main/java/io/opentdf/platform/sdk/KASClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import io.opentdf.platform.kas.PublicKeyResponse;
1818
import io.opentdf.platform.kas.RewrapRequest;
1919
import io.opentdf.platform.kas.RewrapResponse;
20-
import io.opentdf.platform.sdk.Config.KASInfo;
2120
import io.opentdf.platform.sdk.SDK.KasBadRequestException;
2221

2322
import okhttp3.OkHttpClient;
@@ -127,7 +126,7 @@ public byte[] unwrap(Manifest.KeyAccess keyAccess, String policy, KeyType sessi
127126
ECKeyPair ecKeyPair = null;
128127
if (sessionKeyType.isEc()) {
129128
var curve = sessionKeyType.getECCurve();
130-
ecKeyPair = new ECKeyPair(curve, ECKeyPair.ECAlgorithm.ECDH);
129+
ecKeyPair = new ECKeyPair(curve);
131130
clientPublicKey = ecKeyPair.publicKeyInPEMFormat();
132131
} else {
133132
// Initialize the RSA key pair only once and reuse it for future unwrap operations

sdk/src/main/java/io/opentdf/platform/sdk/TDF.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private Manifest.KeyAccess createKeyAccess(Config.TDFConfig tdfConfig, Config.KA
245245
private ECKeyWrappedKeyInfo createECWrappedKey(Config.KASInfo kasInfo,
246246
byte[] symKey, KeyType keyType) {
247247
var curveName = keyType.getECCurve();
248-
var keyPair = new ECKeyPair(curveName, ECKeyPair.ECAlgorithm.ECDH);
248+
var keyPair = new ECKeyPair(curveName);
249249

250250
ECPublicKey kasPubKey;
251251
try {

sdk/src/test/java/io/opentdf/platform/sdk/ECKeyPairTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ void extractPemPubKeyFromX509() throws CertificateException, IOException, NoSuch
124124

125125
@Test
126126
void createSymmetricKeysWithOtherCurves() {
127-
ECKeyPair pubPair = new ECKeyPair(ECCurve.SECP384R1, ECKeyPair.ECAlgorithm.ECDH);
128-
ECKeyPair keyPair = new ECKeyPair(ECCurve.SECP384R1, ECKeyPair.ECAlgorithm.ECDH);
127+
ECKeyPair pubPair = new ECKeyPair(ECCurve.SECP384R1);
128+
ECKeyPair keyPair = new ECKeyPair(ECCurve.SECP384R1);
129129

130130
byte[] sharedSecret = ECKeyPair.computeECDHKey(pubPair.getPublicKey(), keyPair.getPrivateKey());
131131
byte[] encryptionKey = ECKeyPair.calculateHKDF(ECKeys.salt.getBytes(StandardCharsets.UTF_8), sharedSecret);
@@ -172,7 +172,7 @@ void testECDSA() {
172172
if (!curve.isSupported()) {
173173
continue;
174174
}
175-
ECKeyPair keyPair = new ECKeyPair(curve, ECKeyPair.ECAlgorithm.ECDSA);
175+
ECKeyPair keyPair = new ECKeyPair(curve);
176176
byte[] signature = ECKeyPair.computeECDSASig(plainText.getBytes(), keyPair.getPrivateKey());
177177
boolean verify = ECKeyPair.verifyECDSAig(plainText.getBytes(), signature, keyPair.getPublicKey());
178178
assertEquals(verify, true);

0 commit comments

Comments
 (0)