Virgil Security Crypto library  2.1.2
VirgilKeyPair.h
1 
37 #ifndef VIRGIL_KEY_PAIR_H
38 #define VIRGIL_KEY_PAIR_H
39 
40 #include <virgil/crypto/VirgilByteArray.h>
41 
42 namespace virgil { namespace crypto {
43 
48 public:
52  enum class Type {
53  RSA_256,
54  RSA_512,
55  RSA_1024,
56  RSA_2048,
57  RSA_3072,
58  RSA_4096,
59  RSA_8192,
60  EC_SECP192R1,
61  EC_SECP224R1,
62  EC_SECP256R1,
63  EC_SECP384R1,
64  EC_SECP521R1,
65  EC_BP256R1,
66  EC_BP384R1,
67  EC_BP512R1,
68  EC_SECP192K1,
69  EC_SECP224K1,
70  EC_SECP256K1,
74  };
75 public:
81  static VirgilKeyPair generate(
83  const VirgilByteArray& pwd = VirgilByteArray());
84 
90  const VirgilByteArray& pwd = VirgilByteArray());
91 
99  const VirgilKeyPair& donorKeyPair,
100  const VirgilByteArray& donorPrivateKeyPassword = VirgilByteArray(),
101  const VirgilByteArray& newKeyPairPassword = VirgilByteArray());
102 
106 
116  static bool isKeyPairMatch(
117  const VirgilByteArray& publicKey,
119  const VirgilByteArray& privateKeyPassword = VirgilByteArray());
120 
129  static bool checkPrivateKeyPassword(
130  const VirgilByteArray& key,
131  const VirgilByteArray& pwd);
132 
140  static bool isPrivateKeyEncrypted(const VirgilByteArray& privateKey);
142 
145 
158  const VirgilByteArray& privateKey,
159  const VirgilByteArray& oldPassword, const VirgilByteArray& newPassword);
160 
176  const VirgilByteArray& privateKey,
177  const VirgilByteArray& privateKeyPassword);
178 
195  const VirgilByteArray& privateKey,
196  const VirgilByteArray& privateKeyPassword);
197 
207  const VirgilByteArray& privateKey,
208  const VirgilByteArray& privateKeyPassword);
209 
217  static VirgilByteArray publicKeyToPEM(const VirgilByteArray& publicKey);
218 
226  static VirgilByteArray publicKeyToDER(const VirgilByteArray& publicKey);
227 
238  const VirgilByteArray& privateKey,
239  const VirgilByteArray& privateKeyPassword = VirgilByteArray());
250  const VirgilByteArray& privateKey,
251  const VirgilByteArray& privateKeyPassword = VirgilByteArray());
253 
257  VirgilKeyPair(const VirgilByteArray& publicKey, const VirgilByteArray& privateKey);
258 
262  VirgilByteArray publicKey() const;
263 
267  VirgilByteArray privateKey() const;
268 
269 private:
270  VirgilByteArray publicKey_;
271  VirgilByteArray privateKey_;
272 };
273 
274 }}
275 
276 #endif /* VIRGIL_KEY_PAIR_H */
static bool isPrivateKeyEncrypted(const VirgilByteArray &privateKey)
Check if given private key is encrypted.
Curve25519 as ECP deprecated format.
RSA 2048 bit (not recommended)
static VirgilKeyPair generate(VirgilKeyPair::Type type, const VirgilByteArray &pwd=VirgilByteArray())
Generate new key pair given type.
RSA 1024 bit (not recommended)
static bool checkPrivateKeyPassword(const VirgilByteArray &key, const VirgilByteArray &pwd)
Check if given private key and it's password matches.
Type
Type of the keypair.
Definition: VirgilKeyPair.h:52
static VirgilByteArray privateKeyToDER(const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray())
Convert given private key to the DER format.
Root namespace for all Virgil Security libraries.
Definition: VirgilAsn1Compatible.h:46
std::vector< unsigned char > VirgilByteArray
This type represents a sequence of bytes.
Definition: VirgilByteArray.h:53
static bool isKeyPairMatch(const VirgilByteArray &publicKey, const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray())
Check if a public-private pair of keys matches.
static VirgilByteArray publicKeyToDER(const VirgilByteArray &publicKey)
Convert given public key to the DER format.
RSA 1024 bit (not recommended)
This class handles information about Virgil Security key pair.
Definition: VirgilKeyPair.h:47
RSA 1024 bit (not recommended)
static VirgilByteArray extractPublicKey(const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword)
Extract public key from the private key.
static VirgilByteArray publicKeyToPEM(const VirgilByteArray &publicKey)
Convert given public key to the PEM format.
static VirgilByteArray decryptPrivateKey(const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword)
Return plain (non encrypted) private key.
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.
static VirgilByteArray encryptPrivateKey(const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword)
Return encrypted private key in PKCS#8 format.
VirgilKeyPair(const VirgilByteArray &publicKey, const VirgilByteArray &privateKey)
Initialize key pair with given public and private key.
static VirgilByteArray privateKeyToPEM(const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray())
Convert given private key to the PEM format.
static VirgilByteArray resetPrivateKeyPassword(const VirgilByteArray &privateKey, const VirgilByteArray &oldPassword, const VirgilByteArray &newPassword)
Reset password for the given private key.
static VirgilKeyPair generateRecommended(const VirgilByteArray &pwd=VirgilByteArray())
Generate new key pair with recommended most safe type.
VirgilByteArray publicKey() const
Provide access to the public key.
VirgilByteArray privateKey() const
Provide access to the private key.