Search in sources :

Example 1 with RC5ParameterSpec

use of javax.crypto.spec.RC5ParameterSpec in project j2objc by google.

the class RC5ParameterSpecTest method testGetRounds.

/**
 * getRounds() method testing. Tests that returned value is
 * equal to the value specified in the constructor.
 */
public void testGetRounds() {
    int version = 1;
    int rounds = 5;
    int wordSize = 16;
    RC5ParameterSpec ps = new RC5ParameterSpec(version, rounds, wordSize);
    assertTrue("The returned rounds value should be equal to the " + "value specified in the constructor.", ps.getRounds() == rounds);
}
Also used : RC5ParameterSpec(javax.crypto.spec.RC5ParameterSpec)

Example 2 with RC5ParameterSpec

use of javax.crypto.spec.RC5ParameterSpec in project j2objc by google.

the class RC5ParameterSpecTest method testEquals.

/**
 * equals(Object obj) method testing. Tests the correctness of equal
 * operation: it should be reflexive, symmetric, transitive, consistent
 * and should be false on null object.
 */
public void testEquals() {
    int version = 1;
    int rounds = 5;
    int wordSize = 16;
    byte[] iv = { 1, 2, 3, 4, 5, 6 };
    RC5ParameterSpec ps1 = new RC5ParameterSpec(version, rounds, wordSize, iv);
    RC5ParameterSpec ps2 = new RC5ParameterSpec(version, rounds, wordSize, iv);
    RC5ParameterSpec ps3 = new RC5ParameterSpec(version, rounds, wordSize, new byte[] { 1, 2, 3, 4 });
    // checking for reflexive law:
    assertTrue("The equivalence relation should be reflexive.", ps1.equals(ps1));
    assertTrue("Objects built on the same parameters should be equal.", ps1.equals(ps2));
    // checking for symmetric law:
    assertTrue("The equivalence relation should be symmetric.", ps2.equals(ps1));
    assertTrue("Objects built on the equal parameters should be equal.", ps2.equals(ps3));
    // checking for transitive law:
    assertTrue("The equivalence relation should be transitive.", ps1.equals(ps3));
    assertFalse("Should return not be equal to null object.", ps1.equals(null));
    ps2 = new RC5ParameterSpec(version + 1, rounds, wordSize, iv);
    assertFalse("Objects should not be equal.", ps1.equals(ps2));
    ps2 = new RC5ParameterSpec(version, rounds + 1, wordSize, iv);
    assertFalse("Objects should not be equal.", ps1.equals(ps2));
    ps2 = new RC5ParameterSpec(version, rounds, wordSize / 2, iv);
    assertFalse("Objects should not be equal.", ps1.equals(ps2));
    ps2 = new RC5ParameterSpec(version, rounds, wordSize, new byte[] { 4, 3, 2, 1 });
    assertFalse("Objects should not be equal.", ps1.equals(ps2));
}
Also used : RC5ParameterSpec(javax.crypto.spec.RC5ParameterSpec)

Example 3 with RC5ParameterSpec

use of javax.crypto.spec.RC5ParameterSpec in project j2objc by google.

the class RC5ParameterSpecTest method testRC5ParameterSpec1.

/**
 * RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv) method
 * testing. Tests that IllegalArgumentException is thrown in the case of
 * inappropriate constructor parameters and that input iv array is
 * copied to protect against subsequent modification.
 */
public void testRC5ParameterSpec1() {
    int version = 1;
    int rounds = 5;
    int wordSize = 16;
    byte[] iv = { 1, 2, 3, 4 };
    try {
        new RC5ParameterSpec(version, rounds, wordSize, null);
        fail("An IllegalArgumentException should be thrown " + "in the case of null iv.");
    } catch (IllegalArgumentException e) {
    }
    try {
        new RC5ParameterSpec(version, rounds, wordSize + 8, iv);
        fail("An IllegalArgumentException should be thrown " + "in the case of short iv.");
    } catch (IllegalArgumentException e) {
    }
    try {
        new RC5ParameterSpec(version, rounds, wordSize, new byte[] { 1, 2, 3 });
        fail("An IllegalArgumentException should be thrown " + "in the case of short iv.");
    } catch (IllegalArgumentException e) {
    }
    RC5ParameterSpec ps = new RC5ParameterSpec(version, rounds, wordSize, iv);
    iv[0]++;
    assertFalse("The change of iv specified in the constructor " + "should not cause the change of internal array.", iv[0] == ps.getIV()[0]);
}
Also used : RC5ParameterSpec(javax.crypto.spec.RC5ParameterSpec)

Example 4 with RC5ParameterSpec

use of javax.crypto.spec.RC5ParameterSpec in project j2objc by google.

