Package org.apache.harmony.crypto.internal

Examples of org.apache.harmony.crypto.internal.NullCipherSpi


    /**
     * @com.intel.drl.spec_ref
     *
     */
    public NullCipher() {
        super(new NullCipherSpi(), null, null);
        try {
            this.init(Cipher.ENCRYPT_MODE, (Key)null, (SecureRandom)null);   
        } catch (InvalidKeyException e) {       
        }
    }
View Full Code Here


  /*
   * Class under test for int engineDoFinal(ByteBuffer, ByteBuffer)
   */
  public void testEngineDoFinalByteBufferByteBuffer() throws Exception {
    NullCipherSpi spi = new NullCipherSpi();
    byte[] b = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

    ByteBuffer inbuf = ByteBuffer.wrap(b,0,b.length);
    ByteBuffer outbuf = ByteBuffer.allocate(6);
   
    try {
      spi.engineDoFinal(null, outbuf);
      fail("No expected NullPointerException");
    } catch (NullPointerException e) {     
    }
   
    try {
      spi.engineDoFinal(inbuf, null);
      fail("No expected NullPointerException");
    } catch (NullPointerException e) {     
    }
   
    inbuf.get();
    inbuf.get();
    inbuf.get();
    inbuf.get();
    int result = spi.engineDoFinal(inbuf, outbuf);
        assertEquals("incorrect result", b.length - 4, result);
        for (int i = 0; i < result; i++) {
            assertEquals("incorrect outbuf", i + 4, outbuf.get(i));
        }
   
    inbuf = ByteBuffer.wrap(b,0,b.length);
    outbuf = ByteBuffer.allocate(5);
    inbuf.get();
    inbuf.get();
    inbuf.get();
    inbuf.get();
    try {
      spi.engineDoFinal(inbuf, outbuf);
      fail("No expected ShortBufferException");
    } catch (ShortBufferException e) {
    }
  }
View Full Code Here

  /*
   * Class under test for byte[] engineWrap(Key)
   */
  public void testEngineWrapKey() throws Exception {
    NullCipherSpi spi = new NullCipherSpi();
    try {
      spi.engineWrap(null);
      fail("No expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    } 
    }
View Full Code Here

  /*
   * Class under test for Key engineUnwrap(byte[], String, int)
   */
  public void testEngineUnwrapbyteArrayStringint() throws Exception {
    NullCipherSpi spi = new NullCipherSpi();
    try {
      spi.engineUnwrap(new byte[3], "", 10);
      fail("No expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
  }
View Full Code Here

  /*
   * Class under test for int engineGetKeySize(Key)
   */
  public void testEngineGetKeySize() throws Exception {
    NullCipherSpi spi = new NullCipherSpi();
    try {
      spi.engineGetKeySize(null);
      fail("No expected UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
  }
View Full Code Here

* Tests for NullCipher implementation
*/
public class NullCipherSpiTest extends TestCase {

  public void testEngineGetBlockSize() {
    NullCipherSpi spi = new NullCipherSpi();
        assertEquals("incorrect block size", 1, spi.engineGetBlockSize());
  }
View Full Code Here

    NullCipherSpi spi = new NullCipherSpi();
        assertEquals("incorrect block size", 1, spi.engineGetBlockSize());
  }

  public void testEngineGetOutputSize() {
    NullCipherSpi spi = new NullCipherSpi();
        assertEquals("incorrect output size", 100, spi.engineGetOutputSize(100));
  }
View Full Code Here

    NullCipherSpi spi = new NullCipherSpi();
        assertEquals("incorrect output size", 100, spi.engineGetOutputSize(100));
  }

  public void testEngineGetIV() {
    NullCipherSpi spi = new NullCipherSpi();
        assertTrue("Incorrect IV", Arrays.equals(spi.engineGetIV() , new byte[8]));
  }
View Full Code Here

  /*
   * Class under test for byte[] engineUpdate(byte[], int, int)
   */
  public void testEngineUpdatebyteArrayintint() {
    NullCipherSpi spi = new NullCipherSpi();
    byte[] b = {1,2,3,4,5,6,7,8,9};
    byte[] b1 =  spi.engineUpdate(b, 3, 4);
    for (int i = 0; i < 4; i++) {
            assertEquals("incorrect update result", b[3+i], b1[i]);
    }
  }
View Full Code Here

  /*
   * Class under test for int engineUpdate(byte[], int, int, byte[], int)
   */
  public void testEngineUpdatebyteArrayintintbyteArrayint() throws Exception {
    NullCipherSpi spi = new NullCipherSpi();
    byte[] b = {1,2,3,4,5,6,7,8,9};
    byte[] b1 =  new byte[10];
    assertEquals("incorrect update result", 4, spi.engineUpdate(b, 3, 4, b1, 5));
    for (int i = 0; i < 4; i++) {
            assertEquals("incorrect update result", b[3+i], b1[5+i]);
   
  }
View Full Code Here

TOP

Related Classes of org.apache.harmony.crypto.internal.NullCipherSpi

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.