Virgil Security Crypto library  1.8.2
Public Types | Public Member Functions | Static Public Member Functions | List of all members
virgil::crypto::VirgilKeyPair Class Reference

This class handles information about Virgil Security key pair. More...

#include <VirgilKeyPair.h>

Public Types

enum  Type {
  Type_Default = 0, Type_RSA_256, Type_RSA_512, Type_RSA_1024,
  Type_RSA_2048, Type_RSA_3072, Type_RSA_4096, Type_RSA_8192,
  Type_EC_SECP192R1, Type_EC_SECP224R1, Type_EC_SECP256R1, Type_EC_SECP384R1,
  Type_EC_SECP521R1, Type_EC_BP256R1, Type_EC_BP384R1, Type_EC_BP512R1,
  Type_EC_M221, Type_EC_M255, Type_EC_Curve25519 = 17, Type_EC_M383,
  Type_EC_M511, Type_EC_SECP192K1, Type_EC_SECP224K1, Type_EC_SECP256K1
}
 Type of the keypair. More...
 

Public Member Functions

 VirgilKeyPair (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with default settings. More...
 
 VirgilKeyPair (const virgil::crypto::VirgilByteArray &publicKey, const virgil::crypto::VirgilByteArray &privateKey)
 Initialize key pair with given public and private key.
 
virgil::crypto::VirgilByteArray publicKey () const
 Provide access to the public key.
 
virgil::crypto::VirgilByteArray privateKey () const
 Provide access to the private key.
 

Static Public Member Functions

static VirgilKeyPair generate (VirgilKeyPair::Type type=VirgilKeyPair::Type_Default, const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair given type. More...
 
static VirgilKeyPair generateFrom (const VirgilKeyPair &donorKeyPair, const virgil::crypto::VirgilByteArray &donorPrivateKeyPassword=virgil::crypto::VirgilByteArray(), const virgil::crypto::VirgilByteArray &newKeyPairPassword=virgil::crypto::VirgilByteArray())
 Generate new key pair of the same type based on the donor key pair. More...
 
static VirgilKeyPair ecNist192 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 192-bits NIST curve. More...
 
static VirgilKeyPair ecNist224 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 224-bits NIST curve. More...
 
static VirgilKeyPair ecNist256 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 256-bits NIST curve. More...
 
static VirgilKeyPair ecNist384 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 384-bits NIST curve. More...
 
static VirgilKeyPair ecNist521 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 521-bits NIST curve. More...
 
static VirgilKeyPair ecBrainpool256 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 256-bits Brainpool curve. More...
 
static VirgilKeyPair ecBrainpool384 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 384-bits Brainpool curve. More...
 
static VirgilKeyPair ecBrainpool512 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 512-bits Brainpool curve. More...
 
static VirgilKeyPair ecKoblitz192 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 192-bits "Koblitz" curve. More...
 
static VirgilKeyPair ecKoblitz224 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 224-bits "Koblitz" curve. More...
 
static VirgilKeyPair ecKoblitz256 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with 256-bits "Koblitz" curve. More...
 
static VirgilKeyPair rsa256 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with RSA 256-bits. More...
 
static VirgilKeyPair rsa512 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with RSA 512-bits. More...
 
static VirgilKeyPair rsa1024 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with RSA 1024-bits. More...
 
static VirgilKeyPair rsa2048 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with RSA 2048-bits. More...
 
static VirgilKeyPair rsa4096 (const virgil::crypto::VirgilByteArray &pwd=virgil::crypto::VirgilByteArray())
 Generate new key pair with RSA 4096-bits. More...
 
Keys validation
static bool isKeyPairMatch (const virgil::crypto::VirgilByteArray &publicKey, const virgil::crypto::VirgilByteArray &privateKey, const virgil::crypto::VirgilByteArray &privateKeyPassword=virgil::crypto::VirgilByteArray())
 Check if a public-private pair of keys matches. More...
 
static bool checkPrivateKeyPassword (const virgil::crypto::VirgilByteArray &key, const virgil::crypto::VirgilByteArray &pwd)
 Check if given private key and it's password matches. More...
 
static bool isPrivateKeyEncrypted (const virgil::crypto::VirgilByteArray &privateKey)
 Check if given private key is encrypted. More...
 
Keys
static virgil::crypto::VirgilByteArray resetPrivateKeyPassword (const virgil::crypto::VirgilByteArray &privateKey, const virgil::crypto::VirgilByteArray &oldPassword, const virgil::crypto::VirgilByteArray &newPassword)
 Reset password for the given private key. More...
 
static virgil::crypto::VirgilByteArray extractPublicKey (const virgil::crypto::VirgilByteArray &privateKey, const virgil::crypto::VirgilByteArray &privateKeyPassword)
 Extract public key from the private key. More...
 

Detailed Description

This class handles information about Virgil Security key pair.

Member Enumeration Documentation

Type of the keypair.

Enumerator
Type_Default 

recommended most safe type

Type_RSA_256 

RSA 1024 bit (not recommended)

Type_RSA_512 

RSA 1024 bit (not recommended)

Type_RSA_1024 

RSA 1024 bit (not recommended)

Type_RSA_2048 

RSA 2048 bit (not recommended)

Type_RSA_3072 

RSA 3072 bit.

Type_RSA_4096 

RSA 4096 bit.

Type_RSA_8192 

RSA 8192 bit.

Type_EC_SECP192R1 

192-bits NIST curve

Type_EC_SECP224R1 

224-bits NIST curve

Type_EC_SECP256R1 

256-bits NIST curve

Type_EC_SECP384R1 

384-bits NIST curve

Type_EC_SECP521R1 

521-bits NIST curve

Type_EC_BP256R1 

256-bits Brainpool curve

Type_EC_BP384R1 

384-bits Brainpool curve

Type_EC_BP512R1 

512-bits Brainpool curve

Type_EC_M221 

(not implemented yet)

Type_EC_M255 

Curve25519.

Type_EC_Curve25519 

Curve25519.

Type_EC_M383 

(not implemented yet)

Type_EC_M511 

(not implemented yet)

Type_EC_SECP192K1 

192-bits "Koblitz" curve

Type_EC_SECP224K1 

224-bits "Koblitz" curve

Type_EC_SECP256K1 

256-bits "Koblitz" curve

Constructor & Destructor Documentation

virgil::crypto::VirgilKeyPair::VirgilKeyPair ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
explicit

Generate new key pair with default settings.

Deprecated:
Use generate() with default type instead.

Member Function Documentation

static bool virgil::crypto::VirgilKeyPair::checkPrivateKeyPassword ( const virgil::crypto::VirgilByteArray &  key,
const virgil::crypto::VirgilByteArray &  pwd 
)
static

Check if given private key and it's password matches.

Parameters
key- private key in DER or PEM format.
pwd- private key password.
Returns
true - if private key and it's password matches.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecBrainpool256 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 256-bits Brainpool curve.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecBrainpool384 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 384-bits Brainpool curve.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecBrainpool512 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 512-bits Brainpool curve.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecKoblitz192 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 192-bits "Koblitz" curve.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecKoblitz224 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 224-bits "Koblitz" curve.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecKoblitz256 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 256-bits "Koblitz" curve.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecNist192 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 192-bits NIST curve.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecNist224 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 224-bits NIST curve.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecNist256 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 256-bits NIST curve.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecNist384 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 384-bits NIST curve.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::ecNist521 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with 521-bits NIST curve.

Deprecated:
Use generate() instead.
static virgil::crypto::VirgilByteArray virgil::crypto::VirgilKeyPair::extractPublicKey ( const virgil::crypto::VirgilByteArray &  privateKey,
const virgil::crypto::VirgilByteArray &  privateKeyPassword 
)
static

Extract public key from the private key.

Parameters
privateKey- Private Key.
privateKeyPassword- Private Key password.
Returns
Public Key.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::generate ( VirgilKeyPair::Type  type = VirgilKeyPair::Type_Default,
const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray() 
)
static

Generate new key pair given type.

Parameters
type- private key type to be generated.
pwd- private key password.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::generateFrom ( const VirgilKeyPair donorKeyPair,
const virgil::crypto::VirgilByteArray &  donorPrivateKeyPassword = virgil::crypto::VirgilByteArray(),
const virgil::crypto::VirgilByteArray &  newKeyPairPassword = virgil::crypto::VirgilByteArray() 
)
static

Generate new key pair of the same type based on the donor key pair.

Parameters
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 bool virgil::crypto::VirgilKeyPair::isKeyPairMatch ( const virgil::crypto::VirgilByteArray &  publicKey,
const virgil::crypto::VirgilByteArray &  privateKey,
const virgil::crypto::VirgilByteArray &  privateKeyPassword = virgil::crypto::VirgilByteArray() 
)
static

Check if a public-private pair of keys matches.

Parameters
publicKey- public key in DER or PEM format.
privateKey- private key in DER or PEM format.
privateKeyPassword- private key password if exists.
Returns
true - if public-private pair of keys matches.
static bool virgil::crypto::VirgilKeyPair::isPrivateKeyEncrypted ( const virgil::crypto::VirgilByteArray &  privateKey)
static

Check if given private key is encrypted.

Parameters
privateKey- private key in DER or PEM format.
Returns
true - if private key is encrypted.
static virgil::crypto::VirgilByteArray virgil::crypto::VirgilKeyPair::resetPrivateKeyPassword ( const virgil::crypto::VirgilByteArray &  privateKey,
const virgil::crypto::VirgilByteArray &  oldPassword,
const virgil::crypto::VirgilByteArray &  newPassword 
)
static

Reset password for the given private key.

Re-encrypt given Private Key with a new password.

Parameters
privateKey- Private Key that is encrypted with old password.
oldPassword- current Private Key password.
newPassword- new Private Key password.
Returns
Private Key that is encrypted with the new password.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::rsa1024 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with RSA 1024-bits.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::rsa2048 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with RSA 2048-bits.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::rsa256 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with RSA 256-bits.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::rsa4096 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with RSA 4096-bits.

Deprecated:
Use generate() instead.
static VirgilKeyPair virgil::crypto::VirgilKeyPair::rsa512 ( const virgil::crypto::VirgilByteArray &  pwd = virgil::crypto::VirgilByteArray())
static

Generate new key pair with RSA 512-bits.

Deprecated:
Use generate() instead.

The documentation for this class was generated from the following file: