• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TweakableBlockCipherParameters类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.bouncycastle.crypto.params.TweakableBlockCipherParameters的典型用法代码示例。如果您正苦于以下问题:Java TweakableBlockCipherParameters类的具体用法?Java TweakableBlockCipherParameters怎么用?Java TweakableBlockCipherParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TweakableBlockCipherParameters类属于org.bouncycastle.crypto.params包,在下文中一共展示了TweakableBlockCipherParameters类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import org.bouncycastle.crypto.params.TweakableBlockCipherParameters; //导入依赖的package包/类
public void init(boolean forEncryption, CipherParameters params)
    throws IllegalArgumentException
{
    if (params instanceof TweakableBlockCipherParameters)
    {
        init(forEncryption, (TweakableBlockCipherParameters)params);
    }
    else if (params instanceof KeyParameter)
    {
        init(forEncryption, new TweakableBlockCipherParameters((KeyParameter)params, new byte[TWEAK_SIZE]));
    }
    else
    {
        throw new IllegalArgumentException("Invalid parameter passed to Threefish init - "
            + params.getClass().getName());
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:18,代码来源:ThreefishReferenceEngine.java


示例2: runTestVector

import org.bouncycastle.crypto.params.TweakableBlockCipherParameters; //导入依赖的package包/类
private static void runTestVector(String name, byte[] key, byte[] tweak, byte[] plaintext, byte[] expected, BlockCipher cipher)
{
    System.out.println("====");
    System.out.println(name + ": ");
    cipher.init(true, new TweakableBlockCipherParameters(new KeyParameter(key), tweak));

    byte[] ciphertext = new byte[key.length];
    cipher.processBlock(plaintext, 0, ciphertext, 0);

    System.out.println("Plaintext  : " + new String(Hex.encode(plaintext)));
    System.out.println("Expected   : " + new String(Hex.encode(expected)));
    System.out.println("Ciphertext : " + new String(Hex.encode(ciphertext)));
    System.out.println("  Encrypt  : " + org.bouncycastle.util.Arrays.areEqual(expected, ciphertext));

    cipher.init(false, new TweakableBlockCipherParameters(new KeyParameter(key), tweak));
    byte[] replain = new byte[plaintext.length];
    cipher.processBlock(ciphertext, 0, replain, 0);

    System.out.println("Replain    : " + new String(Hex.encode(replain)));
    System.out.println("  Decrypt  : " + org.bouncycastle.util.Arrays.areEqual(plaintext, replain));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:22,代码来源:ThroughputTest.java


示例3: init

import org.bouncycastle.crypto.params.TweakableBlockCipherParameters; //导入依赖的package包/类
/**
 * Initialise the engine.
 *
 * @param params an instance of {@link TweakableBlockCipherParameters}, or {@link KeyParameter} (to
 *               use a 0 tweak)
 */
public void init(boolean forEncryption, CipherParameters params)
    throws IllegalArgumentException
{
    final byte[] keyBytes;
    final byte[] tweakBytes;

    if (params instanceof TweakableBlockCipherParameters)
    {
        TweakableBlockCipherParameters tParams = (TweakableBlockCipherParameters)params;
        keyBytes = tParams.getKey().getKey();
        tweakBytes = tParams.getTweak();
    }
    else if (params instanceof KeyParameter)
    {
        keyBytes = ((KeyParameter)params).getKey();
        tweakBytes = null;
    }
    else
    {
        throw new IllegalArgumentException("Invalid parameter passed to Threefish init - "
            + params.getClass().getName());
    }

    long[] keyWords = null;
    long[] tweakWords = null;

    if (keyBytes != null)
    {
        if (keyBytes.length != this.blocksizeBytes)
        {
            throw new IllegalArgumentException("Threefish key must be same size as block (" + blocksizeBytes
                + " bytes)");
        }
        keyWords = new long[blocksizeWords];
        for (int i = 0; i < keyWords.length; i++)
        {
            keyWords[i] = bytesToWord(keyBytes, i * 8);
        }
    }
    if (tweakBytes != null)
    {
        if (tweakBytes.length != TWEAK_SIZE_BYTES)
        {
            throw new IllegalArgumentException("Threefish tweak must be " + TWEAK_SIZE_BYTES + " bytes");
        }
        tweakWords = new long[]{bytesToWord(tweakBytes, 0), bytesToWord(tweakBytes, 8)};
    }
    init(forEncryption, keyWords, tweakWords);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:56,代码来源:ThreefishEngine.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FMLEvent类代码示例发布时间:2022-05-22
下一篇:
Java ApplicationStartDataProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap