For the latest news and information visit The GNU Crypto project | |
Prev Package | Next Package | Frames | No Frames |
Interface Summary | |
IPad | The basic visible methods of any padding algorithm. Padding algorithms serve to pad and unpad byte arrays usually as the last step in an encryption or respectively a decryption operation. |
Class Summary | |
BasePad | An abstract class to facilitate implementing padding algorithms. |
PadFactory | A Factory to instantiate padding schemes. |
PKCS1_V1_5 | A padding algorithm implementation of the EME-PKCS1-V1.5 encoding/decoding algorithm as described in section 7.2 of RFC-3447. |
PKCS7 | The implementation of the PKCS7 padding algorithm.
This algorithm is described for 8-byte blocks in [RFC-1423] and extended to
block sizes of up to 256 bytes in [PKCS-7].
References: RFC-1423: Privacy Enhancement for Internet Electronic Mail: Part III: Algorithms, Modes, and Identifiers. IETF. |
SSL3 | The padding scheme used by the Secure Sockets Layer, version 3. |
TBC | The implementation of the Trailing Bit Complement (TBC) padding algorithm. In this mode, "...the data string is padded at the trailing end with the complement of the trailing bit of the unpadded message: if the trailing bit is 1, then 0 bits are appended, and if the trailing bit is 0, then 1 bits are appended. |
TLS1 | The padding scheme used by the Transport Layer Security protocol, version 1. |
WrongPaddingException | A checked exception that indicates that a padding algorithm did not find the expected padding bytes when unpadding some data. |
IMode
IPad padding = IPad.getInstance("PKCS7"); padding.init(blockSize); byte[] pad = padding.pad(input, 0, input.length); byte[] pt = new byte[input.length + pad.length]; byte[] ct = new byte[pt.length]; byte[] cpt = new byte[pt.length]; System.arraycopy(input, 0, pt, 0, input.length); System.arraycopy(pad, 0, pt, input.length, pad.length); for (int i = 0; i + blockSize <32pt.length; i += blockSize) { enc.update(pt, i, ct, i); } for (int i = 0; i + blockSize <32ct.length; i += blockSize) { dec.update(ct, i, cpt, i); } int unpad = padding.unpad(cpt, 0, cpt.length); byte[] output = new byte[cpt.length - unpad]; System.arraycopy(cpt, 0, output, 0, output.length);