public static void writeOpaque24(byte[] buf, OutputStream output) throws IOException { checkUint24(buf.length); writeUint24(buf.length, output); output.write(buf); }
public static void writeOpaque24(byte[] buf, OutputStream output) throws IOException { checkUint24(buf.length); writeUint24(buf.length, output); output.write(buf); }
protected void sendServerHelloDoneMessage() throws IOException { byte[] message = new byte[4]; TlsUtils.writeUint8(HandshakeType.server_hello_done, message, 0); TlsUtils.writeUint24(0, message, 1); writeHandshakeMessage(message, 0, message.length); }
void writeToRecordStream() throws IOException { // Patch actual length back in int length = count - 4; TlsUtils.checkUint24(length); TlsUtils.writeUint24(length, buf, 1); writeHandshakeMessage(buf, 0, count); buf = null; } }
void writeToRecordStream() throws IOException { // Patch actual length back in int length = count - 4; TlsUtils.checkUint24(length); TlsUtils.writeUint24(length, buf, 1); writeHandshakeMessage(buf, 0, count); buf = null; } }
protected void sendServerHelloDoneMessage() throws IOException { byte[] message = new byte[4]; TlsUtils.writeUint8(HandshakeType.server_hello_done, message, 0); TlsUtils.writeUint24(0, message, 1); writeHandshakeMessage(message, 0, message.length); }
/** * Encode this {@link Certificate} to an {@link OutputStream}. * * @param output the {@link OutputStream} to encode to. * @throws IOException */ public void encode(OutputStream output) throws IOException { Vector derEncodings = new Vector(this.certificateList.length); int totalLength = 0; for (int i = 0; i < this.certificateList.length; ++i) { byte[] derEncoding = certificateList[i].getEncoded(ASN1Encoding.DER); derEncodings.addElement(derEncoding); totalLength += derEncoding.length + 3; } TlsUtils.checkUint24(totalLength); TlsUtils.writeUint24(totalLength, output); for (int i = 0; i < derEncodings.size(); ++i) { byte[] derEncoding = (byte[])derEncodings.elementAt(i); TlsUtils.writeOpaque24(derEncoding, output); } }
/** * Encode this {@link Certificate} to an {@link OutputStream}. * * @param output the {@link OutputStream} to encode to. * @throws IOException */ public void encode(OutputStream output) throws IOException { Vector derEncodings = new Vector(this.certificateList.length); int totalLength = 0; for (int i = 0; i < this.certificateList.length; ++i) { byte[] derEncoding = certificateList[i].getEncoded(ASN1Encoding.DER); derEncodings.addElement(derEncoding); totalLength += derEncoding.length + 3; } TlsUtils.checkUint24(totalLength); TlsUtils.writeUint24(totalLength, output); for (int i = 0; i < derEncodings.size(); ++i) { byte[] derEncoding = (byte[])derEncodings.elementAt(i); TlsUtils.writeOpaque24(derEncoding, output); } }
private void writeHandshakeFragment(Message message, int fragment_offset, int fragment_length) throws IOException { RecordLayerBuffer fragment = new RecordLayerBuffer(12 + fragment_length); TlsUtils.writeUint8(message.getType(), fragment); TlsUtils.writeUint24(message.getBody().length, fragment); TlsUtils.writeUint16(message.getSeq(), fragment); TlsUtils.writeUint24(fragment_offset, fragment); TlsUtils.writeUint24(fragment_length, fragment); fragment.write(message.getBody(), fragment_offset, fragment_length); fragment.sendToRecordLayer(recordLayer); }
private void writeHandshakeFragment(Message message, int fragment_offset, int fragment_length) throws IOException { RecordLayerBuffer fragment = new RecordLayerBuffer(MESSAGE_HEADER_LENGTH + fragment_length); TlsUtils.writeUint8(message.getType(), fragment); TlsUtils.writeUint24(message.getBody().length, fragment); TlsUtils.writeUint16(message.getSeq(), fragment); TlsUtils.writeUint24(fragment_offset, fragment); TlsUtils.writeUint24(fragment_length, fragment); fragment.write(message.getBody(), fragment_offset, fragment_length); fragment.sendToRecordLayer(recordLayer); }
private Message updateHandshakeMessagesDigest(Message message) throws IOException { if (message.getType() != HandshakeType.hello_request) { byte[] body = message.getBody(); byte[] buf = new byte[MESSAGE_HEADER_LENGTH]; TlsUtils.writeUint8(message.getType(), buf, 0); TlsUtils.writeUint24(body.length, buf, 1); TlsUtils.writeUint16(message.getSeq(), buf, 4); TlsUtils.writeUint24(0, buf, 6); TlsUtils.writeUint24(body.length, buf, 9); handshakeHash.update(buf, 0, buf.length); handshakeHash.update(body, 0, body.length); } return message; }
private Message updateHandshakeMessagesDigest(Message message) throws IOException { if (message.getType() != HandshakeType.hello_request) { byte[] body = message.getBody(); byte[] buf = new byte[12]; TlsUtils.writeUint8(message.getType(), buf, 0); TlsUtils.writeUint24(body.length, buf, 1); TlsUtils.writeUint16(message.getSeq(), buf, 4); TlsUtils.writeUint24(0, buf, 6); TlsUtils.writeUint24(body.length, buf, 9); handshakeHash.update(buf, 0, buf.length); handshakeHash.update(body, 0, body.length); } return message; }