提交 37d3ba0c 编写于 作者: V vinnie

7198901: correct the field size check when decoding a point on ECC curve

Reviewed-by: xuelei
上级 a8173074
...@@ -87,8 +87,10 @@ public final class ECParameters extends AlgorithmParametersSpi { ...@@ -87,8 +87,10 @@ public final class ECParameters extends AlgorithmParametersSpi {
if ((data.length == 0) || (data[0] != 4)) { if ((data.length == 0) || (data[0] != 4)) {
throw new IOException("Only uncompressed point format supported"); throw new IOException("Only uncompressed point format supported");
} }
int n = data.length / 2; // Per ANSI X9.62, an encoded point is a 1 byte type followed by
if (n > ((curve.getField().getFieldSize() + 7 ) >> 3)) { // ceiling(log base 2 field-size / 8) bytes of x and the same of y.
int n = (data.length - 1) / 2;
if (n != ((curve.getField().getFieldSize() + 7 ) >> 3)) {
throw new IOException("Point does not match field size"); throw new IOException("Point does not match field size");
} }
byte[] xb = new byte[n]; byte[] xb = new byte[n];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册