本文整理匯總了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;
}
}