Virgil Security C++ SDK
|
Class for high level interactions with crypto library. More...
#include <Crypto.h>
Public Member Functions | |
Crypto (bool useSHA256Fingerprints=false) | |
Constructor. More... | |
keys::KeyPair | generateKeyPair () const |
Generates KeyPair of default key type. More... | |
keys::PrivateKey | importPrivateKey (const VirgilByteArray &data, const std::string &password="") const |
Imports private key from raw data in DER or PEM format. More... | |
keys::PublicKey | importPublicKey (const VirgilByteArray &data) const |
Imports public key from DER or PEM format. More... | |
keys::PublicKey | extractPublicKeyFromPrivateKey (const keys::PrivateKey &privateKey) const |
Extracts public key from private key. More... | |
VirgilByteArray | exportPrivateKey (const keys::PrivateKey &privateKey, const std::string &password="") const |
Exports encrypted using password private key. More... | |
VirgilByteArray | exportPublicKey (const keys::PublicKey &publicKey) const |
Exports public key in DER format. More... | |
VirgilByteArray | encrypt (const VirgilByteArray &data, const std::vector< keys::PublicKey > &recipients) const |
Encrypts data for passed PublicKeys. More... | |
void | encrypt (std::istream &istream, std::ostream &ostream, const std::vector< keys::PublicKey > &recipients) const |
Encrypts data stream for passed PublicKeys. More... | |
bool | verify (const VirgilByteArray &data, const VirgilByteArray &signature, const keys::PublicKey &signerPublicKey) const |
Verifies digital signature of data. More... | |
bool | verify (std::istream &istream, const VirgilByteArray &signature, const keys::PublicKey &signerPublicKey) const |
Verifies digital signature of data stream. More... | |
VirgilByteArray | decrypt (const VirgilByteArray &data, const keys::PrivateKey &privateKey) const |
Decrypts data using passed PrivateKey. More... | |
void | decrypt (std::istream &istream, std::ostream &ostream, const keys::PrivateKey &privateKey) const |
Decrypts data stream using passed PrivateKey. More... | |
VirgilByteArray | signThenEncrypt (const VirgilByteArray &data, const keys::PrivateKey &privateKey, const std::vector< keys::PublicKey > &recipients) const |
Signs (with private key) Then Encrypts data for passed PublicKeys. More... | |
VirgilByteArray | decryptThenVerify (const VirgilByteArray &data, const keys::PrivateKey &privateKey, const keys::PublicKey &signerPublicKey) const |
Decrypts (with private key) Then Verifies data using signer PublicKey. More... | |
VirgilByteArray | decryptThenVerify (const VirgilByteArray &data, const keys::PrivateKey &privateKey, const std::vector< keys::PublicKey > &signersPublicKeys) const |
Decrypts (with private key) Then Verifies data using any of signers' PublicKeys. More... | |
VirgilByteArray | generateSignature (const VirgilByteArray &data, const keys::PrivateKey &privateKey) const |
Generates digital signature of data using private key. More... | |
VirgilByteArray | generateSignature (std::istream &istream, const keys::PrivateKey &privateKey) const |
Generates digital signature of data stream using private key. More... | |
VirgilByteArray | generateSHA512 (const VirgilByteArray &data) const |
Computes SHA-512. More... | |
VirgilByteArray | computeHash (const VirgilByteArray &data, VirgilHashAlgorithm algorithm) const |
Computes hash of data using selected algorithm. More... | |
bool | useSHA256Fingerprints () const |
Getter. More... | |
Class for high level interactions with crypto library.
virgil::sdk::crypto::Crypto::Crypto | ( | bool | useSHA256Fingerprints = false | ) |
Constructor.
useSHA256Fingerprints | use old algorithm to generate key fingerprints |
VirgilByteArray virgil::sdk::crypto::Crypto::computeHash | ( | const VirgilByteArray & | data, |
VirgilHashAlgorithm | algorithm | ||
) | const |
Computes hash of data using selected algorithm.
data | data of which hash is computed |
algorithm | hash algorithm |
VirgilByteArray virgil::sdk::crypto::Crypto::decrypt | ( | const VirgilByteArray & | data, |
const keys::PrivateKey & | privateKey | ||
) | const |
Decrypts data using passed PrivateKey.
data | encrypted data |
privateKey | recipient's private key |
void virgil::sdk::crypto::Crypto::decrypt | ( | std::istream & | istream, |
std::ostream & | ostream, | ||
const keys::PrivateKey & | privateKey | ||
) | const |
Decrypts data stream using passed PrivateKey.
istream | stream with encrypted data |
ostream | stream with decrypted data |
privateKey | recipient's private key |
VirgilByteArray virgil::sdk::crypto::Crypto::decryptThenVerify | ( | const VirgilByteArray & | data, |
const keys::PrivateKey & | privateKey, | ||
const keys::PublicKey & | signerPublicKey | ||
) | const |
Decrypts (with private key) Then Verifies data using signer PublicKey.
data | data to be signed, then verified |
privateKey | receiver's private key |
signerPublicKey | signer public key |
VirgilByteArray virgil::sdk::crypto::Crypto::decryptThenVerify | ( | const VirgilByteArray & | data, |
const keys::PrivateKey & | privateKey, | ||
const std::vector< keys::PublicKey > & | signersPublicKeys | ||
) | const |
Decrypts (with private key) Then Verifies data using any of signers' PublicKeys.
data | data to be signed, then verified |
privateKey | receiver's private key |
signerPublicKey | signer public key |
VirgilByteArray virgil::sdk::crypto::Crypto::encrypt | ( | const VirgilByteArray & | data, |
const std::vector< keys::PublicKey > & | recipients | ||
) | const |
Encrypts data for passed PublicKeys.
data | data to be encrypted |
recipients | std::vector with recipient's Public Keys |
void virgil::sdk::crypto::Crypto::encrypt | ( | std::istream & | istream, |
std::ostream & | ostream, | ||
const std::vector< keys::PublicKey > & | recipients | ||
) | const |
Encrypts data stream for passed PublicKeys.
istream | stream to be encrypted |
ostream | stream with encrypted data |
recipients | std::vector with recipient's Public Keys |
VirgilByteArray virgil::sdk::crypto::Crypto::exportPrivateKey | ( | const keys::PrivateKey & | privateKey, |
const std::string & | password = "" |
||
) | const |
Exports encrypted using password private key.
privateKey | PrivateKey to export |
password | Password |
VirgilByteArray virgil::sdk::crypto::Crypto::exportPublicKey | ( | const keys::PublicKey & | publicKey | ) | const |
Exports public key in DER format.
publicKey | PublicKey to export |
keys::PublicKey virgil::sdk::crypto::Crypto::extractPublicKeyFromPrivateKey | ( | const keys::PrivateKey & | privateKey | ) | const |
Extracts public key from private key.
privateKey | Private key to extract from |
keys::KeyPair virgil::sdk::crypto::Crypto::generateKeyPair | ( | ) | const |
Generates KeyPair of default key type.
VirgilByteArray virgil::sdk::crypto::Crypto::generateSHA512 | ( | const VirgilByteArray & | data | ) | const |
Computes SHA-512.
data | data to be hashed |
VirgilByteArray virgil::sdk::crypto::Crypto::generateSignature | ( | const VirgilByteArray & | data, |
const keys::PrivateKey & | privateKey | ||
) | const |
Generates digital signature of data using private key.
data | data to sign |
privateKey | Private Key to be used to generate signature |
VirgilByteArray virgil::sdk::crypto::Crypto::generateSignature | ( | std::istream & | istream, |
const keys::PrivateKey & | privateKey | ||
) | const |
Generates digital signature of data stream using private key.
istream | data stream to sign |
privateKey | Private Key to be used to generate signature |
keys::PrivateKey virgil::sdk::crypto::Crypto::importPrivateKey | ( | const VirgilByteArray & | data, |
const std::string & | password = "" |
||
) | const |
Imports private key from raw data in DER or PEM format.
data | Private Key in DER or PEM format |
password | password, if password is encrypted |
keys::PublicKey virgil::sdk::crypto::Crypto::importPublicKey | ( | const VirgilByteArray & | data | ) | const |
Imports public key from DER or PEM format.
data | Public Key in DER or PEM format |
VirgilByteArray virgil::sdk::crypto::Crypto::signThenEncrypt | ( | const VirgilByteArray & | data, |
const keys::PrivateKey & | privateKey, | ||
const std::vector< keys::PublicKey > & | recipients | ||
) | const |
Signs (with private key) Then Encrypts data for passed PublicKeys.
data | data to be signed, then encrypted |
privateKey | sender private key |
recipients | std::vector with recipient's Public Keys |
bool virgil::sdk::crypto::Crypto::useSHA256Fingerprints | ( | ) | const |
Getter.
bool virgil::sdk::crypto::Crypto::verify | ( | const VirgilByteArray & | data, |
const VirgilByteArray & | signature, | ||
const keys::PublicKey & | signerPublicKey | ||
) | const |
Verifies digital signature of data.
data | data that was signed |
signature | digital signature |
signerPublicKey | signer public key |
bool virgil::sdk::crypto::Crypto::verify | ( | std::istream & | istream, |
const VirgilByteArray & | signature, | ||
const keys::PublicKey & | signerPublicKey | ||
) | const |
Verifies digital signature of data stream.
istream | data stream that was signed |
signature | digital signature |
signerPublicKey | signer public key |