diff --git a/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedMessageSerializer.java b/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedMessageSerializer.java index 06273ee..2375150 100644 --- a/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedMessageSerializer.java +++ b/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedMessageSerializer.java @@ -15,7 +15,7 @@ public void serialize(T msg, ByteBuf out) throws IOException { ByteBuf serial = Unpooled.buffer(); serial.writeShort(msg.getId()); this.serializeBody(msg, serial); - msg.serializedMessage = ByteBufUtil.getBytes(serial); + msg.serializedMessage = ByteBufUtil.getBytes(serial.slice()); } out.writeInt(msg.serializedMessage.length); diff --git a/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedProtoMessage.java b/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedProtoMessage.java index 877f69f..65778c0 100644 --- a/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedProtoMessage.java +++ b/src/main/java/pt/unl/fct/di/novasys/babel/generic/signed/SignedProtoMessage.java @@ -38,6 +38,7 @@ public final void signMessage(PrivateKey key) throws NoSuchAlgorithmException, I "\nVerify that the serializer exists and is returned by the method getSerializer()"); } else { ByteBuf b = Unpooled.buffer(); + b.writeShort(this.getId()); serializer.serializeBody(this, b); this.serializedMessage = ByteBufUtil.getBytes(b.slice()); }