• OctoMY API
  • OctoMY API Reference
  • C++ Classes
  • OctoMY
  • Pki
  • oc_crypt::Pki Class

    Wraps one mbedTLS public-key context for RSA and EC keys. More...

    Header: #include <Pki>

    Detailed Description

    A Pki wraps an mbedtls_pk_context and its own random generator. Load a key from PEM data or a file with parseKey(), parsePublicKey() or their From variants, or create an RSA key pair with generateKeyPair(), which uses the public exponent 65537. getPEMKey() and getPEMPubkey() write the key back as PEM text. sign() and verify() hash the message with the given algorithm first. With no hash algorithm, a message shorter than the key is used as it is. The parse, generate and verify functions return the mbedTLS error code, 0 on success.

    The class cannot be copied. RSAKeyPrivate holds one Pki for the key it represents, and PKIManager uses one to generate keys.