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


Java RC2ParameterSpec类代码示例

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


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

示例1: generateParameterSpec

import javax.crypto.spec.RC2ParameterSpec; //导入依赖的package包/类
protected AlgorithmParameterSpec generateParameterSpec(ASN1ObjectIdentifier macOID, SecretKey encKey)
    throws CMSException
{
    try
    {
        if (macOID.equals(PKCSObjectIdentifiers.RC2_CBC))
        {
            byte[] iv = new byte[8];

            random.nextBytes(iv);

            return new RC2ParameterSpec(encKey.getEncoded().length * 8, iv);
        }

        AlgorithmParameterGenerator pGen = helper.createAlgorithmParameterGenerator(macOID);

        AlgorithmParameters p = pGen.generateParameters();

        return p.getParameterSpec(IvParameterSpec.class);
    }
    catch (GeneralSecurityException e)
    {
        return null;
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:26,代码来源:JceCMSMacCalculatorBuilder.java

示例2: localEngineGetParameterSpec

import javax.crypto.spec.RC2ParameterSpec; //导入依赖的package包/类
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == RC2ParameterSpec.class)
    {
        if (parameterVersion != -1)
        {
            if (parameterVersion < 256)
            {
                return new RC2ParameterSpec(ekb[parameterVersion], iv);
            }
            else
            {
                return new RC2ParameterSpec(parameterVersion, iv);
            }
        }
    }

    if (paramSpec == IvParameterSpec.class)
    {
        return new IvParameterSpec(iv);
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to RC2 parameters object.");
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:RC2.java

示例3: engineInit

import javax.crypto.spec.RC2ParameterSpec; //导入依赖的package包/类
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {

    if (!(paramSpec instanceof RC2ParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    RC2ParameterSpec rps = (RC2ParameterSpec) paramSpec;

    // check effective key size (a value of 0 means it is unspecified)
    effectiveKeySize = rps.getEffectiveKeyBits();
    if (effectiveKeySize != 0) {
        if (effectiveKeySize < 1 || effectiveKeySize > 1024) {
            throw new InvalidParameterSpecException("RC2 effective key " +
                "size must be between 1 and 1024 bits");
        }
        if (effectiveKeySize < 256) {
            version = EKB_TABLE[effectiveKeySize];
        } else {
            version = effectiveKeySize;
        }
    }
    this.iv = rps.getIV();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:RC2Parameters.java

示例4: engineInit

import javax.crypto.spec.RC2ParameterSpec; //导入依赖的package包/类
protected void engineInit(int opmode, Key key,
        AlgorithmParameters params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (params != null && params.getAlgorithm().equals("RC2")) {
        try {
            RC2ParameterSpec rc2Params =
                    params.getParameterSpec(RC2ParameterSpec.class);
            engineInit(opmode, key, rc2Params, random);
        } catch (InvalidParameterSpecException ipse) {
            throw new InvalidAlgorithmParameterException
                        ("Wrong parameter type: RC2 expected");
        }
    } else {
        embeddedCipher.initEffectiveKeyBits(0);
        core.init(opmode, key, params, random);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:RC2Cipher.java

示例5: testGetEffectiveKeyBits

import javax.crypto.spec.RC2ParameterSpec; //导入依赖的package包/类
/**
 * getEffectiveKeyBits() method testing. Tests that returned value is
 * equal to the value specified in the constructor.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getEffectiveKeyBits",
    args = {}
)
public void testGetEffectiveKeyBits() {
    int effectiveKeyBits = 10;
    byte[] iv = {1, 2, 3, 4, 5, 6, 7, 8};

    RC2ParameterSpec ps = new RC2ParameterSpec(effectiveKeyBits, iv);
    assertTrue("The returned effectiveKeyBits value is not equal to the "
            + "value specified in the constructor.",
            effectiveKeyBits == ps.getEffectiveKeyBits());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:20,代码来源:RC2ParameterSpecTest.java

示例6: testHashCode

import javax.crypto.spec.RC2ParameterSpec; //导入依赖的package包/类
/**
 * hashCode() method testing. Tests that for equal objects hash codes
 * are equal.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "hashCode",
    args = {}
)
public void testHashCode() {
    int effectiveKeyBits = 0;
    byte[] iv = new byte[] {1, 2, 3, 4, 5, 6, 7, 8};

    RC2ParameterSpec ps1 = new RC2ParameterSpec(effectiveKeyBits, iv);
    RC2ParameterSpec ps2 = new RC2ParameterSpec(effectiveKeyBits, iv);

    assertTrue("Equal objects should have the same hash codes.",
                                        ps1.hashCode() == ps2.hashCode());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:RC2ParameterSpecTest.java

示例7: engineInit

import javax.crypto.spec.RC2ParameterSpec; //导入依赖的package包/类
protected void engineInit(int opmode, Key key,
        AlgorithmParameters params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (params != null && params.getAlgorithm().equals("RC2")) {
        try {
            RC2ParameterSpec rc2Params = (RC2ParameterSpec)
                params.getParameterSpec(RC2ParameterSpec.class);
            engineInit(opmode, key, rc2Params, random);
        } catch (InvalidParameterSpecException ipse) {
            throw new InvalidAlgorithmParameterException
                        ("Wrong parameter type: RC2 expected");
        }
    } else {
        embeddedCipher.initEffectiveKeyBits(0);
        core.init(opmode, key, params, random);
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:18,代码来源:RC2Cipher.java

示例8: localEngineGetParameterSpec

import javax.crypto.spec.RC2ParameterSpec; //导入依赖的package包/类
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec) 
    throws InvalidParameterSpecException
{
    if (paramSpec == RC2ParameterSpec.class)
    {
        if (parameterVersion != -1)
        {
            if (parameterVersion < 256)
            {
                return new RC2ParameterSpec(ekb[parameterVersion], iv);
            }
            else
            {
                return new RC2ParameterSpec(parameterVersion, iv);
            }
        }
    }

    if (paramSpec == IvParameterSpec.class)
    {
        return new IvParameterSpec(iv);
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to RC2 parameters object.");
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:27,代码来源:JDKAlgorithmParameters.java


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