Package freenet.crypt

Examples of freenet.crypt.BlockCipher.initialize()


        } catch (UnsupportedCipherException e) {
          // Impossible
          throw new Error(e);
        }
//        System.err.println("Outer key: "+HexUtil.bytesToHex(outerKey));
        cipher.initialize(outerKey);
        PCFBMode pcfb = PCFBMode.create(cipher, iv);
        pcfb.blockDecipher(dataAndHash, 0, dataAndHash.length);
//        System.err.println("Decrypted data and hash: "+HexUtil.bytesToHex(dataAndHash));
        byte[] data = Arrays.copyOf(dataAndHash, dataAndHash.length - HASH_LENGTH);
        byte[] hash = Arrays.copyOfRange(dataAndHash, data.length, dataAndHash.length);
View Full Code Here


        } catch (UnsupportedCipherException e) {
            // Impossible
            throw new Error(e);
        }
//      System.err.println("Outer key: "+HexUtil.bytesToHex(outerKey));
        cipher.initialize(outerKey);
        PCFBMode pcfb = PCFBMode.create(cipher, iv);
        pcfb.blockDecipher(dataAndHash, 0, dataAndHash.length);
//      System.err.println("Decrypted data and hash: "+HexUtil.bytesToHex(dataAndHash));
        byte[] data = Arrays.copyOf(dataAndHash, dataAndHash.length - OLD_HASH_LENGTH);
        byte[] hash = Arrays.copyOfRange(dataAndHash, data.length, dataAndHash.length);
View Full Code Here

      cipher = new Rijndael(256, 256);
    } catch (UnsupportedCipherException e) {
      // Impossible
      throw new Error(e);
    }
    cipher.initialize(outerKey);
    PCFBMode pcfb = PCFBMode.create(cipher, iv);
    pcfb.blockEncipher(data, hashedStart, data.length - hashedStart);

    RandomAccessFile raf = new RandomAccessFile(masterKeysFile, "rw");
View Full Code Here

        | (sharedData[15] & 0xFF);
    }
    if(logMINOR)
      Logger.minor(this, "Their initial message ID: "+theirInitialMsgID+" ours "+ourInitialMsgID);

    c.initialize(Ke);
    int ivLength = PCFBMode.lengthIV(c);
    int decypheredPayloadOffset = 0;
    // We compute the HMAC of ("I"+cyphertext) : the cyphertext includes the IV!
    byte[] decypheredPayload = Arrays.copyOf(JFK_PREFIX_INITIATOR, JFK_PREFIX_INITIATOR.length + payload.length - inputOffset);
    decypheredPayloadOffset += JFK_PREFIX_INITIATOR.length;
View Full Code Here

    } catch (UnsupportedCipherException e) {
      throw new RuntimeException(e);
    }
    outgoingCipher.initialize(outgoingKey);
    incommingCipher.initialize(incommingKey);
    ivCipher.initialize(ivKey);

    // Promote if necessary
    boolean dontWant = false;
    if(oldOpennetPeer && pn instanceof OpennetPeerNode /* true */) {
      OpennetManager opennet = node.getOpennet();
View Full Code Here

    }

    byte[] hmac = Arrays.copyOfRange(payload, inputOffset, inputOffset+HASH_LENGTH);
    inputOffset += HASH_LENGTH;

    c.initialize(pn.jfkKe);
    int ivLength = PCFBMode.lengthIV(c);
    int decypheredPayloadOffset = 0;
    // We compute the HMAC of ("R"+cyphertext) : the cyphertext includes the IV!
    byte[] decypheredPayload = Arrays.copyOf(JFK_PREFIX_RESPONDER, JFK_PREFIX_RESPONDER.length + payload.length - inputOffset);
    decypheredPayloadOffset += JFK_PREFIX_RESPONDER.length;
View Full Code Here

    } catch (UnsupportedCipherException e) {
      throw new RuntimeException(e);
    }

    outgoingCipher.initialize(pn.outgoingKey);
    incommingCipher.initialize(pn.incommingKey);
    ivCipher.initialize(pn.ivKey);

    long newTrackerID = pn.completedHandshake(
        bootID, hisRef, 0, hisRef.length, outgoingCipher, pn.outgoingKey, incommingCipher,
        pn.incommingKey, replyTo, false, negType, trackerID, true, reusedTracker, pn.hmacKey,
View Full Code Here

     
    if(logMINOR)
      Logger.minor(this, "Their initial message ID: "+pn.theirInitialMsgID+" ours "+pn.ourInitialMsgID);


    c.initialize(pn.jfkKe);
    int ivLength = PCFBMode.lengthIV(c);
    byte[] iv = new byte[ivLength];
    node.random.nextBytes(iv);
    PCFBMode pcfb = PCFBMode.create(c, iv);
    int cleartextOffset = 0;
View Full Code Here

 
  /* 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

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.