public class PEMProcessor
extends java.lang.Object
PEMProcessorError
if an invalid
PEMObject is passed into the constructor. Once initialized the PEMProcessor can be used to
return the type, DER format, or algorithm used to create the PEMObject.Constructor and Description |
---|
PEMProcessor(java.lang.String pemObject)
Initialize PEMProcessor with PEM content in String format.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
extractEOSPublicKeyFromPrivateKey(boolean isLegacy)
Extract EOS public key
|
java.lang.String |
extractPEMPublicKeyFromPrivateKey(boolean isLegacy)
Extract PEM public key
|
@NotNull AlgorithmEmployed |
getAlgorithm()
Gets the algorithm used to generate the key from its PEM format.
|
static org.bouncycastle.crypto.params.ECDomainParameters |
getCurveDomainParameters(AlgorithmEmployed curve)
Gets EC Curve's domain parameter by curve type
|
@NotNull java.lang.String |
getDERFormat()
Gets the DER encoded format of the key from its PEM format.
|
@NotNull byte[] |
getKeyData()
Gets the key as a byte array from its PEM format.
|
@NotNull java.lang.String |
getType()
Gets the PEM Object key type (i.e.
|
public PEMProcessor(java.lang.String pemObject) throws PEMProcessorError
pemObject
- - input PEM content in String format.PEMProcessorError
- When failing to read pem data from the input.@NotNull public @NotNull java.lang.String getType()
@NotNull public @NotNull java.lang.String getDERFormat()
@NotNull public @NotNull AlgorithmEmployed getAlgorithm() throws PEMProcessorError
PEMProcessorError
- if the algorithm fetch leads to an exception.@NotNull public @NotNull byte[] getKeyData() throws PEMProcessorError
PEMProcessorError
- when key data is unobtainable.public java.lang.String extractEOSPublicKeyFromPrivateKey(boolean isLegacy) throws PEMProcessorError
isLegacy
- - Set to true if the legacy format of the key is desired. This uses "EOS"
to prefix the key data and only applies to keys generated with the secp256k1 algorithm. The
new format prefixes the key data with "PUB_K1_".PEMProcessorError
- when the public key extraction fails.public java.lang.String extractPEMPublicKeyFromPrivateKey(boolean isLegacy) throws PEMProcessorError
isLegacy
- Whether to return the legacy format of the key. This uses "EOS"
to prefix the key data and only applies to keys generated with the secp256k1 algorithm. The
new format prefixes the key data with "PUB_K1_".PEMProcessorError
- when public key extraction fails.public static org.bouncycastle.crypto.params.ECDomainParameters getCurveDomainParameters(AlgorithmEmployed curve) throws PEMProcessorError
curve
- - typePEMProcessorError
- would be throw if input curve is not supported.