Virgil Security Crypto library
2.1.2
|
This class handles information about Virgil Security key pair. More...
#include <VirgilKeyPair.h>
Public Member Functions | |
VirgilKeyPair (const VirgilByteArray &publicKey, const VirgilByteArray &privateKey) | |
Initialize key pair with given public and private key. | |
VirgilByteArray | publicKey () const |
Provide access to the public key. | |
VirgilByteArray | privateKey () const |
Provide access to the private key. | |
Static Public Member Functions | |
static VirgilKeyPair | generate (VirgilKeyPair::Type type, const VirgilByteArray &pwd=VirgilByteArray()) |
Generate new key pair given type. More... | |
static VirgilKeyPair | generateRecommended (const VirgilByteArray &pwd=VirgilByteArray()) |
Generate new key pair with recommended most safe type. More... | |
static VirgilKeyPair | generateFrom (const VirgilKeyPair &donorKeyPair, const VirgilByteArray &donorPrivateKeyPassword=VirgilByteArray(), const VirgilByteArray &newKeyPairPassword=VirgilByteArray()) |
Generate new key pair of the same type based on the donor key pair. More... | |
Keys validation | |
static bool | isKeyPairMatch (const VirgilByteArray &publicKey, const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray()) |
Check if a public-private pair of keys matches. More... | |
static bool | checkPrivateKeyPassword (const VirgilByteArray &key, const VirgilByteArray &pwd) |
Check if given private key and it's password matches. More... | |
static bool | isPrivateKeyEncrypted (const VirgilByteArray &privateKey) |
Check if given private key is encrypted. More... | |
Keys | |
static VirgilByteArray | resetPrivateKeyPassword (const VirgilByteArray &privateKey, const VirgilByteArray &oldPassword, const VirgilByteArray &newPassword) |
Reset password for the given private key. More... | |
static VirgilByteArray | encryptPrivateKey (const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword) |
Return encrypted private key in PKCS#8 format. More... | |
static VirgilByteArray | decryptPrivateKey (const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword) |
Return plain (non encrypted) private key. More... | |
static VirgilByteArray | extractPublicKey (const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword) |
Extract public key from the private key. More... | |
static VirgilByteArray | publicKeyToPEM (const VirgilByteArray &publicKey) |
Convert given public key to the PEM format. More... | |
static VirgilByteArray | publicKeyToDER (const VirgilByteArray &publicKey) |
Convert given public key to the DER format. More... | |
static VirgilByteArray | privateKeyToPEM (const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray()) |
Convert given private key to the PEM format. More... | |
static VirgilByteArray | privateKeyToDER (const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray()) |
Convert given private key to the DER format. More... | |
This class handles information about Virgil Security key pair.
|
strong |
Type of the keypair.
|
static |
Check if given private key and it's password matches.
key | - private key in DER or PEM format. |
pwd | - private key password. |
|
static |
Return plain (non encrypted) private key.
Decrypt the given private key and return result.
privateKey | - Encrypted Private Key. |
privateKeyPassword | - current Private Key password. |
VirgilCryptoException,with | VirgilCryptoError::InvalidPrivateKeyPassword if password is wrong. |
VirgilCryptoException,with | VirgilCryptoError::InvalidFormat if key has invalid format. |
|
static |
Return encrypted private key in PKCS#8 format.
Encrypt the given private key and return result.
privateKey | - Private Key in the plain text. |
privateKeyPassword | - new Private Key password. |
VirgilCryptoException,with | VirgilCryptoError::InvalidArgument if key is empty. |
VirgilCryptoException,with | VirgilCryptoError::InvalidPrivateKeyPassword if key is already encrypted. |
VirgilCryptoException,with | VirgilCryptoError::InvalidFormat if key has invalid format. |
|
static |
Extract public key from the private key.
privateKey | - Private Key. |
privateKeyPassword | - Private Key password. |
|
static |
Generate new key pair given type.
type | - private key type to be generated. |
pwd | - private key password. |
|
static |
Generate new key pair of the same type based on the donor key pair.
donorKeyPair | - public key or private key is used to determine the new key pair type. |
donorPrivateKeyPassword | - donor private key password, optional if public key is defined. |
newKeyPairPassword | - private key password of the new key pair. |
|
static |
Generate new key pair with recommended most safe type.
pwd | - private key password. |
|
static |
Check if a public-private pair of keys matches.
publicKey | - public key in DER or PEM format. |
privateKey | - private key in DER or PEM format. |
privateKeyPassword | - private key password if exists. |
|
static |
Check if given private key is encrypted.
privateKey | - private key in DER or PEM format. |
|
static |
Convert given private key to the DER format.
privateKey | - Private Key to be converted. |
privateKeyPassword | - password for the Private Key. |
VirgilCryptoException,with | VirgilCryptoError::InvalidPrivateKeyPassword if password is wrong. |
VirgilCryptoException,with | VirgilCryptoError::InvalidFormat if key has invalid format. |
|
static |
Convert given private key to the PEM format.
privateKey | - Private Key to be converted. |
privateKeyPassword | - password for the Private Key. |
VirgilCryptoException,with | VirgilCryptoError::InvalidPrivateKeyPassword if password is wrong. |
VirgilCryptoException,with | VirgilCryptoError::InvalidFormat if key has invalid format. |
|
static |
Convert given public key to the DER format.
publicKey | - Public Key to be converted. |
VirgilCryptoException,with | VirgilCryptoError::InvalidFormat if key has invalid format. |
|
static |
Convert given public key to the PEM format.
publicKey | - Public Key to be converted. |
VirgilCryptoException,with | VirgilCryptoError::InvalidFormat if key has invalid format. |
|
static |
Reset password for the given private key.
Re-encrypt given Private Key with a new password.
privateKey | - Private Key that is encrypted with old password. |
oldPassword | - current Private Key password. |
newPassword | - new Private Key password. |