Package javax.crypto

Examples of javax.crypto.Cipher.update()


    switch (asymAlgorithm.getEncScheme()) {
    case 0x3: // <-- most likely with NTRU, TrouSerS
      Cipher asymCipher = Cipher.getInstance("RSA/ECB/OAEPWithSha1AndMGF1Padding");
      OAEPParameterSpec oaepSpec = new OAEPParameterSpec("Sha1", "MGF1", MGF1ParameterSpec.SHA1, new PSource.PSpecified("TCPA".getBytes()));
      asymCipher.init(Cipher.PRIVATE_KEY, privCaKey, oaepSpec);
      asymCipher.update(asymBlob);
      byte[] temparray = null;
      try {
        temparray = asymCipher.doFinal();
      } catch (BadPaddingException e) { //<- TrouSerS does not use an OAEP parameter string of "TCPA", per 1.1b spec. This results in a BadPaddingException -- try again without!
        oaepSpec = new OAEPParameterSpec("Sha1", "MGF1", MGF1ParameterSpec.SHA1, new PSource.PSpecified("".getBytes()));
View Full Code Here


      try {
        temparray = asymCipher.doFinal();
      } catch (BadPaddingException e) { //<- TrouSerS does not use an OAEP parameter string of "TCPA", per 1.1b spec. This results in a BadPaddingException -- try again without!
        oaepSpec = new OAEPParameterSpec("Sha1", "MGF1", MGF1ParameterSpec.SHA1, new PSource.PSpecified("".getBytes()));
        asymCipher.init(Cipher.PRIVATE_KEY, privCaKey, oaepSpec);
        asymCipher.update(asymBlob);
        temparray = asymCipher.doFinal();
        TrousersModeBlankOeap = true;
      }
      if (temparray == null)
        throw new PrivacyCaException("Unable to decrypt asym blob from incoming request.");
View Full Code Here

      if (serializedData != null) {
                int numBytes;
                byte[] buf = new byte[8192];
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                while ((numBytes = serializedData.read(buf)) != -1) {
                    byte[] data = c.update(buf, 0, numBytes);
                    baos.write(data);
                }
                baos.write(c.doFinal());
                encryptedBytes = baos.toByteArray();
            } else {
View Full Code Here

                    + ".ciphertext";
            InputStream is = Support_Resources.getResourceStream(resPath);

            int bytesRead = is.read(input, 0, 256);
            while (bytesRead > 0) {
                byte[] output = c.update(input, 0, bytesRead);
                if (output != null) {
                    baos.write(output);
                }
                bytesRead = is.read(input, 0, 256);
            }
View Full Code Here

                    + ".plaintext";
            InputStream is = Support_Resources.getResourceStream(resPath);

            int bytesRead = is.read(input, 0, 256);
            while (bytesRead > 0) {
                byte[] output = c.update(input, 0, bytesRead);
                if (output != null) {
                    baos.write(output);
                }
                bytesRead = is.read(input, 0, 256);
            }
View Full Code Here

        Cipher c = Cipher.getInstance("DESede");
        c.init(Cipher.ENCRYPT_MODE, cipherKey);
        byte[] b = {1,2,3,4,5,6,7,8,9,10};
        byte[] b1 = new byte[6];
        try {
            c.update(b, 0, 10, b1, 5);
            fail("No expected ShortBufferException");
        } catch (ShortBufferException e) {
        }
    }
   
View Full Code Here

    Cipher c = Cipher.getInstance("DES");

    byte[] b = {1,2,3,4};
    try {
      c.update(b);
      fail("No expected IllegalStateException");
    } catch (IllegalStateException e){
    }
    if (noKey) {
      return;
View Full Code Here

      return;
    }

    c.init(Cipher.DECRYPT_MODE, key);
    try {
      c.update(null);
      fail("No expected IllegalArgumentException");
    } catch (IllegalArgumentException e){
    }
    assertNull(c.update(new byte[0]));
  }
View Full Code Here

    try {
      c.update(null);
      fail("No expected IllegalArgumentException");
    } catch (IllegalArgumentException e){
    }
    assertNull(c.update(new byte[0]));
  }
 
  private class MyProvider1 extends Provider {
    MyProvider1() {
      super("MyProvider1", 1.0, "Provider1 for testing");
View Full Code Here

            if (serializedData != null) {
                int numBytes;
                byte[] buf = new byte[8192];
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                while ((numBytes = serializedData.read(buf)) != -1) {
                    byte[] data = c.update(buf, 0, numBytes);
                    baos.write(data);
                }
                baos.write(c.doFinal());
                encryptedBytes = baos.toByteArray();
            } else {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.