本文整理汇总了Java中org.bouncycastle.crypto.BufferedBlockCipher.getBlockSize方法的典型用法代码示例。如果您正苦于以下问题:Java BufferedBlockCipher.getBlockSize方法的具体用法?Java BufferedBlockCipher.getBlockSize怎么用?Java BufferedBlockCipher.getBlockSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.BufferedBlockCipher
的用法示例。
在下文中一共展示了BufferedBlockCipher.getBlockSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDataDecryptor
import org.bouncycastle.crypto.BufferedBlockCipher; //导入方法依赖的package包/类
public static PGPDataDecryptor createDataDecryptor(boolean withIntegrityPacket, BlockCipher engine, byte[] key)
{
final BufferedBlockCipher c = createStreamCipher(false, engine, withIntegrityPacket, key);
return new PGPDataDecryptor()
{
public InputStream getInputStream(InputStream in)
{
return new CipherInputStream(in, c);
}
public int getBlockSize()
{
return c.getBlockSize();
}
public PGPDigestCalculator getIntegrityCalculator()
{
return new SHA1PGPDigestCalculator();
}
};
}
示例2: CipherOutputStream
import org.bouncycastle.crypto.BufferedBlockCipher; //导入方法依赖的package包/类
/**
* Constructs a CipherOutputStream from an OutputStream and a
* BufferedBlockCipher.
*/
public CipherOutputStream(
OutputStream os,
BufferedBlockCipher cipher)
{
super(os);
this.bufferedBlockCipher = cipher;
this.buf = new byte[cipher.getBlockSize()];
}
示例3: decrypt
import org.bouncycastle.crypto.BufferedBlockCipher; //导入方法依赖的package包/类
public static byte[] decrypt(byte[] input, BufferedBlockCipher cipher) {
synchronized(cipher) {
byte[] cipherText = new byte[cipher.getOutputSize(input.length) - pad.length];
int padCopied = 0;
if(input.length -1 >= cipher.getBlockSize() * 2) {
//If the pad is not relevant for the last two blocks, simply process it out ahead of time
padCopied = cipher.getUnderlyingCipher().processBlock(input, 0, new byte[pad.length], 0);
} else {
//Otherwise, the pad may be relevant for the CTS step, so we'll need to process it
//normally
padCopied = cipher.processBytes(input, 0, pad.length, new byte[pad.length], 0);
}
int outputLen = cipher.processBytes(input, pad.length, input.length - pad.length, cipherText, 0);
byte[] lastBlock = new byte[input.length - padCopied - outputLen];
try {
int size = cipher.doFinal(lastBlock, 0);
int count = 0;
for(int i = pad.length - padCopied ; i < size ; ++i) {
cipherText[outputLen + count] = lastBlock[i];
count++;
}
} catch(CryptoException e) {
Logger.die("process", e);
}
return cipherText;
}
}