mirror of https://github.com/jwtk/jjwt.git
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)
This commit is contained in:
parent
fd619e0a42
commit
f61cfa875d
|
@ -63,14 +63,18 @@ class AbstractEcJwkFactoryTest {
|
||||||
def y = Decoders.BASE64URL.decode(ys)
|
def y = Decoders.BASE64URL.decode(ys)
|
||||||
def d = Decoders.BASE64URL.decode(ds)
|
def d = Decoders.BASE64URL.decode(ds)
|
||||||
|
|
||||||
// most important part of the test: the decoded byte arrays must have a length equal to the curve
|
// most important part of the test: 'x' and 'y' decoded byte arrays must have a length equal to the curve
|
||||||
// field size (in bytes):
|
// field size (in bytes) per https://datatracker.ietf.org/doc/html/rfc7518#section-6.2.1.2 and
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc7518#section-6.2.1.3
|
||||||
int fieldSizeInBits = key.getParams().getCurve().getField().getFieldSize()
|
int fieldSizeInBits = key.getParams().getCurve().getField().getFieldSize()
|
||||||
int fieldSizeInBytes = Bytes.length(fieldSizeInBits)
|
int fieldSizeInBytes = Bytes.length(fieldSizeInBits)
|
||||||
|
|
||||||
assertEquals fieldSizeInBytes, x.length
|
assertEquals fieldSizeInBytes, x.length
|
||||||
assertEquals fieldSizeInBytes, y.length
|
assertEquals fieldSizeInBytes, y.length
|
||||||
assertEquals fieldSizeInBytes, d.length
|
|
||||||
|
// and 'd' must have a length equal to the curve order size in bytes per
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc7518#section-6.2.2.1
|
||||||
|
int orderSizeInBytes = Bytes.length(key.params.order.bitLength())
|
||||||
|
assertEquals orderSizeInBytes, d.length
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue