Java 类org.bouncycastle.crypto.params.RC2Parameters 实例源码

项目:ipack    文件:RC2Engine.java   
/**
 * initialise a RC2 cipher.
 *
 * @param encrypting whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           encrypting,
    CipherParameters  params)
{
    this.encrypting = encrypting;

    if (params instanceof RC2Parameters)
    {
        RC2Parameters   param = (RC2Parameters)params;

        workingKey = generateWorkingKey(param.getKey(),
                                        param.getEffectiveKeyBits());
    }
    else if (params instanceof KeyParameter)
    {
        byte[]    key = ((KeyParameter)params).getKey();

        workingKey = generateWorkingKey(key, key.length * 8);
    }
    else
    {
        throw new IllegalArgumentException("invalid parameter passed to RC2 init - " + params.getClass().getName());
    }

}
项目:gwt-crypto    文件:RC2Engine.java   
/**
 * initialise a RC2 cipher.
 *
 * @param encrypting whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           encrypting,
    CipherParameters  params)
{
    this.encrypting = encrypting;

    if (params instanceof RC2Parameters)
    {
        RC2Parameters   param = (RC2Parameters)params;

        workingKey = generateWorkingKey(param.getKey(),
                                        param.getEffectiveKeyBits());
    }
    else if (params instanceof KeyParameter)
    {
        byte[]    key = ((KeyParameter)params).getKey();

        workingKey = generateWorkingKey(key, key.length * 8);
    }
    else
    {
        throw new IllegalArgumentException("invalid parameter passed to RC2 init - " + params.getClass().getName());
    }

}
项目:gwt-crypto    文件:RC2WrapTest.java   
public TestResult perform()
{
    byte[]  kek1 = Hex.decode("fd04fd08060707fb0003fefffd02fe05");
    byte[]  iv1 = Hex.decode("c7d90059b29e97f7");
    byte[]  in1 = Hex.decode("b70a25fbc9d86a86050ce0d711ead4d9");
    byte[]  out1 = Hex.decode("70e699fb5701f7833330fb71e87c85a420bdc99af05d22af5a0e48d35f3138986cbaafb4b28d4f35");
    // 
    // note the RFC 3217 test specifies a key to be used with an effective key size of
    // 40 bits which is why it is done here - in practice nothing less than 128 bits should be used.
    //
    CipherParameters paramWrap = new ParametersWithRandom(new ParametersWithIV(new RC2Parameters(kek1, 40), iv1), new RFCRandom());
    CipherParameters paramUnwrap = new RC2Parameters(kek1, 40);

    TestResult result = wrapTest(1, paramWrap, paramUnwrap, in1, out1);

    if (!result.isSuccessful())
    {
        return result;
    }

    return new SimpleTestResult(true, getName() + ": Okay");
}
项目:Aki-SSL    文件:RC2Engine.java   
/**
 * initialise a RC2 cipher.
 *
 * @param encrypting whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           encrypting,
    CipherParameters  params)
{
    this.encrypting = encrypting;

    if (params instanceof RC2Parameters)
    {
        RC2Parameters   param = (RC2Parameters)params;

        workingKey = generateWorkingKey(param.getKey(),
                                        param.getEffectiveKeyBits());
    }
    else if (params instanceof KeyParameter)
    {
        byte[]    key = ((KeyParameter)params).getKey();

        workingKey = generateWorkingKey(key, key.length * 8);
    }
    else
    {
        throw new IllegalArgumentException("invalid parameter passed to RC2 init - " + params.getClass().getName());
    }

}
项目:TinyTravelTracker    文件:RC2Engine.java   
/**
 * initialise a RC2 cipher.
 *
 * @param encrypting whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           encrypting,
    CipherParameters  params)
{
    this.encrypting = encrypting;

    if (params instanceof RC2Parameters)
    {
        RC2Parameters   param = (RC2Parameters)params;

        workingKey = generateWorkingKey(param.getKey(),
                                        param.getEffectiveKeyBits());
    }
    else if (params instanceof KeyParameter)
    {
        byte[]    key = ((KeyParameter)params).getKey();

        workingKey = generateWorkingKey(key, key.length * 8);
    }
    else
    {
        throw new IllegalArgumentException("invalid parameter passed to RC2 init - " + params.getClass().getName());
    }

}
项目:CryptMeme    文件:RC2Engine.java   
/**
 * initialise a RC2 cipher.
 *
 * @param encrypting whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           encrypting,
    CipherParameters  params)
{
    this.encrypting = encrypting;

    if (params instanceof RC2Parameters)
    {
        RC2Parameters   param = (RC2Parameters)params;

        workingKey = generateWorkingKey(param.getKey(),
                                        param.getEffectiveKeyBits());
    }
    else if (params instanceof KeyParameter)
    {
        byte[]    key = ((KeyParameter)params).getKey();

        workingKey = generateWorkingKey(key, key.length * 8);
    }
    else
    {
        throw new IllegalArgumentException("invalid parameter passed to RC2 init - " + params.getClass().getName());
    }

}
项目:irma_future_id    文件:RC2Engine.java   
/**
 * initialise a RC2 cipher.
 *
 * @param encrypting whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           encrypting,
    CipherParameters  params)
{
    this.encrypting = encrypting;

    if (params instanceof RC2Parameters)
    {
        RC2Parameters   param = (RC2Parameters)params;

        workingKey = generateWorkingKey(param.getKey(),
                                        param.getEffectiveKeyBits());
    }
    else if (params instanceof KeyParameter)
    {
        byte[]    key = ((KeyParameter)params).getKey();

        workingKey = generateWorkingKey(key, key.length * 8);
    }
    else
    {
        throw new IllegalArgumentException("invalid parameter passed to RC2 init - " + params.getClass().getName());
    }

}
项目:irma_future_id    文件:RC2WrapTest.java   
public TestResult perform()
{
    byte[]  kek1 = Hex.decode("fd04fd08060707fb0003fefffd02fe05");
    byte[]  iv1 = Hex.decode("c7d90059b29e97f7");
    byte[]  in1 = Hex.decode("b70a25fbc9d86a86050ce0d711ead4d9");
    byte[]  out1 = Hex.decode("70e699fb5701f7833330fb71e87c85a420bdc99af05d22af5a0e48d35f3138986cbaafb4b28d4f35");
    // 
    // note the RFC 3217 test specifies a key to be used with an effective key size of
    // 40 bits which is why it is done here - in practice nothing less than 128 bits should be used.
    //
    CipherParameters paramWrap = new ParametersWithRandom(new ParametersWithIV(new RC2Parameters(kek1, 40), iv1), new RFCRandom());
    CipherParameters paramUnwrap = new RC2Parameters(kek1, 40);

    TestResult result = wrapTest(1, paramWrap, paramUnwrap, in1, out1);

    if (!result.isSuccessful())
    {
        return result;
    }

    return new SimpleTestResult(true, getName() + ": Okay");
}
项目:bc-java    文件:RC2Engine.java   
/**
 * initialise a RC2 cipher.
 *
 * @param encrypting whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           encrypting,
    CipherParameters  params)
{
    this.encrypting = encrypting;

    if (params instanceof RC2Parameters)
    {
        RC2Parameters   param = (RC2Parameters)params;

        workingKey = generateWorkingKey(param.getKey(),
                                        param.getEffectiveKeyBits());
    }
    else if (params instanceof KeyParameter)
    {
        byte[]    key = ((KeyParameter)params).getKey();

        workingKey = generateWorkingKey(key, key.length * 8);
    }
    else
    {
        throw new IllegalArgumentException("invalid parameter passed to RC2 init - " + params.getClass().getName());
    }

}
项目:bc-java    文件:RC2WrapTest.java   
public TestResult perform()
{
    byte[]  kek1 = Hex.decode("fd04fd08060707fb0003fefffd02fe05");
    byte[]  iv1 = Hex.decode("c7d90059b29e97f7");
    byte[]  in1 = Hex.decode("b70a25fbc9d86a86050ce0d711ead4d9");
    byte[]  out1 = Hex.decode("70e699fb5701f7833330fb71e87c85a420bdc99af05d22af5a0e48d35f3138986cbaafb4b28d4f35");
    // 
    // note the RFC 3217 test specifies a key to be used with an effective key size of
    // 40 bits which is why it is done here - in practice nothing less than 128 bits should be used.
    //
    CipherParameters paramWrap = new ParametersWithRandom(new ParametersWithIV(new RC2Parameters(kek1, 40), iv1), new RFCRandom());
    CipherParameters paramUnwrap = new RC2Parameters(kek1, 40);

    TestResult result = wrapTest(1, paramWrap, paramUnwrap, in1, out1);

    if (!result.isSuccessful())
    {
        return result;
    }

    return new SimpleTestResult(true, getName() + ": Okay");
}