Package ch.ethz.inf.vs.scandium.util

Examples of ch.ethz.inf.vs.scandium.util.DatagramWriter.toByteArray()


    // http://tools.ietf.org/html/rfc4492#section-5.7
    int length = pointEncoded.length;
    writer.write(length, LENGTH_BITS);
    writer.writeBytes(pointEncoded);

    return writer.toByteArray();
  }

  public static HandshakeMessage fromByteArray(byte[] byteArray) {
    DatagramReader reader = new DatagramReader(byteArray);
    int length = reader.read(LENGTH_BITS);
View Full Code Here


    length = fragmentBytes.length;
    writer.write(length, LENGTH_BITS);

    writer.writeBytes(fragmentBytes);

    return writer.toByteArray();
  }

  /**
   * Parses raw binary representations of DTLS records into an object representation.
   *
 
View Full Code Here

    DatagramWriter writer = new DatagramWriter();
   
    writer.writeBytes(implicitNonce);
    writer.writeBytes(explicitNonce);
   
    return writer.toByteArray();
  }

 
  /**
   * Generates the explicit part of the nonce to be used with the AEAD Cipher.
View Full Code Here

    DatagramWriter writer = new DatagramWriter();
   
    writer.write(epoch, EPOCH_BITS);
    writer.writeLong(sequenceNumber, SEQUENCE_NUMBER_BITS);
   
    return writer.toByteArray();
  }

  /**
   * See <a href="http://tools.ietf.org/html/rfc5246#section-6.2.3.3">RFC
   * 5246</a>:
 
View Full Code Here

    writer.write(version.getMajor(), VERSION_BITS);
    writer.write(version.getMinor(), VERSION_BITS);
   
    writer.write(length, LENGTH_BITS);

    return writer.toByteArray();
  }

  // Getters and Setters ////////////////////////////////////////////

  public ContentType getType() {
View Full Code Here

        writer.write(field, 16);
        writer.writeLong(lengthA, 64);
      }
      writer.writeBytes(a);

      byte[] aEncoded = writer.toByteArray();
      blocks.addAll(ByteArrayUtils.splitAndPad(aEncoded, BLOCK_SIZE));
    }
    /*
     * After the (optional) additional authentication blocks have been
     * added, we add the message blocks. The message blocks are formed by
View Full Code Here

      // the Nonce N
      writer.writeBytes(nonce);

      // writer the Counter i (L bytes)
      writer.writeLong(i, L * 8);
      byte[] S = writer.toByteArray();

      // S_i := E( K, A_i )
      S_i.add(ByteArrayUtils.truncate(cipher.doFinal(S), BLOCK_SIZE));
    }

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.