security_services Class Reference

This class provides security services for all layers as specified in TSI TS 102 723-8 and ETSI TS 103 097. More...

`#include <security_services.hh>`

## Public Member Functions

int | verify_and_extract_gn_payload (const OCTETSTRING &p_secured_gn_payload, const bool p_verify, IEEE1609dot2::Ieee1609Dot2Data &p_ieee_1609dot2_data, OCTETSTRING &p_unsecured_gn_payload, Params &p_params)
| Verify and extract the unsecured payload from the provided secured payload. The secured payload could signed only, encryted only or signed and encrypted. More...
int | secure_gn_payload (const OCTETSTRING &p_unsecured_gn_payload, OCTETSTRING &p_secured_gn_payload, Params &p_params)
| Apply security to the provided unsecured payload. More...
int | setup (Params &p_params)
int | store_certificate (const CHARSTRING &p_cert_id, const OCTETSTRING &p_cert, const OCTETSTRING &p_private_key, const OCTETSTRING &p_public_key_x, const OCTETSTRING &p_public_key_y, const OCTETSTRING &p_hashid8, const OCTETSTRING &p_issuer, const OCTETSTRING &p_private_enc_key, const OCTETSTRING &p_public_enc_key_x, const OCTETSTRING &p_public_enc_key_y)
void | set_position (const int p_latitude, const int p_longitude, const int p_elevation=0)
int | read_certificate (const CHARSTRING &p_certificate_id, OCTETSTRING &p_certificate) const
int | read_certificate_digest (const CHARSTRING &p_certificate_id, OCTETSTRING &p_digest) const
int | read_certificate_from_digest (const OCTETSTRING &p_digest, CHARSTRING &p_certificate_id) const
int | read_private_key (const CHARSTRING &p_certificate_id, OCTETSTRING &p_private_key) const
int | read_private_enc_key (const CHARSTRING &p_certificate_id, OCTETSTRING &p_private_enc_key) const

## Static Public Member Functions

static security_services & | get_instance ()
| Public accessor to the single object reference. More...

## Private Member Functions

| security_services ()
| Default private ctor. More...
| ~security_services ()
| Default private dtor. More...
int | sign_gn_payload (const OCTETSTRING &p_unsecured_gn_payload, OCTETSTRING &p_signed_gn_payload, Params &p_params)
| Sign the payload according provided parameters. More...
int | encrypt_gn_payload (const OCTETSTRING &p_unsecured_gn_payload, OCTETSTRING &p_enc_gn_payload, Params &p_params)
| Encrypt the payload according provided parameters. More...
int | process_ieee_1609_dot2_content (const IEEE1609dot2::Ieee1609Dot2Content &p_ieee_1609_dot2_content, const bool p_verify, OCTETSTRING &p_unsecured_payload, Params &p_params)
| Verify and extract the unsecured payload from the IEEE1609dot2::Ieee1609Dot2Content data structure. More...
int | process_ieee_1609_dot2_signed_data (const IEEE1609dot2::SignedData &p_signed_data, const bool p_verify, OCTETSTRING &p_unsecured_payload, Params &p_params)
int | process_ieee_1609_dot2_encrypted_data (const IEEE1609dot2::EncryptedData &p_encrypted_data, const bool p_verify, OCTETSTRING &p_unsecured_payload, Params &p_params)
int | sign_tbs_data (const IEEE1609dot2::ToBeSignedData &p_tbs_data, const IEEE1609dot2BaseTypes::HashAlgorithm &p_hashAlgorithm, IEEE1609dot2BaseTypes::Signature &p_signature, Params &p_params)
int | hash_sha256 (const OCTETSTRING &p_data, OCTETSTRING &p_hash_data)
int | hash_sha384 (const OCTETSTRING &p_data, OCTETSTRING &p_hash_data)
int | sign_ecdsa_nistp256 (const OCTETSTRING &p_hash, IEEE1609dot2BaseTypes::Signature &p_signature, Params &p_params)
int | verify_sign_ecdsa_nistp256 (const OCTETSTRING &p_hash, const IEEE1609dot2BaseTypes::Signature &p_signature, const std::string &p_certificate_id, Params &p_params)
int | extract_encryption_keys (const IEEE1609dot2::CertificateBase &p_cert, OCTETSTRING &p_public_enc_key_x, OCTETSTRING &p_public_enc_key_y)

## Private Attributes

bool | _setup_done
std::unique_ptr< security_ecc > | _ec_keys_enc
std::unique_ptr< security_ecc > | _ec_keys_dec
std::unique_ptr< security_cache > | _security_cache
std::unique_ptr< security_db > | _security_db
unsigned long long | _last_generation_time
std::vector< unsigned char > | _unknown_certificate
int | _latitude
int | _longitude
int | _elevation

