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

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


  // Serialization //////////////////////////////////////////////////
 
  @Override
  public byte[] toByteArray() {
    DatagramWriter writer = new DatagramWriter();
    writer.writeBytes(super.toByteArray());

    int listLength = ecPointFormatList.size();
    // list length + list length field (1 byte)
    writer.write(listLength + 1, LENGTH_BITS);
    writer.write(listLength, LIST_LENGTH_BITS);
View Full Code Here


   
    writer.write(getCertificateAuthoritiesLength(), CERTIFICATE_AUTHORITIES_LENGTH_BITS);
    for (DistinguishedName distinguishedName : certificateAuthorities) {
      // since a distinguished name has variable length, we need to write length field for each name as well, has influence on total length!
      writer.write(distinguishedName.getName().length, CERTIFICATE_AUTHORITY_LENGTH_BITS);
      writer.writeBytes(distinguishedName.getName());
    }

    return writer.toByteArray();
  }
View Full Code Here

  @Override
  public byte[] fragmentToByteArray() {
    DatagramWriter writer = new DatagramWriter();
   
    writer.writeBytes(verifyData);

    return writer.toByteArray();
  }

  public static HandshakeMessage fromByteArray(byte[] byteArray) {
View Full Code Here

    // signature algorithm must also be included
    writer.write(signatureAndHashAlgorithm.getHash().getCode(), HASH_ALGORITHM_BITS);
    writer.write(signatureAndHashAlgorithm.getSignature().getCode(), SIGNATURE_ALGORITHM_BITS);

    writer.write(signatureBytes.length, SIGNATURE_LENGTH_BITS);
    writer.writeBytes(signatureBytes);

    return writer.toByteArray();
  }

  public static HandshakeMessage fromByteArray(byte[] byteArray) {
View Full Code Here

    writer.write(serverVersion.getMajor(), VERSION_BITS);
    writer.write(serverVersion.getMinor(), VERSION_BITS);

    writer.write(cookie.length(), COOKIE_LENGTH_BITS);
    writer.writeBytes(cookie.getCookie());

    return writer.toByteArray();
  }

  public static HandshakeMessage fromByteArray(byte[] byteArray) {
View Full Code Here

      writer.write(getMessageLength() - (CERTIFICATE_LIST_LENGTH/8), CERTIFICATE_LIST_LENGTH);
      for (byte[] encoded : encodedChain) {
        // the size of the current certificate
        writer.write(encoded.length, CERTIFICATE_LENGTH_BITS);
        // the encoded current certificate
        writer.writeBytes(encoded);
      }
    } else {
      writer.write(getMessageLength() - 3, CERTIFICATE_LIST_LENGTH);
      writer.write(rawPublicKeyBytes.length, CERTIFICATE_LENGTH_BITS);
      writer.writeBytes(rawPublicKeyBytes);
View Full Code Here

        writer.writeBytes(encoded);
      }
    } else {
      writer.write(getMessageLength() - 3, CERTIFICATE_LIST_LENGTH);
      writer.write(rawPublicKeyBytes.length, CERTIFICATE_LENGTH_BITS);
      writer.writeBytes(rawPublicKeyBytes);
    }

    return writer.toByteArray();
  }
View Full Code Here

      // and fragment_length=length
      fragmentLength = getMessageLength();
    }
    writer.write(fragmentLength, FRAGMENT_LENGTH_BITS);
   
    writer.writeBytes(fragmentToByteArray());

    return writer.toByteArray();
  }

  public static HandshakeMessage fromByteArray(byte[] byteArray, KeyExchangeAlgorithm keyExchange, boolean useRawPublicKey) throws HandshakeException {
View Full Code Here

  public byte[] toByteArray() {
    DatagramWriter writer = new DatagramWriter();

    writer.write(getLength(), LENGTH_BITS);
    for (HelloExtension extension : extensions) {
      writer.writeBytes(extension.toByteArray());
    }

    return writer.toByteArray();
  }
View Full Code Here

  // Serialization //////////////////////////////////////////////////

  @Override
  public byte[] toByteArray() {
    DatagramWriter writer = new DatagramWriter();
    writer.writeBytes(super.toByteArray());

    int listLength = ellipticCurveList.size() * 2;
    writer.write(listLength + 2, LENGTH_BITS);
    writer.write(listLength, LIST_LENGTH_BITS);

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.