equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
30 import java.security.*; |
30 import java.security.*; |
31 import java.security.interfaces.*; |
31 import java.security.interfaces.*; |
32 import java.security.spec.*; |
32 import java.security.spec.*; |
33 import java.util.Arrays; |
33 import java.util.Arrays; |
34 |
34 |
35 public class ECUtil { |
35 public final class ECUtil { |
36 |
36 |
37 // Used by SunPKCS11 and SunJSSE. |
37 // Used by SunPKCS11 and SunJSSE. |
38 public static ECPoint decodePoint(byte[] data, EllipticCurve curve) |
38 public static ECPoint decodePoint(byte[] data, EllipticCurve curve) |
39 throws IOException { |
39 throws IOException { |
40 if ((data.length == 0) || (data[0] != 4)) { |
40 if ((data.length == 0) || (data[0] != 4)) { |
217 return null; |
217 return null; |
218 } |
218 } |
219 |
219 |
220 return nameSpec.getName(); |
220 return nameSpec.getName(); |
221 } |
221 } |
|
222 |
|
223 public static boolean equals(ECParameterSpec spec1, ECParameterSpec spec2) { |
|
224 if (spec1 == spec2) { |
|
225 return true; |
|
226 } |
|
227 |
|
228 if (spec1 == null || spec2 == null) { |
|
229 return false; |
|
230 } |
|
231 return (spec1.getCofactor() == spec2.getCofactor() && |
|
232 spec1.getOrder().equals(spec2.getOrder()) && |
|
233 spec1.getCurve().equals(spec2.getCurve()) && |
|
234 spec1.getGenerator().equals(spec2.getGenerator())); |
|
235 } |
|
236 |
222 |
237 |
223 // Convert the concatenation R and S in into their DER encoding |
238 // Convert the concatenation R and S in into their DER encoding |
224 public static byte[] encodeSignature(byte[] signature) throws SignatureException { |
239 public static byte[] encodeSignature(byte[] signature) throws SignatureException { |
225 |
240 |
226 try { |
241 try { |