Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove puts debugging method. #642

Merged
merged 1 commit into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/main/java/zmq/io/mechanism/Mechanism.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,38 +285,28 @@ protected final int receiveAndProcessZapReply()
return session.errno.get();
}
if ((msg.flags() & Msg.MORE) == (idx < 6 ? 0 : Msg.MORE)) {
// Temporary support for security debugging
puts("NULL I: ZAP handler sent incomplete reply message " + msg);
return ZError.EPROTO;
}
msgs.add(msg);
}

// Address delimiter frame
if (msgs.get(0).size() > 0) {
// Temporary support for security debugging
puts("NULL I: ZAP handler sent malformed reply message in address delimiter frame " + msgs.get(0));
return ZError.EPROTO;
}

// Version frame
if (msgs.get(1).size() != 3 || !compare(msgs.get(1), "1.0", false)) {
// Temporary support for security debugging
puts("NULL I: ZAP handler sent bad version number " + msgs.get(1));
return ZError.EPROTO;
}

// Request id frame
if (msgs.get(2).size() != 1 || !compare(msgs.get(2), "1", false)) {
// Temporary support for security debugging
puts("NULL I: ZAP handler sent bad request ID " + msgs.get(2));
return ZError.EPROTO;
}

// Status code frame
if (msgs.get(3).size() != 3) {
// Temporary support for security debugging
puts("NULL I: ZAP handler rejected client authentication " + msgs.get(3));
return ZError.EPROTO;
}

Expand All @@ -331,12 +321,6 @@ protected final int receiveAndProcessZapReply()
return parseMetadata(msgs.get(6), 0, true);
}

protected final void puts(String msg)
{
// Temporary support for security debugging
System.out.println(session + " " + msg);
}

