Class: Key

api. Key

Key represents a cryptographic key. It can be symmetric or asymmetric. In the case of an asymmetric key, the key can be public or private. In the case of a private asymmetric key, the getPublicKey() method allows to retrieve the corresponding public-key. A key can be referenced via the Subject Key Identifier in DER or PEM encoding

new Key()

Methods


getPublicKey()

Returns the corresponding public key if this key is an asymmetric private key. If this key is already public, PublicKey returns this key itself.
Returns:
the corresponding public key if this key is an asymmetric private key. If this key is already public, PublicKey returns this key itself.
Type
Key

getSKI()

Returns the subject key identifier of this key in DER encoding for private keys or PEM encoding for public keys.
Returns:
the subject key identifier of this key
Type
Array.<byte>

isPrivate()

Returns true if this key is an asymmetric private key, false otherwise.
Returns:
if this key is an asymmetric private key
Type
boolean

isSymmetric()

Returns true if this key is a symmetric key, false is this key is asymmetric
Returns:
if this key is a symmetric key
Type
boolean

toBytes()

Converts this key to its byte representation, if this operation is allowed.
Returns:
the byte representation of the key
Type
Array.<byte>