Package freenet.support

Examples of freenet.support.ByteArrayWrapper


      byte[] data = new byte[DATA1.length];
      int read = is.read(data, 0, DATA1.length);
      is.close();

      assertEquals("Read-1-SIZE", DATA1.length, read);
      assertEquals("Read-1", new ByteArrayWrapper(DATA1), new ByteArrayWrapper(data));

      // Write again
      os = bucket.getOutputStream();
      os.write(DATA2);
      os.close();

      // Read byte[]
      is = bucket.getInputStream();
      data = new byte[DATA2.length];
      read = is.read(data, 0, DATA2.length);
      is.close();

      assertEquals("Read-2-SIZE", DATA2.length, read);
      assertEquals("Read-2", new ByteArrayWrapper(DATA2), new ByteArrayWrapper(data));
    } finally {
      freeBucket(bucket);
    }
  }
View Full Code Here


      // Read byte[]
      DataInputStream is = new DataInputStream(bucket.getInputStream());
      for (int i = 0; i < 16; i++) {
        byte[] buf = new byte[DATA_LONG.length];
        is.readFully(buf);
        assertEquals("Read-Long", new ByteArrayWrapper(DATA_LONG), new ByteArrayWrapper(buf));
      }

      int read = is.read(new byte[1]);
      assertEquals("Read-Long-Size", -1, read);
View Full Code Here

      byte[] data = new byte[DATA1.length];
      int read = is.read(data, 0, DATA1.length);
      is.close();

      assertEquals("SimpleRead-1-SIZE", DATA1.length, read);
      assertEquals("SimpleRead-1", new ByteArrayWrapper(DATA1), new ByteArrayWrapper(data));

      // Read byte
      is = bucket.getInputStream();
      for (byte b : DATA1)
        assertEquals("SimpleRead-2", b, (byte) is.read());
View Full Code Here

    // Check try to find the authenticator in the cache.
    // If authenticator is already present, indicates duplicate/replayed message2
    // Now simply transmit the corresponding message3
    Object message3 = null;
    synchronized (authenticatorCache) {
      message3 = authenticatorCache.get(new ByteArrayWrapper(authenticator));
    }
    if(message3 != null) {
      Logger.normal(this, "We replayed a message from the cache (shouldn't happen often) - "+pn.getPeer());
      sendAuthPacket(1, negType, 3, (byte[]) message3, pn, replyTo);
      return;
View Full Code Here

    // Check try to find the authenticator in the cache.
    // If authenticator is already present, indicates duplicate/replayed message3
    // Now simply transmit the corresponding message4
    Object message4 = null;
    synchronized (authenticatorCache) {
      message4 = authenticatorCache.get(new ByteArrayWrapper(authenticator));
    }
    if(message4 != null) {
      Logger.normal(this, "We replayed a message from the cache (shouldn't happen often) - "+pn);
      // We are replaying a JFK(4).
      // Therefore if it is anon-initiator it is encrypted with our setup key.
View Full Code Here

    // Try to find the HMAC in the cache:
    // If it is already present it indicates duplicate/replayed message4 and we can discard
    // If it's not, we can add it with a timestamp
    byte[] message4Timestamp = null;
    synchronized (authenticatorCache) {
      ByteArrayWrapper hmacBAW = new ByteArrayWrapper(hmac);
      message4Timestamp = authenticatorCache.get(hmacBAW);
      if(message4Timestamp == null) { // normal behaviour
        authenticatorCache.put(hmacBAW, Fields.longToBytes(t1));
      }
    }
View Full Code Here

    System.arraycopy(cleartext, cleartextToEncypherOffset, message3, offset, cleartext.length-cleartextToEncypherOffset);

    // cache the message
    synchronized (authenticatorCache) {
      if(!maybeResetTransientKey())
        authenticatorCache.put(new ByteArrayWrapper(authenticator),message3);
    }
    final long timeSent = System.currentTimeMillis();
    if(unknownInitiator) {
      sendAnonAuthPacket(1, negType, 2, setupType, message3, pn, replyTo, pn.anonymousInitiatorSetupCipher);
    } else {
View Full Code Here

    System.arraycopy(cyphertext, cleartextToEncypherOffset, message4, offset, cyphertext.length - cleartextToEncypherOffset);

    // cache the message
    synchronized (authenticatorCache) {
      if(!maybeResetTransientKey())
        authenticatorCache.put(new ByteArrayWrapper(authenticator), message4);
      if(logDEBUG) Logger.debug(this, "Storing JFK(4) for "+HexUtil.bytesToHex(authenticator));
    }

    if(unknownInitiator) {
      sendAnonAuthPacket(1, negType, 3, setupType, message4, pn, replyTo, crypto.anonSetupCipher);
View Full Code Here

    int count = connectSomeNodesInner(seeds);
    boolean stillConnecting = false;
    List<SeedServerPeerNode> tryingSeeds = node.peers.getSeedServerPeersVector();
    synchronized(this) {
      for(SeedServerPeerNode seed : tryingSeeds) {
        if(!announcedToIdentities.contains(new ByteArrayWrapper(seed.pubKeyHash))) {
          // Either:
          // a) we are still trying to connect to this node,
          // b) there is a race condition and we haven't sent the announcement yet despite connecting, or
          // c) something is severely broken and we didn't send an announcement.
          // In any of these cases, we want to delay for 1 minute before resetting the connection process and connecting to everyone.
View Full Code Here

        if(node.wantAnonAuth(true) && Arrays.equals(node.getOpennetPubKeyHash(), seed.pubKeyHash)) {
                                    if(logMINOR)
                                        Logger.minor("Not adding: I am a seednode attempting to connect to myself!", seed.userToString());
                                    continue;
                                }
                                if(announcedToIdentities.contains(new ByteArrayWrapper(seed.pubKeyHash))) {
          if(logMINOR)
            Logger.minor(this, "Not adding: already announced-to: "+seed.userToString());
          continue;
        }
        if(logMINOR)
View Full Code Here

TOP

Related Classes of freenet.support.ByteArrayWrapper

Copyright © 2018 www.massapicom. 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.