Key

public abstract class Key extends TokenObject

Abstract class describes a key object. Inherits from TokenObject.

API Changes (since 6.23.44.2)

The mobile SDK API has evolved to support different key types: PrivateKey and PublicKey are now abstract classes.

Subclasses:

Methods specific to a particular key type have been moved into these concrete classes. For example:

This change introduces some backward compatibility issues: to use these methods, you must cast the key to the appropriate class.

Example

PrivateKey privateKey;

if (privateKey instanceof PrivateKeyRSA) {
    PrivateKeyRSA rsaPrivateKey = (PrivateKeyRSA) privateKey;
    BigInteger modulus = rsaPrivateKey.getModulus();
}

On the other hand, methods common to all private keys (PrivateKey.sign(), PrivateKey.decrypt(), PrivateKey.hashAndSign(), PrivateKey.getPssParameters(), PrivateKey.isPartialHash()) remain defined in PrivateKey. Their usage has not changed.

Methods

getAlgorithmName

public String getAlgorithmName()

Gets the algorithm of the key. The possible values are "RSA" or "ECDSA".

Returns:

the algorithm of the key.

getKeyLength

public int getKeyLength()

Gets the key length, in bits.

Returns:

the key length.