Package org.drasyl.crypto
Interface Signable
- All Known Implementing Classes:
SignedMessage
public interface Signable
Instances of classes that implement this interface are considered signable. A signable
object can be converted into a signature and can store that signature itself.
-
Method Summary
Modifier and TypeMethodDescriptiondefault byte[]
Returns a byte representation of the object that can be used for signing the object.Returns the signature this signable object was signed with.void
setSignature
(Signature signature) Signs the object with the specified signature.default void
writeFieldsTo
(OutputStream outstream) Write any content into the passed output-stream to have them included in the signing process.
-
Method Details
-
getSignableBytes
default byte[] getSignableBytes()Returns a byte representation of the object that can be used for signing the object. Attention: If you omit fields in this method those fields will not be signed. That means that they can be modified by a third party without detection.
The default-implementation creates a
ByteArrayOutputStream
and callswriteFieldsTo(OutputStream)
to have content written to it.- Returns:
- byte-array or
null
-
writeFieldsTo
Write any content into the passed output-stream to have them included in the signing process.
Only use this with the default-implementation of
getSignableBytes()
- Parameters:
outstream
- an outputstream to write to- Throws:
IOException
-
getSignature
Signature getSignature()Returns the signature this signable object was signed with. -
setSignature
Signs the object with the specified signature. After this method was invoked subsequent calls togetSignature()
should return aSignature
object that is equal to the specifiedsignature
.
-