Skip to content

Commit f61cfa8

Browse files
authored
Test case change to reflect accurate assertion for Elliptic Curve 'd' values against the curve order (not the field size) per https://datatracker.ietf.org/doc/html/rfc7518#section-6.2.2.1 (#906)
1 parent fd619e0 commit f61cfa8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

impl/src/test/groovy/io/jsonwebtoken/impl/security/AbstractEcJwkFactoryTest.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,18 @@ class AbstractEcJwkFactoryTest {
6363
def y = Decoders.BASE64URL.decode(ys)
6464
def d = Decoders.BASE64URL.decode(ds)
6565

66-
// most important part of the test: the decoded byte arrays must have a length equal to the curve
67-
// field size (in bytes):
66+
// most important part of the test: 'x' and 'y' decoded byte arrays must have a length equal to the curve
67+
// field size (in bytes) per https://datatracker.ietf.org/doc/html/rfc7518#section-6.2.1.2 and
68+
// https://datatracker.ietf.org/doc/html/rfc7518#section-6.2.1.3
6869
int fieldSizeInBits = key.getParams().getCurve().getField().getFieldSize()
6970
int fieldSizeInBytes = Bytes.length(fieldSizeInBits)
70-
7171
assertEquals fieldSizeInBytes, x.length
7272
assertEquals fieldSizeInBytes, y.length
73-
assertEquals fieldSizeInBytes, d.length
73+
74+
// and 'd' must have a length equal to the curve order size in bytes per
75+
// https://datatracker.ietf.org/doc/html/rfc7518#section-6.2.2.1
76+
int orderSizeInBytes = Bytes.length(key.params.order.bitLength())
77+
assertEquals orderSizeInBytes, d.length
7478
}
7579
}
7680
}

0 commit comments

Comments
 (0)