public class EntrustAsymKeyType
extends java.lang.Object
Asymmetric key types (in string representation) are used in various Entrust policy settings to convey information about a particular key pair. Specifically, the information necessary to generate a key pair of this type. This includes the following:
The class provides the ability to convert to/from an asymmetric key type in string representation. An asymmetric key type in string representation is simply the asymmetric key type name, which the following format:
| Algorithm | Parameters Format |
|---|---|
| 'RSA' | An integer key size in bits |
| 'EC' | An EC domain name (see EcParameterFactory for a details on
supported EC named domains)
|
| 'DSA' | An integer key size in bits |
| 'ECDSA' | An integer key size in bits (this indicates the default EC domain
parameters at this key size; see EcParameterFactory for details on
the default EC domain parameters at a given key size) |
This class also provides the ability to extract an asymmetric key type from an existing key. This functionality is supported for keys of the following type:
java.security.interfaces.RSAKey
java.security.interfaces.DSAKey
java.security.interfaces.ECKey,
and instances of
com.entrust.toolkit.security.provider.ECDSAPrivateKey and
com.entrust.toolkit.security.provider.ECDSAPublicKey)| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
Indicates whether or not another asymmetric key type is equal to this
asymmetric key type.
|
static java.lang.String |
getAsymKeyTypeString(java.security.Key key)
Returns a string representation of the asymmetric key type for the
provided key.
|
int |
getBitsOfSecurity()
Returns the bits of security that keys generated using this asymmetric
key type provide.
|
static EntrustAsymKeyType |
getEcInstance(java.security.spec.AlgorithmParameterSpec ecKeyParams)
Determines the asymmetric key type of an EC key by examining the EC
domain parameters associated with the key.
|
static EntrustAsymKeyType |
getInstance(java.security.Key key)
Determines the asymmetric key type of the specific key.
|
static EntrustAsymKeyType |
getInstance(java.lang.String name)
Parses an asymmetric key type from string name representation.
|
java.lang.String |
getKeyAlgorithm()
Gets the key algorithm component of this asymmetric key type.
|
java.security.spec.AlgorithmParameterSpec |
getKeyParams()
Gets the key parameters component of this asymmetric key type.
|
int |
getKeySizeBits()
Gets the key size component of this asymmetric key type.
|
java.lang.String |
getName()
Gets the name of this asymmetric key type.
|
int |
hashCode()
Returns a hash code value for this object.
|
boolean |
isDsaKeyType()
Indicates whether keys generated using this asymmetric key type are DSA
keys.
|
boolean |
isEcKeyType()
Indicates whether keys generated using this key type are EC keys.
|
boolean |
isRsaKeyType()
Indicates whether keys generated using this asymmetric key type are RSA
keys.
|
boolean |
isStrongerThan(EntrustAsymKeyType keyType)
Determines whether or not this asymmetric key type is stronger than
another asymmetric key type.
|
boolean |
supportsKeyEstablishment()
Indicates whether keys generated using this asymmetric key type can be
used for key establishment.
|
java.lang.String |
toString()
Returns the string representation of this object which is the name of
this asymmetric key type.
|
public static EntrustAsymKeyType getEcInstance(java.security.spec.AlgorithmParameterSpec ecKeyParams)
Currently, the following EC domain parameter representations are supported:
java.security.spec.ECParameterSpecjava.security.spec.ECGenParameterSpeccom.entrust.toolkit.security.provider.ECParametersjava.lang.IllegalArgumentException - if the provided EC domain parameters are invalid (unsupported
parameter representation)public static EntrustAsymKeyType getInstance(java.lang.String name) throws java.lang.IllegalArgumentException
All key types listed in the class documentation of
EntrustAsymKeyType are supported by this API.
name - name of the asymmetric key typejava.lang.IllegalArgumentException - if the provided name is invalid (invalid string name for an
asymmetric key type)public static EntrustAsymKeyType getInstance(java.security.Key key) throws java.lang.IllegalArgumentException
Refer to the class documentation of EntrustAsymKeyType for
details on the keys that are supported.
key - a keyjava.lang.IllegalArgumentException - if type of key is not supportedpublic static java.lang.String getAsymKeyTypeString(java.security.Key key)
The string representation is the asymmetric key type name for supported
asymmetric key types (see getName()) or the string 'UNSUPPORTED
(key algorithm)' for unsupported key types (where 'key algorithm' is the
algorithm of the key).
All asymmetric key types supported by the getInstance(Key) are
also supported by this API. This API was designed for use in exception
messages and log messages.
key - a keypublic java.lang.String getName()
public java.lang.String getKeyAlgorithm()
public int getKeySizeBits()
public java.security.spec.AlgorithmParameterSpec getKeyParams()
Note: Only certain asymmetric key types support key parameters; for example RSA-based and DSA-based key types do not contain key parameters, but EC-based key types do contain key parameters
null
for asymmetric key types that do not contain key parameterspublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean isEcKeyType()
An asymmetric key type is EC-based if the algorithm component is "EC" or "ECDSA".
true if the asymmetric key type is EC-based;
false otherwisepublic boolean isRsaKeyType()
An asymmetric key type is RSA-based if the algorithm component is "RSA".
true if the asymmetric key type is RSA-based;
false otherwisepublic boolean isDsaKeyType()
An asymmetric key type is DSA-based if the algorithm component is "DSA".
true if the asymmetric key type is DSA-based;
false otherwisepublic boolean supportsKeyEstablishment()
Note: EC and RSA keys can be used for key establishment; DSA keys cannot.
true if the asymmetric key type support key
establishment; false otherwisepublic boolean isStrongerThan(EntrustAsymKeyType keyType)
For asymmetric key types with the same algorithm component, or for two
EC-based key types, the key size is compared; if this asymmetric key type
has a larger key size, then it is stronger. Otherwise, the bits of
security provided by the key (see getBitsOfSecurity() is
compared; if this asymmetric key type has more bits of security, then it
is stronger.
keyType - the other asymmetric key typetrue if this asymmetric key type is stronger;
false otherwisepublic int getBitsOfSecurity()
Bits of security for a particular asymmetric key type are determined based on the "Comparable strengths" table from NIST SP 800-57 Part 1, which indicates the following:
| Bits of Security | Key size in bits | ||
|---|---|---|---|
| RSA | DSA | ECDSA | |
| 80 | 1024 | 1024 | 160..223 |
| 112 | 2048 | 2048 | 224..255 |
| 128 | 3072 | 1024 | 256..383 |
| 192 | 7680 | 7680 | 384..511 |
| 256 | 15360 | 15360 | 512+ |
Note: For key sizes not listed here, the bits of security is
considered to be the same as the next smaller key size that is listed
here (i.e. RSA-1024, RSA-1280, and RSA-1536 all offer 80-bits of
security).
Note: For key sizes smaller than the smallest key size listed
here, these keys are treated as offering 0-bits of security (they are
weak and should not be used).
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objecttrue if the two objects are equal;
false otherwisepublic int hashCode()
hashCode in class java.lang.Object