public final class PK11KeyWrapper extends java.lang.Object implements KeyWrapper
| Modifier and Type | Method and Description |
|---|---|
void |
initUnwrap()
For plaintext-wrapped keys.
|
void |
initUnwrap(PrivateKey unwrappingKey,
java.security.spec.AlgorithmParameterSpec parameters) |
void |
initUnwrap(SymmetricKey unwrappingKey,
java.security.spec.AlgorithmParameterSpec parameters) |
void |
initWrap()
For wrapping keys in plaintext.
|
void |
initWrap(java.security.PublicKey wrappingKey,
java.security.spec.AlgorithmParameterSpec parameters) |
void |
initWrap(SymmetricKey wrappingKey,
java.security.spec.AlgorithmParameterSpec parameters) |
PrivateKey |
unwrapPrivate(byte[] wrapped,
PrivateKey.Type type,
java.security.PublicKey publicKey)
Unwraps a private key, creating a permanent private key object.
|
SymmetricKey |
unwrapSymmetric(byte[] wrapped,
SymmetricKey.Type type,
int keyLen)
Unwraps a key and allows it to be used for all operations.
|
SymmetricKey |
unwrapSymmetric(byte[] wrapped,
SymmetricKey.Type type,
SymmetricKey.Usage usage,
int keyLen) |
SymmetricKey |
unwrapSymmetricPerm(byte[] wrapped,
SymmetricKey.Type type,
int keyLen)
Unwraps a key and allows it to be used for all operations.
|
SymmetricKey |
unwrapSymmetricPerm(byte[] wrapped,
SymmetricKey.Type type,
SymmetricKey.Usage usage,
int keyLen) |
PrivateKey |
unwrapTemporaryPrivate(byte[] wrapped,
PrivateKey.Type type,
java.security.PublicKey publicKey)
Unwraps a private key, creating a temporary private key object.
|
byte[] |
wrap(PrivateKey toBeWrapped) |
byte[] |
wrap(SymmetricKey toBeWrapped) |
public void initWrap(SymmetricKey wrappingKey, java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
initWrap in interface KeyWrapperjava.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionpublic void initWrap(java.security.PublicKey wrappingKey,
java.security.spec.AlgorithmParameterSpec parameters)
throws java.security.InvalidKeyException,
java.security.InvalidAlgorithmParameterException
initWrap in interface KeyWrapperjava.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionpublic void initWrap()
throws java.security.InvalidKeyException,
java.security.InvalidAlgorithmParameterException
KeyWrapperinitWrap in interface KeyWrapperjava.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionpublic void initUnwrap(PrivateKey unwrappingKey, java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
initUnwrap in interface KeyWrapperjava.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionpublic void initUnwrap(SymmetricKey unwrappingKey, java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
initUnwrap in interface KeyWrapperjava.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionpublic void initUnwrap()
throws java.security.InvalidKeyException,
java.security.InvalidAlgorithmParameterException
KeyWrapperinitUnwrap in interface KeyWrapperjava.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionpublic byte[] wrap(PrivateKey toBeWrapped) throws java.security.InvalidKeyException, java.lang.IllegalStateException, TokenException
wrap in interface KeyWrapperjava.security.InvalidKeyExceptionjava.lang.IllegalStateExceptionTokenExceptionpublic byte[] wrap(SymmetricKey toBeWrapped) throws java.security.InvalidKeyException, java.lang.IllegalStateException, TokenException
wrap in interface KeyWrapperjava.security.InvalidKeyExceptionjava.lang.IllegalStateExceptionTokenExceptionpublic PrivateKey unwrapPrivate(byte[] wrapped, PrivateKey.Type type, java.security.PublicKey publicKey) throws TokenException, java.security.InvalidKeyException, java.lang.IllegalStateException
unwrapPrivate in interface KeyWrapperpublicKey - Used to calculate the key identifier that must be stored
with the private key. Must be a RSAPublicKey or a
DSAPublicKey.java.security.InvalidKeyException - If the type of the public key does not
match the type of the private key to be unwrapped.TokenExceptionjava.lang.IllegalStateExceptionpublic PrivateKey unwrapTemporaryPrivate(byte[] wrapped, PrivateKey.Type type, java.security.PublicKey publicKey) throws TokenException, java.security.InvalidKeyException, java.lang.IllegalStateException
unwrapTemporaryPrivate in interface KeyWrapperpublicKey - Used to calculate the key identifier that must be stored
with the private key. Must be a RSAPublicKey or a
DSAPublicKey.java.security.InvalidKeyException - If the type of the public key does not
match the type of the private key to be unwrapped.TokenExceptionjava.lang.IllegalStateExceptionpublic SymmetricKey unwrapSymmetric(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLen) throws TokenException, java.lang.IllegalStateException, java.security.InvalidAlgorithmParameterException
unwrapSymmetric in interface KeyWrapperusage - The operation the key will be used for after it is
unwrapped. You have to specify this so that the key can be properly
marked with the operation it supports. Some PKCS #11 tokens require
that a key be marked for an operation before it can perform that
operation.keyLen - The expected length of the key in bytes. This is
only used for variable-length keys (RC4) and non-padding
algorithms. Otherwise, it can be set to anything(like 0).TokenExceptionjava.lang.IllegalStateExceptionjava.security.InvalidAlgorithmParameterExceptionpublic SymmetricKey unwrapSymmetric(byte[] wrapped, SymmetricKey.Type type, int keyLen) throws TokenException, java.lang.IllegalStateException, java.security.InvalidAlgorithmParameterException
KeyWrapperunwrapSymmetric in interface KeyWrapperkeyLen - The expected length of the key in bytes. This is
only used for variable-length keys (RC4) and non-padding
algorithms. Otherwise, it can be set to anything(like 0).TokenExceptionjava.lang.IllegalStateExceptionjava.security.InvalidAlgorithmParameterExceptionpublic SymmetricKey unwrapSymmetricPerm(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLen) throws TokenException, java.lang.IllegalStateException, java.security.InvalidAlgorithmParameterException
unwrapSymmetricPerm in interface KeyWrapperTokenExceptionjava.lang.IllegalStateExceptionjava.security.InvalidAlgorithmParameterExceptionpublic SymmetricKey unwrapSymmetricPerm(byte[] wrapped, SymmetricKey.Type type, int keyLen) throws TokenException, java.lang.IllegalStateException, java.security.InvalidAlgorithmParameterException
KeyWrapperunwrapSymmetricPerm in interface KeyWrapperkeyLen - The expected length of the key in bytes. This is
only used for variable-length keys (RC4) and non-padding
algorithms. Otherwise, it can be set to anything(like 0).TokenExceptionjava.lang.IllegalStateExceptionjava.security.InvalidAlgorithmParameterException