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


Java DESParameters.setOddParity方法代码示例

本文整理汇总了Java中org.bouncycastle.crypto.params.DESParameters.setOddParity方法的典型用法代码示例。如果您正苦于以下问题:Java DESParameters.setOddParity方法的具体用法?Java DESParameters.setOddParity怎么用?Java DESParameters.setOddParity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.crypto.params.DESParameters的用法示例。


在下文中一共展示了DESParameters.setOddParity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateKey

import org.bouncycastle.crypto.params.DESParameters; //导入方法依赖的package包/类
public byte[] generateKey()
{
    byte[]  newKey = new byte[DESParameters.DES_KEY_LENGTH];

    do
    {
        random.nextBytes(newKey);

        DESParameters.setOddParity(newKey);
    }
    while (DESParameters.isWeakKey(newKey, 0));

    return newKey;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:DESKeyGenerator.java

示例2: engineGenerateSecret

import org.bouncycastle.crypto.params.DESParameters; //导入方法依赖的package包/类
protected SecretKey engineGenerateSecret(
    String algorithm) 
{
    if (x == null)
    {
        throw new IllegalStateException("Diffie-Hellman not initialised.");
    }

    String algKey = Strings.toUpperCase(algorithm);
    byte[] res = bigIntToBytes(result);

    if (algorithms.containsKey(algKey))
    {
        Integer length = (Integer)algorithms.get(algKey);

        byte[] key = new byte[length.intValue() / 8];
        System.arraycopy(res, 0, key, 0, key.length);

        if (algKey.startsWith("DES"))
        {
            DESParameters.setOddParity(key);
        }
        
        return new SecretKeySpec(key, algorithm);
    }

    return new SecretKeySpec(res, algorithm);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:29,代码来源:KeyAgreementSpi.java

示例3: performTest

import org.bouncycastle.crypto.params.DESParameters; //导入方法依赖的package包/类
public void performTest()
{
    byte[]  k1In = { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff,
                    (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff };
    byte[]  k1Out = { (byte)0xfe, (byte)0xfe, (byte)0xfe, (byte)0xfe,
                    (byte)0xfe, (byte)0xfe, (byte)0xfe, (byte)0xfe };

    byte[]  k2In = { (byte)0xef, (byte)0xcb, (byte)0xda, (byte)0x4f,
                    (byte)0xaa, (byte)0x99, (byte)0x7f, (byte)0x63 };
    byte[]  k2Out = { (byte)0xef, (byte)0xcb, (byte)0xda, (byte)0x4f,
                    (byte)0xab, (byte)0x98, (byte)0x7f, (byte)0x62 };

    DESParameters.setOddParity(k1In);

    for (int i = 0; i != k1In.length; i++)
    {
        if (k1In[i] != k1Out[i])
        {
            fail("Failed " 
                + "got " + new String(Hex.encode(k1In))
                + " expected " + new String(Hex.encode(k1Out)));
        }
    }

    DESParameters.setOddParity(k2In);

    for (int i = 0; i != k2In.length; i++)
    {
        if (k2In[i] != k2Out[i])
        {
            fail("Failed " 
                + "got " + new String(Hex.encode(k2In))
                + " expected " + new String(Hex.encode(k2Out)));
        }
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:37,代码来源:DESTest.java

示例4: engineGenerateSecret

import org.bouncycastle.crypto.params.DESParameters; //导入方法依赖的package包/类
protected SecretKey engineGenerateSecret(
    KeySpec keySpec)
throws InvalidKeySpecException
{
    if (keySpec instanceof PBEKeySpec)
    {
        PBEKeySpec pbeSpec = (PBEKeySpec)keySpec;
        CipherParameters param;

        if (pbeSpec.getSalt() == null)
        {
            return new BCPBEKey(this.algName, this.algOid, scheme, digest, keySize, ivSize, pbeSpec, null);
        }

        if (forCipher)
        {
            param = PBE.Util.makePBEParameters(pbeSpec, scheme, digest, keySize, ivSize);
        }
        else
        {
            param = PBE.Util.makePBEMacParameters(pbeSpec, scheme, digest, keySize);
        }

        KeyParameter kParam;
        if (param instanceof ParametersWithIV)
        {
            kParam = (KeyParameter)((ParametersWithIV)param).getParameters();
        }
        else
        {
            kParam = (KeyParameter)param;
        }

        DESParameters.setOddParity(kParam.getKey());

        return new BCPBEKey(this.algName, this.algOid, scheme, digest, keySize, ivSize, pbeSpec, param);
    }

    throw new InvalidKeySpecException("Invalid KeySpec");
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:41,代码来源:DES.java


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