Fixed NPE when 'from' doesn't have a public key. From will get lost in those cases unless it's saved separately.
This commit is contained in:
parent
0bb455d433
commit
31eca20cca
@ -178,12 +178,23 @@ public class Plaintext implements Streamable {
|
|||||||
public void write(OutputStream out, boolean includeSignature) throws IOException {
|
public void write(OutputStream out, boolean includeSignature) throws IOException {
|
||||||
Encode.varInt(from.getVersion(), out);
|
Encode.varInt(from.getVersion(), out);
|
||||||
Encode.varInt(from.getStream(), out);
|
Encode.varInt(from.getStream(), out);
|
||||||
Encode.int32(from.getPubkey().getBehaviorBitfield(), out);
|
if (from.getPubkey() == null) {
|
||||||
out.write(from.getPubkey().getSigningKey(), 1, 64);
|
Encode.int32(0, out);
|
||||||
out.write(from.getPubkey().getEncryptionKey(), 1, 64);
|
byte[] empty = new byte[64];
|
||||||
if (from.getVersion() >= 3) {
|
out.write(empty);
|
||||||
Encode.varInt(from.getPubkey().getNonceTrialsPerByte(), out);
|
out.write(empty);
|
||||||
Encode.varInt(from.getPubkey().getExtraBytes(), out);
|
if (from.getVersion() >= 3) {
|
||||||
|
Encode.varInt(0, out);
|
||||||
|
Encode.varInt(0, out);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Encode.int32(from.getPubkey().getBehaviorBitfield(), out);
|
||||||
|
out.write(from.getPubkey().getSigningKey(), 1, 64);
|
||||||
|
out.write(from.getPubkey().getEncryptionKey(), 1, 64);
|
||||||
|
if (from.getVersion() >= 3) {
|
||||||
|
Encode.varInt(from.getPubkey().getNonceTrialsPerByte(), out);
|
||||||
|
Encode.varInt(from.getPubkey().getExtraBytes(), out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (type == Type.MSG) {
|
if (type == Type.MSG) {
|
||||||
out.write(to.getRipe());
|
out.write(to.getRipe());
|
||||||
@ -213,12 +224,23 @@ public class Plaintext implements Streamable {
|
|||||||
public void write(ByteBuffer buffer, boolean includeSignature) {
|
public void write(ByteBuffer buffer, boolean includeSignature) {
|
||||||
Encode.varInt(from.getVersion(), buffer);
|
Encode.varInt(from.getVersion(), buffer);
|
||||||
Encode.varInt(from.getStream(), buffer);
|
Encode.varInt(from.getStream(), buffer);
|
||||||
Encode.int32(from.getPubkey().getBehaviorBitfield(), buffer);
|
if (from.getPubkey() == null) {
|
||||||
buffer.put(from.getPubkey().getSigningKey(), 1, 64);
|
Encode.int32(0, buffer);
|
||||||
buffer.put(from.getPubkey().getEncryptionKey(), 1, 64);
|
byte[] empty = new byte[64];
|
||||||
if (from.getVersion() >= 3) {
|
buffer.put(empty);
|
||||||
Encode.varInt(from.getPubkey().getNonceTrialsPerByte(), buffer);
|
buffer.put(empty);
|
||||||
Encode.varInt(from.getPubkey().getExtraBytes(), buffer);
|
if (from.getVersion() >= 3) {
|
||||||
|
Encode.varInt(0, buffer);
|
||||||
|
Encode.varInt(0, buffer);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Encode.int32(from.getPubkey().getBehaviorBitfield(), buffer);
|
||||||
|
buffer.put(from.getPubkey().getSigningKey(), 1, 64);
|
||||||
|
buffer.put(from.getPubkey().getEncryptionKey(), 1, 64);
|
||||||
|
if (from.getVersion() >= 3) {
|
||||||
|
Encode.varInt(from.getPubkey().getNonceTrialsPerByte(), buffer);
|
||||||
|
Encode.varInt(from.getPubkey().getExtraBytes(), buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (type == Type.MSG) {
|
if (type == Type.MSG) {
|
||||||
buffer.put(to.getRipe());
|
buffer.put(to.getRipe());
|
||||||
|
Loading…
Reference in New Issue
Block a user