/**
* TLS-Attacker - A Modular Penetration Testing Framework for TLS
*
* Copyright 2014-2016 Ruhr University Bochum / Hackmanit GmbH
*
* Licensed under Apache License 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
package de.rub.nds.tlsattacker.dtls.protocol.handshake;
import de.rub.nds.tlsattacker.modifiablevariable.ModifiableVariableFactory;
import de.rub.nds.tlsattacker.modifiablevariable.ModifiableVariableProperty;
import de.rub.nds.tlsattacker.modifiablevariable.bytearray.ModifiableByteArray;
import de.rub.nds.tlsattacker.modifiablevariable.singlebyte.ModifiableByte;
import de.rub.nds.tlsattacker.tls.constants.ConnectionEnd;
import de.rub.nds.tlsattacker.tls.protocol.handshake.ClientHelloMessage;
import de.rub.nds.tlsattacker.util.ArrayConverter;
/**
* @author Florian Pfützenreuter <Florian.Pfuetzenreuter@rub.de>
*/
public class ClientHelloDtlsMessage extends ClientHelloMessage {
@ModifiableVariableProperty(type = ModifiableVariableProperty.Type.COOKIE)
ModifiableByteArray cookie = null;
@ModifiableVariableProperty(type = ModifiableVariableProperty.Type.LENGTH)
ModifiableByte cookieLength = null;
public ClientHelloDtlsMessage() {
cookie = ModifiableVariableFactory.safelySetValue(cookie, new byte[0]);
cookieLength = ModifiableVariableFactory.safelySetValue(cookieLength, (byte) 0);
this.messageIssuer = ConnectionEnd.CLIENT;
}
public ClientHelloDtlsMessage(ConnectionEnd messageIssuer) {
this();
this.messageIssuer = messageIssuer;
}
public ModifiableByteArray getCookie() {
return cookie;
}
public ModifiableByte getCookieLength() {
return cookieLength;
}
public void setCookie(byte[] cookie) {
this.cookie = ModifiableVariableFactory.safelySetValue(this.cookie, cookie);
}
public void setCookie(ModifiableByteArray cookie) {
this.cookie = cookie;
}
public void setCookieLength(byte cookieLength) {
this.cookieLength = ModifiableVariableFactory.safelySetValue(this.cookieLength, cookieLength);
}
public void setCookieLength(ModifiableByte cookieLength) {
this.cookieLength = cookieLength;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(super.toString()).append("\n DTLS cookie length: ").append(cookieLength.getValue())
.append("\n DTLS cookie: ").append(ArrayConverter.bytesToHexString(cookie.getValue()));
return sb.toString();
}
}