AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
PKCS11Session.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ACSDKPKCS11_PRIVATE_PKCS11SESSION_H_
17 #define ACSDKPKCS11_PRIVATE_PKCS11SESSION_H_
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 
24 
25 namespace alexaClientSDK {
26 namespace acsdkPkcs11 {
27 
28 class PKCS11Functions;
29 class PKCS11Key;
31 
38 class PKCS11Session : public std::enable_shared_from_this<PKCS11Session> {
39 public:
41  ~PKCS11Session() noexcept;
42 
50  bool logIn(const std::string& userPin) noexcept;
51 
57  bool logOut() noexcept;
58 
66  std::unique_ptr<PKCS11Key> findKey(const PKCS11KeyDescriptor& descriptor) noexcept;
67 
68 private:
69  friend class PKCS11Key;
70  friend class PKCS11Slot;
71 
78  PKCS11Session(const std::shared_ptr<PKCS11Functions>& functions, CK_SESSION_HANDLE sessionHandle) noexcept;
79 
85  bool closeSession() noexcept;
86 
88  std::mutex m_mutex;
89 
91  std::shared_ptr<PKCS11Functions> m_functions;
92 
94  CK_SESSION_HANDLE m_sessionHandle;
95 };
96 
97 } // namespace acsdkPkcs11
98 } // namespace alexaClientSDK
99 
100 #endif // ACSDKPKCS11_PRIVATE_PKCS11SESSION_H_
alexaClientSDK::acsdkPkcs11::PKCS11Session
PKCS11 session wrapper.
Definition: PKCS11Session.h:38
alexaClientSDK::acsdkPkcs11::PKCS11Functions
PKCS11 API Wrapper.
Definition: PKCS11Functions.h:47
alexaClientSDK::acsdkPkcs11::PKCS11Session::~PKCS11Session
~PKCS11Session() noexcept
Public destructor (closes session).
Definition: PKCS11Session.cpp:39
alexaClientSDK::acsdkPkcs11::PKCS11Slot
PKCS11 slot wrapper.
Definition: PKCS11Slot.h:36
alexaClientSDK::acsdkPkcs11::PKCS11Session::logOut
bool logOut() noexcept
Log out from HSM.
Definition: PKCS11Session.cpp:63
alexaClientSDK::acsdkPkcs11::PKCS11KeyDescriptor
Class to identify key object in HSM.
Definition: PKCS11KeyDescriptor.h:36
alexaClientSDK
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
alexaClientSDK::acsdkPkcs11::PKCS11Session::findKey
std::unique_ptr< PKCS11Key > findKey(const PKCS11KeyDescriptor &descriptor) noexcept
Loads existing key.
Definition: PKCS11Session.cpp:88
PKCS11KeyDescriptor.h
std
Definition: CapabilityConfiguration.h:190
alexaClientSDK::acsdkPkcs11::PKCS11Key
PKCS11 key object wrapper.
Definition: PKCS11Key.h:38
alexaClientSDK::acsdkCryptoInterfaces::AlgorithmType
AlgorithmType
Enumeration of all supported encryption protocols.
Definition: AlgorithmType.h:31
alexaClientSDK::acsdkPkcs11::PKCS11Session::logIn
bool logIn(const std::string &userPin) noexcept
Log into HSM.
Definition: PKCS11Session.cpp:43

AlexaClientSDK 1.26.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0