Examples of AESEngine


Examples of org.bouncycastle.crypto.engines.AESEngine

     * @param blockMode block mode name
     * @return instance to the block mode
     */
    public static AEADBlockCipher getNewCipher(Mode blockMode) {

        AESEngine aesEngine = new AESEngine();

        switch (blockMode) {

        case GCM:
            return new GCMBlockCipher(aesEngine);
View Full Code Here

Examples of org.bouncycastle.crypto.engines.AESEngine

     * @param blockMode block mode name
     * @return instance to the block mode
     */
    public static AEADBlockCipher getNewCipher(Mode blockMode) {

        AESEngine aesEngine = new AESEngine();

        switch (blockMode) {

        case GCM:
            return new GCMBlockCipher(aesEngine);
View Full Code Here

Examples of org.bouncycastle.crypto.engines.AESEngine

  private static byte[] processAESCiphering(boolean forEncrypting, byte[] data, SecretKey key, byte[] initVector)
      throws DataLengthException, IllegalStateException, InvalidCipherTextException {

    // set up engine, block cipher mode and padding
    AESEngine aesEngine = new AESEngine();
    CBCBlockCipher cbc = new CBCBlockCipher(aesEngine);
    PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(cbc);

    // apply parameters
    CipherParameters parameters = new ParametersWithIV(new KeyParameter(key.getEncoded()), initVector);
View Full Code Here

Examples of org.bouncycastle.crypto.engines.AESEngine

    // checksum added to the end of the encrypted data, update on each encryption call
    this.mac = new HMac( new SHA1Digest() );
    mac.init( new KeyParameter(authenticationCodeBytes) );

    this.aesCipher = new SICBlockCipher(new AESEngine());
    this.blockSize = aesCipher.getBlockSize();

    // incremented on each 16 byte block and used as encryption NONCE (ivBytes)
    nonce = 1;
  }
View Full Code Here

Examples of org.bouncycastle.crypto.engines.AESEngine

    // checksum added to the end of the encrypted data, update on each encryption call
    this.mac = new HMac( new SHA1Digest() );
    mac.init( new KeyParameter(authenticationCodeBytes) );

    this.aesCipher = new SICBlockCipher(new AESEngine());
    this.blockSize = aesCipher.getBlockSize();

    // incremented on each 16 byte block and used as encryption NONCE (ivBytes)
    nonce = 1;
   
View Full Code Here

Examples of org.bouncycastle.crypto.engines.AESEngine

   * @return The AES cipher.
   */
  public static AESEngine createCipher(final SecretKey secretKey,
                                 final boolean forEncryption) {

    AESEngine cipher = new AESEngine();

    CipherParameters cipherParams = new KeyParameter(secretKey.getEncoded());

    cipher.init(forEncryption, cipherParams);

    return cipher;
  }
View Full Code Here

Examples of org.bouncycastle.crypto.engines.AESEngine

    protected int getIterationCount() {
        return getIntInputParam("Jitterbit.AES.IterationCount", 1);
    }

    private BufferedBlockCipher createCipher(boolean encrypt) throws Exception {
        AESEngine blockCipher = new AESEngine();
        CBCBlockCipher cbcCipher = new CBCBlockCipher(blockCipher);
        BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(cbcCipher);
        CipherParameters params = createCipherParams();
        cipher.init(encrypt, params);
        return cipher;
View Full Code Here

Examples of org.bouncycastle.crypto.engines.AESEngine

    }

    protected abstract PBEParametersGenerator createPBEParametersGenerator();

    private BufferedBlockCipher createCipher(boolean encrypt) {
        AESEngine blockCipher = new AESEngine();
        CBCBlockCipher cbcCipher = new CBCBlockCipher(blockCipher);
        BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(cbcCipher);
        CipherParameters params = createCipherParams();
        cipher.init(encrypt, params);
        return cipher;
View Full Code Here

Examples of org.bouncycastle.crypto.engines.AESEngine

    // Attack / alter ciphertext (an attacker would do this!)
    byte[] alteredCiphertext = Arrays.clone(originalCiphertext);   
    alteredCiphertext[8] = (byte) (alteredCiphertext[8] ^ 0x08); // <<< Change 100$ to 900$
   
    // Decrypt with BouncyCastle implementation of CipherInputStream
    AEADBlockCipher cipher = new GCMBlockCipher(new AESEngine());
    cipher.init(false, new AEADParameters(new KeyParameter(randomKey), 128, randomIv));
   
    try {
      readFromStream(new org.bouncycastle.crypto.io.CipherInputStream(new ByteArrayInputStream(alteredCiphertext), cipher));
      //             ^^^^^^^^^^^^^^^ INTERESTING PART ^^^^^^^^^^^^^^^^ 
View Full Code Here

Examples of org.bouncycastle.crypto.engines.AESEngine

    byte[] randomIv = createRandomArray(16);   
    byte[] originalPlaintext = createRandomArray(4080); // <<<< 4080 bytes fails, 4079 bytes works!  
    byte[] originalCiphertext = encryptWithAesGcm(originalPlaintext, randomKey, randomIv);
   
    // Decrypt with BouncyCastle implementation of CipherInputStream
    AEADBlockCipher cipher = new GCMBlockCipher(new AESEngine());
    cipher.init(false, new AEADParameters(new KeyParameter(randomKey), 128, randomIv));
   
    try {
      readFromStream(new org.bouncycastle.crypto.io.CipherInputStream(new ByteArrayInputStream(originalCiphertext), cipher));
      //             ^^^^^^^^^^^^^^^ INTERESTING PART ^^^^^^^^^^^^^^^^ 
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.