public class LunaECUtils
extends java.lang.Object
Constructor and Description |
---|
LunaECUtils() |
Modifier and Type | Method and Description |
---|---|
static java.math.BigInteger |
bi(java.lang.String s)
Convert the given String representing a hexadecimal number into a BigInteger.
|
static java.security.spec.ECPoint |
decodePoint(byte[] data,
java.security.spec.EllipticCurve curve)
Converts the a byte representation of a point on the given elliptic curve into an ECPoint object.
|
static java.security.spec.ECPoint |
decodePointNWS(byte[] data,
java.security.spec.EllipticCurve curve)
Converts the a byte representation of a point on the given elliptic curve into a
non-Weierstrass form ECPoint object.
|
static byte[] |
encodePoint(java.security.spec.ECPoint point,
java.security.spec.EllipticCurve curve)
Converts an ECPoint on the given elliptic curve into an ASN.1-encoded octet string (as required
by the Luna hardware).
|
static byte[] |
encodePointNoAsn(java.security.spec.ECPoint point,
java.security.spec.EllipticCurve curve)
Converts an ECPoint on the given elliptic curve into a byte array as specified in SEC1 2.3.3.
|
static byte[] |
encodePointNoAsnNWS(java.security.spec.ECPoint point,
java.security.spec.EllipticCurve curve)
Converts an ECPoint on the given elliptic curve into a byte array as specified in SEC1 2.3.3.
|
static byte[] |
extractXCoordinate(java.security.spec.ECPoint point) |
static java.lang.String |
getCurveCommonName(java.security.spec.ECParameterSpec params)
Given a set of parameters, returns the common name of the curve (ex.
|
static java.lang.String |
getCurveName(java.security.spec.ECParameterSpec params)
Given a set of parameters, returns the a String representation of the curve's OID (ex.
|
static int |
getFieldSize(java.security.spec.ECParameterSpec spec)
Return the field size of the curve defined by the given spec
|
static int |
getRawSignatureSize(java.security.interfaces.ECKey key)
Returns the size of a raw ECDSA signature generated on the HSM for the given key.
|
static boolean |
isCompressed(byte[] point)
Detects if a given encoded EC point is using compressed notation.
|
public static java.security.spec.ECPoint decodePoint(byte[] data, java.security.spec.EllipticCurve curve)
data
- The ASN.1-encoded byte representation of an EC pointcurve
- The curve on which the point residesLunaException
- If the encoded point is invalid in any waypublic static java.security.spec.ECPoint decodePointNWS(byte[] data, java.security.spec.EllipticCurve curve)
data
- The ASN.1-encoded byte representation of an EC pointcurve
- The curve on which the point residesLunaException
- If the encoded point is invalid in any waypublic static byte[] encodePointNoAsn(java.security.spec.ECPoint point, java.security.spec.EllipticCurve curve)
point
- The ECPoint to convertcurve
- The curve on which the point residespublic static byte[] encodePointNoAsnNWS(java.security.spec.ECPoint point, java.security.spec.EllipticCurve curve)
point
- The ECPoint to convertcurve
- The curve on which the point residespublic static byte[] encodePoint(java.security.spec.ECPoint point, java.security.spec.EllipticCurve curve)
point
- The ECPoint to convertcurve
- The curve on which the point residespublic static byte[] extractXCoordinate(java.security.spec.ECPoint point)
public static boolean isCompressed(byte[] point)
point
- The encoded pointpublic static java.lang.String getCurveName(java.security.spec.ECParameterSpec params)
params
- The EC parameter spec to examinepublic static java.lang.String getCurveCommonName(java.security.spec.ECParameterSpec params)
params
- The EC parameter spec to examinepublic static java.math.BigInteger bi(java.lang.String s)
s
- String representation of a hexadecimal numberpublic static int getFieldSize(java.security.spec.ECParameterSpec spec)
spec
- the JCA specification objectpublic static int getRawSignatureSize(java.security.interfaces.ECKey key)
key
will have the same signature size.
Note that the final ECDSA signature will include ASN.1 encoding which is not figured into this total.
key
- the key to analyzeCopyright 2014-2018 SafeNet. All rights reserved.