AWS IoT Device SDK C++ v2: Aws::Crt::Io::Pkcs11Lib Class Reference

AWS IoT Device SDK C++ v2 1.14.0 AWS IoT Device SDK C++ v2

Public Types | Public Member Functions | Static Public Member Functions | List of all members
Aws::Crt::Io::Pkcs11Lib Class Reference

`#include <Pkcs11.h>`

## Public Types
enum class | InitializeFinalizeBehavior { Default , Omit , Strict }

## Public Member Functions
| ~Pkcs11Lib ()

## Static Public Member Functions
static std::shared_ptr< Pkcs11Lib > | Create (const String &filename, Allocator *allocator=g_allocator)
static std::shared_ptr< Pkcs11Lib > | Create (const String &filename, InitializeFinalizeBehavior initializeFinalizeBehavior, Allocator *allocator=g_allocator)

## Detailed Description

Handle to a loaded PKCS#11 library.

For most use cases, a single instance of Pkcs11Lib should be used for the lifetime of your application.

## Member Enumeration Documentation

## ◆ InitializeFinalizeBehavior

enum class Aws::Crt::Io::Pkcs11Lib::InitializeFinalizeBehavior
| strong

Controls how Pkcs11Lib calls `C_Initialize()` and `C_Finalize()` on the PKCS#11 library.

Enumerator
Default | Default behavior that accommodates most use cases. `C_Initialize()` is called on creation, and "already-initialized" errors are ignored. `C_Finalize()` is never called, just in case another part of your application is still using the PKCS#11 library.
Omit | Skip calling `C_Initialize()` and `C_Finalize()`. Use this if your application has already initialized the PKCS#11 library, and you do not want `C_Initialize()` called again.
Strict | `C_Initialize()` is called on creation and `C_Finalize()` is called on cleanup. If `C_Initialize()` reports that's it's already initialized, this is treated as an error. Use this if you need perfect cleanup (ex: running valgrind with –leak-check).

## Constructor & Destructor Documentation

## ◆ ~Pkcs11Lib()

Aws::Crt::Io::Pkcs11Lib::~Pkcs11Lib | ( |  | ) |

## Member Function Documentation

## ◆ Create() [1/2]

std::shared_ptr< Pkcs11Lib > Aws::Crt::Io::Pkcs11Lib::Create | ( | const String & | filename,
|  | Allocator * | allocator = `g_allocator`
| ) |  |
| static

Load and initialize a PKCS#11 library.

`C_Initialize()` and `C_Finalize()` are called on the PKCS#11 library in the InitializeFinalizeBehavior::Default way.

Parameters

  filename | Name or path of PKCS#11 library file to load (UTF-8). Pass an empty string if your application already has PKCS#11 symbols linked in.
  allocator | Memory allocator to use.

Returns
  If successful a `shared_ptr` containing the Pkcs11Lib is returned. If unsuccessful the `shared_ptr` will be empty, and Aws::Crt::LastError() will contain the error that occurred.

## ◆ Create() [2/2]

std::shared_ptr< Pkcs11Lib > Aws::Crt::Io::Pkcs11Lib::Create | ( | const String & | filename,
|  | InitializeFinalizeBehavior | initializeFinalizeBehavior,
|  | Allocator * | allocator = `g_allocator`
| ) |  |
| static

Load a PKCS#11 library, specifying how `C_Initialize()` and `C_Finalize()` will be called.

Parameters

  filename | Name or path of PKCS#11 library file to load (UTF-8). Pass an empty string if your application already has PKCS#11 symbols linked in.
  initializeFinalizeBehavior | Specifies how `C_Initialize()` and `C_Finalize()` will be called on the PKCS#11 library.
  allocator | Memory allocator to use.

Returns
  If successful a `shared_ptr` containing the Pkcs11Lib is returned. If unsuccessful the `shared_ptr` will be empty, and Aws::Crt::LastError() will contain the error that occurred.

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

- crt/aws-crt-cpp/include/aws/crt/io/Pkcs11.h
- crt/aws-crt-cpp/source/io/Pkcs11.cpp