Package com.gherynos.libsaltpack
Class MessageReader
java.lang.Object
com.gherynos.libsaltpack.MessageReader
The class used to decrypt or verify a message.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new MessageReader instance to verify a signed message.MessageReader
(InputParameters in, byte[] recipientSecretkey) Creates a new MessageReader instance to decrypt a message.MessageReader
(InputParameters in, byte[] recipientSecretkey, byte[][] symmetricKey) Creates a new MessageReader instance to decrypt and verify a signcrypted message.MessageReader
(InputParameters in, InputStream messageIn) Creates a new MessageReader instance to verify a signed message. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Desctructor.byte[]
getBlock()
Returns the next block of the decrypted/verified message.byte[][]
Returns the public keys of the recipients if they're visible (see flagvisibleRecipients
inMessageWriter
).byte[]
Returns the public key of the sender.boolean
Helper method to process all the blocks.boolean
Sender's anonimity status (seeMessageWriter(OutputParameters, byte[][])
).
-
Constructor Details
-
MessageReader
Creates a new MessageReader instance to decrypt a message.- Parameters:
in
- the InputParameters with the source input stream containing the encrypted message.recipientSecretkey
- the private key of the sender.- Throws:
SaltpackException
-
MessageReader
Creates a new MessageReader instance to verify a signed message.- Parameters:
in
- the InputParameters with the source input stream containing the message with its signature attached.- Throws:
SaltpackException
-
MessageReader
Creates a new MessageReader instance to verify a signed message.- Parameters:
in
- the InputParameters with the source input stream containing the detached signature.messageIn
- the input stream containing the message to verify.- Throws:
SaltpackException
- if the signature verification fails.
-
MessageReader
public MessageReader(InputParameters in, byte[] recipientSecretkey, byte[][] symmetricKey) throws SaltpackException Creates a new MessageReader instance to decrypt and verify a signcrypted message.- Parameters:
in
- the InputParameters with the source input stream containing the detached signature.recipientSecretkey
- the Curve25519 private key of the recipient. The array can be empty.symmetricKey
- the symmetric key of the recipient: the first array is treated as the identifier, the second as the key itself. The arrays can be empty.- Throws:
SaltpackException
- if the signature verification fails.
-
-
Method Details
-
destroy
public void destroy()Desctructor.Securely deletes the allocated buffers using `sodium_memzero`.
This method has to be called when the instance is no longer required.
-
hasMoreBlocks
Helper method to process all the blocks.- Returns:
- true when there are more blocks to read, false otherwise.
- Throws:
SaltpackException
-
getBlock
Returns the next block of the decrypted/verified message.- Returns:
- the decrypted/verified data.
- Throws:
SaltpackException
- if the block cannot be decrypted or its signature is not valid.
-
getRecipients
Returns the public keys of the recipients if they're visible (see flagvisibleRecipients
inMessageWriter
).- Returns:
- the recipients if they're visible, an empty array otherwise.
- Throws:
SaltpackException
-
getSender
Returns the public key of the sender.- Returns:
- the sender's public key.
- Throws:
SaltpackException
-
isIntentionallyAnonymous
Sender's anonimity status (seeMessageWriter(OutputParameters, byte[][])
).- Returns:
- true if the sender of the message is intentionally anonymous, false otherwise.
- Throws:
SaltpackException
-