📄 sicblockcipher.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: SICBlockCipher.java
package org.bouncycastle.crypto.modes;
import org.bouncycastle.crypto.*;
import org.bouncycastle.crypto.params.ParametersWithIV;
public class SICBlockCipher
implements BlockCipher
{
private BlockCipher cipher;
private int blockSize;
private byte IV[];
private byte counter[];
private byte counterOut[];
private boolean encrypting;
public SICBlockCipher(BlockCipher c)
{
cipher = null;
cipher = c;
blockSize = cipher.getBlockSize();
IV = new byte[blockSize];
counter = new byte[blockSize];
counterOut = new byte[blockSize];
}
public BlockCipher getUnderlyingCipher()
{
return cipher;
}
public void init(boolean forEncryption, CipherParameters params)
throws IllegalArgumentException
{
encrypting = forEncryption;
if (params instanceof ParametersWithIV)
{
ParametersWithIV ivParam = (ParametersWithIV)params;
byte iv[] = ivParam.getIV();
System.arraycopy(iv, 0, IV, 0, IV.length);
reset();
cipher.init(true, ivParam.getParameters());
}
}
public String getAlgorithmName()
{
return (new StringBuilder()).append(cipher.getAlgorithmName()).append("/SIC").toString();
}
public int getBlockSize()
{
return cipher.getBlockSize();
}
public int processBlock(byte in[], int inOff, byte out[], int outOff)
throws DataLengthException, IllegalStateException
{
cipher.processBlock(counter, 0, counterOut, 0);
for (int i = 0; i < counterOut.length; i++)
out[outOff + i] = (byte)(counterOut[i] ^ in[inOff + i]);
int carry = 1;
for (int i = counter.length - 1; i >= 0; i--)
{
int x = (counter[i] & 0xff) + carry;
if (x > 255)
carry = 1;
else
carry = 0;
counter[i] = (byte)x;
}
return counter.length;
}
public void reset()
{
System.arraycopy(IV, 0, counter, 0, counter.length);
cipher.reset();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -