• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java McElieceCCA2KeyGenerationParameters类的典型用法和代码示例

java 2次浏览

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

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

示例1: initialize

点赞 2

import org.bouncycastle.pqc.crypto.mceliece.McElieceCCA2KeyGenerationParameters; //导入依赖的package包/类
public void initialize(AlgorithmParameterSpec params)
    throws InvalidAlgorithmParameterException
{
    kpg = new McElieceCCA2KeyPairGenerator();
    super.initialize(params);
    ECCKeyGenParameterSpec ecc = (ECCKeyGenParameterSpec)params;

    McElieceCCA2KeyGenerationParameters mccca2KGParams = new McElieceCCA2KeyGenerationParameters(new SecureRandom(), new McElieceCCA2Parameters(ecc.getM(), ecc.getT()));
    kpg.init(mccca2KGParams);
}
 

开发者ID:Appdome,
项目名称:ipack,
代码行数:11,
代码来源:McElieceKeyPairGeneratorSpi.java

示例2: performTest

点赞 2

import org.bouncycastle.pqc.crypto.mceliece.McElieceCCA2KeyGenerationParameters; //导入依赖的package包/类
public void performTest()
{
    int numPassesKPG = 1;
    int numPassesEncDec = 10;
    Random rand = new Random();
    byte[] mBytes;
    for (int j = 0; j < numPassesKPG; j++)
    {

        McElieceCCA2Parameters params = new McElieceCCA2Parameters();
        McElieceCCA2KeyPairGenerator mcElieceCCA2KeyGen = new McElieceCCA2KeyPairGenerator();
        McElieceCCA2KeyGenerationParameters genParam = new McElieceCCA2KeyGenerationParameters(keyRandom, params);

        mcElieceCCA2KeyGen.init(genParam);
        AsymmetricCipherKeyPair pair = mcElieceCCA2KeyGen.generateKeyPair();

        ParametersWithRandom param = new ParametersWithRandom(pair.getPublic(), keyRandom);
        Digest msgDigest = new SHA256Digest();
        McEliecePointchevalDigestCipher mcEliecePointchevalDigestCipher = new McEliecePointchevalDigestCipher(new McEliecePointchevalCipher(), msgDigest);


        for (int k = 1; k <= numPassesEncDec; k++)
        {
            System.out.println("############### test: " + k);
            // initialize for encryption
            mcEliecePointchevalDigestCipher.init(true, param);

            // generate random message
            int mLength = (rand.nextInt() & 0x1f) + 1;
            mBytes = new byte[mLength];
            rand.nextBytes(mBytes);

            // encrypt
            mcEliecePointchevalDigestCipher.update(mBytes, 0, mBytes.length);
            byte[] enc = mcEliecePointchevalDigestCipher.messageEncrypt();

            // initialize for decryption
            mcEliecePointchevalDigestCipher.init(false, pair.getPrivate());
            byte[] constructedmessage = mcEliecePointchevalDigestCipher.messageDecrypt(enc);

            // XXX write in McElieceFujisakiDigestCipher?
            msgDigest.update(mBytes, 0, mBytes.length);
            byte[] hash = new byte[msgDigest.getDigestSize()];
            msgDigest.doFinal(hash, 0);

            boolean verified = true;
            for (int i = 0; i < hash.length; i++)
            {
                verified = verified && hash[i] == constructedmessage[i];
            }

            if (!verified)
            {
                fail("en/decryption fails");
            }
            else
            {
                System.out.println("test okay");
                System.out.println();
            }

        }
    }

}
 

开发者ID:credentials,
项目名称:irma_future_id,
代码行数:66,
代码来源:McEliecePointchevalCipherTest.java

示例3: performTest

点赞 2

