|
JSS 3.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.mozilla.jss.pkcs11.PK11KeyWrapper
Field Summary | |
private KeyWrapAlgorithm |
algorithm
|
private byte[] |
IV
|
private java.security.spec.AlgorithmParameterSpec |
parameters
|
private PrivateKey |
privKey
|
private java.security.PublicKey |
pubKey
|
private int |
state
|
private SymmetricKey |
symKey
|
private PK11Token |
token
|
private static int |
UNINITIALIZED
|
private static int |
UNWRAP
|
private static int |
WRAP
|
Constructor Summary | |
private |
PK11KeyWrapper()
|
(package private) |
PK11KeyWrapper(PK11Token token,
KeyWrapAlgorithm algorithm)
|
Method Summary | |
private static Algorithm |
algFromType(PrivateKey.Type type)
|
private static Algorithm |
algFromType(SymmetricKey.Type type)
|
private PrivateKey |
baseUnwrapPrivate(byte[] wrapped,
PrivateKey.Type type,
java.security.PublicKey publicKey,
boolean temporary)
|
private void |
checkParams(java.security.spec.AlgorithmParameterSpec params)
|
private void |
checkWrappee(PrivateKey privKey)
Makes sure the key lives on the right token. |
private void |
checkWrappee(SymmetricKey symKey)
Makes sure the key lives on the right token. |
private void |
checkWrapper(PrivateKey key)
Makes sure the key is on the token and is right for the algorithm. |
private void |
checkWrapper(java.security.PublicKey key)
Makes sure the key is right for the algorithm. |
private void |
checkWrapper(SymmetricKey key)
Makes sure the key lives on the token and is right for the algorithm. |
private static byte[] |
extractPublicValue(java.security.PublicKey publicKey,
PrivateKey.Type type)
Extracts the "public value" from a public key. |
void |
initUnwrap()
For plaintext-wrapped keys. |
private void |
initUnwrap(java.security.spec.AlgorithmParameterSpec parameters)
Does the key-independent parts of initializing an unwrap. |
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. |
private void |
initWrap(java.security.spec.AlgorithmParameterSpec parameters)
Does everything that is key-independent for initializing a wrap. |
void |
initWrap(java.security.PublicKey wrappingKey,
java.security.spec.AlgorithmParameterSpec parameters)
|
void |
initWrap(SymmetricKey wrappingKey,
java.security.spec.AlgorithmParameterSpec parameters)
|
private static PrivateKey |
nativeUnwrapPrivWithSym(PK11Token token,
SymmetricKey unwrappingKey,
byte[] wrappedKey,
KeyWrapAlgorithm alg,
Algorithm type,
byte[] publicValue,
byte[] IV,
boolean temporary)
Unwrap a private with a symmetric. |
private static SymmetricKey |
nativeUnwrapSymPlaintext(PK11Token token,
byte[] wrappedKey,
Algorithm type,
int usageEnum)
|
private static SymmetricKey |
nativeUnwrapSymWithPriv(PK11Token token,
PrivateKey unwrappingKey,
byte[] wrappedKey,
KeyWrapAlgorithm alg,
Algorithm type,
int keyLen,
byte[] IV,
int usageEnum)
Unwrap a symmetric with a private. |
private static SymmetricKey |
nativeUnwrapSymWithSym(PK11Token token,
SymmetricKey unwrappingKey,
byte[] wrappedKey,
KeyWrapAlgorithm alg,
Algorithm type,
int keyLen,
byte[] IV,
int usageEnum)
Unwrap a symmetric with a symmetric. |
private static byte[] |
nativeWrapPrivWithSym(PK11Token token,
PrivateKey toBeWrapped,
SymmetricKey wrappingKey,
KeyWrapAlgorithm alg,
byte[] IV)
Wrap a private with a symmetric |
private static byte[] |
nativeWrapSymWithPub(PK11Token token,
SymmetricKey toBeWrapped,
java.security.PublicKey wrappingKey,
KeyWrapAlgorithm alg,
byte[] IV)
Wrap a symmetric with a public |
private static byte[] |
nativeWrapSymWithSym(PK11Token token,
SymmetricKey toBeWrapped,
SymmetricKey wrappingKey,
KeyWrapAlgorithm alg,
byte[] IV)
Wrap a symmetric with a symmetric |
private void |
reset()
|
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. |
private SymmetricKey |
unwrapSymmetric(byte[] wrapped,
SymmetricKey.Type type,
int usageEnum,
int keyLen)
|
SymmetricKey |
unwrapSymmetric(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)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private PK11Token token
private KeyWrapAlgorithm algorithm
private int state
private java.security.spec.AlgorithmParameterSpec parameters
private SymmetricKey symKey
private PrivateKey privKey
private java.security.PublicKey pubKey
private byte[] IV
private static final int UNINITIALIZED
private static final int WRAP
private static final int UNWRAP
Constructor Detail |
private PK11KeyWrapper()
PK11KeyWrapper(PK11Token token, KeyWrapAlgorithm algorithm)
Method Detail |
public void initWrap(SymmetricKey wrappingKey, java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
initWrap
in interface KeyWrapper
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
public void initWrap(java.security.PublicKey wrappingKey, java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
initWrap
in interface KeyWrapper
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
public void initWrap() throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
KeyWrapper
initWrap
in interface KeyWrapper
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
private void initWrap(java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidAlgorithmParameterException
java.security.InvalidAlgorithmParameterException
public void initUnwrap(PrivateKey unwrappingKey, java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
initUnwrap
in interface KeyWrapper
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
public void initUnwrap(SymmetricKey unwrappingKey, java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
initUnwrap
in interface KeyWrapper
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
public void initUnwrap() throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
KeyWrapper
initUnwrap
in interface KeyWrapper
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
private void initUnwrap(java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidAlgorithmParameterException
java.security.InvalidAlgorithmParameterException
private void checkWrapper(java.security.PublicKey key) throws java.security.InvalidKeyException
java.security.InvalidKeyException
private void checkWrapper(SymmetricKey key) throws java.security.InvalidKeyException
java.security.InvalidKeyException
private void checkWrapper(PrivateKey key) throws java.security.InvalidKeyException
java.security.InvalidKeyException
private void checkParams(java.security.spec.AlgorithmParameterSpec params) throws java.security.InvalidAlgorithmParameterException
java.security.InvalidAlgorithmParameterException
public byte[] wrap(PrivateKey toBeWrapped) throws java.security.InvalidKeyException, java.lang.IllegalStateException, TokenException
wrap
in interface KeyWrapper
java.security.InvalidKeyException
java.lang.IllegalStateException
TokenException
public byte[] wrap(SymmetricKey toBeWrapped) throws java.security.InvalidKeyException, java.lang.IllegalStateException, TokenException
wrap
in interface KeyWrapper
java.security.InvalidKeyException
java.lang.IllegalStateException
TokenException
private void checkWrappee(SymmetricKey symKey) throws java.security.InvalidKeyException
java.security.InvalidKeyException
private void checkWrappee(PrivateKey privKey) throws java.security.InvalidKeyException
java.security.InvalidKeyException
private static byte[] nativeWrapSymWithSym(PK11Token token, SymmetricKey toBeWrapped, SymmetricKey wrappingKey, KeyWrapAlgorithm alg, byte[] IV) throws TokenException
TokenException
private static byte[] nativeWrapSymWithPub(PK11Token token, SymmetricKey toBeWrapped, java.security.PublicKey wrappingKey, KeyWrapAlgorithm alg, byte[] IV) throws TokenException
TokenException
private static byte[] nativeWrapPrivWithSym(PK11Token token, PrivateKey toBeWrapped, SymmetricKey wrappingKey, KeyWrapAlgorithm alg, byte[] IV) throws TokenException
TokenException
public PrivateKey unwrapPrivate(byte[] wrapped, PrivateKey.Type type, java.security.PublicKey publicKey) throws TokenException, java.security.InvalidKeyException, java.lang.IllegalStateException
unwrapPrivate
in interface KeyWrapper
publicKey
- 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.
TokenException
java.lang.IllegalStateException
public PrivateKey unwrapTemporaryPrivate(byte[] wrapped, PrivateKey.Type type, java.security.PublicKey publicKey) throws TokenException, java.security.InvalidKeyException, java.lang.IllegalStateException
unwrapTemporaryPrivate
in interface KeyWrapper
publicKey
- 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.
TokenException
java.lang.IllegalStateException
private PrivateKey baseUnwrapPrivate(byte[] wrapped, PrivateKey.Type type, java.security.PublicKey publicKey, boolean temporary) throws TokenException, java.security.InvalidKeyException, java.lang.IllegalStateException
TokenException
java.security.InvalidKeyException
java.lang.IllegalStateException
private static byte[] extractPublicValue(java.security.PublicKey publicKey, PrivateKey.Type type) throws java.security.InvalidKeyException
java.security.InvalidKeyException
public SymmetricKey unwrapSymmetric(byte[] wrapped, SymmetricKey.Type type, SymmetricKey.Usage usage, int keyLen) throws TokenException, java.lang.IllegalStateException, java.security.InvalidAlgorithmParameterException
unwrapSymmetric
in interface KeyWrapper
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).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.
TokenException
java.lang.IllegalStateException
java.security.InvalidAlgorithmParameterException
public SymmetricKey unwrapSymmetric(byte[] wrapped, SymmetricKey.Type type, int keyLen) throws TokenException, java.lang.IllegalStateException, java.security.InvalidAlgorithmParameterException
KeyWrapper
unwrapSymmetric
in interface KeyWrapper
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).
TokenException
java.lang.IllegalStateException
java.security.InvalidAlgorithmParameterException
private SymmetricKey unwrapSymmetric(byte[] wrapped, SymmetricKey.Type type, int usageEnum, int keyLen) throws TokenException, java.lang.IllegalStateException, java.security.InvalidAlgorithmParameterException
TokenException
java.lang.IllegalStateException
java.security.InvalidAlgorithmParameterException
private static Algorithm algFromType(PrivateKey.Type type)
private static Algorithm algFromType(SymmetricKey.Type type)
private static PrivateKey nativeUnwrapPrivWithSym(PK11Token token, SymmetricKey unwrappingKey, byte[] wrappedKey, KeyWrapAlgorithm alg, Algorithm type, byte[] publicValue, byte[] IV, boolean temporary) throws TokenException
TokenException
private static SymmetricKey nativeUnwrapSymWithSym(PK11Token token, SymmetricKey unwrappingKey, byte[] wrappedKey, KeyWrapAlgorithm alg, Algorithm type, int keyLen, byte[] IV, int usageEnum) throws TokenException
TokenException
private static SymmetricKey nativeUnwrapSymWithPriv(PK11Token token, PrivateKey unwrappingKey, byte[] wrappedKey, KeyWrapAlgorithm alg, Algorithm type, int keyLen, byte[] IV, int usageEnum) throws TokenException
TokenException
private static SymmetricKey nativeUnwrapSymPlaintext(PK11Token token, byte[] wrappedKey, Algorithm type, int usageEnum)
private void reset()
|
JSS 3.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |