Package org.mozilla.jss.crypto
Interface KeyWrapper
- All Known Implementing Classes:
PK11KeyWrapper
public interface KeyWrapper
-
Method Summary
Modifier and TypeMethodDescriptionvoid
For plaintext-wrapped keys.void
initUnwrap
(PrivateKey unwrappingKey, AlgorithmParameterSpec parameters) void
initUnwrap
(SymmetricKey unwrappingKey, AlgorithmParameterSpec parameters) void
initWrap()
For wrapping keys in plaintext.void
initWrap
(PublicKey wrappingKey, AlgorithmParameterSpec parameters) void
initWrap
(SymmetricKey wrappingKey, AlgorithmParameterSpec parameters) unwrapPrivate
(byte[] wrapped, PrivateKey.Type type, PublicKey publicKey) Unwraps a private key, creating a permanent private key object.unwrapSymmetric
(byte[] wrapped, SymmetricKey.Type type, int keyLength) Unwraps a key and allows it to be used for all operations.unwrapSymmetric
(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLength) unwrapSymmetricPerm
(byte[] wrapped, SymmetricKey.Type type, int keyLength) Unwraps a key and allows it to be used for all operations.unwrapSymmetricPerm
(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLength) unwrapTemporaryPrivate
(byte[] wrapped, PrivateKey.Type type, PublicKey publicKey) Unwraps a private key, creating a temporary private key object.byte[]
wrap
(PrivateKey toBeWrapped) byte[]
wrap
(SymmetricKey toBeWrapped)
-
Method Details
-
initWrap
void initWrap(SymmetricKey wrappingKey, AlgorithmParameterSpec parameters) throws InvalidKeyException, InvalidAlgorithmParameterException -
initWrap
void initWrap(PublicKey wrappingKey, AlgorithmParameterSpec parameters) throws InvalidKeyException, InvalidAlgorithmParameterException -
initWrap
For wrapping keys in plaintext. -
initUnwrap
void initUnwrap(SymmetricKey unwrappingKey, AlgorithmParameterSpec parameters) throws InvalidKeyException, InvalidAlgorithmParameterException -
initUnwrap
void initUnwrap(PrivateKey unwrappingKey, AlgorithmParameterSpec parameters) throws InvalidKeyException, InvalidAlgorithmParameterException -
initUnwrap
For plaintext-wrapped keys. -
wrap
byte[] wrap(PrivateKey toBeWrapped) throws InvalidKeyException, IllegalStateException, TokenException -
wrap
byte[] wrap(SymmetricKey toBeWrapped) throws InvalidKeyException, IllegalStateException, TokenException -
unwrapPrivate
PrivateKey unwrapPrivate(byte[] wrapped, PrivateKey.Type type, PublicKey publicKey) throws TokenException, InvalidKeyException, IllegalStateException Unwraps a private key, creating a permanent private key object. A permanent private key object resides on a token until it is explicitly deleted from the token.- Parameters:
publicKey
- Used to calculate the key identifier that must be stored with the private key. Must be aRSAPublicKey
or aDSAPublicKey
.- Throws:
InvalidKeyException
- If the type of the public key does not match the type of the private key to be unwrapped.TokenException
IllegalStateException
-
unwrapTemporaryPrivate
PrivateKey unwrapTemporaryPrivate(byte[] wrapped, PrivateKey.Type type, PublicKey publicKey) throws TokenException, InvalidKeyException, IllegalStateException Unwraps a private key, creating a temporary private key object. A temporary private key is one that does not permanently reside on a token. As soon as it is garbage-collected, it is gone forever.- Parameters:
publicKey
- Used to calculate the key identifier that must be stored with the private key. Must be aRSAPublicKey
or aDSAPublicKey
.- Throws:
InvalidKeyException
- If the type of the public key does not match the type of the private key to be unwrapped.TokenException
IllegalStateException
-
unwrapSymmetric
SymmetricKey unwrapSymmetric(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLength) throws TokenException, IllegalStateException, InvalidAlgorithmParameterException - Parameters:
usage
- 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.keyLength
- 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).- Throws:
TokenException
IllegalStateException
InvalidAlgorithmParameterException
-
unwrapSymmetric
SymmetricKey unwrapSymmetric(byte[] wrapped, SymmetricKey.Type type, int keyLength) throws TokenException, IllegalStateException, InvalidAlgorithmParameterException Unwraps a key and allows it to be used for all operations.- Parameters:
keyLength
- 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).- Throws:
TokenException
IllegalStateException
InvalidAlgorithmParameterException
-
unwrapSymmetricPerm
SymmetricKey unwrapSymmetricPerm(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLength) throws TokenException, IllegalStateException, InvalidAlgorithmParameterException -
unwrapSymmetricPerm
SymmetricKey unwrapSymmetricPerm(byte[] wrapped, SymmetricKey.Type type, int keyLength) throws TokenException, IllegalStateException, InvalidAlgorithmParameterException Unwraps a key and allows it to be used for all operations.- Parameters:
keyLength
- 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).- Throws:
TokenException
IllegalStateException
InvalidAlgorithmParameterException
-