Skip to content

libsodium.PKI.DecryptData

Andrew Lambert edited this page Jan 21, 2023 · 16 revisions

libsodium.PKI.DecryptData

Method Signatures

 Protected Function DecryptData(CipherText As MemoryBlock, SenderPublicKey As libsodium.PKI.PublicKey, RecipientPrivateKey As libsodium.PKI.EncryptionKey, Nonce As MemoryBlock) As MemoryBlock
 Protected Function DecryptData(CipherText As MemoryBlock, SharedKey As libsodium.PKI.SharedSecret, Nonce As MemoryBlock) As MemoryBlock

Parameters

DecryptData(MemoryBlock, libsodium.PKI.PublicKey, libsodium.PKI.EncryptionKey, MemoryBlock) As MemoryBlock

Name Type Comment
CipherText MemoryBlock The data to be decrypted.
SenderPublicKey PublicKey The public half of the sender's key pair.
RecipientPrivateKey EncryptionKey The recipient's key pair.
Nonce MemoryBlock The random nonce used to encrypt the CipherText.

DecryptData(MemoryBlock, libsodium.PKI.SharedSecret, MemoryBlock) As MemoryBlock

Name Type Comment
CipherText MemoryBlock The data to be decrypted.
SharedKey SharedSecret The precomputed shared key used to encrypt the CipherText.
Nonce MemoryBlock The random nonce used to encrypt the CipherText.

Return value

The decrypted CipherText, or Nil on error.

Remarks

Decrypts the CipherText using the XSalsa20 stream cipher with a shared key and a Nonce. This key is either computed from the SenderPublicKey and RecipientPrivateKey or precomputed as a SharedSecret object. The Poly1305 message authentication code which was prepended to the CipherText by the EncryptData method will be validated by this method.

If the CipherText is authentic and can be decrypted with the specified key(s) and nonce then this method returns the decrypted clear text. If the CipherText is inauthentic or can't be decrypted then this method returns Nil.

If the CipherText is encoded using the text-based export format then you may pass Nil as the Nonce parameter to use the nonce value encoded in the CipherText.

See also

Clone this wiki locally