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

Examples of ch.ethz.inf.vs.scandium.util.DatagramReader.readBytes()


   
    length = reader.read(CERTIFICATE_AUTHORITIES_LENGTH_BITS);
    List<DistinguishedName> certificateAuthorities = new ArrayList<DistinguishedName>();
    while (length > 0) {
      int nameLength = reader.read(CERTIFICATE_AUTHORITY_LENGTH_BITS);
      byte[] name = reader.readBytes(nameLength);
      certificateAuthorities.add(new DistinguishedName(name));
     
      length -= 2 + name.length;
     
    }
View Full Code Here


    int hashAlgorithm = reader.read(HASH_ALGORITHM_BITS);
    int signatureAlgorithm = reader.read(SIGNATURE_ALGORITHM_BITS);
    SignatureAndHashAlgorithm signAndHash = new SignatureAndHashAlgorithm(hashAlgorithm, signatureAlgorithm);

    int length = reader.read(SIGNATURE_LENGTH_BITS);
    byte[] signature = reader.readBytes(length);

    return new CertificateVerify(signAndHash, signature);
  }
 
  // Methods ////////////////////////////////////////////////////////
View Full Code Here

    int major = reader.read(VERSION_BITS);
    int minor = reader.read(VERSION_BITS);
    ProtocolVersion version = new ProtocolVersion(major, minor);

    int cookieLength = reader.read(COOKIE_LENGTH_BITS);
    Cookie cookie = new Cookie(reader.readBytes(cookieLength));

    return new HelloVerifyRequest(version, cookie);
  }
 
  // Methods ////////////////////////////////////////////////////////
View Full Code Here

    int certificateChainLength = reader.read(CERTIFICATE_LENGTH_BITS);
   
    CertificateMessage message;
    if (useRawPublicKey) {
      int certificateLength = reader.read(CERTIFICATE_LENGTH_BITS);
      byte[] rawPublicKey = reader.readBytes(certificateLength);
      message = new CertificateMessage(rawPublicKey);
    } else {
      List<Certificate> certs = new ArrayList<Certificate>();

      CertificateFactory certificateFactory = null;
View Full Code Here

      List<Certificate> certs = new ArrayList<Certificate>();

      CertificateFactory certificateFactory = null;
      while (certificateChainLength > 0) {
        int certificateLength = reader.read(CERTIFICATE_LENGTH_BITS);
        byte[] certificate = reader.readBytes(certificateLength);

        // the size of the length and the actual length of the encoded certificate
        certificateChainLength -= (CERTIFICATE_LENGTH_BITS/8) + certificateLength;

        try {
View Full Code Here

    int messageSeq = reader.read(MESSAGE_SEQ_BITS);

    int fragmentOffset = reader.read(FRAGMENT_OFFSET_BITS);
    int fragmentLength = reader.read(FRAGMENT_LENGTH_BITS);

    byte[] bytesLeft = reader.readBytes(fragmentLength);
   
    if (length != fragmentLength) {
      // fragmented message received
      return new FragmentedHandshakeMessage(type, length, messageSeq, fragmentOffset, bytesLeft);
    }
View Full Code Here

      ExtensionType type = ExtensionType.getExtensionTypeById(reader.read(TYPE_BITS));
      int extensionLength = reader.read(EXTENSION_LENGTH_BITS);
     
      if (type != null) {
        HelloExtension helloExtension = HelloExtension.fromByteArray(reader.readBytes(extensionLength), type);
        extensions.add(helloExtension);
      }

      // the extensions length + 2 bytes for type field and 2 bytes for
      // length field
View Full Code Here

      throw new HandshakeException("Not supported curve type in ServerKeyExchange message", alert);
     
    case NAMED_CURVE:
      int curveId = reader.read(NAMED_CURVE_BITS);
      int length = reader.read(PUBLIC_LENGTH_BITS);
      byte[] pointEncoded = reader.readBytes(length);

      byte[] bytesLeft = reader.readBytesLeft();
     
      // default is SHA256withECDSA
      SignatureAndHashAlgorithm signAndHash = new SignatureAndHashAlgorithm(HashAlgorithm.SHA256, SignatureAlgorithm.ECDSA);
View Full Code Here

        reader = new DatagramReader(bytesLeft);
        int hashAlgorithm = reader.read(HASH_ALGORITHM_BITS);
        int signatureAlgorithm = reader.read(SIGNATURE_ALGORITHM_BITS);
        signAndHash = new SignatureAndHashAlgorithm(hashAlgorithm, signatureAlgorithm);
        length = reader.read(SIGNATURE_LENGTH_BITS);
        signatureEncoded = reader.readBytes(length);
      }

      return new ECDHServerKeyExchange(signAndHash, curveId, pointEncoded, signatureEncoded);

    default:
View Full Code Here

 
  public static HandshakeMessage fromByteArray(byte[] byteArray) {
    DatagramReader reader = new DatagramReader(byteArray);
   
    int length = reader.read(IDENTITY_LENGTH_BITS);
    byte[] identityEncoded = reader.readBytes(length);
   
    return new PSKClientKeyExchange(identityEncoded);
  }
 
  // Getters and Setters ////////////////////////////////////////////
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.