libsaltpack
Loading...
Searching...
No Matches
Public Member Functions | List of all members
saltpack::MessageReader Class Reference

The class used to decrypt or verify a message. More...

#include <MessageReader.h>

Inheritance diagram for saltpack::MessageReader:

Public Member Functions

 MessageReader (std::istream &is, const BYTE_ARRAY &recipientSecretkey)
 
 MessageReader (std::istream &is)
 
 MessageReader (std::istream &is, std::istream &messageStream)
 
 MessageReader (std::istream &is, const BYTE_ARRAY &recipientSecretkey, const std::pair< BYTE_ARRAY, BYTE_ARRAY > &symmetricKey)
 
 ~MessageReader () override
 
BYTE_ARRAY getBlock ()
 
bool hasMoreBlocks ()
 
std::list< BYTE_ARRAYgetRecipients ()
 
BYTE_ARRAY getSender ()
 
bool isIntentionallyAnonymous ()
 

Detailed Description

The class used to decrypt or verify a message.

Use it in conjunction with ArmoredInputStream to process armored BaseX input.

Constructor & Destructor Documentation

◆ MessageReader() [1/4]

saltpack::MessageReader::MessageReader ( std::istream & is,
const BYTE_ARRAY & recipientSecretkey )

Creates a new MessageReader instance to decrypt a message.

Parameters
isthe source input stream containing the encrypted message.
recipientSecretkeythe private key of the recipient.
Exceptions
SaltpackException

◆ MessageReader() [2/4]

saltpack::MessageReader::MessageReader ( std::istream & is)
explicit

Creates a new MessageReader instance to verify a signed message.

Parameters
isthe source input stream containing the message with its signature attached.
Exceptions
SaltpackException

◆ MessageReader() [3/4]

saltpack::MessageReader::MessageReader ( std::istream & is,
std::istream & messageStream )

Creates a new MessageReader instance to verify a signed message.

Parameters
isthe source input stream containing the detached signature.
messageStreamthe input stream containing the message to verify.
Exceptions
SaltpackExceptionif the signature verification fails.

◆ MessageReader() [4/4]

saltpack::MessageReader::MessageReader ( std::istream & is,
const BYTE_ARRAY & recipientSecretkey,
const std::pair< BYTE_ARRAY, BYTE_ARRAY > & symmetricKey )

Creates a new MessageReader instance to decrypt and verify a signcrypted message.

Parameters
isthe source input stream containing the message.
recipientSecretkeythe Curve25519 private key of the recipient. The array can be empty.
symmetricKeythe symmetric key of the recipient: the first array is treated as the identifier, the second as the key itself. The arrays can be empty.
Exceptions
SaltpackException

◆ ~MessageReader()

saltpack::MessageReader::~MessageReader ( )
override

Desctructor. Securely deletes the allocated buffers using sodium_memzero.

Member Function Documentation

◆ getBlock()

BYTE_ARRAY saltpack::MessageReader::getBlock ( )

Returns the next block of the decrypted/verified message.

Exceptions
SaltpackExceptionif the block cannot be decrypted or its signature is not valid.
Returns
the decrypted/verified data.

◆ getRecipients()

std::list< BYTE_ARRAY > saltpack::MessageReader::getRecipients ( )

Returns the public keys / identifiers of the recipients if they're visible (see flag visibleRecipients in MessageWriter).

Exceptions
SaltpackException
Returns
the recipients if they're visible, an empty list otherwise.

◆ getSender()

BYTE_ARRAY saltpack::MessageReader::getSender ( )

Returns the public key of the sender.

Returns
the sender's public key.

◆ hasMoreBlocks()

bool saltpack::MessageReader::hasMoreBlocks ( )

Helper method to process all the blocks.

Exceptions
SaltpackException
Returns
true when there are more blocks to read, false otherwise.

◆ isIntentionallyAnonymous()

bool saltpack::MessageReader::isIntentionallyAnonymous ( )

Sender's anonimity status (see MessageWriter::MessageWriter(std::ostream &, std::list<BYTE_ARRAY>)).

Exceptions
SaltpackException
Returns
true if the sender of the message is intentionally anonymous, false otherwise.

The documentation for this class was generated from the following file: