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.ECParameterSpec |
decodeParameters(byte[] params)
Decodes DER encoded EC Parameters into ECParameterSpec
|
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.ECParameterSpec spec)
Converts the a byte representation of a point on the given elliptic curve into a
non-Weierstrass form ECPoint object.
|
static byte[] |
encodeParameters(java.security.spec.ECParameterSpec params)
DER encodes EC Parameters from Spec
|
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.ECParameterSpec spec)
Converts an ECPoint on the given elliptic curve into a byte array as specified in SEC1 2.3.3.
|
static byte[] |
encodePointNWS(java.security.spec.ECPoint point,
java.security.spec.ECParameterSpec spec)
Converts an ECPoint on the given elliptic curve into an ASN.1-encoded octet string (as required
by the Luna hardware).
|
static byte[] |
extractPointFromEncodedKeyNWS(java.lang.String algorithm,
byte[] encodedKey)
Extracts ECPoint from given X509EncodedKey on the given algorithm's elliptic curve
(Non-Weierstrass keys have named curves based on algorithm) into an ASN.1-encoded
octet string (as required by the Luna hardware).
|
static byte[] |
extractXCoordinate(java.security.spec.ECPoint point) |
static java.lang.String |
getAlgorithmNameFromCurve(java.security.spec.ECParameterSpec spec)
Provides Algorithm name for the specified curve
|
static java.lang.String |
getAlgorithmNameFromCurve(java.lang.String curve)
Provides Algorithm name for the specified curve
|
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.ECParameterSpec spec)
data - The ASN.1-encoded byte representation of an EC pointspec - ECParameterSpec of 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.ECParameterSpec spec)
point - The ECPoint to convertspec - ECParameterSpec of 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[] encodePointNWS(java.security.spec.ECPoint point,
java.security.spec.ECParameterSpec spec)
point - The ECPoint to convertspec - ECParameterSpec of the curve on which the point residespublic static byte[] extractPointFromEncodedKeyNWS(java.lang.String algorithm,
byte[] encodedKey)
throws java.security.spec.InvalidKeySpecException
algorithm - Algorithm nameencodedKey - X509EncodedKey bytesjava.security.spec.InvalidKeySpecException - If encodedKey is invalidpublic 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 analyzepublic static java.lang.String getAlgorithmNameFromCurve(java.security.spec.ECParameterSpec spec)
spec - ECParameterSpec representing a named curvepublic static java.lang.String getAlgorithmNameFromCurve(java.lang.String curve)
curve - EC Named Curvepublic static byte[] encodeParameters(java.security.spec.ECParameterSpec params)
params - EC parameters spec objectpublic static java.security.spec.ECParameterSpec decodeParameters(byte[] params)
throws java.io.IOException
params - DER encoded EC parametersjava.io.IOException - If Unsupported ECC named curve or domain parametersCopyright 2014-2018 SafeNet. All rights reserved.