DecryptorV2 Class

DecryptorV2 decrypts the supplied EncryptedContent element, using asynchronous operations, contingent on the retrieval of the CK Data packet, the KDK, and the successful decryption of both of these. For the meaning of “KDK”, etc. see: https://github.com/named-data/name-based-access-control/blob/new/docs/spec.rst

[C++]:
#include <ndn-cpp/encrypt/decryptor-v2.hpp>
Namespace: ndn
[Python]:Module: pyndn.encrypt
[Java]:Package: net.named_data.jndn.encrypt

DecryptorV2 Constructor

Create a DecryptorV2 with the given parameters.

[C++]:
DecryptorV2(
    PibKey* credentialsKey,
    Validator* validator,
    KeyChain* keyChain,
    Face* face
);
[Python]:
def __init__(self
    credentialsKey,  # PibKey
    validator,       # Validator
    keyChain,        # KeyChain
    face             # Face
)
[JavaScript]:
var DecryptorV2 = function DecryptorV2(
    credentialsKey,  // PibKey
    validator,       // Validator
    keyChain,        // KeyChain
    face             // Face
)
[Java]:
public DecryptorV2(
    PibKey credentialsKey,
    Validator validator,
    KeyChain keyChain,
    Face face
)
Parameters:
  • credentialsKey
    The credentials key to be used to retrieve and decrypt the KDK.
  • validator
    The Validator with the validation policy to ensure the validity of the KDK and CK.
  • keyChain
    The KeyChain that will be used to decrypt the KDK.
  • face
    The Face that will be used to fetch the CK and KDK.

DecryptorV2.decrypt Method

Asynchronously decrypt the encryptedContent.

[C++]:
void decrypt(
    const ptr_lib::shared_ptr<EncryptedContent>& encryptedContent,
    const DecryptSuccessCallback& onSuccess,
    const EncryptError::OnError& onError
);
[Python]:
def decrypt(self,
    encryptedContent,  # EncryptedContent
    onSuccess,         # function object
    onError            # function object
)
[JavaScript]:
DecryptorV2.prototype.decrypt = function(
    encryptedContent,  // EncryptedContent
    onSuccess,         // function
    onError            // function
)
[Java]:
public final void decrypt(
    EncryptedContent encryptedContent,
    DecryptSuccessCallback onSuccess,
    EncryptError.OnError onError
)
Parameters:
  • encryptedContent

    The EncryptedContent to decrypt, which must have a KeyLocator with a KEYNAME and and initial vector. This does not copy the EncryptedContent object. If you may change it later, then pass in a copy of the object.

  • onSuccess

    On successful decryption, this calls onSuccess(plainData) where:

    • plainData is the decrypted Blob.

      Note

      The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.

  • onError

    On failure, this calls onError(errorCode, message) where:

    • errorCode is from EncryptError.ErrorCode.

    • message is an error string.

      Note

      The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.