Initializes a new instance of VirgilCrypto.
Type of keys to generate by default.
Indicates whether to use old algorithm to calculate keypair identifiers.
Current algorithm: first 8 bytes of SHA512 hash of public key in DER format.
Old algorithm: SHA256 hash of public key in DER format.
Use SHA256 identifiers only if you need to be compatible with version 2 of this library (i.e. decrypt data that were encrypted using the version 2).
Default is false
(new algorithm)
Calculates the hash of the given data.
The data to calculate the hash of. If data
is a
string, utf-8 encoding is assumed.
Calculates the signature of the data using the private key.
NOTE: Returned value contains only digital signature, not data itself.
NOTE: Data inside this function is guaranteed to be hashed with SHA512 at least one time.
It's secure to pass raw data here.
The data to be signed. If data
is a
string, utf-8 encoding is assumed.
The private key object.
Creates an instance of VirgilStreamCipher to be used
to encrypt data in chunks using the given publicKey
.
A single public key or an array of public keys to encrypt the data with.
Creates an instance of VirgilStreamDecipher to be used
to decrypt data in chunks using the given privateKey
.
The private key to decrypt the data with.
Creates an instance of VirgilStreamSigner to be used to calculate signature of data in chunks.
Creates an instance of VirgilStreamVerifier to be used
to verify the signature
for the data in coming in chunks.
The signature to be verified.
If signature
is a string,
specifies its encoding, otherwise is ignored. Default is 'utf8'.
Decrypts the data with the given private key following the algorithm below:
privateKey
The data to be decrypted. If encryptedData
is a
string, base64 encoding is assumed.
The private key to decrypt with.
Decrypts the data using the private key, then verifies decrypted data using the attached signature and the given public key.
The data to be decrypted and verified. If encryptedData
is a
string, base64 encoding is assumed.
The private key object to use for decryption.
The public key object
or an array of public key objects to use to verify data integrity. If publicKey
is an array, the attached signature must be valid for any one of them.
Same as {@link IVirgilCrypto.decryptThenVerify} but expects the Virgil Cryptogram
(the content info) to be passed as contentInfo
parameter instead of be embedded
in the encryptedData
.
The data to be decrypted and verified. If encryptedData
is a string, base64 encoding is assumed.
The metadata (i.e. public algorithm parameters used for encryption) required for decryption.
The private key object to use for decryption.
The public key object
or an array of public key objects to use to verify data integrity. If the public key
identifier specified in metadata
does not correspond to the publicKey
argument
(or any of the keys in the publicKey
array), an error is thrown.
Encrypts the data for the given public key(s) following the algorithm below:
The data to be encrypted. If data
is a
string, utf-8 encoding is assumed.
Public key or an array of public keys of the intended recipients.
Exports private key material in DER format from the given private key object.
The private key object.
Exports public key material in DER format from the given public key object.
The public key object.
Extracts a public key from the private key handle.
The private key object to extract from.
Generates a new key pair.
Generates a new key pair from the given key material.
The data to be used for key generation,
must be strong enough (have high entropy). If keyMaterial
is a
string, base64 encoding is assumed.
Generates a pseudo-random sequence of bytes of the given length.
The number of bytes to generate.
Creates a VirgilPrivateKey
object from private key bytes in PEM or DER format.
The private key bytes. If rawPrivateKey
is a
string, base64 encoding is assumed.
Creates a VirgilPublicKey
object from public key material in PEM or DER format.
The public key bytes. If rawPublicKey
is a
string, base64 encoding is assumed.
Calculates the signature on the data using the private key, then encrypts the data along with the signature using the public key(s).
The data to sign and encrypt. If data
is a
string, utf-8 encoding is assumed.
The private key to use to calculate signature.
The public key of the intended recipient or an array of public keys of multiple recipients.
Same as {@link IVirgilCrypto.signThenEncrypt} but returns the metadata (i.e. public
algorithm parameters used for encryption) as a separate property on the response
object rather than embedded in the encrypted data as regular signThenEncrypt
does.
The data to sign and encrypt. If data
is a
string, utf-8 encoding is assumed.
The private key to use to calculate signature.
The public key of the intended recipient or an array of public keys of multiple recipients.
Verifies the provided data using the given signature and public key. Note: Verification algorithm depends on PublicKey type. Default: EdDSA
The data to be verified. If data
is a
string, utf-8 encoding is assumed.
The signature to verify. If signature
is a
string, base64 encoding is assumed.
The public key object.
Provides implementation of high-level cryptographic operations using Virgil Crypto Library.