ETSI STF525 / Internal Testing test suite
This project provides an internal testing test suite and its associated Test Adapter/Codec
|
This class implements the generation of a key pair private/public. More...
#include <security_ecc.hh>
Public Member Functions | |
security_ecc (const ec_elliptic_curves p_elliptic_curve) | |
Default constructor. More... | |
security_ecc (const ec_elliptic_curves p_elliptic_curve, const std::vector< unsigned char > &p_private_key) | |
Constructor based on the private key only. More... | |
security_ecc (const ec_elliptic_curves p_elliptic_curve, const std::vector< unsigned char > &p_public_key_x, const std::vector< unsigned char > &p_public_key_y) | |
Constructor based on the public keys only. More... | |
virtual | ~security_ecc () |
Destructor. More... | |
int | generate () |
Generate a pair (PrivateK, PublicK) of keys for signature or encryption. More... | |
int | sign (const std::vector< unsigned char > &p_data, std::vector< unsigned char > &p_r_sig, std::vector< unsigned char > &p_s_sig) |
Signed the data using ECDSA algorithm. More... | |
int | sign_verif (const std::vector< unsigned char > &p_data, const std::vector< unsigned char > &p_signature) |
Verifiy an ECDSA signature. More... | |
int | encrypt (const encryption_algotithm p_enc_algorithm, const std::vector< unsigned char > &p_message, std::vector< unsigned char > &p_enc_message) |
Encryption using the specified algorithm. More... | |
int | encrypt (const encryption_algotithm p_enc_algorithm, const std::vector< unsigned char > &p_symmetric_key, const std::vector< unsigned char > &p_nonce, const std::vector< unsigned char > &p_message, std::vector< unsigned char > &p_enc_message) |
Encryption using the specified algorithm. More... | |
int | decrypt (const encryption_algotithm p_enc_algorithm, const std::vector< unsigned char > &p_key, const std::vector< unsigned char > &p_nonce, const std::vector< unsigned char > &p_tag, const std::vector< unsigned char > &p_enc_message, std::vector< unsigned char > &p_message) |
Decryption using the specified algorithm. More... | |
int | generate_and_derive_ephemeral_key (const std::vector< unsigned char > &p_peer_public_enc_key_x, const std::vector< unsigned char > &p_peer_public_enc_key_y) |
Generate a shared secret key and derive it using KDF2 algorithm. More... | |
int | decrypt (const std::vector< unsigned char > &p_nonce, const std::vector< unsigned char > &p_tag, const std::vector< unsigned char > &p_enc_message, std::vector< unsigned char > &p_message) |
const std::vector< unsigned char > & | private_key () const |
const std::vector< unsigned char > & | public_key_x () const |
const std::vector< unsigned char > & | public_key_y () const |
const std::vector< unsigned char > & | ephemeral_key () const |
const std::vector< unsigned char > & | encryption_key_x () const |
const std::vector< unsigned char > & | encryption_key_y () const |
const std::vector< unsigned char > & | symmetric_encryption_key () const |
const std::vector< unsigned char > & | nonce () const |
const std::vector< unsigned char > & | tag () const |
Private Member Functions | |
const int | init () |
Called by the constructors to set up encryption environment. More... | |
int | bin_to_ec_point (const std::vector< unsigned char > &p_public_key_x, const std::vector< unsigned char > &p_public_key_y, EC_POINT **p_ec_point) |
Convert a big number object into a public key. More... | |
int | public_key_to_bin (std::vector< unsigned char > &p_bin_key) |
Convert a public key into a big number object. More... | |
Private Attributes | |
ec_elliptic_curves | _elliptic_curve |
encryption_algotithm | _encryption_algotithm |
EC_KEY * | _ec_key |
const EC_GROUP * | _ec_group |
BN_CTX * | _bn_ctx |
std::vector< unsigned char > | _pri_key |
std::vector< unsigned char > | _pub_key_x |
std::vector< unsigned char > | _pub_key_y |
std::vector< unsigned char > | _eph_key |
std::vector< unsigned char > | _enc_key_x |
std::vector< unsigned char > | _enc_key_y |
std::vector< unsigned char > | _sym_key |
std::vector< unsigned char > | _nonce |
std::vector< unsigned char > | _tag |
This class implements the generation of a key pair private/public.
security_ecc::security_ecc | ( | const ec_elliptic_curves | p_elliptic_curve | ) |
Default constructor.
[in] | p_elliptic_curve | The ECDSA curve family to be used |
security_ecc::security_ecc | ( | const ec_elliptic_curves | p_elliptic_curve, |
const std::vector< unsigned char > & | p_private_key | ||
) |
Constructor based on the private key only.
[in] | p_elliptic_curve | The ECDSA curve family to be used |
[in] | p_private_key | The private key |
security_ecc::security_ecc | ( | const ec_elliptic_curves | p_elliptic_curve, |
const std::vector< unsigned char > & | p_public_key_x, | ||
const std::vector< unsigned char > & | p_public_key_y | ||
) |
Constructor based on the public keys only.
[in] | p_elliptic_curve | The ECDSA curve family to be used |
|
virtual |
Destructor.
|
private |
Convert a big number object into a public key.
int security_ecc::decrypt | ( | const encryption_algotithm | p_enc_algorithm, |
const std::vector< unsigned char > & | p_key, | ||
const std::vector< unsigned char > & | p_nonce, | ||
const std::vector< unsigned char > & | p_tag, | ||
const std::vector< unsigned char > & | p_enc_message, | ||
std::vector< unsigned char > & | p_message | ||
) |
Decryption using the specified algorithm.
[in] | p_enc_algorithm | The algorithm to use for the decryption |
[in] | p_nonce | The algorithm to use for the encryption |
[in] | p_tag | The algorithm to use for the encryption |
[in] | p_enc_message | The message to be decrypted |
[out] | p_message | The decrypted message |
int security_ecc::decrypt | ( | const std::vector< unsigned char > & | p_nonce, |
const std::vector< unsigned char > & | p_tag, | ||
const std::vector< unsigned char > & | p_enc_message, | ||
std::vector< unsigned char > & | p_message | ||
) |
int security_ecc::encrypt | ( | const encryption_algotithm | p_enc_algorithm, |
const std::vector< unsigned char > & | p_message, | ||
std::vector< unsigned char > & | p_enc_message | ||
) |
Encryption using the specified algorithm.
[in] | p_enc_algorithm | The algorithm to use for the encryption |
[in] | p_message | The message to be encrypted |
[out] | p_enc_message | The encrypted message |
int security_ecc::encrypt | ( | const encryption_algotithm | p_enc_algorithm, |
const std::vector< unsigned char > & | p_symmetric_key, | ||
const std::vector< unsigned char > & | p_nonce, | ||
const std::vector< unsigned char > & | p_message, | ||
std::vector< unsigned char > & | p_enc_message | ||
) |
Encryption using the specified algorithm.
[in] | p_enc_algorithm | The algorithm to use for the encryption |
[in] | p_symmetric_key | |
[in] | p_nonce | |
[in] | p_message | The message to be encrypted |
[out] | p_enc_message | The encrypted message |
|
inline |
|
inline |
|
inline |
int security_ecc::generate | ( | ) |
Generate a pair (PrivateK, PublicK) of keys for signature or encryption.
int security_ecc::generate_and_derive_ephemeral_key | ( | const std::vector< unsigned char > & | p_public_key_x, |
const std::vector< unsigned char > & | p_public_key_y | ||
) |
Generate a shared secret key and derive it using KDF2 algorithm.
[in] | p_peer_public_key_x | The recipient public key X-coordinate |
[in] | p_peer_public_key_x | The recipient public key Y-coordinate |
|
private |
Called by the constructors to set up encryption environment.
|
inline |
|
inline |
|
private |
Convert a public key into a big number object.
|
inline |
|
inline |
int security_ecc::sign | ( | const std::vector< unsigned char > & | p_data, |
std::vector< unsigned char > & | p_r_sig, | ||
std::vector< unsigned char > & | p_s_sig | ||
) |
Signed the data using ECDSA algorithm.
[in] | p_data | The data to be signed |
[out] | p_r_sig | Part of the signature |
[out] | p_s_sig | Part of the signature |
int security_ecc::sign_verif | ( | const std::vector< unsigned char > & | p_data, |
const std::vector< unsigned char > & | p_signature | ||
) |
Verifiy an ECDSA signature.
[in] | p_data | The signed data |
[in] | p_signature | The signature part, based on r_sig part and s_sig part |
|
inline |
|
inline |
|
private |
Pre-alocated memory used to increase OpenSSL processing
|
private |
EC_GROUP reference
|
private |
EC_KEY reference
|
private |
Selected elleptic curve
|
private |
Public encryption key X-coordinate storage
|
private |
Public encryption key Y-coordinate storage
|
private |
Selected encryption algotithm
|
private |
Ephemeral key generated by ECIES encryption method
|
private |
Initial Vector generated by encryption method
|
private |
Private key storage
|
private |
Public key X-coordinate storage
|
private |
Public key Y-coordinate storage
|
private |
Symmetric encryption key generated by encryption method
|
private |
Tag vector generated by encryption method