14#include "keyple/card/calypso/CommandGenerateAsymmetricKeyPair.hpp"
20#include "keyple/card/calypso/CardAccessForbiddenException.hpp"
21#include "keyple/card/calypso/CardDataAccessException.hpp"
22#include "keyple/card/calypso/CardIllegalParameterException.hpp"
23#include "keyple/card/calypso/CardSecurityContextException.hpp"
24#include "keyple/card/calypso/CardSecurityDataException.hpp"
25#include "keyple/card/calypso/CardTerminatedException.hpp"
26#include "keyple/core/util/ApduUtil.hpp"
27#include "keyple/core/util/HexUtil.hpp"
28#include "keypop/calypso/card/transaction/CryptoException.hpp"
29#include "keypop/calypso/card/transaction/CryptoIOException.hpp"
30#include "keypop/calypso/card/transaction/InvalidPinException.hpp"
31#include "keypop/calypso/crypto/symmetric/SymmetricCryptoException.hpp"
32#include "keypop/calypso/crypto/symmetric/SymmetricCryptoIOException.hpp"
38using keyple::core::util::ApduUtil;
39using keyple::core::util::HexUtil;
40using keypop::calypso::card::transaction::CryptoException;
41using keypop::calypso::card::transaction::CryptoIOException;
42using keypop::calypso::card::transaction::InvalidPinException;
43using keypop::calypso::crypto::symmetric::SymmetricCryptoException;
44using keypop::calypso::crypto::symmetric::SymmetricCryptoIOException;
46const std::string CommandGenerateAsymmetricKeyPair::SECP256R1_OID
47 =
"06082A8648CE3D030107";
49const std::map<int, const std::shared_ptr<Command::StatusProperties>>
50 CommandGenerateAsymmetricKeyPair::STATUS_TABLE = [] {
51 std::map<int, const std::shared_ptr<Command::StatusProperties>> m(
52 Command::STATUS_TABLE);
56 std::make_shared<StatusProperties>(
57 "Lc value not supported",
typeid(CardDataAccessException))},
59 std::make_shared<StatusProperties>(
60 "Conditions of use not satisfied: a secure session is "
61 "running or a card key pair already available",
62 typeid(CardAccessForbiddenException))},
64 std::make_shared<StatusProperties>(
65 "Incorrect file type: the current DF is not an autonomous "
67 typeid(CardDataAccessException))},
69 std::make_shared<StatusProperties>(
70 "Incorrect incoming data",
71 typeid(CardIllegalParameterException))},
73 std::make_shared<StatusProperties>(
74 "PKI mode not available",
75 typeid(CardIllegalParameterException))}});
79CommandGenerateAsymmetricKeyPair::CommandGenerateAsymmetricKeyPair(
80 const std::shared_ptr<DtoAdapters::TransactionContextDto>&
82 const std::shared_ptr<DtoAdapters::CommandContextDto>& commandContext)
84 CardCommandRef::GENERATE_ASYMMETRIC_KEY_PAIR,
85 std::unique_ptr<int>(new int(0)),
91 std::make_shared<DtoAdapters::ApduRequestAdapter>(ApduUtil::build(
92 getTransactionContext()->getCard()->getCardClass().getValue(),
93 getCommandRef().getInstructionByte(),
96 HexUtil::toByteArray(SECP256R1_OID))));
100CommandGenerateAsymmetricKeyPair::finalizeRequest()
106CommandGenerateAsymmetricKeyPair::isCryptoServiceRequiredToFinalizeRequest()
113CommandGenerateAsymmetricKeyPair::synchronizeCryptoServiceBeforeCardProcessing()
120CommandGenerateAsymmetricKeyPair::parseResponse(
121 std::shared_ptr<ApduResponseApi> apduResponse)
123 Command::setApduResponseAndCheckStatus(apduResponse);
126const std::map<int, const std::shared_ptr<Command::StatusProperties>>&
127CommandGenerateAsymmetricKeyPair::getStatusTable()
const