当前位置: 首页>>代码示例>>Java>>正文


Java Salsa20Engine.salsaCore方法代码示例

本文整理汇总了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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:SCrypt.java

示例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);
}
 
开发者ID:codahale,项目名称:xsalsa20poly1305,代码行数:41,代码来源:HSalsa20.java


注:本文中的org.bouncycastle.crypto.engines.Salsa20Engine.salsaCore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。