Skip to content

Commit 4de44cf

Browse files
committed
JCE: use Ecc.getCurveSizeFromName in WolfCryptSignature to get curve size
1 parent 8ee4d34 commit 4de44cf

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/main/java/com/wolfssl/provider/jce/WolfCryptSignature.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,6 @@ public wcSHA512wRSAPSS() throws NoSuchAlgorithmException {
17191719

17201720
/**
17211721
* Get the component size in bytes for P1363 format based on curve.
1722-
* This is calculated as ceil(curve_bits / 8).
17231722
*
17241723
* @param ecc ECC key to get curve size from
17251724
*
@@ -1730,11 +1729,27 @@ public wcSHA512wRSAPSS() throws NoSuchAlgorithmException {
17301729
private static int getP1363ComponentSize(Ecc ecc)
17311730
throws SignatureException {
17321731

1732+
int curveId;
1733+
String curveName;
17331734
int componentSize;
17341735

17351736
try {
1736-
/* Get curve size in bytes, gives us the component size */
1737-
componentSize = ecc.getCurveSizeByKey();
1737+
/* Get curve ID from key */
1738+
curveId = ecc.getCurveId();
1739+
if (curveId < 0) {
1740+
throw new SignatureException(
1741+
"Invalid curve ID for P1363 format");
1742+
}
1743+
1744+
/* Get curve name from ID */
1745+
curveName = Ecc.getCurveNameFromId(curveId);
1746+
if (curveName == null) {
1747+
throw new SignatureException(
1748+
"Failed to get curve name for P1363 format");
1749+
}
1750+
1751+
/* Get fixed curve field size from name */
1752+
componentSize = Ecc.getCurveSizeFromName(curveName.toUpperCase());
17381753
if (componentSize <= 0) {
17391754
throw new SignatureException(
17401755
"Invalid curve size for P1363 format");

0 commit comments

Comments
 (0)