keyple-card-calypso-crypto-legacysam-cpp-lib - 1.0.2
Component of the Keyple C++ middleware
FreeTransactionManagerAdapter.cpp
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2023 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional *
5 * information regarding copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the *
8 * terms of the Eclipse Public License 2.0 which is available at *
9 * http://www.eclipse.org/legal/epl-2.0 *
10 * *
11 * SPDX-License-Identifier: EPL-2.0 *
12 ******************************************************************************/
13
14#include "keyple/card/calypso/crypto/legacysam/FreeTransactionManagerAdapter.hpp"
15
16#include <memory>
17#include <set>
18#include <string>
19#include <vector>
20
21#include "keyple/card/calypso/crypto/legacysam/CommandCardGenerateAsymmetricKeyPair.hpp"
22#include "keyple/card/calypso/crypto/legacysam/CommandDataCipher.hpp"
23#include "keyple/card/calypso/crypto/legacysam/CommandGetData.hpp"
24#include "keyple/card/calypso/crypto/legacysam/CommandPsoComputeCertificate.hpp"
25#include "keyple/card/calypso/crypto/legacysam/CommandPsoComputeSignature.hpp"
26#include "keyple/card/calypso/crypto/legacysam/CommandPsoVerifySignature.hpp"
27#include "keyple/card/calypso/crypto/legacysam/CommandReadCeilings.hpp"
28#include "keyple/card/calypso/crypto/legacysam/CommandReadCounter.hpp"
29#include "keyple/card/calypso/crypto/legacysam/CommandReadKeyParameters.hpp"
30#include "keyple/card/calypso/crypto/legacysam/CommandReadParameters.hpp"
31#include "keyple/card/calypso/crypto/legacysam/CommandSelectDiversifier.hpp"
32#include "keyple/card/calypso/crypto/legacysam/CommandWriteKey.hpp"
33#include "keyple/card/calypso/crypto/legacysam/DtoAdapters.hpp"
34#include "keyple/card/calypso/crypto/legacysam/LegacySamAdapter.hpp"
35#include "keyple/card/calypso/crypto/legacysam/LegacySamConstants.hpp"
36#include "keyple/core/util/ByteArrayUtil.hpp"
37#include "keyple/core/util/HexUtil.hpp"
38#include "keyple/core/util/KeypleAssert.hpp"
39#include "keyple/core/util/cpp/exception/IllegalArgumentException.hpp"
40#include "keypop/calypso/crypto/legacysam/transaction/ReaderIOException.hpp"
41#include "keypop/calypso/crypto/legacysam/transaction/SamIOException.hpp"
42#include "keypop/calypso/crypto/legacysam/transaction/SamRevokedException.hpp"
43#include "keypop/calypso/crypto/legacysam/transaction/UnexpectedCommandStatusException.hpp"
44#include "keypop/reader/CardCommunicationException.hpp"
45#include "keypop/reader/InvalidCardResponseException.hpp"
46#include "keypop/reader/ReaderCommunicationException.hpp"
47
48namespace keyple {
49namespace card {
50namespace calypso {
51namespace crypto {
52namespace legacysam {
53
54using keyple::core::util::Assert;
55using keyple::core::util::ByteArrayUtil;
56using keyple::core::util::HexUtil;
57using keyple::core::util::cpp::exception::IllegalArgumentException;
58using keypop::calypso::crypto::legacysam::transaction::ReaderIOException;
59using keypop::calypso::crypto::legacysam::transaction::SamIOException;
60using keypop::calypso::crypto::legacysam::transaction::SamRevokedException;
61using keypop::calypso::crypto::legacysam::transaction::
62 UnexpectedCommandStatusException;
63using keypop::reader::CardCommunicationException;
64using keypop::reader::InvalidCardResponseException;
65using keypop::reader::ReaderCommunicationException;
66
72
73const std::string FreeTransactionManagerAdapter::MSG_INPUT_OUTPUT_DATA
74 = "input/output data";
75const std::string FreeTransactionManagerAdapter::MSG_SIGNATURE_SIZE
76 = "signature size";
77const std::string
78 FreeTransactionManagerAdapter::MSG_KEY_DIVERSIFIER_SIZE_IS_IN_RANGE_1_8
79 = "key diversifier size is in range [1..8]";
80
81FreeTransactionManagerAdapter::FreeTransactionManagerAdapter(
82 std::shared_ptr<ProxyReaderApi> targetSamReader,
83 std::shared_ptr<LegacySamAdapter> targetSam)
84: CommonTransactionManagerAdapter(targetSamReader, targetSam, nullptr, nullptr)
85, mSamKeyDiversifier(targetSam->getSerialNumber())
86{
87}
88
89FreeTransactionManager&
90FreeTransactionManagerAdapter::prepareGetData(GetDataTag tag)
91{
92 addTargetSamCommand(std::make_shared<CommandGetData>(getContext(), tag));
93
94 return *this;
95}
96
97FreeTransactionManager&
98FreeTransactionManagerAdapter::prepareGenerateCardAsymmetricKeyPair(
99 std::shared_ptr<KeyPairContainer> keyPairContainer)
100{
101 Assert::getInstance().notNull(keyPairContainer, "keyPairContainer");
102 if (!std::dynamic_pointer_cast<KeyPairContainerAdapter>(keyPairContainer)) {
103 throw IllegalArgumentException(
104 "Cannot cast 'keyPairContainer' to KeyPairContainerAdapter");
105 }
106 addTargetSamCommand(
107 std::make_shared<CommandCardGenerateAsymmetricKeyPair>(
108 getContext(), keyPairContainer));
109
110 return *this;
111}
112
113FreeTransactionManager&
114FreeTransactionManagerAdapter::prepareComputeCardCertificate(
115 std::shared_ptr<LegacyCardCertificateComputationData> data)
116{
117 Assert::getInstance().notNull(data, "data");
118 if (!std::dynamic_pointer_cast<LegacyCardCertificateComputationDataAdapter>(
119 data)) {
120 throw IllegalArgumentException(
121 "Cannot cast 'data' to "
122 "LegacyCardCertificateComputationDataAdapter");
123 }
124 addTargetSamCommand(
125 std::make_shared<CommandPsoComputeCertificate>(getContext(), data));
126
127 return *this;
128}
129
130FreeTransactionManager&
131FreeTransactionManagerAdapter::preparePlainWriteLock(
132 uint8_t lockIndex,
133 uint8_t lockParameters,
134 const std::vector<uint8_t>& lockValue)
135{
136 Assert::getInstance().isEqual(
137 lockValue.size(),
138 LegacySamConstants::LOCK_VALUE_LENGTH,
139 "lockValue.length");
140
141 addTargetSamCommand(
142 std::make_shared<CommandWriteKey>(
143 getContext(),
144 CommandWriteKey::buildPlainLockDataBlock(
145 lockIndex, lockParameters, lockValue)));
146
147 return *this;
148}
149
150FreeTransactionManager&
151FreeTransactionManagerAdapter::prepareComputeSignature(
152 std::shared_ptr<SignatureComputationDataBase> data)
153{
154 std::shared_ptr<BasicSignatureComputationDataAdapter> basicDataAdapter(
155 std::dynamic_pointer_cast<BasicSignatureComputationDataAdapter>(data));
156 if (basicDataAdapter) {
157 // Basic signature
158 Assert::getInstance()
159 .notNull(basicDataAdapter, MSG_INPUT_OUTPUT_DATA)
160 .isInRange(
161 basicDataAdapter->getData().size(),
162 1,
163 208,
164 "length of data to sign")
165 .isTrue(
166 basicDataAdapter->getData().size() % 8 == 0,
167 "length of data to sign is a multiple of 8")
168 .isInRange(
169 basicDataAdapter->getSignatureSize(), 1, 8, MSG_SIGNATURE_SIZE)
170 .isTrue(
171 !basicDataAdapter->hasKeyDiversifier()
172 || (basicDataAdapter->getKeyDiversifier().size() >= 1
173 && basicDataAdapter->getKeyDiversifier().size() <= 8),
174 MSG_KEY_DIVERSIFIER_SIZE_IS_IN_RANGE_1_8);
175
176 prepareSelectDiversifierIfNeeded(basicDataAdapter->getKeyDiversifier());
177 addTargetSamCommand(
178 std::make_shared<CommandDataCipher>(
179 getContext(), basicDataAdapter, nullptr));
180
181 } else {
182 std::shared_ptr<TraceableSignatureComputationDataAdapter>
183 traceableDataAdapter(
184 std::dynamic_pointer_cast<
186 if (traceableDataAdapter) {
187 // Traceable signature
188 bool traceabilityOffsetInRange
189 = !traceableDataAdapter->isSamTraceabilityMode()
190 || (traceableDataAdapter->getTraceabilityOffset() >= 0
191 && traceableDataAdapter->getTraceabilityOffset()
192 <= static_cast<int>(
193 ((traceableDataAdapter->getData().size() * 8)
194 - (traceableDataAdapter
195 ->getSamTraceabilityMode()
196 == SamTraceabilityMode::
197 TRUNCATED_SERIAL_NUMBER
198 ? 7 * 8
199 : 8 * 8))));
200 Assert::getInstance()
201 .notNull(traceableDataAdapter, "input/output data")
202 .isInRange(
203 traceableDataAdapter->getData().size(),
204 1,
205 traceableDataAdapter->isSamTraceabilityMode() ? 206 : 208,
206 "length of data to sign")
207 .isInRange(
208 traceableDataAdapter->getSignatureSize(),
209 1,
210 8,
211 "signature size")
212 .isTrue(
213 traceabilityOffsetInRange,
214 "traceability offset is in range")
215 .isTrue(
216 !traceableDataAdapter->hasKeyDiversifier()
217 || (traceableDataAdapter->getKeyDiversifier().size()
218 >= 1
219 && traceableDataAdapter->getKeyDiversifier().size()
220 <= 8),
221 "key diversifier size is in range [1..8]");
222
223 prepareSelectDiversifierIfNeeded(
224 traceableDataAdapter->getKeyDiversifier());
225 addTargetSamCommand(
226 std::make_shared<CommandPsoComputeSignature>(
227 getContext(), traceableDataAdapter));
228
229 } else {
230 throw IllegalArgumentException(
231 "Cannot cast 'data' to BasicSignatureComputationDataAdapter or "
232 "TraceableSignatureComputationDataAdapter");
233 }
234 }
235
236 return *this;
237}
238
239FreeTransactionManager&
240FreeTransactionManagerAdapter::prepareVerifySignature(
241 std::shared_ptr<SignatureVerificationDataBase> data)
242{
243 std::shared_ptr<BasicSignatureVerificationDataAdapter> basicDataAdapter(
244 std::dynamic_pointer_cast<BasicSignatureVerificationDataAdapter>(data));
245 if (basicDataAdapter) {
246 // Basic signature
247 Assert::getInstance()
248 .notNull(basicDataAdapter, MSG_INPUT_OUTPUT_DATA)
249 .isInRange(
250 basicDataAdapter->getData().size(),
251 1,
252 208,
253 "length of signed data to verify")
254 .isTrue(
255 basicDataAdapter->getData().size() % 8 == 0,
256 "length of data to verify is a multiple of 8")
257 .isInRange(
258 basicDataAdapter->getSignature().size(),
259 1,
260 8,
261 MSG_SIGNATURE_SIZE)
262 .isTrue(
263 !basicDataAdapter->hasKeyDiversifier()
264 || (basicDataAdapter->getKeyDiversifier().size() >= 1
265 && basicDataAdapter->getKeyDiversifier().size() <= 8),
266 "key diversifier size is in range [1..8]");
267
268 prepareSelectDiversifierIfNeeded(basicDataAdapter->getKeyDiversifier());
269 addTargetSamCommand(
270 std::make_shared<CommandDataCipher>(
271 getContext(), nullptr, basicDataAdapter));
272
273 } else {
274 std::shared_ptr<TraceableSignatureVerificationDataAdapter>
275 traceableDataAdapter(
276 std::dynamic_pointer_cast<
277 TraceableSignatureVerificationDataAdapter>(data));
278 if (traceableDataAdapter) {
279 // Traceable signature
280 const bool isTracebilityOffsetInRange
281 = !traceableDataAdapter->isSamTraceabilityMode()
282 || (traceableDataAdapter->getTraceabilityOffset() >= 0
283 && traceableDataAdapter->getTraceabilityOffset()
284 <= static_cast<int>(
285 ((traceableDataAdapter->getData().size() * 8)
286 - (traceableDataAdapter
287 ->getSamTraceabilityMode()
288 == SamTraceabilityMode::
289 TRUNCATED_SERIAL_NUMBER
290 ? 7 * 8
291 : 8 * 8))));
292
293 Assert::getInstance()
294 .notNull(traceableDataAdapter, "input/output data")
295 .isInRange(
296 traceableDataAdapter->getData().size(),
297 1,
298 traceableDataAdapter->isSamTraceabilityMode() ? 206 : 208,
299 "length of signed data to verify")
300 .isInRange(
301 traceableDataAdapter->getSignature().size(),
302 1,
303 8,
304 "signature size")
305 .isTrue(
306 isTracebilityOffsetInRange,
307 "traceability offset is in range")
308 .isTrue(
309 !traceableDataAdapter->hasKeyDiversifier()
310 || (traceableDataAdapter->getKeyDiversifier().size()
311 >= 1
312 && traceableDataAdapter->getKeyDiversifier().size()
313 <= 8),
314 MSG_KEY_DIVERSIFIER_SIZE_IS_IN_RANGE_1_8);
315
316 // Check SAM revocation status if requested.
317 if (traceableDataAdapter->getSamRevocationService()) {
318 // Extract the SAM serial number and the counter value from the
319 // data.
320 std::vector<uint8_t> samSerialNumber
321 = ByteArrayUtil::extractBytes(
322 traceableDataAdapter->getData(),
323 traceableDataAdapter->getTraceabilityOffset(),
324 traceableDataAdapter->getSamTraceabilityMode()
325 == SamTraceabilityMode::TRUNCATED_SERIAL_NUMBER
326 ? 3
327 : 4);
328
329 int samCounterValue = ByteArrayUtil::extractInt(
330 ByteArrayUtil::extractBytes(
331 traceableDataAdapter->getData(),
332 traceableDataAdapter->getTraceabilityOffset()
333 + (traceableDataAdapter->getSamTraceabilityMode()
334 == SamTraceabilityMode::
335 TRUNCATED_SERIAL_NUMBER
336 ? 3 * 8
337 : 4 * 8),
338 3),
339 0,
340 3,
341 false);
342
343 // Is SAM revoked ?
344 if (traceableDataAdapter->getSamRevocationService()
345 ->isSamRevoked(samSerialNumber, samCounterValue)) {
346 throw SamRevokedException(
347 "SAM is revoked. Serial number: "
348 + HexUtil::toHex(samSerialNumber) + "h, Counter value: "
349 + std::to_string(samCounterValue));
350 }
351 }
352
353 prepareSelectDiversifierIfNeeded(
354 traceableDataAdapter->getKeyDiversifier());
355 addTargetSamCommand(
356 std::make_shared<CommandPsoVerifySignature>(
357 getContext(), traceableDataAdapter));
358
359 } else {
360 throw IllegalArgumentException(
361 "Cannot cast 'data' to BasicSignatureVerificationDataAdapter "
362 "or TraceableSignatureVerificationDataAdapter");
363 }
364 }
365
366 return *this;
367}
368
369FreeTransactionManager&
370FreeTransactionManagerAdapter::prepareReadSamParameters()
371{
372 addTargetSamCommand(std::make_shared<CommandReadParameters>(getContext()));
373
374 return *this;
375}
376
377FreeTransactionManager&
378FreeTransactionManagerAdapter::prepareReadSystemKeyParameters(
379 SystemKeyType systemKeyType)
380{
381 addTargetSamCommand(
382 std::make_shared<CommandReadKeyParameters>(
383 getContext(), systemKeyType));
384
385 return *this;
386}
387
388FreeTransactionManager&
389FreeTransactionManagerAdapter::prepareReadWorkKeyParameters(int recordNumber)
390{
391 Assert::getInstance().isInRange(
392 recordNumber,
393 LegacySamConstants::MIN_KEY_RECORD_NUMBER,
394 LegacySamConstants::MAX_KEY_RECORD_NUMBER,
395 "recordNumber");
396 addTargetSamCommand(
397 std::make_shared<CommandReadKeyParameters>(getContext(), recordNumber));
398
399 return *this;
400}
401
402FreeTransactionManager&
403FreeTransactionManagerAdapter::prepareReadWorkKeyParameters(
404 uint8_t kif, uint8_t kvc)
405{
406 addTargetSamCommand(
407 std::make_shared<CommandReadKeyParameters>(getContext(), kif, kvc));
408
409 return *this;
410}
411
412FreeTransactionManager&
413FreeTransactionManagerAdapter::prepareReadCounterStatus(int counterNumber)
414{
415 Assert::getInstance().isInRange(
416 counterNumber,
417 LegacySamConstants::MIN_COUNTER_NUMBER,
418 LegacySamConstants::MAX_COUNTER_NUMBER,
419 "counterNumber");
420 for (const auto& command : getTargetSamCommands()) {
421 auto readCounterCommand
422 = std::dynamic_pointer_cast<CommandReadCounter>(command);
423 if (readCounterCommand
424 && readCounterCommand->getCounterFileRecordNumber()
425 == LegacySamConstants::COUNTER_TO_RECORD_LOOKUP
426 [counterNumber]) {
427 // already scheduled
428 return *this;
429 }
430 }
431 addTargetSamCommand(
432 std::make_shared<CommandReadCounter>(
433 getContext(),
434 LegacySamConstants::COUNTER_TO_RECORD_LOOKUP[counterNumber]));
435 addTargetSamCommand(
436 std::make_shared<CommandReadCeilings>(
437 getContext(),
438 LegacySamConstants::COUNTER_TO_RECORD_LOOKUP[counterNumber]));
439
440 return *this;
441}
442
443FreeTransactionManager&
444FreeTransactionManagerAdapter::prepareReadAllCountersStatus()
445{
446 for (int i = 0; i < 3; i++) {
447 addTargetSamCommand(
448 std::make_shared<CommandReadCounter>(getContext(), i));
449 addTargetSamCommand(
450 std::make_shared<CommandReadCeilings>(getContext(), i));
451 }
452
453 return *this;
454}
455
456std::string
457FreeTransactionManagerAdapter::exportTargetSamContextForAsyncTransaction()
458{
459 std::vector<std::shared_ptr<Command>> commands;
460
461 // read system key parameters if not available
462 if (!getContext()->getTargetSam()->getSystemKeyParameter(
463 SystemKeyType::PERSONALIZATION)) {
464 commands.push_back(
465 std::make_shared<CommandReadKeyParameters>(
466 getContext(), SystemKeyType::PERSONALIZATION));
467 }
468 if (!getContext()->getTargetSam()->getSystemKeyParameter(
469 SystemKeyType::KEY_MANAGEMENT)) {
470 commands.push_back(
471 std::make_shared<CommandReadKeyParameters>(
472 getContext(), SystemKeyType::KEY_MANAGEMENT));
473 }
474 if (!getContext()->getTargetSam()->getSystemKeyParameter(
475 SystemKeyType::RELOADING)) {
476 commands.push_back(
477 std::make_shared<CommandReadKeyParameters>(
478 getContext(), SystemKeyType::RELOADING));
479 }
480 processTargetSamCommands(commands);
481 commands.clear();
482
483 // The parameter PAR4 of each key contains the associated counter number (if
484 // a key has no associated counter, the value of its PAR4 is set to 0)
485 int counterPersonalization
486 = getContext()
487 ->getTargetSam()
488 ->getSystemKeyParameter(SystemKeyType::PERSONALIZATION)
489 ->getParameterValue(4)
490 & 0xFF;
491 int counterKeyManagement
492 = getContext()
493 ->getTargetSam()
494 ->getSystemKeyParameter(SystemKeyType::KEY_MANAGEMENT)
495 ->getParameterValue(4)
496 & 0xFF;
497 int counterReloading = getContext()
498 ->getTargetSam()
499 ->getSystemKeyParameter(SystemKeyType::RELOADING)
500 ->getParameterValue(4)
501 & 0xFF;
502
503 // store serial number, KVCs and counter number if any in the target SAM
504 // context
505 auto targetSamContextDto
506 = std::make_shared<DtoAdapters::TargetSamContextDto>(
507 getContext()->getTargetSam()->getSerialNumber(), false);
508 targetSamContextDto
509 ->getSystemKeyTypeToKvcMap()[SystemKeyType::PERSONALIZATION]
510 = getContext()
511 ->getTargetSam()
512 ->getSystemKeyParameter(SystemKeyType::PERSONALIZATION)
513 ->getKvc();
514 targetSamContextDto
515 ->getSystemKeyTypeToKvcMap()[SystemKeyType::KEY_MANAGEMENT]
516 = getContext()
517 ->getTargetSam()
518 ->getSystemKeyParameter(SystemKeyType::KEY_MANAGEMENT)
519 ->getKvc();
520 targetSamContextDto->getSystemKeyTypeToKvcMap()[SystemKeyType::RELOADING]
521 = getContext()
522 ->getTargetSam()
523 ->getSystemKeyParameter(SystemKeyType::RELOADING)
524 ->getKvc();
525 if (counterPersonalization != 0) {
526 targetSamContextDto->getSystemKeyTypeToCounterNumberMap()
527 [SystemKeyType::PERSONALIZATION] = counterPersonalization;
528 }
529 if (counterKeyManagement != 0) {
530 targetSamContextDto->getSystemKeyTypeToCounterNumberMap()
531 [SystemKeyType::KEY_MANAGEMENT] = counterKeyManagement;
532 }
533 if (counterReloading != 0) {
534 targetSamContextDto
535 ->getSystemKeyTypeToCounterNumberMap()[SystemKeyType::RELOADING]
536 = counterReloading;
537 }
538
539 // compute needed counter file records
540 std::set<int> counterFileRecordNumbers;
541 if (counterPersonalization != 0) {
542 counterFileRecordNumbers.insert(
543 LegacySamConstants::COUNTER_TO_RECORD_LOOKUP
544 [counterPersonalization]);
545 }
546 if (counterKeyManagement != 0) {
547 counterFileRecordNumbers.insert(
548 LegacySamConstants::COUNTER_TO_RECORD_LOOKUP[counterKeyManagement]);
549 }
550 if (counterReloading != 0) {
551 counterFileRecordNumbers.insert(
552 LegacySamConstants::COUNTER_TO_RECORD_LOOKUP[counterReloading]);
553 }
554
555 // read counters
556 for (int counterFileRecordNumber : counterFileRecordNumbers) {
557 commands.push_back(
558 std::make_shared<CommandReadCounter>(
559 getContext(), counterFileRecordNumber));
560 }
561 processTargetSamCommands(commands);
562
563 if (counterPersonalization != 0) {
564 targetSamContextDto
565 ->getCounterNumberToCounterValueMap()[counterPersonalization] = *(
566 getContext()->getTargetSam()->getCounter(counterPersonalization));
567 }
568 if (counterKeyManagement != 0) {
569 targetSamContextDto
570 ->getCounterNumberToCounterValueMap()[counterKeyManagement]
571 = *(getContext()->getTargetSam()->getCounter(counterKeyManagement));
572 }
573 if (counterReloading != 0) {
574 targetSamContextDto
575 ->getCounterNumberToCounterValueMap()[counterReloading]
576 = *(getContext()->getTargetSam()->getCounter(counterReloading));
577 }
578
579 // export as json
580 // This is a placeholder implementation.
581 return "{}";
582}
583
584FreeTransactionManager&
585FreeTransactionManagerAdapter::processCommands()
586{
587 try {
588 return processCommands(ChannelControl::KEEP_OPEN);
589 } catch (const ReaderCommunicationException& e) {
590 throw ReaderIOException(e.what(), e);
591 } catch (const CardCommunicationException& e) {
592 throw SamIOException(e.what(), e);
593 } catch (const InvalidCardResponseException& e) {
594 throw UnexpectedCommandStatusException(e.what(), e);
595 }
596}
597
598FreeTransactionManager&
599FreeTransactionManagerAdapter::processCommands(ChannelControl channelControl)
600{
601 processTargetSamCommands(channelControl);
602
603 return *this;
604}
605
606void
607FreeTransactionManagerAdapter::prepareSelectDiversifierIfNeeded(
608 const std::vector<uint8_t>& specificKeyDiversifier)
609{
610 if (!specificKeyDiversifier.empty()) {
611 if (specificKeyDiversifier != mCurrentKeyDiversifier) {
612 mCurrentKeyDiversifier = specificKeyDiversifier;
613 prepareSelectDiversifier();
614 }
615
616 } else {
617 prepareSelectDiversifierIfNeeded();
618 }
619}
620
621void
622FreeTransactionManagerAdapter::prepareSelectDiversifierIfNeeded()
623{
624 if (mCurrentKeyDiversifier != mSamKeyDiversifier) {
625 mCurrentKeyDiversifier = mSamKeyDiversifier;
626 prepareSelectDiversifier();
627 }
628}
629
630void
631FreeTransactionManagerAdapter::prepareSelectDiversifier()
632{
633 addTargetSamCommand(
634 std::make_shared<CommandSelectDiversifier>(
635 getContext(), mCurrentKeyDiversifier));
636}
637
638} /* namespace legacysam */
639} /* namespace crypto */
640} /* namespace calypso */
641} /* namespace card */
642} /* namespace keyple */
DtoAdapters::BasicSignatureComputationDataAdapter BasicSignatureComputationDataAdapter
DtoAdapters::TraceableSignatureComputationDataAdapter TraceableSignatureComputationDataAdapter
DtoAdapters::KeyPairContainerAdapter KeyPairContainerAdapter