Keypop Calypso Crypto Symmetric C++ API - 0.1.1
Component of the Keypop C++ API
SymmetricCryptoCardTransactionManagerSpi.hpp
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * This program and the accompanying materials are made available under the *
5 * terms of the MIT License which is available at *
6 * https://opensource.org/licenses/MIT. *
7 * *
8 * SPDX-License-Identifier: MIT *
9 ******************************************************************************/
10
11#pragma once
12
13#include <memory>
14#include <vector>
15
19
20namespace keypop {
21namespace calypso {
22namespace crypto {
23namespace symmetric {
24namespace spi {
25
39public:
50 virtual std::vector<uint8_t> initTerminalSecureSessionContext() = 0;
51
66 const std::vector<uint8_t>& openSecureSessionDataOut,
67 const uint8_t kif,
68 const uint8_t kvc)
69 = 0;
70
85 virtual std::vector<uint8_t>
86 updateTerminalSessionMac(const std::vector<uint8_t>& cardApdu)
87 = 0;
88
99 virtual std::vector<uint8_t> finalizeTerminalSessionMac() = 0;
100
111 virtual std::vector<uint8_t> generateTerminalSessionMac() = 0;
112
121 virtual void activateEncryption() = 0;
122
131 virtual void deactivateEncryption() = 0;
132
144 virtual bool
145 isCardSessionMacValid(const std::vector<uint8_t>& cardSessionMac)
146 = 0;
147
158 const std::shared_ptr<SvCommandSecurityDataApi> data)
159 = 0;
160
171 virtual bool isCardSvMacValid(const std::vector<uint8_t>& cardSvMac) = 0;
172
191 virtual std::vector<uint8_t> cipherPinForPresentation(
192 const std::vector<uint8_t>& cardChallenge,
193 const std::vector<uint8_t>& pin,
194 const std::shared_ptr<uint8_t> kif,
195 const std::shared_ptr<uint8_t> kvc)
196 = 0;
197
217 virtual std::vector<uint8_t> cipherPinForModification(
218 const std::vector<uint8_t>& cardChallenge,
219 const std::vector<uint8_t>& currentPin,
220 const std::vector<uint8_t>& newPin,
221 const std::shared_ptr<uint8_t> kif,
222 const std::shared_ptr<uint8_t> kvc)
223 = 0;
224
240 virtual std::vector<uint8_t> generateCipheredCardKey(
241 const std::vector<uint8_t>& cardChallenge,
242 const uint8_t issuerKeyKif,
243 const uint8_t issuerKeyKvc,
244 const uint8_t targetKeyKif,
245 const uint8_t targetKeyKvc)
246 = 0;
247
257 virtual void synchronize() = 0;
258};
259
260} /* namespace spi */
261} /* namespace symmetric */
262} /* namespace crypto */
263} /* namespace calypso */
264} /* namespace keypop */
virtual void computeSvCommandSecurityData(const std::shared_ptr< SvCommandSecurityDataApi > data)=0
Computes the needed data to operate SV card commands.
virtual bool isCardSvMacValid(const std::vector< uint8_t > &cardSvMac)=0
Verifies the SV card MAC.
virtual std::vector< uint8_t > finalizeTerminalSessionMac()=0
Finalizes the digest computation and returns the terminal part of the session MAC.
virtual void deactivateEncryption()=0
Deactivates the encryption/decryption of the data sent/received during the secure session.
virtual void activateEncryption()=0
Activates the encryption/decryption of the data sent/received during the secure session.
virtual void initTerminalSessionMac(const std::vector< uint8_t > &openSecureSessionDataOut, const uint8_t kif, const uint8_t kvc)=0
Stores the data needed to initialize the session MAC computation for a Secure Session.
virtual bool isCardSessionMacValid(const std::vector< uint8_t > &cardSessionMac)=0
Verifies the card part of the session MAC finalizing the mutual authentication process.
virtual std::vector< uint8_t > generateCipheredCardKey(const std::vector< uint8_t > &cardChallenge, const uint8_t issuerKeyKif, const uint8_t issuerKeyKvc, const uint8_t targetKeyKif, const uint8_t targetKeyKvc)=0
Generates an encrypted key data block for loading a key into a card.
virtual void synchronize()=0
Synchronizes data of the associated card transaction crypto extension if needed.
virtual std::vector< uint8_t > updateTerminalSessionMac(const std::vector< uint8_t > &cardApdu)=0
Updates the digest computation with data sent or received from the card.
virtual std::vector< uint8_t > cipherPinForPresentation(const std::vector< uint8_t > &cardChallenge, const std::vector< uint8_t > &pin, const std::shared_ptr< uint8_t > kif, const std::shared_ptr< uint8_t > kvc)=0
Computes a block of encrypted data to be sent to the card for an enciphered PIN presentation.
virtual std::vector< uint8_t > initTerminalSecureSessionContext()=0
Initializes the crypto service context for operating a Secure Session with a card and gets the termin...
virtual std::vector< uint8_t > cipherPinForModification(const std::vector< uint8_t > &cardChallenge, const std::vector< uint8_t > &currentPin, const std::vector< uint8_t > &newPin, const std::shared_ptr< uint8_t > kif, const std::shared_ptr< uint8_t > kvc)=0
Computes a block of encrypted data to be sent to the card for a PIN modification.
virtual std::vector< uint8_t > generateTerminalSessionMac()=0
Generates the terminal part of the session MAC used for an early mutual authentication.