|
1 | 1 | package io.opentdf.platform.sdk; |
2 | 2 |
|
3 | 3 | public class NanoTDFType { |
4 | | - public enum ECCurve { |
5 | | - SECP256R1("secp256r1"), |
6 | | - SECP384R1("secp384r1"), |
7 | | - SECP521R1("secp384r1"), |
8 | | - SECP256K1("secp256k1"); |
| 4 | + enum ECCurve { |
| 5 | + SECP256R1("secp256r1", 32, 33, 0x00), |
| 6 | + SECP384R1("secp384r1", 48, 49, 0x01), |
| 7 | + SECP521R1("secp512r1", 66, 67, 0x02), |
| 8 | + SECP256K1("secp256k1",-1, -1, -1, false); // Note: SECP256K1 is not supported by the SDK |
9 | 9 |
|
10 | | - private final String name; |
| 10 | + final int curveMode; |
| 11 | + final int keySize; |
| 12 | + final int compressedPubKeySize; |
| 13 | + final String curveName; |
| 14 | + final boolean isSupported; |
11 | 15 |
|
12 | | - ECCurve(String curveName) { |
13 | | - this.name = curveName; |
| 16 | + |
| 17 | + ECCurve(String curveName, int compressedPubKeySize, int keySize, int curveMode) { |
| 18 | + this(curveName, compressedPubKeySize, keySize, curveMode, true); |
| 19 | + } |
| 20 | + |
| 21 | + ECCurve(String curveName, int compressedPubKeySize, int keySize, int curveMode, boolean isSupported) { |
| 22 | + this.compressedPubKeySize = compressedPubKeySize; |
| 23 | + this.keySize = keySize; |
| 24 | + this.curveMode = curveMode; |
| 25 | + this.curveName = curveName ; |
| 26 | + this.isSupported = isSupported; |
14 | 27 | } |
15 | 28 |
|
16 | | - @Override |
17 | | - public String toString() { |
18 | | - return name; |
| 29 | + static ECCurve fromCurveMode(int curveMode) { |
| 30 | + for (ECCurve curve : ECCurve.values()) { |
| 31 | + if (curve.curveMode == curveMode) { |
| 32 | + return curve; |
| 33 | + } |
| 34 | + } |
| 35 | + throw new IllegalArgumentException("No enum constant for curve mode: " + curveMode); |
19 | 36 | } |
20 | 37 | } |
21 | 38 | // ResourceLocator Protocol |
|
0 commit comments