the class RC5ParameterSpecTest method test_constructorIII.

public void test_constructorIII() {
    int version = 1;
    int rounds = 5;
    int wordSize = 16;
    RC5ParameterSpec ps1 = new RC5ParameterSpec(version, rounds, wordSize);
    RC5ParameterSpec ps2 = new RC5ParameterSpec(version, rounds, wordSize);
    RC5ParameterSpec ps3 = new RC5ParameterSpec(version, rounds, wordSize + 1);
    assertTrue(ps1.equals(ps2));
    assertFalse(ps1.equals(ps3));
}
Also used : RC5ParameterSpec(javax.crypto.spec.RC5ParameterSpec)

Example 5 with RC5ParameterSpec

use of javax.crypto.spec.RC5ParameterSpec in project robovm by robovm.

the class RC5ParameterSpecTest method testEquals.

/**
     * equals(Object obj) method testing. Tests the correctness of equal
     * operation: it should be reflexive, symmetric, transitive, consistent
     * and should be false on null object.
     */
public void testEquals() {
    int version = 1;
    int rounds = 5;
    int wordSize = 16;
    byte[] iv = { 1, 2, 3, 4, 5, 6 };
    RC5ParameterSpec ps1 = new RC5ParameterSpec(version, rounds, wordSize, iv);
    RC5ParameterSpec ps2 = new RC5ParameterSpec(version, rounds, wordSize, iv);
    RC5ParameterSpec ps3 = new RC5ParameterSpec(version, rounds, wordSize, new byte[] { 1, 2, 3, 4 });
    // checking for reflexive law:
    assertTrue("The equivalence relation should be reflexive.", ps1.equals(ps1));
    assertTrue("Objects built on the same parameters should be equal.", ps1.equals(ps2));
    // checking for symmetric law:
    assertTrue("The equivalence relation should be symmetric.", ps2.equals(ps1));
    assertTrue("Objects built on the equal parameters should be equal.", ps2.equals(ps3));
    // checking for transitive law:
    assertTrue("The equivalence relation should be transitive.", ps1.equals(ps3));
    assertFalse("Should return not be equal to null object.", ps1.equals(null));
    ps2 = new RC5ParameterSpec(version + 1, rounds, wordSize, iv);
    assertFalse("Objects should not be equal.", ps1.equals(ps2));
    ps2 = new RC5ParameterSpec(version, rounds + 1, wordSize, iv);
    assertFalse("Objects should not be equal.", ps1.equals(ps2));
    ps2 = new RC5ParameterSpec(version, rounds, wordSize / 2, iv);
    assertFalse("Objects should not be equal.", ps1.equals(ps2));
    ps2 = new RC5ParameterSpec(version, rounds, wordSize, new byte[] { 4, 3, 2, 1 });
    assertFalse("Objects should not be equal.", ps1.equals(ps2));
}
Also used : RC5ParameterSpec(javax.crypto.spec.RC5ParameterSpec)

Aggregations

RC5ParameterSpec (javax.crypto.spec.RC5ParameterSpec)21 CipherParameters (com.github.zhenwei.core.crypto.CipherParameters)2 KeyParameter (com.github.zhenwei.core.crypto.params.KeyParameter)2 ParametersWithIV (com.github.zhenwei.core.crypto.params.ParametersWithIV)2 RC2Parameters (com.github.zhenwei.core.crypto.params.RC2Parameters)2 RC5Parameters (com.github.zhenwei.core.crypto.params.RC5Parameters)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)2 IvParameterSpec (javax.crypto.spec.IvParameterSpec)2 RC2ParameterSpec (javax.crypto.spec.RC2ParameterSpec)2 DataLengthException (com.github.zhenwei.core.crypto.DataLengthException)1 InvalidCipherTextException (com.github.zhenwei.core.crypto.InvalidCipherTextException)1 OutputLengthException (com.github.zhenwei.core.crypto.OutputLengthException)1 AEADCipher (com.github.zhenwei.core.crypto.modes.AEADCipher)1 AEADParameters (com.github.zhenwei.core.crypto.params.AEADParameters)1 FPEParameters (com.github.zhenwei.core.crypto.params.FPEParameters)1 ParametersWithRandom (com.github.zhenwei.core.crypto.params.ParametersWithRandom)1 ParametersWithSBox (com.github.zhenwei.core.crypto.params.ParametersWithSBox)1 PBKDF1Key (com.github.zhenwei.provider.jcajce.PBKDF1Key)1 PBKDF1KeyWithParameters (com.github.zhenwei.provider.jcajce.PBKDF1KeyWithParameters)1 PKCS12Key (com.github.zhenwei.provider.jcajce.PKCS12Key)1