Package javax.crypto

Examples of javax.crypto.NullCipher


   * 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) {
        }
  }
View Full Code Here


   * 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 ArrayIndexOutOfBoundsException was not thrown");
        } catch (ArrayIndexOutOfBoundsException e) {
        }
  }
View Full Code Here

    /**
     * @tests javax.crypto.CipherInputStream#read(byte[] b, int off, int len)
     */
    public void testReadBII() throws Exception {
        // Regression for HARMONY-1080
        CipherInputStream stream = new CipherInputStream(null, new NullCipher());
        try {
            stream.read(new byte[1], 1, 0);
            fail("NullPointerException expected");
        } catch (NullPointerException e) {
            // expected
View Full Code Here

     * deserialized, the content od deserialized object equals to the
     * content of initial object.
     */
    public void testReadObject() throws Exception {
        String secret = "secret string";
        SealedObject so = new SealedObject(secret, new NullCipher());
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(so);

        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
                bos.toByteArray()));

        SealedObject so_des = (SealedObject) ois.readObject();
        assertEquals("The secret content of deserialized object "
                + "should be equal to the secret content of initial object",
                secret, so_des.getObject(new NullCipher()));
        assertEquals("The value returned by getAlgorithm() method of "
                + "deserialized object should be equal to the value returned "
                + "by getAlgorithm() method of initial object", so
                .getAlgorithm(), so_des.getAlgorithm());
    }
View Full Code Here

                    + "of null SealedObject.");
        } catch (NullPointerException e) {
        }

        String secret = "secret string";
        Cipher cipher = new NullCipher();
        SealedObject so1 = new SealedObject(secret, cipher);
        SealedObject so2 = new SealedObject(so1);

        assertEquals("The secret content of the object should equals "
                + "to the secret content of initial object.", secret, so2
View Full Code Here

     * with encryption algorithm and specified parameters can be retrieved by
     * specifying the initialized Cipher object.
     */
    public void testGetObject2() throws Exception {
        try {
            new SealedObject("secret string", new NullCipher())
                    .getObject((Cipher) null);
            fail("NullPointerException should be thrown in the case of "
                    + "null cipher.");
        } catch (NullPointerException e) {
        }
View Full Code Here

     * object sealed with encryption algorithm can be retrieved by specifying
     * the cryptographic key and provider name.
     */
    public void testGetObject3() throws Exception {
        try {
            new SealedObject("secret string", new NullCipher()).getObject(
                    new SecretKeySpec(new byte[] { 0, 0, 0 }, "algorithm"),
                    null);
            fail("IllegalArgumentException should be thrown in the case of "
                    + "null provider.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new SealedObject("secret string", new NullCipher()).getObject(
                    new SecretKeySpec(new byte[] { 0, 0, 0 }, "algorithm"), "");
            fail("IllegalArgumentException should be thrown in the case of "
                    + "empty provider.");
        } catch (IllegalArgumentException e) {
        }
View Full Code Here

    // Regression test for HARMONY-6347
    public void testGetObject4() throws Exception {
        try {
            new SealedObject("secret string",
                             new NullCipher()).getObject((Key)null);
            fail("NullPointerException should be thrown when key is null");
        } catch (NullPointerException e) {
        }
    }
View Full Code Here

     * (related to the InputStream) and that it returns -1 at the end of stream.
     */
    public void testRead1() throws Exception {
        byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
        TestInputStream tis = new TestInputStream(data);
        CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
        byte res;
        for (int i = 0; i < data.length; i++) {
            if ((res = (byte) cis.read()) != data[i]) {
                fail("read() returned the incorrect value. " + "Expected: "
                        + data[i] + ", Got: " + res + ".");
View Full Code Here

     * stream.
     */
    public void testRead2() throws Exception {
        byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
        TestInputStream tis = new TestInputStream(data);
        CipherInputStream cis = new CipherInputStream(tis, new NullCipher());

        int expected = data.length;
        byte[] result = new byte[expected];

        int ind = 0; // index into the data array (to check the got data)
View Full Code Here

TOP

Related Classes of javax.crypto.NullCipher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.