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

Java GOST3411Digest类代码示例

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

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



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

示例1: engineInitSign

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
protected void engineInitSign(
    PrivateKey privateKey)
    throws InvalidKeyException
{
    CipherParameters param = null;

    if (privateKey instanceof ECKey)
    {
        param = ECUtil.generatePrivateKeyParameter(privateKey);
    }

    digest = new GOST3411Digest(DEFAULT_SBOX);

    if (appRandom != null)
    {
        signer.init(true, new ParametersWithRandom(param, appRandom));
    }
    else
    {
        signer.init(true, param);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:23,代码来源:SignatureSpi.java


示例2: clone

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
public Object clone()
    throws CloneNotSupportedException
{
    Digest d = (Digest)super.clone();
    d.digest = new GOST3411Digest((GOST3411Digest)digest);

    return d;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:9,代码来源:GOST3411.java


示例3: engineInitVerify

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
protected void engineInitVerify(
    PublicKey publicKey)
    throws InvalidKeyException
{
    CipherParameters param;

    if (publicKey instanceof ECPublicKey)
    {
        param = ECUtil.generatePublicKeyParameter(publicKey);
    }
    else
    {
        try
        {
            byte[] bytes = publicKey.getEncoded();

            publicKey = BouncyCastleProvider.getPublicKey(SubjectPublicKeyInfo.getInstance(bytes));

            if (publicKey instanceof ECPublicKey)
            {
                param = ECUtil.generatePublicKeyParameter(publicKey);
            }
            else
            {
                throw new InvalidKeyException("can't recognise key type in DSA based signer");
            }
        }
        catch (Exception e)
        {
            throw new InvalidKeyException("can't recognise key type in DSA based signer");
        }
    }

    digest = new GOST3411Digest(expandSbox(((BCDSTU4145PublicKey)publicKey).getSbox()));
    signer.init(false, param);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:37,代码来源:SignatureSpi.java


示例4: generateKey

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
private byte[] generateKey(byte[] startkey)
{
    byte[]  newKey = new byte[GOST28147_KEY_LENGTH];

    GOST3411Digest digest = new GOST3411Digest();
    
    digest.update(startkey, 0, startkey.length);
    digest.doFinal(newKey, 0);

    return newKey;
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:12,代码来源:GOST28147Test.java


示例5: initDigesters

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
private static void initDigesters() {
	digesters.put("Blake2b", Blake2bDigest.class);
	digesters.put("GOST3411", GOST3411Digest.class);
	digesters.put("Keccak", KeccakDigest.class);
	digesters.put("MD2", MD2Digest.class);
	digesters.put("MD4", MD4Digest.class);
	digesters.put("MD5", MD5Digest.class);
	digesters.put("RIPEMD128", RIPEMD128Digest.class);
	digesters.put("RIPEMD160", RIPEMD160Digest.class);
	digesters.put("RIPEMD256", RIPEMD256Digest.class);
	digesters.put("RIPEMD320", RIPEMD320Digest.class);
	digesters.put("SHA1", SHA1Digest.class);
	digesters.put("SHA224", SHA224Digest.class);
	digesters.put("SHA256", SHA256Digest.class);
	digesters.put("SHA384", SHA384Digest.class);
	digesters.put("SHA3-512", SHA3Digest.class);
	digesters.put("SHA3-256", SHA3Digest.class);
	digesters.put("SHA3-224", SHA3Digest.class);
	digesters.put("SHA3-384", SHA3Digest.class);
	digesters.put("SHA512", SHA512Digest.class);
	digesters.put("SHAKE-128", SHAKEDigest.class);
	digesters.put("SHAKE-256", SHAKEDigest.class);
	digesters.put("Skein256", SkeinDigest.class);
	digesters.put("Skein512", SkeinDigest.class);
	digesters.put("Skein1024", SkeinDigest.class);
	digesters.put("SM3", SM3Digest.class);
	digesters.put("Tiger", TigerDigest.class);
	digesters.put("Whirlpool", WhirlpoolDigest.class);
}
 
开发者ID:shilongdai,项目名称:vsDiaryWriter,代码行数:30,代码来源:Digesters.java


示例6: main

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
public static void main(
    String[]    args)
{
    HMac gMac = new HMac(new GOST3411Digest(GOST28147Engine.getSBox("D-Test")));

    gMac.init(new KeyParameter(PKCS5S1ParametersGenerator.PKCS5PasswordToUTF8Bytes("Boss".toCharArray())));
    byte[] iBuf = new byte[4];
    byte[] data = Hex.decode("b5d78fa546ba645c");

    gMac.update(data, 0, data.length);
    byte[] mac = new byte[gMac.getMacSize()];

    int pos = 3;
    while (++iBuf[pos] == 0)
    {
        --pos;
    }
    gMac.update(iBuf, 0, iBuf.length);

    gMac.doFinal(mac, 0);

    System.err.println(mac.length + " " + new String(Hex.encode(mac)));

    PKCS5S2ParametersGenerator pGen = new PKCS5S2ParametersGenerator(new GOST3411Digest());

    pGen.init(PKCS5S1ParametersGenerator.PKCS5PasswordToUTF8Bytes("1".toCharArray()), data, 2048);

    KeyParameter kp = (KeyParameter)pGen.generateDerivedMacParameters(256);

    System.err.println(kp.getKey().length + " " + new String(Hex.encode(kp.getKey())));

    runTest(new GOST3411DigestTest());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:34,代码来源:GOST3411DigestTest.java


示例7: Digest

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
public Digest()
{
    super(new GOST3411Digest());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:GOST3411.java


示例8: HashMac

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
public HashMac()
{
    super(new HMac(new GOST3411Digest()));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:GOST3411.java


示例9: SignatureSpi

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
public SignatureSpi()
{
    this.digest = new GOST3411Digest();
    this.signer = new GOST3410Signer();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:6,代码来源:SignatureSpi.java


示例10: SignatureSpi

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
public SignatureSpi()
{
    this.digest = new GOST3411Digest();
    this.signer = new ECGOST3410Signer();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:6,代码来源:SignatureSpi.java


示例11: ecGOST3410_TestParam

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
/**
 * Test Sign & Verify with test parameters
 * see: http://www.ietf.org/internet-drafts/draft-popov-cryptopro-cpalgs-01.txt
 * gostR3410-2001-TestParamSet  P.46
 */
private void ecGOST3410_TestParam()
{
    SecureRandom    random = new SecureRandom();

    BigInteger mod_p = new BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564821041"); //p
    BigInteger mod_q = new BigInteger("57896044618658097711785492504343953927082934583725450622380973592137631069619");

    ECCurve.Fp curve = new ECCurve.Fp(
        mod_p, // p
        new BigInteger("7"), // a
        new BigInteger("43308876546767276905765904595650931995942111794451039583252968842033849580414"), // b
        mod_q, ECConstants.ONE);

    ECDomainParameters params = new ECDomainParameters(
        curve,
        curve.createPoint(
            new BigInteger("2"), // x
            new BigInteger("4018974056539037503335449422937059775635739389905545080690979365213431566280")), // y
        mod_q);

    ECKeyPairGenerator          pGen = new ECKeyPairGenerator();
    ECKeyGenerationParameters   genParam = new ECKeyGenerationParameters(
                                    params,
                                    random);

    pGen.init(genParam);

    AsymmetricCipherKeyPair  pair = pGen.generateKeyPair();

    ParametersWithRandom param = new ParametersWithRandom(pair.getPrivate(), random);

    ECGOST3410Signer ecgost3410 = new ECGOST3410Signer();

    ecgost3410.init(true, param);

    //get hash message using the digest GOST3411.
    byte[] message = "Message for sign".getBytes();
    GOST3411Digest  gost3411 = new GOST3411Digest();
    gost3411.update(message, 0, message.length);
    byte[] hashmessage = new byte[gost3411.getDigestSize()];
    gost3411.doFinal(hashmessage, 0);

    BigInteger[] sig = ecgost3410.generateSignature(hashmessage);

    ecgost3410.init(false, pair.getPublic());

    if (!ecgost3410.verifySignature(hashmessage, sig[0], sig[1]))
    {
        fail("signature fails");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:57,代码来源:ECGOST3410Test.java


示例12: GOST3411DigestTest

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
GOST3411DigestTest()
{
    super(new GOST3411Digest(), messages, digests);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:5,代码来源:GOST3411DigestTest.java


示例13: performTest

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
public void performTest()
{
    super.performTest();

    millionATest(million_a_digest);

    HMac gMac = new HMac(new GOST3411Digest());

    gMac.init(new KeyParameter(PKCS5S1ParametersGenerator.PKCS5PasswordToUTF8Bytes("1".toCharArray())));

    byte[] data = "fred".getBytes();

    gMac.update(data, 0, data.length);
    byte[] mac = new byte[gMac.getMacSize()];

    gMac.doFinal(mac, 0);

    if (!Arrays.areEqual(Hex.decode("e9f98610cfc80084462b175a15d2b4ec10b2ab892eae5a6179d572d9b1db6b72"), mac))
    {
        fail("mac calculation failed.");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:23,代码来源:GOST3411DigestTest.java


示例14: cloneDigest

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
protected Digest cloneDigest(Digest digest)
{
    return new GOST3411Digest((GOST3411Digest)digest);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:5,代码来源:GOST3411DigestTest.java


示例15: register

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
public static final void register(final Map<String, Hasher> hashers) {
  hashers.put(BouncyCastleHasher.GOST,
          new BouncyCastleHasher(new GOST3411Digest()));
  hashers.put(BouncyCastleHasher.MD2,
          new BouncyCastleHasher(new MD2Digest()));
  hashers.put(BouncyCastleHasher.MD4,
          new BouncyCastleHasher(new MD4Digest()));
  hashers.put(BouncyCastleHasher.MD5,
          new BouncyCastleHasher(new MD5Digest()));
  hashers.put(BouncyCastleHasher.RIPEMD128,
          new BouncyCastleHasher(new RIPEMD128Digest()));
  hashers.put(BouncyCastleHasher.RIPEMD160,
          new BouncyCastleHasher(new RIPEMD160Digest()));
  hashers.put(BouncyCastleHasher.RIPEMD256,
          new BouncyCastleHasher(new RIPEMD256Digest()));
  hashers.put(BouncyCastleHasher.RIPEMD320,
          new BouncyCastleHasher(new RIPEMD320Digest()));
  hashers.put(BouncyCastleHasher.SHA1,
          new BouncyCastleHasher(new SHA1Digest()));
  hashers.put(BouncyCastleHasher.SHA224,
          new BouncyCastleHasher(new SHA224Digest()));
  hashers.put(BouncyCastleHasher.SHA256,
          new BouncyCastleHasher(new SHA256Digest()));
  hashers.put(BouncyCastleHasher.SHA3,
          new BouncyCastleHasher(new SHA3Digest()));
  hashers.put(BouncyCastleHasher.SHA384,
          new BouncyCastleHasher(new SHA384Digest()));
  hashers.put(BouncyCastleHasher.SHA512,
          new BouncyCastleHasher(new SHA512Digest()));
  hashers.put(BouncyCastleHasher.SHA512_T,
          new BouncyCastleHasher(new SHA512tDigest(7 * 8)));
  hashers.put(BouncyCastleHasher.SKEIN1024, new BouncyCastleHasher(
          new SkeinDigest(SkeinDigest.SKEIN_1024, Long.BYTES * 8)));
  hashers.put(BouncyCastleHasher.SKEIN256, new BouncyCastleHasher(
          new SkeinDigest(SkeinDigest.SKEIN_256, Long.BYTES * 8)));
  hashers.put(BouncyCastleHasher.SKEIN512, new BouncyCastleHasher(
          new SkeinDigest(SkeinDigest.SKEIN_512, Long.BYTES * 8)));
  hashers.put(BouncyCastleHasher.SM3,
          new BouncyCastleHasher(new SM3Digest()));
  hashers.put(BouncyCastleHasher.TIGER,
          new BouncyCastleHasher(new TigerDigest()));
  hashers.put(BouncyCastleHasher.WHIRLPOOL2,
          new BouncyCastleHasher(new WhirlpoolDigest()));
}
 
开发者ID:benalexau,项目名称:hash-bench,代码行数:45,代码来源:BouncyCastleHasher.java


示例16: ecGOST3410_TestParam

import org.bouncycastle.crypto.digests.GOST3411Digest; //导入依赖的package包/类
/**
 * Test Sign & Verify with test parameters
 * see: http://www.ietf.org/internet-drafts/draft-popov-cryptopro-cpalgs-01.txt
 * gostR3410-2001-TestParamSet  P.46
 */
private void ecGOST3410_TestParam()
{
    SecureRandom    random = new SecureRandom();

    BigInteger mod_p = new BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564821041"); //p

    ECCurve.Fp curve = new ECCurve.Fp(
        mod_p, // p
        new BigInteger("7"), // a
        new BigInteger("43308876546767276905765904595650931995942111794451039583252968842033849580414")); // b

    ECDomainParameters params = new ECDomainParameters(
        curve,
        new ECPoint.Fp(curve,
                       new ECFieldElement.Fp(mod_p,new BigInteger("2")), // x
                       new ECFieldElement.Fp(mod_p,new BigInteger("4018974056539037503335449422937059775635739389905545080690979365213431566280"))), // y
        new BigInteger("57896044618658097711785492504343953927082934583725450622380973592137631069619")); // q

    ECKeyPairGenerator          pGen = new ECKeyPairGenerator();
    ECKeyGenerationParameters   genParam = new ECKeyGenerationParameters(
                                    params,
                                    random);

    pGen.init(genParam);

    AsymmetricCipherKeyPair  pair = pGen.generateKeyPair();

    ParametersWithRandom param = new ParametersWithRandom(pair.getPrivate(), random);

    ECGOST3410Signer ecgost3410 = new ECGOST3410Signer();

    ecgost3410.init(true, param);

    //get hash message using the digest GOST3411.
    byte[] message = "Message for sign".getBytes();
    GOST3411Digest  gost3411 = new GOST3411Digest();
    gost3411.update(message, 0, message.length);
    byte[] hashmessage = new byte[gost3411.getDigestSize()];
    gost3411.doFinal(hashmessage, 0);

    BigInteger[] sig = ecgost3410.generateSignature(hashmessage);

    ecgost3410.init(false, pair.getPublic());

    if (!ecgost3410.verifySignature(hashmessage, sig[0], sig[1]))
    {
        fail("signature fails");
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:55,代码来源:ECGOST3410Test.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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