org.mozilla.jss.pkcs11

Class PK11PubKey

Implemented Interfaces:
java.security.PublicKey
Known Direct Subclasses:
PK11DSAPublicKey, PK11RSAPublicKey

public class PK11PubKey
extends org.mozilla.jss.pkcs11.PK11Key
implements java.security.PublicKey

Field Summary

Fields inherited from class org.mozilla.jss.pkcs11.PK11Key

keyProxy

Constructor Summary

PK11PubKey(byte[] pointer)

Method Summary

static PK11PubKey
fromRaw(PrivateKey.Type type, byte[] rawKey)
Deprecated. This method works for RSA keys but not DSA keys.
static PK11PubKey
fromSPKI(byte[] spki)
Creates a PK11PubKey from a SubjectPublicKeyInfo.
String
getAlgorithm()
byte[]
getEncoded()
Returns a DER-encoded SubjectPublicKeyInfo representing this key.
String
getFormat()
The name of the primary encoding format of this key.
org.mozilla.jss.pkcs11.KeyType
getKeyType()
void
verifyKeyIsOnToken(PK11Token token)
Make sure this key lives on the given token.

Methods inherited from class org.mozilla.jss.pkcs11.PK11Key

getEncoded, getFormat

Constructor Details

PK11PubKey

protected PK11PubKey(byte[] pointer)

Method Details

fromRaw

public static PK11PubKey fromRaw(PrivateKey.Type type,
                                 byte[] rawKey)
            throws InvalidKeyFormatException

Deprecated. This method works for RSA keys but not DSA keys. Use fromSPKI() instead.

Creates a PK11PubKey from its raw form. The raw form is a DER encoding of the public key. For example, this is what is stored in a SubjectPublicKeyInfo.
Parameters:
type - The type of private key to be decoded.
rawKey - The bytes of the raw key.
Throws:
InvalidKeyFormatException - If the raw key could not be decoded.

fromSPKI

public static PK11PubKey fromSPKI(byte[] spki)
            throws InvalidKeyFormatException
Creates a PK11PubKey from a SubjectPublicKeyInfo.
Parameters:
spki - The BER-encoded SubjectPublicKeyInfo.
Throws:
InvalidKeyFormatException - If the SPKI could not be decoded.

getAlgorithm

public String getAlgorithm()

getEncoded

public byte[] getEncoded()
Returns a DER-encoded SubjectPublicKeyInfo representing this key.
Overrides:
getEncoded in interface org.mozilla.jss.pkcs11.PK11Key

getFormat

public String getFormat()
The name of the primary encoding format of this key. The primary encoding format is X.509 SubjectPublicKeyInfo, and the name is "X.509".
Overrides:
getFormat in interface org.mozilla.jss.pkcs11.PK11Key

getKeyType

public org.mozilla.jss.pkcs11.KeyType getKeyType()

verifyKeyIsOnToken

public void verifyKeyIsOnToken(PK11Token token)
            throws NoSuchItemOnTokenException
Make sure this key lives on the given token.