Search in sources :

Example 21 with NullCipher

use of javax.crypto.NullCipher in project robovm by robovm.

the class NullCipherTest method testDoFinalbyteArrayintintbyteArray3.

/*
     * Class under test for int doFinal(byte[], int, int, byte[])
     */
public void testDoFinalbyteArrayintintbyteArray3() throws Exception {
    //Regression for HARMONY-758
    try {
        new NullCipher().update(new byte[1], 0, 1, new byte[0]);
        fail("Expected IndexOutOfBoundsException was not thrown");
    } catch (IndexOutOfBoundsException e) {
    }
}
Also used : NullCipher(javax.crypto.NullCipher)

Example 22 with NullCipher

use of javax.crypto.NullCipher in project robovm by robovm.

the class NullCipherTest method testDoFinalbyteArrayintintbyteArrayint3.

/*
     * Class under test for int doFinal(byte[], int, int, byte[], int)
     */
public void testDoFinalbyteArrayintintbyteArrayint3() throws Exception {
    //Regression for HARMONY-758
    try {
        new NullCipher().update(new byte[1], 0, 1, new byte[0], 0);
        fail("Expected IndexOutOfBoundsException was not thrown");
    } catch (IndexOutOfBoundsException e) {
    }
}
Also used : NullCipher(javax.crypto.NullCipher)

Example 23 with NullCipher

use of javax.crypto.NullCipher in project robovm by robovm.

the class NullCipherTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    c = new NullCipher();
}
Also used : NullCipher(javax.crypto.NullCipher)

Example 24 with NullCipher

use of javax.crypto.NullCipher in project robovm by robovm.

the class NullCipherTest method testDoFinalbyteArrayintintbyteArrayint2.

/*
     * Class under test for int doFinal(byte[], int, int, byte[], int)
     */
public void testDoFinalbyteArrayintintbyteArrayint2() throws Exception {
    //Regression for HARMONY-758
    try {
        new NullCipher().update(new byte[1], 1, Integer.MAX_VALUE, new byte[1], 0);
        fail("Expected IllegalArgumentException was not thrown");
    } catch (IllegalArgumentException e) {
    }
}
Also used : NullCipher(javax.crypto.NullCipher)

Example 25 with NullCipher

use of javax.crypto.NullCipher in project jdk8u_jdk by JetBrains.

the class CipherNCFuncTest method main.

public static void main(String[] args) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException {
    byte[] plainText = new byte[801];
    // Initialization
    RandomFactory.getRandom().nextBytes(plainText);
    Cipher ci = new NullCipher();
    // Encryption
    byte[] cipherText = new byte[ci.getOutputSize(plainText.length)];
    int offset = ci.update(plainText, 0, plainText.length, cipherText, 0);
    ci.doFinal(cipherText, offset);
    // Decryption
    byte[] recoveredText = new byte[ci.getOutputSize(cipherText.length)];
    int len = ci.doFinal(cipherText, 0, cipherText.length, recoveredText);
    // Comparison
    if (len != plainText.length || !TestUtilities.equalsBlock(plainText, cipherText, len) || !TestUtilities.equalsBlock(plainText, recoveredText, len)) {
        throw new RuntimeException("Test failed because plainText not equal to cipherText and revoveredText");
    }
}
Also used : NullCipher(javax.crypto.NullCipher) NullCipher(javax.crypto.NullCipher) Cipher(javax.crypto.Cipher)

Aggregations

NullCipher (javax.crypto.NullCipher)25 CipherInputStream (javax.crypto.CipherInputStream)9 Cipher (javax.crypto.Cipher)6 SealedObject (javax.crypto.SealedObject)5 CipherOutputStream (javax.crypto.CipherOutputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Key (java.security.Key)2 KeyGenerator (javax.crypto.KeyGenerator)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 FilterInputStream (java.io.FilterInputStream)1 InputStream (java.io.InputStream)1 LineNumberInputStream (java.io.LineNumberInputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 OutputStream (java.io.OutputStream)1 PushbackInputStream (java.io.PushbackInputStream)1 DigestInputStream (java.security.DigestInputStream)1