Examples of blockEncipher()


Examples of freenet.crypt.PCFBMode.blockEncipher()

    System.arraycopy(sessionKey.ivNonce, 0, IV, 0, IV.length);
    System.arraycopy(seqNumBytes, 0, IV, IV.length - seqNumBytes.length, seqNumBytes.length);
    ivCipher.encipher(IV, IV);

    PCFBMode cipher = PCFBMode.create(sessionKey.incommingCipher, IV);
    cipher.blockEncipher(seqNumBytes, 0, seqNumBytes.length);

    return seqNumBytes;
  }

  @Override
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockEncipher()

    System.arraycopy(data, hmacLength, IV, IV.length - 4, 4);

    ivCipher.encipher(IV, IV);

    PCFBMode payloadCipher = PCFBMode.create(sessionKey.outgoingCipher, IV);
    payloadCipher.blockEncipher(data, hmacLength, paddedLen - hmacLength);

    //Add hash
    byte[] text = new byte[paddedLen - hmacLength];
    System.arraycopy(data, hmacLength, text, 0, text.length);
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockEncipher()

    cleartextOffset += sig.length;
    System.arraycopy(data, 0, cleartext, cleartextOffset, data.length);
    cleartextOffset += data.length;

    int cleartextToEncypherOffset = JFK_PREFIX_INITIATOR.length + ivLength;
    pcfb.blockEncipher(cleartext, cleartextToEncypherOffset, cleartext.length-cleartextToEncypherOffset);

    // We compute the HMAC of (prefix + cyphertext) Includes the IV!
    byte[] hmac = HMAC.macWithSHA256(pn.jfkKa, cleartext, HASH_LENGTH);

    // copy stuffs back to the message
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockEncipher()

    cleartextOffset += sig.length;
    System.arraycopy(data, 0, cyphertext, cleartextOffset, dataLength);
    cleartextOffset += dataLength;
    // Now encrypt the cleartext[Signature]
    int cleartextToEncypherOffset = JFK_PREFIX_RESPONDER.length + ivLength;
    pk.blockEncipher(cyphertext, cleartextToEncypherOffset, cyphertext.length - cleartextToEncypherOffset);

    // We compute the HMAC of (prefix + iv + signature)
    byte[] hmac = HMAC.macWithSHA256(Ka, cyphertext, HASH_LENGTH);

    // Message4 = hmac + IV + encryptedSignature
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockEncipher()

    }
    if(paddingLength < 0) paddingLength = 0;
    byte[] data = new byte[prePaddingLength + paddingLength];
    PCFBMode pcfb = PCFBMode.create(cipher, iv);
    System.arraycopy(iv, 0, data, 0, iv.length);
    pcfb.blockEncipher(hash, 0, hash.length);
    System.arraycopy(hash, 0, data, iv.length, hash.length);
    if(logMINOR) Logger.minor(this, "Payload length: "+length+" padded length "+data.length);
    data[hash.length+iv.length] = (byte) pcfb.encipher((byte)(length>>8));
    data[hash.length+iv.length+1] = (byte) pcfb.encipher((byte)length);
    pcfb.blockEncipher(output, 0, output.length);
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockEncipher()

    pcfb.blockEncipher(hash, 0, hash.length);
    System.arraycopy(hash, 0, data, iv.length, hash.length);
    if(logMINOR) Logger.minor(this, "Payload length: "+length+" padded length "+data.length);
    data[hash.length+iv.length] = (byte) pcfb.encipher((byte)(length>>8));
    data[hash.length+iv.length+1] = (byte) pcfb.encipher((byte)length);
    pcfb.blockEncipher(output, 0, output.length);
    System.arraycopy(output, 0, data, hash.length+iv.length+2, output.length);

    Util.randomBytes(node.fastWeakRandom, data, hash.length+iv.length+2+output.length, paddingLength);
    try {
      sendPacket(data, replyTo, pn);
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockEncipher()

      // 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);

      // Create headers
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockEncipher()

      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.
      md256.update(headers, 0, x);
      md256.update(encryptedDataHash);
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockEncipher()

        // And the following 32 bytes are always XORed with the same value.
        // Ouch!
        // Those bytes being 2 bytes for the length, followed by the first 30 bytes of the data.
       
        PCFBMode pcfb = PCFBMode.create(cipher);
        pcfb.blockEncipher(header, 2, header.length-2);
        pcfb.blockEncipher(data, 0, data.length);
       
        // Now calculate the final hash
        md256.update(header);
        byte[] finalHash = md256.digest(data);
View Full Code Here

Examples of freenet.crypt.PCFBMode.blockEncipher()

        // Ouch!
        // Those bytes being 2 bytes for the length, followed by the first 30 bytes of the data.
       
        PCFBMode pcfb = PCFBMode.create(cipher);
        pcfb.blockEncipher(header, 2, header.length-2);
        pcfb.blockEncipher(data, 0, data.length);
       
        // Now calculate the final hash
        md256.update(header);
        byte[] finalHash = md256.digest(data);
       
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.