Package anbxj

Class AnBx_WireFormats.SignedMessage

java.lang.Object
anbxj.AnBx_WireFormats.SignedMessage
All Implemented Interfaces:
Serializable
Enclosing class:
AnBx_WireFormats

public static final class AnBx_WireFormats.SignedMessage extends Object implements Serializable
A language-agnostic representation of a digitally signed message.

This wrapper replaces Java-specific types (@link javax.crypto.SignedObject}. It holds the raw content that was signed, the raw signature bytes, and the name of the signature algorithm (e.g. "SHA256withRSA"). The content is stored as a byte array, which should be the serialised form of a Protobuf message (e.g., Step1_Payload) when used in typed Protobuf mode.

In Java serialisation mode, the whole object is written via ObjectOutputStream; in typed Protobuf mode, the Channel_ProtobufSerializer converts it to/from a Protobuf message of type SignedMessage.

See Also:
  • Constructor Details

    • SignedMessage

      public SignedMessage(byte[] content, byte[] signature, String algorithm)
      Constructs a new SignedMessage wrapper.
      Parameters:
      content - the raw bytes that were signed (must not be null)
      signature - the raw signature bytes (must not be null)
      algorithm - the signature algorithm name (e.g. "SHA256withRSA")
      Throws:
      NullPointerException - if any argument is null
  • Method Details

    • getContent

      public byte[] getContent()
      Returns a copy of the signed content bytes.
      Returns:
      a fresh copy of the content byte array
    • getSignature

      public byte[] getSignature()
      Returns a copy of the signature bytes.
      Returns:
      a fresh copy of the signature byte array
    • getAlgorithm

      public String getAlgorithm()
      Returns the signature algorithm name.
      Returns:
      the algorithm string (never null)
    • toByteArray

      public byte[] toByteArray()
      Serialises this signed message to a deterministic byte format.

      The format is: 4-byte content length (big-endian) | content bytes | 4-byte signature length | signature bytes | 2-byte algorithm length | algorithm bytes (UTF-8).

      Returns:
      the serialised bytes
    • parseFrom

      public static AnBx_WireFormats.SignedMessage parseFrom(byte[] data) throws IOException
      Reconstructs a SignedMessage from the bytes produced by toByteArray().
      Parameters:
      data - the serialised bytes (must not be null)
      Returns:
      the reconstructed signed message
      Throws:
      IOException - if the bytes are malformed
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object