import org.bouncycastle.pqc.crypto.mceliece.McElieceCCA2KeyGenerationParameters; //导入依赖的package包/类
public void performTest()
{
    int numPassesKPG = 1;
    int numPassesEncDec = 10;
    Random rand = new Random();
    byte[] mBytes;
    for (int j = 0; j < numPassesKPG; j++)
    {

        McElieceCCA2Parameters params = new McElieceCCA2Parameters();
        McElieceCCA2KeyPairGenerator mcElieceCCA2KeyGen = new McElieceCCA2KeyPairGenerator();
        McElieceCCA2KeyGenerationParameters genParam = new McElieceCCA2KeyGenerationParameters(keyRandom, params);

        mcElieceCCA2KeyGen.init(genParam);
        AsymmetricCipherKeyPair pair = mcElieceCCA2KeyGen.generateKeyPair();

        ParametersWithRandom param = new ParametersWithRandom(pair.getPublic(), keyRandom);
        Digest msgDigest = new SHA256Digest();
        McElieceKobaraImaiDigestCipher mcElieceKobaraImaiDigestCipher = new McElieceKobaraImaiDigestCipher(new McElieceKobaraImaiCipher(), msgDigest);


        for (int k = 1; k <= numPassesEncDec; k++)
        {
            System.out.println("############### test: " + k);
            // initialize for encryption
            mcElieceKobaraImaiDigestCipher.init(true, param);

            // generate random message
            int mLength = (rand.nextInt() & 0x1f) + 1;
            mBytes = new byte[mLength];
            rand.nextBytes(mBytes);

            // encrypt
            mcElieceKobaraImaiDigestCipher.update(mBytes, 0, mBytes.length);
            byte[] enc = mcElieceKobaraImaiDigestCipher.messageEncrypt();

            // initialize for decryption
            mcElieceKobaraImaiDigestCipher.init(false, pair.getPrivate());
            byte[] constructedmessage = mcElieceKobaraImaiDigestCipher.messageDecrypt(enc);

            // XXX write in McElieceFujisakiDigestCipher?
            msgDigest.update(mBytes, 0, mBytes.length);
            byte[] hash = new byte[msgDigest.getDigestSize()];
            msgDigest.doFinal(hash, 0);

            boolean verified = true;
            for (int i = 0; i < hash.length; i++)
            {
                verified = verified && hash[i] == constructedmessage[i];
            }

            if (!verified)
            {
                fail("en/decryption fails");
            }
            else
            {
                System.out.println("test okay");
                System.out.println();
            }

        }
    }

}
 

开发者ID:credentials,
项目名称:irma_future_id,
代码行数:66,
代码来源:McElieceKobaraImaiCipherTest.java

示例4: performTest

点赞 2

import org.bouncycastle.pqc.crypto.mceliece.McElieceCCA2KeyGenerationParameters; //导入依赖的package包/类
public void performTest()
{
    int numPassesKPG = 1;
    int numPassesEncDec = 10;
    Random rand = new Random();
    byte[] mBytes;
    for (int j = 0; j < numPassesKPG; j++)
    {

        McElieceCCA2Parameters params = new McElieceCCA2Parameters();
        McElieceCCA2KeyPairGenerator mcElieceCCA2KeyGen = new McElieceCCA2KeyPairGenerator();
        McElieceCCA2KeyGenerationParameters genParam = new McElieceCCA2KeyGenerationParameters(keyRandom, params);

        mcElieceCCA2KeyGen.init(genParam);
        AsymmetricCipherKeyPair pair = mcElieceCCA2KeyGen.generateKeyPair();

        ParametersWithRandom param = new ParametersWithRandom(pair.getPublic(), keyRandom);
        Digest msgDigest = new SHA256Digest();
        McElieceFujisakiDigestCipher mcElieceFujisakiDigestCipher = new McElieceFujisakiDigestCipher(new McElieceFujisakiCipher(), msgDigest);


        for (int k = 1; k <= numPassesEncDec; k++)
        {
            System.out.println("############### test: " + k);
            // initialize for encryption
            mcElieceFujisakiDigestCipher.init(true, param);

            // generate random message
            int mLength = (rand.nextInt() & 0x1f) + 1;;
            mBytes = new byte[mLength];
            rand.nextBytes(mBytes);

            // encrypt
            mcElieceFujisakiDigestCipher.update(mBytes, 0, mBytes.length);
            byte[] enc = mcElieceFujisakiDigestCipher.messageEncrypt();

            // initialize for decryption
            mcElieceFujisakiDigestCipher.init(false, pair.getPrivate());
            byte[] constructedmessage = mcElieceFujisakiDigestCipher.messageDecrypt(enc);

            // XXX write in McElieceFujisakiDigestCipher?
            msgDigest.update(mBytes, 0, mBytes.length);
            byte[] hash = new byte[msgDigest.getDigestSize()];
            msgDigest.doFinal(hash, 0);

            boolean verified = true;
            for (int i = 0; i < hash.length; i++)
            {
                verified = verified && hash[i] == constructedmessage[i];
            }

            if (!verified)
            {
                fail("en/decryption fails");
            }
            else
            {
                System.out.println("test okay");
                System.out.println();
            }

        }
    }

}
 

开发者ID:credentials,
项目名称:irma_future_id,
代码行数:66,
代码来源:McElieceFujisakiCipherTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)