Java 类javax.crypto.spec.RC2ParameterSpec 实例源码

项目:Aki-SSL    文件:JceCMSMacCalculatorBuilder.java   
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;
    }
}
项目:ipack    文件:RC2.java   
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.");
}
项目:ipack    文件:JceCMSMacCalculatorBuilder.java   
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;
    }
}
项目:OpenJSharp    文件:RC2Parameters.java   
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();
}
项目:OpenJSharp    文件:RC2Cipher.java   
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);
    }
}
项目:jdk8u-jdk    文件:RC2Parameters.java   
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();
}
项目:jdk8u-jdk    文件:RC2Cipher.java   
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);
    }
}
项目:openjdk-jdk10    文件:RC2Parameters.java   
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();
}
项目:openjdk-jdk10    文件:RC2Cipher.java   
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);
    }
}
项目:openjdk9    文件:RC2Parameters.java   
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();
}
项目:openjdk9    文件:RC2Cipher.java   
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);
    }
}
项目:jdk8u_jdk    文件:RC2Parameters.java   
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();
}
项目:jdk8u_jdk    文件:RC2Cipher.java   
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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:RC2Parameters.java   
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();
}
项目:lookaside_java-1.8.0-openjdk    文件:RC2Cipher.java   
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);
    }
}
项目:Aki-SSL    文件:RC2.java   
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.");
}
项目:infobip-open-jdk-8    文件:RC2Parameters.java   
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();
}
项目:infobip-open-jdk-8    文件:RC2Cipher.java   
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);
    }
}
项目:jdk8u-dev-jdk    文件:RC2Parameters.java   
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();
}
项目:jdk8u-dev-jdk    文件:RC2Cipher.java   
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);
    }
}
项目:In-the-Box-Fork    文件:RC2ParameterSpecTest.java   
/**
 * 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());
}
项目:In-the-Box-Fork    文件:RC2ParameterSpecTest.java   
/**
 * 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());
}
项目:jdk7-jdk    文件:RC2Parameters.java   
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();
}
项目:jdk7-jdk    文件:RC2Cipher.java   
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);
    }
}
项目:openjdk-source-code-learn    文件:RC2Parameters.java   
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();
}
项目:openjdk-source-code-learn    文件:RC2Cipher.java   
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);
    }
}
项目:RipplePower    文件:RC2.java   
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.");
}
项目:OLD-OpenJDK8    文件:RC2Parameters.java   
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();
}
项目:OLD-OpenJDK8    文件:RC2Cipher.java   
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);
    }
}
项目:CryptMeme    文件:RC2.java   
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.");
}
项目:openjdk-jdk7u-jdk    文件:RC2Parameters.java   
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();
}
项目:openjdk-jdk7u-jdk    文件:RC2Cipher.java   
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);
    }
}
项目:ripple-lib-java    文件:RC2.java   
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.");
}
项目:openjdk-icedtea7    文件:RC2Parameters.java   
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();
}
项目:openjdk-icedtea7    文件:RC2Cipher.java   
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);
    }
}
项目:irma_future_id    文件:JceCMSMacCalculatorBuilder.java   
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;
    }
}
项目:irma_future_id    文件:JceCMSMacCalculatorBuilder.java   
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;
    }
}
项目:irma_future_id    文件:RC2.java   
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.");
}
项目:irma_future_id    文件:JDKAlgorithmParameters.java   
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.");
}
项目:bc-java    文件:JceCMSMacCalculatorBuilder.java   
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;
    }
}