|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xwiki.crypto.passwd.internal.AbstractPasswordCiphertext
public abstract class AbstractPasswordCiphertext
A service allowing users to encrypt and decrypt text using a password.
Note: Subclasses implementing other encryption methods should override
getCipher() and optionally getKeyLength()
also subclasses should avoid using fields since this class is serialized to produce the ciphertext.
| Constructor Summary | |
|---|---|
AbstractPasswordCiphertext()
|
|
| Method Summary | |
|---|---|
byte[] |
decrypt(java.lang.String password)
Get the message (i.e. |
protected org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher |
getCipher()
Get the the cipher. |
protected int |
getKeyLength()
Get the size of the cipher key. |
int |
getRequiredKeySize()
Get the length of the key which should be output by the keyFunction which is to be passed to PasswordCiphertext.init(byte[], String, KeyDerivationFunction). |
void |
init(byte[] message,
java.lang.String password,
KeyDerivationFunction initializedKeyFunction)
Initialize this ciphertext with a given message (i.e. |
protected abstract org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher |
newCipherInstance()
The cipher engine. |
byte[] |
serialize()
Serialize this ciphertext into a byte array which can later be deserialized and the text decrypted from that. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractPasswordCiphertext()
| Method Detail |
|---|
public void init(byte[] message,
java.lang.String password,
KeyDerivationFunction initializedKeyFunction)
throws java.security.GeneralSecurityException
PasswordCiphertext.decrypt(String) with the same password.
init in interface PasswordCiphertextmessage - the message which will be encrypted.password - the password used to encrypt the message.initializedKeyFunction - an initialized KeyDerivationFunction which will return a key of the length given
by PasswordCiphertext.getRequiredKeySize().
java.security.GeneralSecurityException - if something goes wrong while encrypting.PasswordCiphertext.init(byte[], java.lang.String, org.xwiki.crypto.passwd.KeyDerivationFunction)
public byte[] decrypt(java.lang.String password)
throws java.security.GeneralSecurityException
decrypt in interface PasswordCiphertextpassword - the user supplied password.
java.security.GeneralSecurityException - if something goes wrong while decrypting.PasswordCiphertext.decrypt(java.lang.String)
public byte[] serialize()
throws java.io.IOException
serialize in interface PasswordCiphertextjava.io.IOException - if something goes wrong in the serialization framework.PasswordCiphertext.serialize()public int getRequiredKeySize()
PasswordCiphertext.init(byte[], String, KeyDerivationFunction).
Users are expected to call this method and pass the result when initializing the key derivation function then
pass the initialized key derivation function to PasswordCiphertext.init(byte[], String, KeyDerivationFunction).
getRequiredKeySize in interface PasswordCiphertextPasswordCiphertext.getRequiredKeySize()protected int getKeyLength()
getRequiredKeySize()
protected org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher getCipher()
protected abstract org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher newCipherInstance()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||