## Static Private Attributes

static constexpr unsigned int | ProtocolVersion = 3
static security_services * | instance = nullptr
| Unique static object reference of this class. More...

## Detailed Description

This class provides security services for all layers as specified in TSI TS 102 723-8 and ETSI TS 103 097.

Remarks
  Singleton pattern

## Constructor & Destructor Documentation

## security_services()

security_services::security_services | ( |  | ) |

private

Default private ctor.

## ~security_services()

security_services::~security_services | ( |  | ) |

inlineprivate

Default private dtor.

## Member Function Documentation

## encrypt_gn_payload()

int security_services::encrypt_gn_payload | ( | const OCTETSTRING & | p_unsecured_gn_payload,
|  | OCTETSTRING & | p_signed_gn_payload,
|  | Params & | p_params
| ) |  |

private

Encrypt the payload according provided parameters.

Parameters

  [in] | p_unsecured_gn_payload | The payload to be encrypted
  [in] | p_enc_gn_payload | The encrypted payload
  [in] | p_params | The Test System parameters

Returns
  0 on success, negative value otherwise

## extract_encryption_keys()

int security_services::extract_encryption_keys | ( | const IEEE1609dot2::CertificateBase & | p_cert,
|  | OCTETSTRING & | p_public_enc_key_x,
|  | OCTETSTRING & | p_public_enc_key_y
| ) |  |

private

## get_instance()

static security_services& security_services::get_instance | ( |  | ) |

inlinestatic

Public accessor to the single object reference.

## hash_sha256()

int security_services::hash_sha256 | ( | const OCTETSTRING & | p_data,
|  | OCTETSTRING & | p_hash_data
| ) |  |

private

## hash_sha384()

int security_services::hash_sha384 | ( | const OCTETSTRING & | p_data,
|  | OCTETSTRING & | p_hash_data
| ) |  |

private

## process_ieee_1609_dot2_content()

int security_services::process_ieee_1609_dot2_content | ( | const IEEE1609dot2::Ieee1609Dot2Content & | p_ieee_1609_dot2_content,
|  | const bool | p_verify,
|  | OCTETSTRING & | p_unsecured_payload,
|  | Params & | p_params
| ) |  |

private

Verify and extract the unsecured payload from the IEEE1609dot2::Ieee1609Dot2Content data structure.

Parameters

  [in] | p_content | The secured content to be processed
  [in] | p_verify | Set to true if security checks shall be applied
  [in] | p_unsecured_payload | The extracted payload

Returns
  0 on success, negative value otherwise

## process_ieee_1609_dot2_encrypted_data()

int security_services::process_ieee_1609_dot2_encrypted_data | ( | const IEEE1609dot2::EncryptedData & | p_encrypted_data,
|  | const bool | p_verify,
|  | OCTETSTRING & | p_unsecured_payload,
|  | Params & | p_params
| ) |  |

private

## process_ieee_1609_dot2_signed_data()

int security_services::process_ieee_1609_dot2_signed_data | ( | const IEEE1609dot2::SignedData & | p_signed_data,
|  | const bool | p_verify,
|  | OCTETSTRING & | p_unsecured_payload,
|  | Params & | p_params
| ) |  |

private

## read_certificate()

int security_services::read_certificate | ( | const CHARSTRING & | p_certificate_id,
|  | OCTETSTRING & | p_certificate
| ) |  | const

## read_certificate_digest()

int security_services::read_certificate_digest | ( | const CHARSTRING & | p_certificate_id,
|  | OCTETSTRING & | p_digest
| ) |  | const

## read_certificate_from_digest()

int security_services::read_certificate_from_digest | ( | const OCTETSTRING & | p_digest,
|  | CHARSTRING & | p_certificate_id
| ) |  | const

## read_private_enc_key()

int security_services::read_private_enc_key | ( | const CHARSTRING & | p_certificate_id,
|  | OCTETSTRING & | p_private_enc_key
| ) |  | const

## read_private_key()

int security_services::read_private_key | ( | const CHARSTRING & | p_certificate_id,
|  | OCTETSTRING & | p_private_key
| ) |  | const

## secure_gn_payload()

int security_services::secure_gn_payload | ( | const OCTETSTRING & | p_unsecured_gn_payload,
|  | OCTETSTRING & | p_secured_gn_payload,
|  | Params & | p_params
| ) |  |

Apply security to the provided unsecured payload.

