Package freenet.crypt.ciphers

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


 
  /* This checks the output of the sequence number encryption function to
   * make sure it doesn't change accidentally. */
  public void testSequenceNumberEncryption() {
    BlockCipher ivCipher = new Rijndael();
    ivCipher.initialize(new byte[] {
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00
    });
View Full Code Here


    });

    byte[] ivNonce = new byte[16];

    BlockCipher incommingCipher = new Rijndael();
    incommingCipher.initialize(new byte[] {
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00
    });
View Full Code Here

        throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e);
      }
      byte[] buf = md.digest();
      try {
        Rijndael aes = new Rijndael(256, 256);
        aes.initialize(cryptoKey);
        aes.encipher(buf, buf);
        ehDocname = buf;
      } catch (UnsupportedCipherException e) {
        throw new Error(e);
      }
View Full Code Here

    try {
      aes = new Rijndael(256, 256);
    } catch (UnsupportedCipherException e) {
      throw new Error(e);
    }
    aes.initialize(key);
    return aes;
  }

  @SuppressWarnings("deprecation")
  public PCFBMode getPCFB() {
View Full Code Here

      Logger.minor(this, "cryptoAlgorithm="+key.cryptoAlgorithm+" for "+getClientKey().getURI());
      aes = new Rijndael(256,256);
    } catch (UnsupportedCipherException e) {
      throw new Error(e);
    }
    aes.initialize(key.cryptoKey);
    // ECB-encrypted E(H(docname)) serves as IV.
    PCFBMode pcfb = PCFBMode.create(aes, key.ehDocname);
    pcfb.blockDecipher(decryptedHeaders, 0, decryptedHeaders.length);
    // First 32 bytes are the key
    byte[] dataDecryptKey = Arrays.copyOf(decryptedHeaders, DATA_DECRYPT_KEY_LENGTH);
View Full Code Here

    // ECB-encrypted E(H(docname)) serves as IV.
    PCFBMode pcfb = PCFBMode.create(aes, key.ehDocname);
    pcfb.blockDecipher(decryptedHeaders, 0, decryptedHeaders.length);
    // First 32 bytes are the key
    byte[] dataDecryptKey = Arrays.copyOf(decryptedHeaders, DATA_DECRYPT_KEY_LENGTH);
    aes.initialize(dataDecryptKey);
    byte[] dataOutput = block.data.clone();
    // Data decrypt key should be unique, so use it as IV
    pcfb.reset(dataDecryptKey);
    pcfb.blockDecipher(dataOutput, 0, dataOutput.length);
    // 2 bytes - data length
View Full Code Here

      aes = new Rijndael(256, 128);
    } catch (UnsupportedCipherException e) {
      // Impossible
      throw new Error(e);
    }
        aes.initialize(encKey);
        CTRBlockCipher ctr = new CTRBlockCipher(aes);
        // CTR mode IV is only 16 bytes.
        // That's still plenty though. It will still be unique.
        ctr.init(hash, 0, 16);
        System.arraycopy(hash, 0, header, 2, hash.length);
View Full Code Here

  }

  private void checkKnownValues(int bits, byte[] key, byte[] iv, byte[] plaintext,
      byte[] ciphertext) throws UnsupportedCipherException {
    Rijndael cipher = new Rijndael(bits, bits);
    cipher.initialize(key);
    PCFBMode ctr = PCFBMode.create(cipher);
    ctr.reset(iv);
    byte[] output = new byte[plaintext.length];
    System.arraycopy(plaintext, 0, output, 0, plaintext.length);
    //ctr.blockEncipher(plaintext, 0, plaintext.length, output, 0);
View Full Code Here

      throws UnsupportedCipherException {
    for (int i = 0; i < 1024; i++) {
      long seed = mt.nextLong();

      Rijndael cipher = new Rijndael(bits, bits);
      cipher.initialize(key);
      PCFBMode ctr = PCFBMode.create(cipher);
      ctr.reset(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, 256);
      cipher.initialize(key);
      PCFBMode ctr = PCFBMode.create(cipher);
      ctr.reset(iv);
      byte[] ciphertext = new byte[plaintext.length];
      System.arraycopy(plaintext, 0, ciphertext, 0, ciphertext.length);
      //ctr.blockEncipher(plaintext, 0, plaintext.length, ciphertext, 0);
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.