Class AnBx_WireFormats.SignedMessage
- All Implemented Interfaces:
Serializable
- Enclosing class:
AnBx_WireFormats
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 Summary
ConstructorsConstructorDescriptionSignedMessage(byte[] content, byte[] signature, String algorithm) Constructs a newSignedMessagewrapper. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the signature algorithm name.byte[]Returns a copy of the signed content bytes.byte[]Returns a copy of the signature bytes.inthashCode()parseFrom(byte[] data) Reconstructs aSignedMessagefrom the bytes produced bytoByteArray().byte[]Serialises this signed message to a deterministic byte format.
-
Constructor Details
-
SignedMessage
Constructs a newSignedMessagewrapper.- Parameters:
content- the raw bytes that were signed (must not benull)signature- the raw signature bytes (must not benull)algorithm- the signature algorithm name (e.g."SHA256withRSA")- Throws:
NullPointerException- if any argument isnull
-
-
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
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
Reconstructs aSignedMessagefrom the bytes produced bytoByteArray().- Parameters:
data- the serialised bytes (must not benull)- Returns:
- the reconstructed signed message
- Throws:
IOException- if the bytes are malformed
-
equals
-
hashCode
public int hashCode()
-