package aalg.crypto;


public class Pkcs7PaddingReader extends BytePaddingReader {

	@Override
	protected void decodePadding() {
		final int paddingBytes = buffer[blockLength - 1] & 0xFF;
		
		for (int i = blockLength - paddingBytes; i < blockLength; i++) {
			if ((buffer[i] & 0xFF) != paddingBytes)
				throw new RuntimeException("Wrong padding");
		}
		
		blockBegin = 0;
		blockEnd = blockLength - paddingBytes;
		
		System.arraycopy(buffer, 0, block, 0, blockEnd);
	}

}