Parameters

  [in] | p_unsecured_gn_payload | The unsecured payload to be processed
  [in] | p_secured_gn_payload | The secured payload
  [in] | p_params | The Test System parameters

Returns
  0 on success, negative value otherwise

## set_position()

void security_services::set_position | ( | const int | p_latitude,
|  | const int | p_longitude,
|  | const int | p_elevation = `0`
| ) |  |

inline

## setup()

int security_services::setup | ( | Params & | p_params | ) |

## sign_ecdsa_nistp256()

int security_services::sign_ecdsa_nistp256 | ( | const OCTETSTRING & | p_hash,
|  | IEEE1609dot2BaseTypes::Signature & | p_signature,
|  | Params & | p_params
| ) |  |

private

## sign_gn_payload()

int security_services::sign_gn_payload | ( | const OCTETSTRING & | p_unsecured_gn_payload,
|  | OCTETSTRING & | p_signed_gn_payload,
|  | Params & | p_params
| ) |  |

private

Sign the payload according provided parameters.

Parameters

  [in] | p_unsecured_gn_payload | The payload to be signed
  [in] | p_signed_gn_payload | The signed payload
  [in] | p_params | The Test System parameters

Returns
  0 on success, negative value otherwise

## sign_tbs_data()

int security_services::sign_tbs_data | ( | const IEEE1609dot2::ToBeSignedData & | p_tbs_data,
|  | const IEEE1609dot2BaseTypes::HashAlgorithm & | p_hashAlgorithm,
|  | IEEE1609dot2BaseTypes::Signature & | p_signature,
|  | Params & | p_params
| ) |  |

private

## store_certificate()

int security_services::store_certificate | ( | const CHARSTRING & | p_cert_id,
|  | const OCTETSTRING & | p_cert,
|  | const OCTETSTRING & | p_private_key,
|  | const OCTETSTRING & | p_public_key_x,
|  | const OCTETSTRING & | p_public_key_y,
|  | const OCTETSTRING & | p_hashid8,
|  | const OCTETSTRING & | p_issuer,
|  | const OCTETSTRING & | p_private_enc_key,
|  | const OCTETSTRING & | p_public_enc_key_x,
|  | const OCTETSTRING & | p_public_enc_key_y
| ) |  |

## verify_and_extract_gn_payload()

int security_services::verify_and_extract_gn_payload | ( | const OCTETSTRING & | p_secured_gn_payload,
|  | const bool | p_verify,
|  | IEEE1609dot2::Ieee1609Dot2Data & | p_ieee_1609dot2_data,
|  | OCTETSTRING & | p_unsecured_gn_payload,
|  | Params & | p_params
| ) |  |

Verify and extract the unsecured payload from the provided secured payload. The secured payload could signed only, encryted only or signed and encrypted.

Parameters

  [in] | p_secured_gn_payload | The secured payload to be processed
  [in] | p_verify | Set to true if security checks shall be applied
  [out] | p_unsecured_gn_payload | The extracted payload
  [out] | p_ieee_1609dot2_data | The secured message
  [in,out] | p_params | The Test System parameters

Returns
  0 on success, negative value otherwise

## verify_sign_ecdsa_nistp256()

int security_services::verify_sign_ecdsa_nistp256 | ( | const OCTETSTRING & | p_hash,
|  | const IEEE1609dot2BaseTypes::Signature & | p_signature,
|  | const std::string & | p_certificate_id,
|  | Params & | p_params
| ) |  |

private

## Member Data Documentation

## _ec_keys_dec

std::unique_ptr<security_ecc> security_services::_ec_keys_dec

private

## _ec_keys_enc

std::unique_ptr<security_ecc> security_services::_ec_keys_enc

private

## _elevation

int security_services::_elevation

private

## _last_generation_time

unsigned long long security_services::_last_generation_time

private

## _latitude

int security_services::_latitude

private

## _longitude

int security_services::_longitude

private

## _security_cache

std::unique_ptr<security_cache> security_services::_security_cache

private

## _security_db

std::unique_ptr<security_db> security_services::_security_db

private

## _setup_done

bool security_services::_setup_done

private

## _unknown_certificate

std::vector<unsigned char> security_services::_unknown_certificate

private

## instance

security_services * security_services::instance = nullptr

staticprivate

Unique static object reference of this class.

## ProtocolVersion

constexpr unsigned int security_services::ProtocolVersion = 3

staticprivate

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

- /home/vagrant/TriesAndDelete/etsi_its/framework/include/security_services.hh
- /home/vagrant/TriesAndDelete/etsi_its/framework/src/security_services.cc