Package javax.crypto

Examples of javax.crypto.Cipher.update()


                des.update(header, 0, header.length, temp, 0);
            }

            // Iterate over all but the last block
            for (int i = 0; i < numBlocks; i++) {
                des.update(data, offset, blockSize,
                           temp, 0);
                offset += blockSize;
            }

            // Now process the final block
View Full Code Here


                offset += blockSize;
            }

            // Now process the final block
            byte[] retVal = new byte[blockSize];
            des.update(finalBlock, 0, blockSize, retVal, 0);
            des.doFinal();

            return retVal;
        } catch (GeneralSecurityException e) {
            GSSException ge = new GSSException(GSSException.FAILURE, -1,
View Full Code Here

            /*
             * Remove the counfounder first.
             * CONFOUNDER_SIZE is one DES block ie 8 bytes.
             */
            temp = des.update(cipherText, offset, WrapToken.CONFOUNDER_SIZE,
                              token.confounder);
            // temp should be CONFOUNDER_SIZE
            // debug("\n\ttemp is " + temp + " and CONFOUNDER_SIZE is "
            //  + CONFOUNDER_SIZE);

View Full Code Here

            int blockSize = des.getBlockSize();
            int numBlocks = len / blockSize - 1;

            // Iterate over all but the last block
            for (int i = 0; i < numBlocks; i++) {
                temp = des.update(cipherText, offset, blockSize,
                                  dataOutBuf, dataOffset);
                // temp should be blockSize
                // debug("\n\ttemp is " + temp + " and blockSize is "
                //    + blockSize);
View Full Code Here

                dataOffset += blockSize;
            }

            // Now process the last block
            byte[] finalBlock = new byte[blockSize];
            des.update(cipherText, offset, blockSize, finalBlock);

            des.doFinal();

            /*
             * There is always at least one padding byte. The padding bytes
View Full Code Here

      cipher.init(Cipher.DECRYPT_MODE, skeySpec);
    } catch (InvalidKeyException e) {
      throw new RuntimeException(e);
    }
    byte[] origData = origText.getBytes();
    byte[] altEncr = cipher.update(origData);
    if (!Arrays.equals(expEncr, altEncr)) {
      throw new RuntimeException("Mismatch from jdk provider");
    }
  }
}
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

      log.debug("Decrypting buffer: {}", message);
      byte[] encrypted = new byte[message.remaining()];
      message.get(encrypted);
      message.clear();
      message.free();
      byte[] plain = cipher.update(encrypted);
      IoBuffer messageDecrypted = IoBuffer.wrap(plain);
      log.debug("Decrypted buffer: {}", messageDecrypted);
      nextFilter.messageReceived(session, messageDecrypted);
    } else {
      log.trace("Not decrypting message received: {}", obj);
View Full Code Here

        byte[] plain = new byte[message.remaining()];
        message.get(plain);
        message.clear();
        message.free();
        //encrypt and write
        byte[] encrypted = cipher.update(plain);
        IoBuffer messageEncrypted = IoBuffer.wrap(encrypted);
        log.debug("Encrypted buffer: {}", messageEncrypted);
        nextFilter.filterWrite(session, new EncryptedWriteRequest(request, messageEncrypted));
      }
    } else {
View Full Code Here

      oaepSpec = new OAEPParameterSpec("Sha1", "MGF1", MGF1ParameterSpec.SHA1, new PSource.PSpecified("".getBytes()));
    else
      oaepSpec = new OAEPParameterSpec("Sha1", "MGF1", MGF1ParameterSpec.SHA1, new PSource.PSpecified("TCPA".getBytes()));
    Cipher asymCipher = Cipher.getInstance("RSA/ECB/OAEPWithSha1AndMGF1Padding");
    asymCipher.init(Cipher.PUBLIC_KEY, caKey, oaepSpec);
    asymCipher.update(symKey.toByteArray());
    asymBlob = asymCipher.doFinal();
  }
  /**
   * Dump the Identity Request as a byte array in the form that it can be sent to a Privacy CA (or as it came from the client, assembled by a TSS)
   *
 
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.