本文整理汇总了Java中org.bouncycastle.crypto.engines.Salsa20Engine.salsaCore方法的典型用法代码示例。如果您正苦于以下问题:Java Salsa20Engine.salsaCore方法的具体用法?Java Salsa20Engine.salsaCore怎么用?Java Salsa20Engine.salsaCore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.engines.Salsa20Engine
的用法示例。
在下文中一共展示了Salsa20Engine.salsaCore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BlockMix
import org.bouncycastle.crypto.engines.Salsa20Engine; //导入方法依赖的package包/类
private static void BlockMix(int[] B, int[] X1, int[] X2, int[] Y, int r)
{
System.arraycopy(B, B.length - 16, X1, 0, 16);
int BOff = 0, YOff = 0, halfLen = B.length >>> 1;
for (int i = 2 * r; i > 0; --i)
{
Xor(X1, B, BOff, X2);
Salsa20Engine.salsaCore(8, X2, X1);
System.arraycopy(X1, 0, Y, YOff, 16);
YOff = halfLen + BOff - YOff;
BOff += 16;
}
System.arraycopy(Y, 0, B, 0, Y.length);
}
示例2: hsalsa20
import org.bouncycastle.crypto.engines.Salsa20Engine; //导入方法依赖的package包/类
static void hsalsa20(byte[] out, byte[] in, byte[] k) {
final int[] x = new int[16];
x[0] = littleEndianToInt(HSalsa20.SIGMA, 0);
x[1] = littleEndianToInt(k, 0);
x[2] = littleEndianToInt(k, 4);
x[3] = littleEndianToInt(k, 8);
x[4] = littleEndianToInt(k, 12);
x[5] = littleEndianToInt(HSalsa20.SIGMA, 4);
x[6] = littleEndianToInt(in, 0);
x[7] = littleEndianToInt(in, 4);
x[8] = littleEndianToInt(in, 8);
x[9] = littleEndianToInt(in, 12);
x[10] = littleEndianToInt(HSalsa20.SIGMA, 8);
x[11] = littleEndianToInt(k, 16);
x[12] = littleEndianToInt(k, 20);
x[13] = littleEndianToInt(k, 24);
x[14] = littleEndianToInt(k, 28);
x[15] = littleEndianToInt(HSalsa20.SIGMA, 12);
Salsa20Engine.salsaCore(20, x, x);
x[0] -= littleEndianToInt(HSalsa20.SIGMA, 0);
x[5] -= littleEndianToInt(HSalsa20.SIGMA, 4);
x[10] -= littleEndianToInt(HSalsa20.SIGMA, 8);
x[15] -= littleEndianToInt(HSalsa20.SIGMA, 12);
x[6] -= littleEndianToInt(in, 0);
x[7] -= littleEndianToInt(in, 4);
x[8] -= littleEndianToInt(in, 8);
x[9] -= littleEndianToInt(in, 12);
intToLittleEndian(x[0], out, 0);
intToLittleEndian(x[5], out, 4);
intToLittleEndian(x[10], out, 8);
intToLittleEndian(x[15], out, 12);
intToLittleEndian(x[6], out, 16);
intToLittleEndian(x[7], out, 20);
intToLittleEndian(x[8], out, 24);
intToLittleEndian(x[9], out, 28);
}