protected final void appendData(Msg msg, String data)
{
Msgs.put(msg, data);
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/zmq/io/mechanism/NullMechanism.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public int nextHandshakeCommand(Msg msg)
public int processHandshakeCommand(Msg msg)
{
if (readyCommandReceived || errorCommandReceived) {
puts("NULL I: client sent invalid NULL handshake (duplicate READY)");
return ZError.EPROTO;
}
int dataSize = msg.size();
Expand All @@ -100,7 +99,6 @@ else if (dataSize >= 6 && compare(msg, ERROR, true)) {
rc = processErrorCommand(msg);
}
else {
puts("NULL I: client sent invalid NULL handshake (not READY) ");
return ZError.EPROTO;
}
return rc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,11 @@ public Msg decode(Msg msg)
assert (state == State.CONNECTED);

if (msg.size() < 33) {
// Temporary support for security debugging
puts("CURVE I: invalid CURVE server, sent malformed command");
errno.set(ZError.EPROTO);
return null;
}

if (!compare(msg, "MESSAGE", true)) {
// Temporary support for security debugging
puts("CURVE I: invalid CURVE server, did not send MESSAGE");
errno.set(ZError.EPROTO);
return null;
}
Expand Down Expand Up @@ -210,8 +206,6 @@ public Msg decode(Msg msg)
return decoded;
}
else {
// Temporary support for security debugging
puts("CURVE I: connection key used for MESSAGE is wrong");
errno.set(ZError.EPROTO);
return null;
}
Expand Down Expand Up @@ -274,8 +268,6 @@ private int produceHello(Msg msg)
private int processWelcome(Msg msg)
{
if (msg.size() != 168) {
// Temporary support for security debugging
puts("CURVE I: server HELLO is not correct size");
return ZError.EPROTO;
}

Expand Down
30 changes: 0 additions & 30 deletions src/main/java/zmq/io/mechanism/curve/CurveServerMechanism.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ public int processHandshakeCommand(Msg msg)
rc = processInitiate(msg);
break;
default:
// Temporary support for security debugging
puts("CURVE I: invalid handshake command");
rc = ZError.EPROTO;
break;

Expand Down Expand Up @@ -165,15 +163,11 @@ public Msg decode(Msg msg)
assert (state == State.CONNECTED);

if (msg.size() < 33) {
// Temporary support for security debugging
puts("CURVE I: invalid CURVE client, sent malformed command");
errno.set(ZError.EPROTO);
return null;
}

if (!compare(msg, "MESSAGE", true)) {
// Temporary support for security debugging
puts("CURVE I: invalid CURVE client, did not send MESSAGE");
errno.set(ZError.EPROTO);
return null;
}
Expand Down Expand Up @@ -212,8 +206,6 @@ public Msg decode(Msg msg)
return decoded;
}
else {
// Temporary support for security debugging
puts("CURVE I: connection key used for MESSAGE is wrong");
errno.set(ZError.EPROTO);
return null;
}
Expand Down Expand Up @@ -250,23 +242,17 @@ else if (state == State.ERROR_SENT) {
private int processHello(Msg msg)
{
if (msg.size() != 200) {
// Temporary support for security debugging
puts("CURVE I: client HELLO is not correct size");
return ZError.EPROTO;
}

if (!compare(msg, "HELLO", true)) {
// Temporary support for security debugging
puts("CURVE I: client HELLO has invalid command name");
return ZError.EPROTO;
}

byte major = msg.get(6);
byte minor = msg.get(7);

if (major != 1 || minor != 0) {
// Temporary support for security debugging
puts("CURVE I: client HELLO has unknown version number");
return ZError.EPROTO;
}

Expand All @@ -287,8 +273,6 @@ private int processHello(Msg msg)
// Open Box [64 * %x0](C'->S)
int rc = cryptoBox.open(helloPlaintext, helloBox, helloBox.capacity(), helloNonce, cnClient, secretKey);
if (rc != 0) {
// Temporary support for security debugging
puts("CURVE I: cannot open client HELLO -- wrong server key?");
return ZError.EPROTO;
}

Expand Down Expand Up @@ -358,14 +342,10 @@ private int produceWelcome(Msg msg)
private int processInitiate(Msg msg)
{
if (msg.size() < 257) {
// Temporary support for security debugging
puts("CURVE I: client INITIATE is not correct size");
return ZError.EPROTO;
}

if (!compare(msg, "INITIATE", true)) {
// Temporary support for security debugging
puts("CURVE I: client INITIATE has invalid command name");
return ZError.EPROTO;
}
ByteBuffer cookieNonce = ByteBuffer.allocate(Curve.Size.NONCE.bytes());
Expand All @@ -381,16 +361,12 @@ private int processInitiate(Msg msg)

int rc = cryptoBox.secretboxOpen(cookiePlaintext, cookieBox, cookieBox.capacity(), cookieNonce, cookieKey);
if (rc != 0) {
// Temporary support for security debugging
puts("CURVE I: cannot open client INITIATE cookie");
return ZError.EPROTO;
}

// Check cookie plain text is as expected [C' + s']
if (!compare(cookiePlaintext, cnClient, Curve.Size.ZERO.bytes(), 32)
|| !compare(cookiePlaintext, cnSecret, Curve.Size.ZERO.bytes() + 32, 32)) {
// Temporary support for security debugging
puts("CURVE I: client INITIATE cookie is not valid");
return ZError.EPROTO;
}

Expand All @@ -411,8 +387,6 @@ private int processInitiate(Msg msg)

rc = cryptoBox.open(initiatePlaintext, initiateBox, clen, initiateNonce, cnClient, cnSecret);
if (rc != 0) {
// Temporary support for security debugging
puts("CURVE I: cannot open client INITIATE");
return ZError.EPROTO;
}

Expand All @@ -435,15 +409,11 @@ private int processInitiate(Msg msg)

rc = cryptoBox.open(vouchPlaintext, vouchBox, vouchBox.capacity(), vouchNonce, clientKey, cnSecret);
if (rc != 0) {
// Temporary support for security debugging
puts("CURVE I: cannot open client INITIATE vouch");
return ZError.EPROTO;
}

// What we decrypted must be the client's short-term public key
if (!compare(vouchPlaintext, cnClient, Curve.Size.ZERO.bytes(), 32)) {
// Temporary support for security debugging
puts("CURVE I: invalid handshake from client (public key)");
return ZError.EPROTO;
}

Expand Down
14 changes: 0 additions & 14 deletions src/main/java/zmq/io/mechanism/plain/PlainServerMechanism.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public int processHandshakeCommand(Msg msg)
rc = produceInitiate(msg);
break;
default:
// Temporary support for security debugging
puts("PLAIN Server I: invalid handshake command");
rc = ZError.EPROTO;
break;

Expand Down Expand Up @@ -119,22 +117,16 @@ private int produceHello(Msg msg)
int bytesLeft = msg.size();
int index = 0;
if (bytesLeft < 6 || !compare(msg, "HELLO", true)) {
// Temporary support for security debugging
puts("PLAIN I: invalid PLAIN client, did not send HELLO");
return ZError.EPROTO;
}
bytesLeft -= 6;
index += 6;
if (bytesLeft < 1) {
// Temporary support for security debugging
puts("PLAIN I: invalid PLAIN client, did not send username");
return ZError.EPROTO;
}
byte length = msg.get(index);
bytesLeft -= 1;
if (bytesLeft < length) {
// Temporary support for security debugging
puts("PLAIN I: invalid PLAIN client, sent malformed username");
return ZError.EPROTO;
}
byte[] tmp = new byte[length];
Expand All @@ -147,8 +139,6 @@ private int produceHello(Msg msg)
length = msg.get(index);
bytesLeft -= 1;
if (bytesLeft < length) {
// Temporary support for security debugging
puts("PLAIN I: invalid PLAIN client, sent malformed password");
return ZError.EPROTO;
}
tmp = new byte[length];
Expand All @@ -159,8 +149,6 @@ private int produceHello(Msg msg)
// index += length;

if (bytesLeft > 0) {
// Temporary support for security debugging
puts("PLAIN I: invalid PLAIN client, sent extraneous data");
return ZError.EPROTO;
}

Expand Down Expand Up @@ -196,8 +184,6 @@ private int produceInitiate(Msg msg)
{
int bytesLeft = msg.size();
if (bytesLeft < 9 || !compare(msg, "INITIATE", true)) {
// Temporary support for security debugging
puts("PLAIN I: invalid PLAIN client, did not send INITIATE");
return ZError.EPROTO;
}

Expand Down