Package org.mozilla.jss.pkcs11
Class PK11KeyWrapper
java.lang.Object
org.mozilla.jss.pkcs11.PK11KeyWrapper
- All Implemented Interfaces:
KeyWrapper
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidFor plaintext-wrapped keys.voidinitUnwrap(PrivateKey unwrappingKey, AlgorithmParameterSpec parameters) voidinitUnwrap(SymmetricKey unwrappingKey, AlgorithmParameterSpec parameters) voidinitWrap()For wrapping keys in plaintext.voidinitWrap(PublicKey wrappingKey, AlgorithmParameterSpec parameters) voidinitWrap(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 keyLen) Unwraps a key and allows it to be used for all operations.unwrapSymmetric(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLen) unwrapSymmetricPerm(byte[] wrapped, SymmetricKey.Type type, int keyLen) Unwraps a key and allows it to be used for all operations.unwrapSymmetricPerm(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLen) 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)
-
Field Details
-
logger
public static final org.slf4j.Logger logger
-
-
Method Details
-
initWrap
public void initWrap(SymmetricKey wrappingKey, AlgorithmParameterSpec parameters) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
initWrapin interfaceKeyWrapper- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
initWrap
public void initWrap(PublicKey wrappingKey, AlgorithmParameterSpec parameters) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
initWrapin interfaceKeyWrapper- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
initWrap
Description copied from interface:KeyWrapperFor wrapping keys in plaintext.- Specified by:
initWrapin interfaceKeyWrapper- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
initUnwrap
public void initUnwrap(PrivateKey unwrappingKey, AlgorithmParameterSpec parameters) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
initUnwrapin interfaceKeyWrapper- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
initUnwrap
public void initUnwrap(SymmetricKey unwrappingKey, AlgorithmParameterSpec parameters) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
initUnwrapin interfaceKeyWrapper- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
initUnwrap
Description copied from interface:KeyWrapperFor plaintext-wrapped keys.- Specified by:
initUnwrapin interfaceKeyWrapper- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
wrap
public byte[] wrap(PrivateKey toBeWrapped) throws InvalidKeyException, IllegalStateException, TokenException - Specified by:
wrapin interfaceKeyWrapper- Throws:
InvalidKeyExceptionIllegalStateExceptionTokenException
-
wrap
public byte[] wrap(SymmetricKey toBeWrapped) throws InvalidKeyException, IllegalStateException, TokenException - Specified by:
wrapin interfaceKeyWrapper- Throws:
InvalidKeyExceptionIllegalStateExceptionTokenException
-
unwrapPrivate
public 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.- Specified by:
unwrapPrivatein interfaceKeyWrapperpublicKey- Used to calculate the key identifier that must be stored with the private key. Must be aRSAPublicKeyor aDSAPublicKey.- Throws:
InvalidKeyException- If the type of the public key does not match the type of the private key to be unwrapped.TokenExceptionIllegalStateException
-
unwrapTemporaryPrivate
public 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.- Specified by:
unwrapTemporaryPrivatein interfaceKeyWrapperpublicKey- Used to calculate the key identifier that must be stored with the private key. Must be aRSAPublicKeyor aDSAPublicKey.- Throws:
InvalidKeyException- If the type of the public key does not match the type of the private key to be unwrapped.TokenExceptionIllegalStateException
-
unwrapSymmetric
public SymmetricKey unwrapSymmetric(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLen) throws TokenException, IllegalStateException, InvalidAlgorithmParameterException - Specified by:
unwrapSymmetricin interfaceKeyWrapperusage- 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).- Throws:
TokenExceptionIllegalStateExceptionInvalidAlgorithmParameterException
-
unwrapSymmetric
public SymmetricKey unwrapSymmetric(byte[] wrapped, SymmetricKey.Type type, int keyLen) throws TokenException, IllegalStateException, InvalidAlgorithmParameterException Description copied from interface:KeyWrapperUnwraps a key and allows it to be used for all operations.- Specified by:
unwrapSymmetricin interfaceKeyWrapperkeyLen- 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:
TokenExceptionIllegalStateExceptionInvalidAlgorithmParameterException
-
unwrapSymmetricPerm
public SymmetricKey unwrapSymmetricPerm(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLen) throws TokenException, IllegalStateException, InvalidAlgorithmParameterException - Specified by:
unwrapSymmetricPermin interfaceKeyWrapper- Throws:
TokenExceptionIllegalStateExceptionInvalidAlgorithmParameterException
-
unwrapSymmetricPerm
public SymmetricKey unwrapSymmetricPerm(byte[] wrapped, SymmetricKey.Type type, int keyLen) throws TokenException, IllegalStateException, InvalidAlgorithmParameterException Description copied from interface:KeyWrapperUnwraps a key and allows it to be used for all operations.- Specified by:
unwrapSymmetricPermin interfaceKeyWrapperkeyLen- 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:
TokenExceptionIllegalStateExceptionInvalidAlgorithmParameterException
-