Package freenet.crypt.ciphers

Examples of freenet.crypt.ciphers.Rijndael.initialize()


      //ctr.blockDecipher(ciphertext, 0, ciphertext.length, finalPlaintext, 0);
      ctr.blockDecipher(finalPlaintext, 0, finalPlaintext.length);
      assertTrue(Arrays.equals(finalPlaintext, plaintext));

      // Now encrypt again, in random pieces.
      cipher.initialize(key);
      ctr = PCFBMode.create(cipher);
      ctr.reset(iv);
      byte[] output = new byte[plaintext.length];

      MersenneTwister random = new MersenneTwister(mt.nextLong());
View Full Code Here


      byte[] output = c.doFinal(plaintext);
      assertTrue(Arrays.equals(output, ciphertext));
    }

    Rijndael cipher = new Rijndael(bits, 128);
    cipher.initialize(key);
    CTRBlockCipher ctr = new CTRBlockCipher(cipher);
    ctr.init(iv);
    byte[] output = new byte[plaintext.length];
    ctr.processBytes(plaintext, 0, plaintext.length, output, 0);
    assertTrue(Arrays.equals(output, ciphertext));
View Full Code Here

            outputPtr);
        assertTrue(Arrays.equals(output, ciphertext));
      }

      Rijndael cipher = new Rijndael(bits, 128);
      cipher.initialize(key);
      CTRBlockCipher ctr = new CTRBlockCipher(cipher);
      ctr.init(iv);
      byte[] output = new byte[plaintext.length];
      MersenneTwister random = new MersenneTwister(seed);
      int ptr = 0;
View Full Code Here

      mt.nextBytes(plaintext);
      mt.nextBytes(key);
      mt.nextBytes(iv);
      // First encrypt as a block.
      Rijndael cipher = new Rijndael(256, 128);
      cipher.initialize(key);
      CTRBlockCipher ctr = new CTRBlockCipher(cipher);
      ctr.init(iv);
      byte[] ciphertext = new byte[plaintext.length];
      ctr.processBytes(plaintext, 0, plaintext.length, ciphertext, 0);
      // Now decrypt.
View Full Code Here

        c.init(Cipher.DECRYPT_MODE, k, new IvParameterSpec(iv));
        byte[] decrypted = c.doFinal(output);
        assertTrue(Arrays.equals(decrypted, plaintext));
      }
      // Now encrypt again, in random pieces.
      cipher.initialize(key);
      ctr = new CTRBlockCipher(cipher);
      ctr.init(iv);
      byte[] output = new byte[plaintext.length];
      MersenneTwister random = new MersenneTwister(mt.nextLong());
      int ptr = 0;
View Full Code Here

        throw new Error("256/256 Rijndael not supported!");
      }

      // Encrypt data. Data encryption key = H(plaintext data).

      aes.initialize(origDataHash);
      PCFBMode pcfb = PCFBMode.create(aes, origDataHash);

      pcfb.blockEncipher(data, 0, data.length);

      byte[] encryptedDataHash = md256.digest(data);
View Full Code Here

      encryptedHeaders[y++] = (byte) len;
      encryptedHeaders[y++] = (byte) (compressionAlgo >> 8);
      encryptedHeaders[y++] = (byte) compressionAlgo;
      if (encryptedHeaders.length != y)
        throw new IllegalStateException("Have more bytes to generate encoding SSK");
      aes.initialize(cryptoKey);
      pcfb.reset(ehDocname);
      pcfb.blockEncipher(encryptedHeaders, 0, encryptedHeaders.length);
      System.arraycopy(encryptedHeaders, 0, headers, x, encryptedHeaders.length);
      x += encryptedHeaders.length;
      // Generate implicit overall hash.
View Full Code Here

      aes = new Rijndael(256, 128);
    } catch (UnsupportedCipherException e) {
      // Impossible.
      throw new Error(e);
    }
    aes.initialize(cryptoKey);
        CTRBlockCipher cipher = new CTRBlockCipher(aes);
        cipher.init(hash, 0, 16);
        byte[] plaintext = new byte[data.length];
        cipher.processBytes(data, 0, data.length, plaintext, 0);
        byte[] lengthBytes = new byte[2];
View Full Code Here

    System.arraycopy(salt, 0, iv2, 0, 0x10);
    System.arraycopy(iv, 0, iv2, 0x10, 0x10);

    try {
      BlockCipher aes = new Rijndael(256, 256);
      aes.initialize(key);

      return PCFBMode.create(aes, iv2);
    } catch (UnsupportedCipherException e) {
      Logger.error(this, "Rijndael not supported!", e);
      throw new Error("Rijndael not supported!", e);
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.