org.mozilla.jss.crypto
public abstract class Cipher extends Object
Deprecated: Use the JCA interface instead (javax.crypto.Cipher)
A context for performing symmetric encryption and decryption. First, the context must be initialized. Then, it can be updated with input through zero or more calls toupdate
. Finally,
doFinal
is called to finalize the operation. Note that
it is not necessary to call update
if all of the data is
available at once. In this case, all of the input can be processed with one
call to doFinal
.
Method Summary | |
---|---|
abstract byte[] | doFinal(byte[] bytes)
Completes an cipher operation. |
abstract byte[] | doFinal(byte[] bytes, int offset, int length)
Completes an cipher operation. |
abstract byte[] | doFinal()
Completes an cipher operation. |
abstract void | initDecrypt(SymmetricKey key)
Initializes a decryption context with a symmetric key. |
abstract void | initDecrypt(SymmetricKey key, AlgorithmParameterSpec parameters)
Initializes a decryption context with a symmetric key and
algorithm parameters. |
abstract void | initEncrypt(SymmetricKey key)
Initializes a encryption context with a symmetric key. |
abstract void | initEncrypt(SymmetricKey key, AlgorithmParameterSpec parameters)
Initializes an encryption context with a symmetric key and
algorithm parameters. |
static byte[] | pad(byte[] toBePadded, int blockSize)
Pads a byte array so that its length is a multiple of the given
blocksize. |
static byte[] | unPad(byte[] padded, int blockSize)
Un-pads a byte array that is padded with PKCS padding.
|
static byte[] | unPad(byte[] padded)
Un-pads a byte array that is padded with PKCS padding. |
abstract byte[] | update(byte[] bytes)
Updates the encryption context with additional input. |
abstract byte[] | update(byte[] bytes, int offset, int length)
Updates the encryption context with additional plaintext. |
update
may be called
any number of times before calling final
.Parameters: bytes Bytes of plaintext (if encrypting) or ciphertext (if decrypting).
Returns: The last of the output.
Parameters: bytes Bytes of plaintext (if encrypting) or ciphertext (if
decrypting). offset The index in bytes
at which to begin reading. length The number of bytes from bytes
to read.
Returns: The last of the output.
Returns: The last of the output.
Parameters: The block size of the encryption algorithm. Must be greater than zero.
See Also: Cipher
Parameters: blockSize The block size of the encryption algorithm. This is only used for error checking: if the pad size is not between 1 and blockSize, a BadPaddingException is thrown.
See Also: Cipher
See Also: Cipher
Parameters: bytes Bytes of plaintext (if encrypting) or ciphertext (if decrypting).
Returns: Bytes of ciphertext (if encrypting) or plaintext (if decrypting).
Parameters: bytes Bytes of plaintext (if encrypting) or ciphertext (if
decrypting). offset The index in bytes
at which to begin reading. length The number of bytes from bytes
to read.
Returns: Bytes of ciphertext (if encrypting) or plaintext (if decrypting).