0% found this document useful (0 votes)
21 views766 pages

Host Function Guide

The Luna EFT Host Function Guide documents version 2.0.6, released in February 2016, detailing updates and support for various payment standards and functionalities. It includes comprehensive information on function construction, message formats, and key management among other technical specifications. The guide emphasizes the protection of intellectual property and provides contact information for SafeNet, Inc.

Uploaded by

amine.mamdouh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views766 pages

Host Function Guide

The Luna EFT Host Function Guide documents version 2.0.6, released in February 2016, detailing updates and support for various payment standards and functionalities. It includes comprehensive information on function construction, message formats, and key management among other technical specifications. The guide emphasizes the protection of intellectual property and provides contact information for SafeNet, Inc.

Uploaded by

amine.mamdouh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Luna EFT

Host Function Guide


Document Information
Document Information
Product Version 2.0.6

Document Part Number 007-012982-001

Release Date February 2016

Revision History
Revision Date Reason

A April 2015 Initial release.

B Assigned to another release.

C October 2015 • Added support for Visa Data Secure Platform


(VDSP) with Point to Point Encryption (P2PE).
• Added support for Unified Payment Interface (UPI).
• Cipher Suite Upgrades.
• Added support for AMB functionality on Luna
EFT 2.0.0.
• Added support for MasterCard and Visa Cloud-
based Payments Standard on Luna EFT 2.0.0.

D February 2016 Support for EMV 4.3 and SECCOS 7.1

All intellectual property is protected by copyright. All trademarks and product names used or referred to are the
copyright of their respective owners. No part of this document may be reproduced, stored in a retrieval system or
transmitted in any form or by any means, electronic, mechanical, chemical, photocopy, recording or otherwise without
the prior written permission of SafeNet, Inc.

Disclaimer
SafeNet makes no representations or warranties with respect to the contents of this document and specifically
disclaims any implied warranties of merchantability or fitness for any particular purpose. Furthermore, SafeNet
reserves the right to revise this publication and to make changes from time to time in the content hereof without the
obligation upon SafeNet to notify any person or organization of any such revisions or changes.
We have attempted to make these documents complete, accurate, and useful, but we cannot guarantee them to be
perfect. When we discover errors or omissions, or they are brought to our attention, we endeavor to correct them in
succeeding releases of the product.
SafeNet invites constructive comments on the contents of this document. Send your comments, together with your
personal and/or company details to the address below.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 2
Contact Method Contact Information

Mail SafeNet, Inc.


4690 Millennium Drive
Belcamp, Maryland 21017
USA

Email [email protected]

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 3
CONTENTS

Document Information 2

About the Host Function Guide 13


Document Conventions 14
Support Contacts 15

CHAPTER 1 Function Construction - Luna EFT 16


Luna EFT Keys 25
Function Message Formats 27
Function Fields 29
Variable Length 29
Key Specifier 31
Variants 32
Key Specifier Formats 35
Key Specifier Formats for HSM-stored Keys 35
Key Specifier Formats for KM-encrypted Keys 36
Key Specifier Format for explicit key type identification 37
Key Specifier Formats for Host-stored Keys 38
Key Specifier Usage 57
PIN Block Formats 60

CHAPTER 2 Function Construction - AMB 62


Function Message Formats 66
Function Field Description 66
Variable Length 67
Key Specifier 69
Variants 70
The ‘Key specifier’ Function Field 72
Key Specifier Formats 73
Key Specifier Formats for Luna EFT Stored Keys 73
Key Specifier Formats for Host Stored Keys 74
Use of key specifiers in host functions 79
RSA Public Key System 79

CHAPTER 3 The Metafunction 83

CHAPTER 4 Function Library 86


AB-KEY-GEN (3B00) 108
ADVANCED-RANDOM-KEY-GENERATION (EE0619) 109
APACS-MAC-GEN (EE0704) 112
APACS-MAC-VER-CONFIRM (EE0705) 113
APACS-MAC-VER-REQUEST (EE0703) 114

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 4
AUTH-PARAM-GENERATE (EF0617) 116
BDKGEN (EE0408) 117
B-DECIPHER-ECB (85) 118
B-ENCIPHER-ECB (84) 119
BPS-DECIPHER (EE0810) 120
BPS-ENCIPHER (EE0811) 122
C-KEY-GEN (3B10) 123
CALC-CSC (EE0501) 124
CALC-CSC-1 (000F) 126
CALCULATE-CSC (A8) 128
CALCULATE-IDN (EE3055) 129
CCM-DECRYPT (EE305E) 130
CCM-ENCRYPT (EE305D) 133
CHECK-AUTHENTICATION-CODE (EE3050) 135
CHECK-CLEAR-MOBILE-PIN (EE3058) 137
CHECK-ENCRYPTED-MOBILE-PIN (EE3059) 139
CHESS-KEK-RECEIVE-6.3 (D002) 141
CLEAR-PIN-ENCRYPT (EE0600) 142
CONSTRUCT-TOKEN-B1 (C850) 143
CREATE-ADDI-ICC-CERTIFICATE (EE0013) 144
CREATE-CSCK (A9) 146
CREATE-CSR (EE9204) 147
CREATE-X509-CERTIFICATE (EE9202) 149
CVC3-GENERATE (EE0010) 152
CVC3-VERIFY (EE0011) 153
CVV-GENERATE (EE0802) 154
CVV-VERIFY (EE0803) 155
D51-PPK-GEN (47) 156
dCVV-GENERATE (EE0014) 157
dCVV-VERIFY (EE0015) 159
DECIPHER-2 (EE0801) 161
DECIPHER-3 (EE0805) 163
DECIPHER-4 (EE0807) 165
DECIPHER-AES (EE0809) 167
DERIVE-CBP-SESSION-KEYS (EE3052) 169
DERIVE-CLOUD-CMK (EE3051) 172
DERIVE-CVC3-KD-IV (EE0012) 176
DERIVE-ICC-MASTER-KEY (EE204A) 178
DERIVE-KEY (EE0409) 181
DERIVE-MOBILE-SESSION-KEY (EE305A) 183
DERIVE-NEW-ICC-KEY (EE2053) 185
DERIVE-NEW-ICC-KEY-SET (EE2052) 187
DUKPT-KEY-MAILER (EE040B) 190
EMV-AC-GEN (EE2000) 192
EMV-AC-GEN-MULTI (EE2019) 194
EMV-AC-GEN-MULTI-AES (EE2023) 199
EMV-AC-VERIFY (EE2001) 202
EMV-ARPC-GEN (EE2006) 204
EMV-DAC-GEN (EE2002) 205

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 5
EMV-DAC-VERIFY (EE2003) 206
EMV-GENERATE-ARPC (EF2012) 207
EMV-ICC-DN-GEN (EE2004) 209
EMV-ICC-DN-VERIFY (EE2005) 210
EMV-PIN-CHANGE-UNBLOCK (EE2016) 211
EMV-PIN-CHANGE-UNBLOCK-EMV-2000 (EE2017) 213
EMV-PIN-CHANGE-UNBLOCK-MULTI (EE2021) 215
EMV-PIN-CHANGE-UNBLOCK-MULTI-AES (EE2025) 224
EMV-PIN-CHANGE-UNBLOCK-VISA (EF2015) 229
EMV-SCRIPT-CRYPTO (EE2007) 233
EMV-SCRIPT-CRYPTO-EMV-2000 (EF2013) 235
EMV-SCRIPT-CRYPTO-MULTI (EE2020) 238
EMV-SCRIPT-CRYPTO-MULTI-AES (EE2024) 244
EMV-SCRIPT-CRYPTO-VISA (EF2014) 247
EMV-VERIFY-AC-EMV-2000 (EF2010) 249
EMV-VERIFY-AC-GEN-ARPC (EE2018) 252
EMV-VERIFY-AC-GEN-ARPC-AES (EE2022) 258
EMV-VERIFY-AC-VISA (EF2011) 261
ENCIPHER-2 (EE0800) 263
ENCIPHER-3 (EE0804) 265
ENCIPHER-AES (EE0808) 267
ENCIPHER-KTM1 (EE0806) 269
ERASE-OLD-KM (13) 271
ESTABLISH-KM (11) 272
EXPORT-CSCK (AA) 273
EXPORT-KEY-2 (EE3061) 274
EXPORT-KEY-PACKAGE (EE3103) 276
EXPORT-PIN-EMV (EE2050) 277
FORMAT-STATUS (0007) 279
FUEL-CARD-PIN-VER (EE0621) 281
FUNCTION-STATUS (0005) 282
GENERATE-DCV (EE2054) 284
GENERATE-ICC-CRT-KEYPAIR (EE2058) 285
GENERATE-ICC-CRT-KEYPAIR-PKCS (EE205A) 289
GENERATE-ICC-KEYPAIR (EE2048) 291
GENERATE-ISSUER-KEY-PAIR (EE2040) 295
GENERATE-KEY-DIEBOLD (EE9101) 297
GENERATE-KTM-NCR (EE9201) 299
GENERATE-MAC-NDC-ATM (5530) 300
GENERATE-MD5-HASH (EE9007) 301
GENERATE-RANDOM-PIN-EMV (EE204F) 302
GENERATE-RSA-KEY-PAIR (EE9001) 304
GENERATE-SHA-HASH (EE9008) 306
GEN-KM-ENC-PIN (EE0640) 307
GEN-RANDOM (EE0002) 308
GEN-TERMINAL-KEY (EE0628) 309
GET-CLOCK (0016) 313
GET-KEY-DETAILS (EE0202) 314
GET-KVC (EEBF29) 316

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 6
GETPUBLICKEY (EE3030) 318
GP-CALC-CARD-CRYPTOGRAM (EE2060) 319
GP-MUTUAL-AUTHENTICATION (EE2059) 320
GP-MUTUAL-AUTHENTICATION-SCP03 (EE2065) 321
GP-SCP10-CALC-HASH-OF-KEY (EE2064) 322
GP-SCP10-SESSION-KEY-TRANSPORT (EE2063) 324
GP-SECURE-MESSAGING-COMMAND (EE2061) 326
GP-SECURE-MESSAGING-COMMAND-SCP03 (EE2066) 328
GP-SECURE-MESSAGING-RESPONSE (EE2062) 330
HSM-STATUS (0001) 332
HSM-STATUS (01) 333
HSM-STATUS-EXTN (0002) 335
HSM-STATUS-REV2 (EE0003) 337
II-KEY-GEN (EE0402) 339
II-KEY-RCV (EE0403) 346
IMP-ENC-PUB-KEY (EE4008) 352
IMPORT-CSCK (AB) 353
IMPORT-EMV-CERTIFICATE (EE9011) 354
IMPORT-KEY-PACKAGE (EE3104) 356
IMPORT-PUBLIC-KEY (EE9003) 357
IMPORT-PUBLIC-KEY-CERTIFICATE (EE9004) 358
IMPORT-RSA-ENC-KEY (EE3060) 361
IMPORT-RSA-PRIVATE-KEY (EE9013) 363
IMPORT-TRANSPORT-KEY (EE9203) 365
INIT-KEY-EXCH (EE4005) 367
INITIAL-KEY-REC (B580) 369
IPEK-DERIVE (EE040A) 370
IPEK-DERIVE-2 (EE040C) 372
IT-KEY-GEN (EE0400) 374
JAPPINTRAN (EF0601) 379
KB-MAC-GEN (73) 381
KB-PIN-VER (64) 382
KEY-EXPORT (EE0201) 383
KEY-EXPORT-AES (EE0206) 387
KEY-IMPORT (EE0200) 391
KEY-IMPORT-AES (EE0205) 395
KEY-MAILER (EE0E01) 400
KEY-PACKAGE-STATUS (EE3102) 403
KEY-RETRIEVE-OPERATION (EE9012) 404
KIR-REC (EE3032) 406
KIS-SEND (EE3031) 407
KM-MIGRATE (12) 408
KM-STATUS (0006) 409
KTK-KEY-EXPORT (EE2051) 411
LOAD-CHARSET (EE0E07) 413
LOAD-PS (EE0E02) 414
LOAD-PUBLIC-KEY (C6A0) 415
LOAD-PUBLIC-KEY (NDC) (C6B0) 416
M-DPK-GEN (49) 419

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 7
MAC-GEN-FINAL (EE0701) 420
MAC-GEN-FINAL-AES (EE0713) 422
MAC-GEN-UPDATE (EE0700) 424
MAC-GEN-UPDATE-AES (EE0712) 426
MAC-VER-FINAL (EE0702) 428
MAC-VER-FINAL-AES (EE0714) 430
MAM-ACTIVATE (EE040D) 432
MAM-DEACTIVATE (EE040E) 433
MD5-GENERATOR (0020) 434
MIGRATE-KM-ENC-PIN (EE0644) 435
MIGRATEPIN (EE0601) 436
M-KEY-GEN (3B20) 437
MT-KPE-GEN (A0) 438
MT-KPE-RCV (A1) 439
MT-PIN-TRAN (A2) 440
MT-PIN-VER (A3) 441
MT-PIN-VER-PVV (A7) 442
NI-KEY-GEN (EE0404) 443
NI-KEY-RCV (EE0405) 447
NODE-KEK-REC-EXPORT (C710) 451
NODEPROOF (EE3033) 452
NODERESP (EE3034) 453
NT-KEY-GEN (EE0401) 454
OAEP-ENCRYPT (EE9205) 459
OBM-CHANGE-PIN-3264 (EE3003) 461
OBM-CHANGE-PIN-HASH (EE3006) 462
OBM-DECRYPT-DATA-RSA (EE3022) 463
OBM-DECRYPT-DATA-SYMMETRIC (EE3023) 464
OBM-GENERATE-RANDOM-PIN (EE3017) 467
OBM-GENERATE-RANDOM-PIN-2 (EE3021) 468
OBM-GEN-RANDOM-NUMBER (EE3001) 470
OBM-GET-PRINT-TOKEN (EE3016) 471
OBM-GET-PUBLIC-KEY (EE3000) 472
OBM-MIGRATE-PIN-3624-TPV (EE3009) 473
OBM-PRINT-ENCRYPTED-PIN (EE3018) 474
OBM-PRINT-PIN (EE3008) 476
OBM-SET-PIN (EE3004) 477
OBM-SET-PIN-TPV (EE3020) 478
OBM-TRANSLATE-PIN (EE3019) 479
OBM-VERIFY-PIN-3624 (EE3002) 480
OBM-VERIFY-PIN-HASH (EE3005) 481
PAN-KEY-EXCH (EE4006) 482
PIN-FROM-OFF (EE0609) 484
PIN-GENERATE (EE0E04) 486
PIN-GENERATION (EF0616) 487
PIN-MAIL (E2) 488
PIN-MAIL-2 (EE0E06) 490
PIN-OFF (EE0604) 492
PIN-PRINT (EE0E05) 494

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 8
PIN-TRAN-2 (EE0602) 496
PIN-TRAN-8 (EE0608) 500
PIN-TRAN-3624 (63) 502
PIN-TRANS-SEED-DES (EE0615) 503
PIN-VER-IBM-MULTI (EE0603) 505
PPID-ENCRYPT (E550) 507
PRINT-KM-ENC-PIN (EE0641) 508
PRINT-PS (EE0E03) 510
PRIVATE-KEY-OPERATIONS (EE9010) 511
PROTECT-CLEAR-MOBILE-PIN (EE3056) 513
PROTECT-DC-FILE (EE305C) 515
PROTECT-ENCRYPTED-MOBILE-PIN (EE3057) 520
PRV-GENERATION (EF0E02) 522
PRV-VERIFICATION (EF0E03) 525
PUBLIC-KEY-OPERATIONS (EE9009) 528
PVV-CALC (EE0607) 530
PVV-CALC-3624 (EE0606) 532
PVV-VER (EE0605) 533
RAND-GEN (B570) 535
RANDOM-KEY-GENERATION (EF0618) 536
READ-USER-STORE-DATA (EE4103) 537
READ-USER-STORE-KEY (EE4101) 538
RETRIEVE-KEY (21) 539
RNS-MESSAGE (EE305F) 541
RSA-ENCIPHER-PIN (EE204E) 544
SELF-CERT-ISSUER-PUBLIC-KEY (EE2041) 546
SELF-SIGN-ISSUER-PK-VISA (EE2044) 549
SET-CLOCK (0015) 551
SHA1-GENERATOR (0021) 552
SIGN-DATA (EE9005) 553
SIGN-FEP-PUB-KEY (EE4007) 554
SIGN-ICC-STATIC-DATA (EE204B) 555
SIGN-PUBLIC-KEY (NDC) (C6C0) 557
SIGN-PUBLIC-PKCS10 (C810) 560
SPONSOR-KEY-GEN (B510) 562
STORE-KEY (22) 563
TERM-AUTH-1 (EE4003) 564
TERM-AUTH-2 (EE4004) 566
TERM-VER-2 (EE0406) 568
TLS-ENCRYPTION-AND-MAC-KEY-DERIVATION (EE6004) 569
TLS-MASTER-KEY-DERIVATION (EE6003) 571
TLS-PRE-MASTER-KEY-GENERATION (EE6000) 572
TLS-PRE-MASTER-KEY-RECEIVE (EE6002) 573
TLS-PRE-MASTER-KEY-SEND (EE6001) 574
TRANS-KM-ENC-PIN (EE0643) 575
TRANSLATE-DATA-P2PE (EE080C) 576
TRANSLATE-DATA-RSA-TO-RSA (EE9014) 580
TRANSLATE-SENSITIVE-DATA (EE0645) 583
TRANSLATE-VFPE-ALPHABET-TO-DATA (EE080E) 585

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 9
TRANSLATE-VFPE-DATA-TO-ALPHABET (EE080D) 586
VALIDATE-CBP-CVC3 (EE3054) 587
VALIDATE-CLOUD-AC-GENERATE-ARPC (EE3053) 589
VAR-KB-PIN-VER (69) 592
VCEPS-GEN-HASH-CEP (EF0F01) 593
VCEPS-GEN-SN (EF0703) 594
VCEPS-MAC-VER-LSAM (EF0704) 595
VCEPS-VER-S1-GEN-S2 (EF0701) 596
VCEPS-VER-SN (EF0702) 597
VER-KM-ENC-PIN (EE0642) 599
VERIFY-ATM-RESPONSE-DIEBOLD (EE9102) 600
VERIFY-CA-PK-VISA (EE2045) 601
VERIFY-CA-PUBLIC-KEY-MC (EE2042) 603
VERIFY-CERTIFICATE (C800) 605
VERIFY-CSC (EE0502) 606
VERIFY-CSC-1 (0010) 608
VERIFY-DETACHED-CERT-VISA (EE2047) 610
VERIFY-EPP (NDC) (C6D0) 611
VERIFY-ICC-CERTIFICATE (EE2049) 613
VERIFY-ICC-DYNAMIC-DATA (EE204D) 615
VERIFY-ICC-STATIC-DATA (EE204C) 617
VERIFY-MAC-NDC-ATM (5630) 619
VERIFY-ISSUER-PK-CERT-MC (EE2043) 620
VERIFY-ISSUER-PK-CERT-VISA (EE2046) 622
VERIFY-SIGNED-DATA (EE9006) 624
VERIFY-TOKEN-A2 (C860) 625
VFPE-DECRYPT (EE080B) 626
VFPE-ENCRYPT (EE080A) 627
VISA-RECEIVE (4501) 628
VISA-RECEIVE-AWK (4504) 629
VISA-RECEIVE-IWK (4503) 630
WEB-SERVICE-MESSAGE (EE305B) 631
WRITE-USER-STORE-DATA (EE4102) 635
WRITE-USER-STORE-KEY (EE4100) 636
ZKA-CALC-PVN (EE0612) 637
ZKA-IMPORT-MK (EE0210) 639
ZKA-MAC-GEN (EE0710) 641
ZKA-MAC-GEN-1 (EE0711) 643
ZKA-PIN-TRANS (EE0610) 645
ZKA-PIN-TRANS-1 (EE0613) 647
ZKA-PIN-VER (EE0611) 649

APPENDIX A Legacy Functions 651


AUTHENTICATION-PARAMETER-GEN (E100) 656
CVV-GEN (9B) 657
CVV-VER (9C) 658
D51-PIN-TRAN (65) 659
D51-PIN-VER (66) 660
DECIPHER (81) 661

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 10
DECIPHER-ECB (83) 662
ENCIPHER (80) 663
ENCIPHER-ECB (82) 664
GEN-SESS-KEYS (4A) 665
II-DPK-GEN (53) 667
II-DPK-RCV (56) 668
II-MPK-GEN (52) 669
II-MPK-RCV (55) 670
II-PPK-GEN (51) 671
II-PPK-RCV (54) 672
IT-DPK-GEN (43) 673
IT-MPK-GEN (42) 674
IT-PPK-GEN (41) 675
MAC-GEN (70) 676
MAC-TRAN (71) 677
MAC-VER (72) 678
NI-DPK-GEN (59) 679
NI-DPK-RCV (5C) 680
NI-MPK-GEN (58) 681
NI-MPK-RCV (5B) 682
NI-PPK-GEN (57) 683
NI-PPK-RCV (5A) 684
NT-DPK-GEN (46) 685
NT-MPK-GEN (45) 686
NT-PPK-GEN (44) 687
PIN-OFF-AS (6A) 688
PIN-OFF-PP (6B) 690
PIN-TRAN (60) 691
PIN-TRAN-1 (94) 692
PIN-TRAN-2-VISA (95) 693
PIN-VER-AS (61) 694
PIN-VER-PP (62) 695
PVV-CHANGE (9A) 696
PVV-GEN-1 (90) 697
PVV-GEN-2 (96) 698
PVV-VER-1 (91) 699
PVV-VER-2 (92) 700
PVV-VER-3 (93) 701
PVV-VER-4 (97) 702
PVV-VER-5 (98) 703
PVV-VER-6 (99) 704
TermKeyInit-6.4 (3130) 705
TERM-VER (4C) 706
VAR-PIN-VER (67) 707
VAR-PIN-VER-PP (68) 708

APPENDIX B Standards and Support 709


3-D SecureTM Support 710
AS2805.6.3 Support 711

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 11
American Express (AMEX) Support 712
CEPS Support 714
Clear PIN Support 715
Contactless Payment Card Support 716
EMV Support 718
Global Platform Support 721
Italian Banking and Debit Card Support 722
Japan PIN Support 723
MasterCard® Support 724
MasterCard Cloud-Based Payments Support 726
Online Banking Support 728
Remote ATM Initialization 735
Smart Card Support 736
Visa Support 739
Visa Cloud-Based Payments Support 741
Visa Data Secure Platform (VDSP) with Point to Point Encryption (P2PE) 742
ZKA Support 743

APPENDIX C Error Codes 747

APPENDIX D References 756

APPENDIX E How to Create and Print a PostScript File 763

APPENDIX F Luna EFT and Cloud Based Payments (CBP) 764

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 12
About the Host Function Guide

This document provides a complete function reference for all functions that make up the Mark II function set. These
function sets, which are supported on SafeNet Hardware Security Modules (HSMs), may be utilized by EFT network
designers to implement a variety of key and PIN management schemes.
Mark II functions are available as standard on Luna EFT. Additionally, SafeNet also develops custom functions to meet
the specific needs of particular customers. Details can be found in a customization guide supplied with the product,
where applicable.
• Function Construction
• The Metafunction
• Function Library
• Error Codes

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 13
About the Host Function Guide

Document Conventions
This document uses standard conventions for describing the user interface and for alerting you to important information.

Notes
Notes are used to alert you to important or helpful information. They use the following format:

Note: Take note. Contains important or helpful information.

Cautions
Cautions are used to alert you to important information that may help prevent unexpected results or data loss. They use
the following format:

CAUTION: Exercise caution. Contains important information that may help prevent
unexpected results or data loss.

Warnings
Warnings are used to alert you to the potential for catastrophic data loss or personal injury. They use the following
format:

WARNING! Be extremely careful and obey all safety and security measures. In this
situation you might do something that could result in catastrophic data loss or
personal injury.

Command syntax and typeface conventions


Format Convention

bold The bold attribute is used to indicate the following:


• Button names (Click Save As.)
• Check box and radio button names (Select the Print Duplex check box.)
• Dialog box titles (On the Protect Document dialog box, click Yes.)
• Field names (User Name: Enter the name of the user.)
• Menu names (On the File menu, click Save.) (Click Menu > Go To > Folders.)
• User input (In the Date box, type April 1.)

italics In type, the italic attribute is used for emphasis or to indicate a related document.

monospace Denotes syntax and code examples.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 14
About the Host Function Guide

Support Contacts
If you encounter a problem while installing, registering or operating this product, please ensure that you have read the
documentation. If you cannot resolve the issue, please contact your supplier or SafeNet support. SafeNet support
operates 24 hours a day, 7 days a week. Your level of access to this service is governed by the support plan
arrangements made between SafeNet and your organization. Please consult this support plan for further information
about your entitlements, including the hours when telephone support is available to you.

Contact Method Contact Information

Address SafeNet, Inc.


4690 Millennium Drive
Belcamp, Maryland 21017
USA

Phone United States (1-800-545-6608)

International (1-410-931-7520)

Technical Support https://serviceportal.safenet-inc.com


Customer Portal Existing customers with a Technical Support Customer Portal account can log in to manage
incidents, get the latest software upgrades, and access the SafeNet Knowledge Base.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 15
CHAPTER 1
Function Construction - Luna EFT

Encryption Notation
The notation used for encryption and decryption is as follows:
• eK(D) where data D is encrypted under the key K.
• dK(D) where data D is decrypted with the key K.

Host Function Overview


Each function involves a host request being sent to the HSM. Each request produces a corresponding response
message containing the results of the function or a status code indicating an error. The message content of each
function is described in this guide and is independent of the selected communications protocol.
A host request message starts with a Function Code followed by function-dependent binary data. These data may be
fixed or variable length depending on the function. Where a function requires multiple fields in a message, there is no
delimiter between fields.
For example Function NT-PPK-GEN (FN 44):
eKM1(KSn) = 12 34 56 78 90 AB CD EF
By adding the function code the complete host request message is
44 12 34 56 78 90 AB CD EF
A response message starts with the Function Code from the host request message followed by a one-byte Return
Code. The Error Codes lists the assignments for the Return (Error) Code. If the Error Code returned is non-zero, there is
no data following the Error Code. Otherwise, the response data follows the Error Code.
For example, function NT-PPK-GEN (FN 44) :
Return Code : 0A (uninitialized key access)
By adding the function code the complete response message is 44 0A

Host Function Specification in this Guide


For each Host Function that is specified in this document, the title of the section which details the specification takes
the following format.
The function name appears at the top of the page. It is important to note that this is an abbreviated form of the function
name that is used in the Console.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 16
CHAPTER 1 Function Construction - Luna EFT

Function definition format

Function Modifier Values


Selection of host key protection method within host functions can be done using the FM field. The Host Key Protection
using Function Modifier can be in the range of x0, where x= 0 , 1, 2, 3, 4.
The FM field is primarily used to alter the functionality of a Luna EFT host function. For a default behavior, FM is set to
00 and for additional behaviors like HSKR settings, Keyblock constraints, it is set to some other value.
This impacts the key-types under the Response since they are generated based on the chosen operation on console
and FM. The following table shows different combinations of FM value and console check box and their impact on
behavior of the host function.

Note:
- FM override is only applicable for those functions that return key specifier in response. For the
functions that receive key spec in request, FM (xy) and x>0 will cause an error.
- Also, Functions not having FM fields will generate keys according to global method.
- Now, keys can be stored on host in ANSI TR-31 key block and binary key block format also.
Hence, FM field value is updated to 3, 4 to allow the selection of key spec format 17 and 18.

State of FM Override Global FM xy Key Protection Method to be used


on console Method (Hex)
Selected

Enabled Legacy 0000 Legacy method

0010 ECB method

0020 CBC method

0030 TR-31 ASCII

0040 TR-31 Binary

ECB 0000 ECB method

0010 ECB method

0020 CBC method

0030 TR-31 ASCII

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 17
CHAPTER 1 Function Construction - Luna EFT

State of FM Override Global FM xy Key Protection Method to be used


on console Method (Hex)
Selected

0040 TR-31 Binary

CBC 0000 CBC method

0010 ECB method

0020 CBC method

0030 TR-31 ASCII

0040 TR-31 Binary

TR-31 ASCII 0000 TR-31 ASCII

0010 ECB method

0020 CBC method

0030 TR-31 ASCII

0040 TR-31 Binary

TR-31 Binary 0000 TR-31 Binary

0010 ECB method

0020 CBC method

0030 TR-31 ASCII

0040 TR-31 Binary

Disabled Legacy 0000 Legacy method

0010 Error (conflict with global method).


Error code : 0x24 FN_INVALID_FN_MODIFIER

0020 Error (conflict with global method).


Error code : : 0x24 FN_INVALID_FN_MODIFIER

0030 Error FN_INVALID_FN_MODIFIER

0040 Error FN_INVALID_FN_MODIFIER

ECB 0000 ECB method

0010 ECB (No conflict with global method)

0020 Error (conflict with global method).


Error code : : 0x24 FN_INVALID_FN_MODIFIER

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 18
CHAPTER 1 Function Construction - Luna EFT

State of FM Override Global FM xy Key Protection Method to be used


on console Method (Hex)
Selected

0030 Error FN_INVALID_FN_MODIFIER

0040 Error FN_INVALID_FN_MODIFIER

CBC 0000 CBC method

0010 Error (conflict with global method).


Error code : : 0x24 FN_INVALID_FN_MODIFIER

0020 CBC (No conflict with global method)

0030 Error FN_INVALID_FN_MODIFIER

0040 Error FN_INVALID_FN_MODIFIER

TR-31 ASCII 0000 TR-31 ASCII

0030 TR-31 ASCII (no conflict with global method)

0020 Error FN_INVALID_FN_MODIFIER

0010 Error FN_INVALID_FN_MODIFIER

0040 Error FN_INVALID_FN_MODIFIER

TR-31 Binary 0000 TR-31 Binary

0040 TR-31 Binary (no conflict with global method)

0010 Error FN_INVALID_FN_MODIFIER

0020 Error FN_INVALID_FN_MODIFIER

0030 Error FN_INVALID_FN_MODIFIER

Key Block Header Fields for Key Block Format Keys


The following table is used to identify valid Key block header fields into host functions which will be updated for
generating/receiving key block format keys.

Key type * TR-31 Key * TR-31 Mode of Algorithms supported


Usage Use

DPK ‘D0’ ‘B’,’D’,’E’,’N’ ‘D’,'T',

PPK ‘P0’ ‘B’,’D’,’E’,’N’ ‘D’,'T',

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 19
CHAPTER 1 Function Construction - Luna EFT

Key type * TR-31 Key * TR-31 Mode of Algorithms supported


Usage Use

MPK ’M0', ‘M1’,’M2’, ‘C’,’G’,’N’,’V’ ‘D’,'T',


‘M3’,’M4’,
‘M5’

KIS ‘K0’ ‘B’,’D’,’E’,’N’ ‘D’,'T'

KIR ‘K0’ ‘B’,’D’,’E’,’N’ ‘D’,'T'

KI ‘K0’ ‘B’,’D’,’E’,’N’ ‘D’,'T'

KTM ‘K0’ ‘B’,’D’,’E’,’N’ ‘D’,'T',

CSCK ‘C0’ ‘C’,’G’,’N’,’V’ ‘T'

KPV, DT ‘V0’,‘V1’ ‘C’,’G’,’N’,’V’ ‘D’,‘T'

KPVV ‘V0',‘V2’ ‘C’,’G’,’N’,’V’ ‘'T',

KCVV ‘C0’ ‘C’,’G’,’N’,’V’ ‘'T',

Key Block encryption -


terminal

Key Block message


authentication –terminal

KTPV

KGK ‘B0’ ‘N’ ‘'T',

KKBLZ ‘V0’ ‘C’,’G’,’N’,’V’ ‘'T',

MK-ZKA ‘K0’ ‘B’,’D’,’E’,’N’ ‘T'

MAC used for Format 15


host stored keys

(K) used for Format 15


host stored keys

BDK ‘B0’ ‘N’ ‘T'

Key Block encryption –


host

Key Block message


authentication – host

PIN Block encryption –


KM encrypted PIN

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 20
CHAPTER 1 Function Construction - Luna EFT

Key type * TR-31 Key * TR-31 Mode of Algorithms supported


Usage Use

IMK-AC ‘E0’ ‘N’ ‘T'

IMK-SMI ‘E2’ ‘N’ ‘T'

IMK-SMC ‘E1’ ‘N’ ‘T'

IMK-DAC ‘E3’ ‘N’ ‘T'

IMK-IDN ‘E4’ ‘N’ ‘T'

KTK ‘K0’ ‘B’,’D’,’E’,’N’ ‘T'

PTK ‘P0’ ‘B’,’D’,’E’,’N’ ‘T'

KMC ‘E5’ ‘N’ ‘T'

IMK-CVC ‘E6’ ‘N’ ‘T'

FPVK ‘V0’ ‘C’, ‘G’, ‘V’ ‘D’,‘T'

* The TR-31 Key Usage and Mode of Use are as defined in Ref. [43] of Mark II.

Note: There is no appropriate key usage in TR-31 draft that matches KGK. KGK is used for key
derivation therefore key usage ‘B0’ will be used for KGK.

Key Usage for MPK


This section provides the key block header attributes for MPK keys. In Mark II Host Functions, the MPK key usage
depends upon the field “Algo/ MAC Method” and MPK key length.

Key Length Algo/Mac Method = Algo/Mac Method =


0 1

Single M1 -

Double M3 M0

Triple M1 M0

TR-31: Defined Values for Exportability Byte


Value Hex Description

‘E’ 0x45 Exportable under trusted key


A trusted key is either the MFK or a KEK in Key Block format.

‘N’ 0x4E Non-exportable

‘S’ 0x53 Sensitive, Exportable under untrusted key


A trusted key is either the MFK or a KEK in Key Block format.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 21
CHAPTER 1 Function Construction - Luna EFT

Value Hex Description

Numeric Values Reserved for Proprietary Use

TR-31: Proprietary values of key usage and Algorithms


Proprietary Key Usage Values

Value Hex Description

'10' 0x31, 0x30

'11' 0x31, 0x31 HMAC-SHA1

'12' 0x31, 0x32 HMAC-SHA224

'13' 0x31, 0x33 HMAC-SHA256

'14' 0x31, 0x34 HMAC-SHA384

'15' 0x31, 0x35 HMAC-SHA512

'16' 0x31, 0x36 ZKA KGK

'17' 0x31, 0x37 ZKA KK BLZ

'18' 0x31, 0x38 ZKA MK

'19' 0x31, 0x39 MAC Algorithm 1 in ISO/IEC


9797-1 with padding method 2

Proprietary Algorithm Values

Value Hex Description

'0' 0x30

'1' 0x31 SEED

'2' 0x32 HMAC

'3' 0x33

'4' 0x34

'5' 0x35

'6' 0x36

'7' 0x37

'8' 0x38

'9' 0x39

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 22
CHAPTER 1 Function Construction - Luna EFT

TR-31 Key Usage and Mark II Key Types


The following table shows mapping of Luna EFT keys with TR-31 key usage. The allowed mode of use and algorithm
for each key type is also defined.
This table corresponds to version B and version C of TR-31 key blocks. For numeric values refer to Algorithm table
under TR-31: Proprietary values of key usage and Algorithms.

Luna EFT Key Name *TR-31 Key usage *TR-31 Mode Algorithms
of use supported

DPK ‘D0’ B,D,E D,T,1

MPK M0,M1,M2,M3,M4,M5 C,G,V D,T

MPK 11,12,13,14,15 C,G,V 2

PPK P0 B,D,E D,T,1

KIS K0 B,D,E D,T

KIR K0 B,D,E D,T

KI K0 B,D,E D,T,A

KTM K0 B,D,E D,T

CSCK C0 C,G,V T

KPV (IBM 3624) V1 C,G D, T

KPVV V2 C,G T

KCVV C0 C, G, V T

KTPV V0 C,G T

ZKA KGK 16 X T

ZKA KK BLZ 17 C T

ZKA MK 18 X T

BDK B0 X T

DUKPT Initial Key (IPEK) B1 X T

IMK-AC E0 X T,A

IMK-SMC E1 X T,A

IMK-SMI E2 X T,A

IMK-DAC E3 X T

IMK-IDN E4 X T

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 23
CHAPTER 1 Function Construction - Luna EFT

Luna EFT Key Name *TR-31 Key usage *TR-31 Mode Algorithms
of use supported

IMK-CVC E6 X T

KTK K0 B,D,E T

PTK P0 B,D,E T

KMC E5 X T

FPVK V0 C, G,V D, T

MKDK 13,19, K0 N A

CCM D0 B,D,E A

* The TR-31 Key Usage and Mode of Use are as defined in Ref. [67] of Mark II.

Note: Mode of usage N in TR-31 version A will be treated as B (both), C (Mac calculate), or X
depending on the context. While importing from version A to version B or version A to version
C, key usage N is replaced by any of the above values depending on the function.

TR-31 – Key Block Structure


The following table describes the fields of Key block structure that contain the attributes which are necessary to prepare
a key into key block format.

Key Block Structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h A 0x41, B 0x42 or C0x43


Host stored key will be generated in version B only.

Key Usage 2 h

Algorithms 1 h

Mode of use 1 h

Key Version No 2 h

Exportability 1 h

Padding Indicator 1 h 00 = Do not pad


03 = Pad to triple length

Number of optional fields 0x00-0x03 (Decimal 00 to 03 Max)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 24
CHAPTER 1 Function Construction - Luna EFT

Key Block Structure

Field Length Type Description

Optional field 0 … n Var h Number of optional field as defined in the above field. First
byte of optional field will be treated as Optional Block ID.

Public Key Verification Code


The KVC for a public key (PVC) is formed as described in AS2805 part 6.1 as follows:
• The modulus and public exponent are each expressed as whole bytes, most significant byte first, with no length
field and no leading zero bytes.
• The modulus and exponent are concatenated in that order.
• The SHA1 digest of that data is calculated.
The first 64 bits of the SHA1 digest will be the PVC of the key.

The "Processing Unit" Field


The processing unit (PU) is a new construct which is used in function requests. It is a shorthand way of specifying a set
of fields and the associated processing just once, rather than repeating the fields and the required processing in each
appropriate function.

Function Identifier Control


The Function Identifier Control allows the HSM to operate with a new optional Function Identifier field which is placed
into the function request and response messages in order to provide message identity.
When enabled, the Function Identifier is a fixed-length field with length as specified by the user, occurring immediately
after the function code field in every function request and response message. Field length can be set in a range from 1
to 99 bytes in length.
To maintain backwards compatibility, the function identifier can be switched on or off via a console operation.

Luna EFT Keys


The table below lists the keys used in Luna EFT.

Category Key Name Description

Data Encryption DPK Data Protection Key


Encrypt data in an interchange zone

PIN Management PPK PIN Protection Key


Encrypt PIN in an interchange zone

KPE Master Card PIN Encryption Key

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 25
CHAPTER 1 Function Construction - Luna EFT

Category Key Name Description

Message MPK MAC Protection Key


Authentication Authenticate Data (MAC) in an interchange zone

Key Management KIS Interchange Key for sending a key encrypt key
(Interchange)
KIR Interchange Receiving key

KI Bidirectional Interchange key

Key Management KTM Terminal (ATM, EFTPOS) Master Key for exchange of working
(Terminal) keys - DPK, PPK, MPK

Key Management KEK Master Card Key Exchange Key


(Exchange)

Key Management IWK Issuer working key used in transaction processing


(VISA Keys)
AWK Acquirer working key used in transaction processing

ZCMK Zone Control Master Key. Encrypts IWK, AWK, PVK A/B, CVK
A/B

Card Verification CVV/CVK Visa (and MasterCard) Card Verification Key

CSCK Calculate and verify card security code

PIN Verification PVK, DT (IBM 3624) PIN Verification Key (Visa) & Decimalisation Table, IBM 3624
Method

PVV (Visa PVV) Visa PVV Verification Key

KTPV Transformed PIN Value Key

FPVK Fuel-card PIN Verification Key

ZKA Processing ZKAKGK Key generation Key for German retail EFT systems

ZKAKK Encrypted PIN Verification key for German retail EFT systems

ZKAKTK Key transport key for German retail EFT systems

ZKAMACCV ZKA Message Authentication Code control vector

ZKAMK Master Key for German retail EFT systems

ZKAMK2 Master Key2 for German retail EFT systems

ZKAMK2KTK Key transport key for German retail EFT systems

ZKAPACCV ZKA PIN Authentication Code Control vector

DUKPT Key BDK DUKPT Master Derivation Key


Management

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 26
CHAPTER 1 Function Construction - Luna EFT

Category Key Name Description

EMV IMK-AC EMV Issuer Master Key for Application Cryptogram

IMK-SMI EMV Issuer Master Key for Secure Messaging Integrity

IMK-SMC EMV Issuer Master Key for Secure Messaging Confidentiality

IMK-DAC EMV Issuer Master Key for Data Authentication Code

IMK-IDN EMV Issuer Master Key for ICC Dynamic Number

Pi-Si EMV Card Issuer Key Pairs Pi, Si

Contactless IMK-CVC EMV Issuer Master Key - Card Verification Code


(PayPass, PayWave) Master Key for dynamic CVV processing (contactless payments)

MDK CEPS Master Derivation Keys

Card Issuance (Data KTK Transport Key to encrypt data between Data Preparation and Card
Preparation & Personalisation System
Personalisation)
PTK Transport Key to encrypt PINs between Data Preparation and Card
Personalisation System

KMC Master Personalisation Key

RSA Keys HSM-stored/Host- Key export, signing, card personalization or terminal initialization.
stored

Master key (To KM Domain Master Key. Encrypt other keys.


encrypt host stored
keys) newKM Encrypt other keys (KM to which the migration for all keys to be
done)

Key Transfer KHT Network Host Transfer Key


Encrypt key package for Network Key Transfer

RKHT Remote Network Host Transfer Key

KTP Smart Card Transfer Protect Key


Encrypt keys stored on backup smart card

Auditing MAC Protect the MAC of audit records

Function Message Formats

Data Item Representation in Request/Response Messages


Request and response may use the following operators and qualifying letters.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 27
CHAPTER 1 Function Construction - Luna EFT

Operator Description

d Decrypt

e Encrypt

L The left part of a key pair

R The right part of a key pair

r Used for receiving

s Used for sending

V Variant

* Prefix to indicate a key pair.

Each field has an associated data type and its length in bytes. The data types are defined as follows:

Type Description

b Represents a binary digit (bit). Fields are grouped in multiples of


eight (8) bits.

h Represents a hexadecimal digit (0 to 9, and A to F). Fields are


grouped in multiples of two (2).

d Represents a BCD digit. These are always in pairs.

x Represents a binary byte.

B64 Represents a data block of 64 bits.

B512 Represents a data block of 512 bits.

P-key Represents an RSA public key.

K-Spec Key specifier. A value that specifies the length, format and index for
a key.

S-Block Represents a variable length, DEA 2 enciphered data Block.

Common Message Header Formats


All functions employ a common format for both request and response messages.

Function Request Headers


Each function request begins with a header of the form:

Description Length Type

Function Code 1 h

Note that with some functions the length of the function code may be longer than one byte.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 28
CHAPTER 1 Function Construction - Luna EFT

Function Response Headers


Each function response begins with a header of the form:

Description Length Type

Function Code 1 h

Return Code 1 h

Note that with some functions the length of the function code may be longer than one byte.

Transmission of Two-byte Integers


For any 2-byte integer values contained in message requests or responses, the function code field should be
transmitted with the most significant byte first unless otherwise stated.

Message Meta-function Format


The meta-function message format provides a transparent mechanism for implementing extensions to the current host
message format. See section, The Metafunction for further information.

Function Fields
Host functions utilize two field constructs, namely the Variable-length field and the Key specifier.

Variable Length
The variable-length field construct provides a standard mechanism for incorporating a field of varying length into HSM
Request or Response messages. It comprises the variable-length data and a prefix which specifies the length of the
data, and which is also of variable-length. This section describes the method for specifying the actual length of a
variable-length data field in a function request or response. The actual length of the length prefix is specified by the most
significant bits of the most significant byte within the prefix. The remaining bits within the most significant byte form
part (or all, in the single-byte case) of the value of the length prefix.

Length of length prefix (bytes) Length indicator bits in most significant byte

1 0…

2 10…

3 110 …

4 1110 …

The encoding defined above results in the following ranges of values for the length prefixes, and ranges of lengths for
the corresponding data values:

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 29
CHAPTER 1 Function Construction - Luna EFT

Length of length prefix Values in length prefix Bytes in data value

(bytes) (hex) (hex) (dec)

1 00 – 7F 00 – 7F 0 – 127

2 8000 – BFFF 0000 – 3FFF 0 – 16383

3 C00000 – DFFFFF 000000 – 1FFFFF 0 – 2097151

4 E0000000 – EFFFFFFF 00000000 – 0FFFFFFF 0 – 268435455

The following points apply to the Mark II implementation of the method.


• A variable-length data value and its associated length prefix form a single field in a function request or request
message, with an indicated length of ‘Var’. Therefore, there is no need to indicate the length as a separate field.
• The length prefix indicates the length of the data portion of the field, i.e. the length prefix is not included in the
length. The specified length is a number of bytes.
• The length prefix is independent of the attributes and contents of the data value.
• For multi-byte length prefixes, the byte order in the field is most significant byte first, i.e. big endian. This is in line
with the general rule for all multi-byte integer fields in Mark II functions.
• The method as defined above is open-ended, and therefore could be extended to a length prefix of more than four
bytes. However, the HSM supports a maximum of four bytes for a length prefix.
• For variable-length fields in response messages, the length prefix consists of the minimum number of bytes
required to express the data length of the field.
• A variable-length field with a data length of zero is represented entirely by a length prefix containing the value zero,
e.g. X’00’ or X’8000’. A zero-length field is useful where a field is not optional, but is not used.

Example Field Formats


The following examples illustrate how a variable-length field containing 27 data bytes could be represented using a
length prefix of differing lengths.

One byte length


msb 1sb
0 b6 b5 b4 b3 b2 b1 b0

Zero indicates one byte length field Length is 7 bit binary number (b6b5b4b3b2b1b0)

Two byte length


First byte transmitted Second byte transmitted
msb 1sb msb 1sb
1 0 b13 b12 b11 b10 b09 b08 b07 b06 b05 b04 b03 b02 b01 b00

1 0 indicates two byte length field


Length is 14 bit binary number (b13b12...b01b00)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 30
CHAPTER 1 Function Construction - Luna EFT

Three byte length


First byte transmitted Second byte transmitted
msb 1sb msb 1sb
1 1 0 b20 b19 b18 b17 b16 b15 b14 b13 b12 b11 b10 b09 b08

Third byte transmitted


msb 1sb
b07 b06 b05 b04 b03 b02 b01 b00

1 1 0 indicates three byte length field


Length is 21 bit binary number (b20b19…b01b00)

Four byte length


First byte transmitted Second byte transmitted
msb 1sb msb 1sb
1 1 1 0 b27 b26 b25 b24 b23 b22 b21 b20 b19 b18 b17 b16

Third byte transmitted Fourth byte transmitted


msb 1sb msb 1sb
b15 b14 b13 b12 b11 b10 b09 b08 b07 b06 b05 b04 b03 b02 b01 b00

1 1 1 0 indicates four byte length field - Length is 28 bit binary number (b27b26...b01b00)

Key Specifier
The key specifier construct is a variable-length field that contains a variable-format specification of a key. In general, a
key specifier may contain either an index to an HSM-stored key, or an encrypted key from host storage – encrypted by
a variant of *KM. The format of a key specifier field is fully described in this section. Formats for key specifiers that
accommodate RSA public and private keys are also covered.
Most host functions perform transformations using cryptographic keys which are stored either within the secure
memory (HSM-stored) or in the host database in encrypted form (Host-stored). Traditionally, the choice of whether a
key should be HSM-stored or host-stored has been on a per-key-type basis and has been fixed in the function design.
The key specifier introduces the capability for that choice to be at the discretion of the user (or host software provider); it
also permits the possibility to HSM-store some keys of a key type and to host-store other keys of that same key type.
To support the capability, a ‘key specifier’ is defined which is a variable format field to be built into host function request
and (possibly) response messages. The key specifier provides access to a key - either by value (an encrypted key
from, or for, host storage) or by reference (an index to a key table).
Being variable format, a key specifier field will be variable length. Refer to the section entitled Variable Length Fields in
Function Request and Response Messages for details of the variable length field.
Although the key specifier introduces extra flexibility for the user, there need be no extra complexity for the host
programmer. One simply selects the appropriate key specifier format for the particular key, and then treats that instance
of the key specifier as a fixed length, fixed format field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 31
CHAPTER 1 Function Construction - Luna EFT

Currently, the functions that access HSM-stored keys, do so via Key Specifier Formats 00 to 03. The key specifier
formats support a 1-2 byte long BCD indices, and 1-2 byte long binary indices, thereby significantly increasing the
maximum index supported. The available formats can accommodate the maximum supported key index i.e. 9999 (or
15000 for KTMs).

Variants

KM Variants
The following KM variants are used to encrypt host stored keys.

Variant Value Used to encrypt

0 X’00’ DPK

1 X’28’ PPK

2 X’24’ MPK

3 X’44’ KIS

4 X’88’ KIR

5 X’22’ KTM

6 X’20’ CSCK

7 X’18’ KPV, DT

8 X’14’ KPVV

9 X’48’ KCVV

10 X’9C’ Bi-directional Interchange Key KI

12 X’90’ MAC Residue

14 X’5C’ KTPV

16 X’0C’ KGK

17 X’0A’ KKBLZ

18 X’1E’ MK-ZKA

19 X’2E’ MAC used for Format 15 host stored keys

20 X’4E’ (K) used for Format 15 host stored keys

24 X’72’ BDK

25 X’70’ SKB-auth

26 X’78’ SKB-enc

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 32
CHAPTER 1 Function Construction - Luna EFT

Variant Value Used to encrypt

27 X’74’ PIN Block encryption – KM encrypted PIN

30 X’30’ IMK-AC

31 X’36’ IMK-SMI

32 X’3A’ IMK-SMC

33 X’3C’ IMK-DAC

34 X’50’ IMK-IDN

35 X’66’ KTK

36 X’6A’ PTK

37 X’6C’ KMC

38 X’7E’ IMK-CVC

39 X’90’ TLS Master secret and Pre-master secret

46 X’96’ FPVK (Fuel-Card PIN Verification Key)

47 X’9A’ Host-stored Random Keys exchanged between the FEP and the
terminal.

48 CCMK

57 MKDK

The variant constant is obtained by repeating the variant byte listed in the table above. The number of occurrence
depends upon the key length, for example, variant byte is repeated 8 times for single length keys, 16 times for double
length and 24 times for triple length.

Derivation Key Variant Scheme


The derivation key for each key type should be a distinct key type. The variant constant for a derivation key is a
variation of the variant constant for the associated working key. The variation sets the 1st and 3rd bytes of each 8 bytes
of the variant constant to a fixed common value, viz. X'EE'. The notation for the derivation key types will be DK-xxx,
where xxx is the key type of the associated working key and the variant id will be 40 more than the variant id for the
working key. Following table lists the variant constants for working keys and those for their corresponding derivation
keys :

Working key Variant Value 8-byte variant constant for working key

DPK 0 00000000
00000000

PPK 1 28282828
28282828

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 33
CHAPTER 1 Function Construction - Luna EFT

Working key Variant Value 8-byte variant constant for working key

MPK 2 24242424
24242424

KIS 3 4444444444444444
4444444444444444

KIR 4 8888888888888888
8888888888888888

KTM 5 2222222222222222
2222222222222222

DK-DPK 40 EE00EE00 00000000

DK-PPK 41 EE28EE28 28282828

DK-MPK 42 EE24EE24 24242424

DK-KIS 43 EE44EE4444444444

DK-KIR 44 EE88EE8888888888

DK-KTM 45 EE22EE2222222222

The variant constant will be applied identically to each 8-byte portion of the double length KM.

SafeNet Variant Scheme


Variants of KIS/KIR keys are used to provide functional separation as described in AS2805 Part 6.1, 1988. The variant
is calculated as described in AS2805 Part 6.1, 1988 using the constants defined in the tables below.
The variant constant is formed by repeating the Variant Byte from the following table 8 times (for single length keys) or
16 times (for double length keys).
Note that no variant is applied to KIS/KIR keys used to encrypt DPK keys. Support for KTM keys added in SafeNet
Variant Scheme.

Variant Byte Used to Protect

X'24' MPK

X'28' PPK

X'22' KTM

Atalla Variant Scheme


The Atalla key management system separates DPK, PPK and MPK keys by storing and downloading then under
different variants of KIS/KIR keys.
Single length key variants are formed by exclusive or’ing (XOR) the variant byte with the left most byte of the key.
Double length key variants are formed by exclusive or’ing (XOR) the variant byte with the left most byte of each half of
the key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 34
CHAPTER 1 Function Construction - Luna EFT

The variant bytes used for the Atalla variant scheme are listed in the following table.

KIS/KIR variant Variant Byte Used to Protect

1 X'08' PPK

2 X'10' DPK

3 X'18' MPK

AS2805.6.1 Variant Scheme


Variants of KIS/KIR keys are used to provide functional separation as described in AS2805 Part 6.1, 2002. The variant
is calculated as described in AS2805 Part 6.1, 2002 using the constants defined in the table below. This variant
scheme is identical to the current APCA variant scheme.
In order to provide additional separation between 64-bit, 128-bit and 192-bit DEA keys the standard has been extended
as described below. In each case the variant key is obtained by an XOR operation of the base key with the Variant
Constant.

Variant Byte Used to Protect

X'22' DPK

X'24' MPK

X'28' PPK

Size of Session Key Method

64-bit DEA keys The variant constant is obtained by repeating the Variant Byte from the above table to yield
an 8 byte constant.

128 bit CBC and DEA The variant constant is obtained by concatenating the variant byte from the above table with
keys the constant xC0 and repeating these 2 bytes 8 times to yield a 16 byte constant.

192 bit CBC and DEA The variant constant is obtained by concatenating the variant byte from the above table with
keys the constant x30 and repeating these 2 bytes 12 times to yield a 24 byte constant.

Key Specifier Formats

Key Specifier Formats for HSM-stored Keys


The following key specifier formats provide access to keys stored in tables (or files) within HSM Secure Memory. The
formats incorporate an index which identifies the required key in a table; the particular table to access is implicit in the
function definition.
All the formats support index values from zero to the maximum value which fits in the field. Restrictions in the values
are applied by other considerations, such as physical capacity of Secure Memory. All tables are indexed from one, so
zero is an invalid value.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 35
CHAPTER 1 Function Construction - Luna EFT

Format 00
Index - short / BCD
Field length: 2

Field Byte Type Description

Format 1 x 00

Index 2 d 00 - 99

Format 01
Index - short / binary
Field length: 2

Field Byte Type Description

Format 1 x 01

Index 2 x 00 - FF

Format 02
Index - long / BCD
Field length: 3

Field Byte Type Description

Format 1 x 02

Index 2-3 d 0000 - 9999

Format 03
Index - long / binary
Field length: 3

Field Byte Type Description

Format 1 x 03

Index 2-3 x 0000 - FFFF

Key Specifier Formats for KM-encrypted Keys


These key specifiers are required for a host function to access and use a key (PPK) in the User Store. The key specifier
identifies the index of the location in the key store. The key specifiers (04-07) as defined below, are similar to the
existing format 00 – 03 key specifiers that provide access to tables of HSM-stored keys.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 36
CHAPTER 1 Function Construction - Luna EFT

Format 04
User Store Index – short / BCD

Field Length Type Description

Format 1 h 04

Index 1 d 01 - 99

Format 05
User Store Index – short / binary

Field Length Type Description

Format 1 h 05

Index 1 h 01 - FF

Format 06
User Store Index – long / BCD

Field Length Type Description

Format 1 h 06

Index 2 d 01 - 9999

Format 07
User Store Index – long / binary

Field Length Type Description

Format 1 h 07

Index 2 h 01 – FFFF

Key Specifier Format for explicit key type identification


The following key specifier format explicitly identifies the key type KI. For HSM-stored keys it specifies which key table
to access and for Host-stored keys it specifies which KM variant to use.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 37
CHAPTER 1 Function Construction - Luna EFT

Format 08
HSM- or host-stored key - explicit

Field Length Type Description

Format 1 h 08

Key Type 1 h 10: KI

Key Index Var K-spec Formats 0 – 3, 10 – 14

Key Specifier Formats for Host-stored Keys


The following key specifier formats incorporate encrypted key values. Formats for single-, double-, and triple-length
keys are specified, and both single and multiple Domain Master Keys (KM) are supported.

Format 10 -14
The field lengths shown for formats 10-14 below assume DES keys appropriate to current functionality. However, the
algorithm and associated key length is not implicit in the key specifier; so these formats could be equally appropriate for
other algorithms, and might then have a different field length.

Format 10
Encrypted key - Single-length
Field length: 9

Field byte type Description

Format 1 x 10

Index 2-9 x eKMx(K)

Format 11
Encrypted key - Double-length - ECB
Field Length: 17

Field byte type Description

Format 1 x 11

Index 2-17 x eKMx(K)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 38
CHAPTER 1 Function Construction - Luna EFT

Format 12
Encrypted key - Triple-length - ECB
Field length: 25

Field byte type Description

Format 1 x 12

Index 2-25 x eKMx(K)

Format 13
Encrypted key - Double-length – CBC
Field length: 17

Field byte type Description

Format 1 x 13

Index 2-17 x eKMx(K)

Format 14
Encrypted key –Triple-length– CBC
Field length: 25

Field byte type Description

Format 1 x 14

Index 2-25 x eKMx(K)

Format 15
The following key specifier format supports the storage of key attributes. Note an IV of all zeros is used in the formation
of the Authentication Code.

Host-stored key / authenticated / with attributes

Field Length Type Description

Format 1 h 15

Version 1 h 01

Key Type 1 h 00 = RFU


01 = Interchange key
02 = BPS Base Derivation Key (BDK)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 39
CHAPTER 1 Function Construction - Luna EFT

Host-stored key / authenticated / with attributes

Field Length Type Description

Key sub-type 1 h 00, unless otherwise specified for a particular Key Type.
For Key Type = 01:
00 = RFU
01 = KIS
02 = KIR
For Key Type = 02:
01 = Derive UKD (DUKPT IK)
02 = Derive TK (DUKPT PIN-encrypting key)

KM-Id 1 h Identifies the KM (applies to AMB HSM) used with the authentication
algorithm, otherwise must be zero.

Authentication 1 h 01 = 3DES CBC 64-bit MAC


Algorithm Id.

Attribute Count 1 h Number of attributes (Key Type = 01)


02 for KIS/KIR keys
Number of attributes (Key Type = 02)
02 for BPS-BDK keys

Padding 1 h 00

eKMv20(K) Var h 3DES CBC-encrypted key.


IV = bytes 1 – 8 of key specifier.

KIS/KIR See below Number related to Attribute Count.


Attributes (See KIS/KIR Attributes below)

MAC 8 h Authentication code calculated on previous fields, using variant 19 of


KM and the algorithm specified in Authentication Algorithm Id.

The following table lists KIS/KIR attributes for Format 15.

Attribute Length Type Description


Number

1 1 h Variant Scheme
00 none
01 Safenet
02 Atalla
03 AS2805.6.3 2000

2 1 h 00 functions enabled
01 functions disabled (only set when
variant type = 00 )

The BPS-BDK Attributes for the format 15 key specifier are as follows:

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 40
CHAPTER 1 Function Construction - Luna EFT

BDK Attributes

Field Length Type Description

w 1 H Number of rounds (08)

F 1 H BPS Function
1 = TDEA

DBL, Triple Length Permitted.

Format 16
The following key specifier format explicitly incorporates algorithms and other parameters associated with the key.

Encrypted key – Algorithm included

Field Length Type Description

Format 1 h 16

Algorithm 1 h Algorithm
E0 = SEED

Key length 1 h Key length


02 = 128

Block length 1 h Block Length


02 = 128

Mode of operation 1 h Mode of Operation


01 = ECB
02 = CBC

eKMv(K) Var h Encrypted key

Format 17-18

Format 17 (Key Specifier Format for ANSI TR-31 Key Block)


The following key specifier format supports a complete ANSI TR-31 Key Block. Variants of the KM are used as the
encryption key and the MAC key for host stored keys. Variants of the KTM are used as the encryption key and the MAC
key for terminal destined keys.

Host-stored key/authenticated/with attributes

Field Length Type Description

Format 1 h 17

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 41
CHAPTER 1 Function Construction - Luna EFT

Host-stored key/authenticated/with attributes

Field Length Type Description

KM-Id 1 h Must be set to zero.


Note: KM Index will be identified by Proprietary Optional Blocks.
See Optional Key Block Header table to specify the KM identifier for format
17 and 18.

Secure key n h ANSI key Block. The length n is identical to that specified in bytes 1 – 4 of
Block the Block header.

Format 18 (Key Specifier Format for ANSI TR-31 Key Block)


The following key specifier format supports an ANSI TR-31 Key Block using binary fields instead of ASCII. This uses
less storage space and provides support for some fields not defined in TR-31 (for example, HMAC-SHA-1 algorithm).
This key specifier format definition allows for a Binary Key Block to be converted to a TR-31 key Block (or vice versa)
with no change to the value of the MAC.
Variants of the KM are used as the encryption key and the MAC key for host stored keys.
Variants of the KTM are used as the encryption key and the MAC key for terminal destined keys.

Host-stored key/authenticated/with attributes

Field Length Type Description

Format 1 h 18

KM-Id 1 h Must be set to zero.


KM Index will be identified by Proprietary Optional Blocks.
See Optional Key Block Header table to specify the KM identifier for format
17 and 18.

Secure key n h Binary Key Block. The key Block is identical Format 17 described above,
Block with the exception that the encrypted key field and the MAC field are
stored in binary and not expanded to hex-ASCII. The Key Block Length in
bytes 1-4 of the Secure Key Block, however, is the length of the equivalent
TR-31 Key Block (that is the length that would occur following the
expansion to hex-ASCII).

Translation (migration, export and import) of host stored keys in-between variant form and key block form requires
restriction and is allowed only if permitted by an administrator.
The following table summarizes the restrictions on keys translation in-between variant form and key block form, where,
A = Allowed
AWR = Allowed with restrictions.

Key Format variant TR-31

variant A A

TR-31 AWR A

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 42
CHAPTER 1 Function Construction - Luna EFT

By default, keys migration/export/import restrictions are enabled. Select Enable Keys Migration/Export/Import from
keyblock to variant check box from the Configuration Control console operation to disable these restrictions. An error
code 'A1' is returned if key translation is performed without disabling these restrictions.

Optional Key Block Header


(The below optional key block header specify the KM identifier for format 17 and 18).

Optional block id 01 2AN Identifier of optional block

Optional block length 08 2H Length

Optional block data 0000-9999 4N Index of KM


Valid values: 0000 - 0015

In case of Format 18, the optional block header fields are provided in binary.

Format 19
The following key specifier format supports a CAP Bitmap. The CAP Bitmap specifier is an authenticated data
structure containing a payload in the clear. Although the CAP Bitmap specifier does not contain a key, it is implemented
as a key specifier, as the key specifier format is easily extended to hold CAP Bitmap data.
The data specifier incorporates a header, a payload and an authentication code. The header indicates the format of the
payload. The present implementation only supports payload data that is not encrypted.
With the exception of the header (first 8 bytes) and the final field (8-byte authentication code) the complete contents of
the data specifier may be CBC-encrypted with KMv20, with the header utilized as the IV. An IV of all zeros is used in
the formation of the Authentication Code.

Host-stored bitmap

Field Length Type Description

Format 1 h 19

Data Specifier Type 1 h = 02 – CAP Bitmap

Encrypted Payload 1 h = 00 - payload is not encrypted

KM-Id 1 h For the AMB HSM, identifies the KM used, otherwise must be
zero.

Payload Length 2 h = 0008

Pad1 2 h = 0000

Bitmap 8 h Field from IPB

Authentication Code 8 h 3DES CBC 64-bit MAC calculated on all previous fields, using
KMv19.

Format 20
The following key specifier format supports a Derived Unique Key per Transaction (DUKPT). DUKPT is a key
management method which uses a unique key for each transaction, and prevents the disclosure of any past key used

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 43
CHAPTER 1 Function Construction - Luna EFT

by the transaction-originating HSM (i.e. terminal PIN pad).


DUKPT utilization is possible via host-stored and HSM-stored base derivation keys.

Host-stored key/authenticated/with attributes

Field Length Type Description

Format 1 h 20

BDK Var K-spec Key specifier for the Base Derivation Key (BDK). (Formats 0-3,
13, 14, 15, 17, 18 )

KSN 10 h Key serial number (= Initial key serial number + Encryption


counter) supplied by pin pad

Derived Key Type 1 h Specifies the length of the transaction key


0x02= double length (TDEA transaction key is derived) and the
variant constant indicator will be used for request or both ways.
0x12= variant constant indicator will be used for response.

Format 20 key specifier incorporates a format 0-3 key specifier for HSM-stored BPS-BDK, or a format 15 key specifier
with Key Type = 02 for a host-stored BPS-BDK.

Format 50
This key specifier calculates a unique-per-card derived key. It is used to derive KKEK (as defined in [Reference [32] of
Mark II]) so that the key may be used to encrypt a key or sensitive data to be sent to the card. CardMethod (01 or 02)
define the mode of encryption.

Unique-per-card derived key

Field Length Type Description

Format 1 h 50

KMC Var K-Spec Key specifier for personalization master key (format 0 –3,
13, 17, 18).

Card-unique derivation data 16 h Derivation data unique to a card.

Card method 1 h = 01: ECB


= 02: CBC

Format 51
This key specifier calculates a unique-per-card derived session key. It is used to derive SKUENC, SKUMAC (as defined
in [32] and [33] of Mark II]) in support of the mutual authentication of the card being personalized and its host.
CardMethod (01 or 02) and SessionMethod (01 or 02) define the mode of encryption.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 44
CHAPTER 1 Function Construction - Luna EFT

Unique-per-card derived session key

Field Length Type Description

Format 1 h 51

KMC Var K-Spec Key specifier for personalization master key (format 0 –
3, 13, 17, 18).

Card-unique derivation data 16 h Derivation data unique to a card.

Card method 1 h = 01: ECB


= 02: CBC

Session data 16 h

Session method 1 h = 01: ECB


= 02: CBC

Format 52 and 53
New key specifier formats are required in order to accommodate AES and the derivation scheme defined in
GlobalPlatform SCP03 [76].

Format 52
Unique-per-card derived AES key

Field Length Type Description

Format 1 h 52

KMC Var K-Spec Key specifier for personalization master key(format 1C).

Card-unique derivation Var h Card derivation data used for deriving key.
data

Card method 1 h = 01: ECB


= 02: CBC
= 03: KDF_1

Key length 1 h Length of key to derive.


02 = 128 bits
03 = 192 bits
04 = 256 bits

KMC Index of HSM stored KMC or Host stored KMC in 1C format.

Card-unique Derivation Card derivation data used for deriving a key.


data

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 45
CHAPTER 1 Function Construction - Luna EFT

Card method Encryption mode employed to derive a key.

Key length Length of key to be derived.

Key Length should not be more than length of Card-unique derivation data.

Processing Steps
1. Process the derivation data using the derivation key and the card method.
2. Select the leftmost bits of the resultant as the derived key (as specified by key length).

NOTES:
1. The KDF-1 card method is as specified in 4.1.5 of [75]. The supplied derivation data should comprise of:

Derivation Constant 1 byte

Context 16 bytes

Input data to PRF (that is called in KDF-1 card method) will contain
PRF (KI, Label || 0x00 || [L] || [i] || Context) where ,

KI = Encrypting key

Label = 11 bytes 0x00 || 1 Byte Derivation Constant

[L] = Length of output key, can be one of following


“0040” for 64-bit length key
“0080” for 128-bit length key
“00C0” for 192-bit length key
“0100” for 256-bit length key

[i] = Iteration counter


“01” for key length 64/128 bit
“02” for key length 192/256 bit

Context = Context as passed in derivation data

2. This is as specified in [75], though no check or alterations will be made to the supplied data.
3. The derived key can be no longer than the derivation key.
KDF_1 specifies KDF in counter mode as specified in NIST SP 800-108. The PRF used in the KDF shall be CMAC as
specified in NIST SP 800-38B, used with full 16 byte output length.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 46
CHAPTER 1 Function Construction - Luna EFT

Format 53
Unique-per-card derived AES key

Field Length Type Description

Format 1 h 53

KMC Var K-Spec Key specifier for personalization master key(format 1C).

Card-unique derivation Var h Card derivation data used for deriving key.
data

Card method 1 h = 01: ECB


= 02: CBC
= 03: KDF_1

Card Key length 1 h Length of card static key to derive.


02 = 128 bits
03 = 192 bits
04 = 256 bits

Session data Var h Session data used for deriving key.

Session method 1 h = 01: ECB


= 02: CBC
= 03: KDF_1

Session key length 1 h Length of card session key to derive.


02 = 128 bits
03 = 192 bits
04 = 256 bits

KMC Index of HSM stored KMC or Host stored KMC in 1C format.

Card-unique Derivation data Card derivation data used for deriving a key.

Card method Encryption mode employed to derive a key.

Card Key length Length of key to derive. Key Length should not be more than length of Card-unique
derivation data.

Session Data Session data used for deriving a key.

Session method Encryption mode employed to derive a key.

Session key length Length of key to derive. Session key length should not be more than length of
Session data.

Processing Steps
1. Process the card-unique derivation data using the derivation key and the card method.
2. Select the leftmost bits of the resultant as the card static key and as specified by card key length.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 47
CHAPTER 1 Function Construction - Luna EFT

3. Process the session derivation data using the derivation key and the session method.
4. Select the leftmost bits of the resultant as the card session key and as specified by session key length.
NOTES
• The KDF-1 card/session method is as specified in 4.1.5 of [75]. The supplied card / session derivation data should
comprise of:
Derivation Constant - 1 byte
Context - 16 bytes
• More details regarding data formatting used in PRF is given in format 52. This is as specified in [77], though no
check or alterations will be made to the supplied data.
• KDF_1 specifies KDF in counter mode as specified in NIST SP 800-108. The PRF used in the KDF shall be CMAC
as specified in NIST SP 800-38B, used with full 16 byte output length.
• Each derived key should not be longer than the length of the derivation key used to derive it. It should be of a length
equal to or less than the derivation key (In 6.1 of [75] it is specified that the derived session key is the same length
as the card static key, but the HSM host functions do not enforce this stipulation).

Format 54
This key specifier format supports AES keys.

Field Length Type Description

Format 1 h 54

Derivation Key Type 1 h 10 = KI

K-Spec Var h Key Spec format 0-3, 17, 18


For format 17 and 18:

Key Usage Mode of Use Algorithm

K0, K1 N A

Algorithm 1 h 00 = Method 1 (Method 1 corresponds to


Schlüsselausgabe_AES_Schlüssel_v1.5, Reference A
[92])
0A = Method 2 (EMV 4.3 AES CSK for MAC verification
only)

Associated Parameter Var h Associated parameter array

Conditions:
1. This key spec is available only for AES keys as of now.
2. KM index field must match the KM index specified in K-Spec in 17, 18.
3. For method type = 00, the associated parameter set will have two random numbers to derive two sub-keys, KIENC
and KIAUTH for decryption and authentication. Associated parameter values will be two sets of ICV and Random
Numbers. The objective of two intermediate keys are - KIENC for encryption/decryption and KIAUTH for
generation/verification of key.
4. For algorithm type = 0A, only 1 set of ICV and random number will be used.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 48
CHAPTER 1 Function Construction - Luna EFT

5. The derivation method for keys for algorithm = 00, 0A}is same as EMV CSK for AES from EMV v4.3
6. All the individual parameters presented as an array in associated parameters will be of type var.
7. All the types defined as RFU will return error until and unless they have been defined and applicable for the function
in which the key spec has been supplied.
8. For encryption and authentication associated parameter will also support MAC length which will vary from decimal
4-16.
For method =00, Associated Parameter table is given below:

Name Length Type Description

Derivation Data - 1 16 h Derivation Data for encryption Key.

Derivation Data - 2 16 h Derivation Data for Authentication Key.

For method = 0A, Associated Parameter table is given below:

Name Length Type Description

Derivation Data 16 h Derivation Data for Authentication Key.

Format 80 - 83
The following formats (80 – 83) for the key specifier structure support the host-storage of RSA public and private keys.
A public key is stored in a clear form, with or without an authentication value, while a private key is stored encrypted by
a variant of KM.

Format 80
In accordance with existing HSM convention, multi-byte integers (modulus and exponent) are stored with the leftmost
byte containing the most-significant bits (i.e. big-endian).

RSA public key – Clear, unauthenticated

Field Length Type Description

Format 1 h 80

Modulus Var h Modulus of RSA public key.

Exponent Var h Exponent of RSA public key.


len(Exponent) ≤ len(Modulus)
No leading zeros

Format 81
This key specifier will be supported by the KM-MIGRATE function, to translate Authentication Value from an old KM to
the current KM.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 49
CHAPTER 1 Function Construction - Luna EFT

RSA public key – Clear, authenticated

Field Length Type Description

Format 1 h 81

Modulus Var h Public key modulus.

Exponent Var h Public key exponent.


len(Exponent) ≤ len(Modulus) Leading zeroes need not
be included.

KM-Id 1 h For the AMB HSM, identifies the KM used with the
authentication algorithm, otherwise must be zero.

Key Type 2 h Key Type attribute bits

Authentication Algorithm Id. 1 h = 013DES CBC 64-bit MAC

User data Var h Optional user data.

Authentication Value Var h Authentication value calculated using variant 19 of KM


and the algorithm specified in Authentication Algorithm
Id.

Format 82
This key specifier will be supported by the KM-MIGRATE function, to translate eKMv20(SK) and Authentication Value
from an old KM to the current KM.

RSA private key – Encrypted

Field Length Type Description

Format 1 h 82

Mod Len 2 h Length of modulus (m) in bytes.

Key format 1 h Format of the encrypted key field.


= 01: Safenet default format.

KM-Id 1 h For the AMB HSM, identifies the KM used to encrypt the
private key and with the authentication algorithm,
otherwise must be zero.

Key Type 2 h Key Type attribute bits

Authentication Algorithm Id. 1 h = 01: 3DES CBC 64-bit MAC

User data Var h Optional user data.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 50
CHAPTER 1 Function Construction - Luna EFT

RSA private key – Encrypted

Field Length Type Description

eKMv20(SK) Var h Private key, encrypted with variant 20 of KM.


Plaintext format of SK prior to encryption defined
elsewhere, and not necessarily for general publication.

Authentication Value Var h Authentication value calculated using variant 19 of KM


and the algorithm specified in Authentication Algorithm
Id.

Format 83
It is required that CA-EFT public key is encrypted for host storage. Format 83 key specifier, as defined below,
incorporates an encrypted public key.

RSA public key - Encrypted

Field Length Type Description

Format 1 h 83

Mod Len 2 h Length of modulus (m) in bytes.

Key format 1 h Format of the encrypted key field.


= 01: Default format.

KM-Id 1 h 00

Key Type 2 h Key Type attribute bits

Authentication 1 h = 01: 3DES CBC 64-bit MAC


Algorithm Id.

User data Var h Optional user data.

eKMv20(PK) Var h Public key, encrypted with variant 20 of KM.


The plaintext format of PK prior to encryption is shown below.

Authentication Var h Authentication value calculated using variant 19 of KM and the


Value algorithm specified in Authentication Algorithm Id.

Plaintext PK prior to encryption

Field Length Type Description

Modulus Mod Len h Public key modulus.

Exponent Mod Len h Public key exponent.


len(Exponent) = len(Modulus) – with leading zeroes.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 51
CHAPTER 1 Function Construction - Luna EFT

Plaintext PK prior to encryption

Field Length Type Description

Padding 0–7 h Pad with zeroes, if required.

Format 90
The following Key Specifier Format specifies the format for a ZKA Random Number. This key specifier incorporates the
data required to produce a clear PAC or MAC session key. A PAC key is produced if the key specifier is used within a
PIN management function and a MAC key is produced if the key specifier is used within a message authentication
function. It can also incorporate a format 92 key specifier as the MK-spec, in order to access a key in the MK2 table.
This key specifier format can also be used as an alternative format in a PPK-spec or MPK-spec request field in
standard functions. Specifically, the following functions will support a ZKA-RND format key specifier:
• MAC-UPDATE, MAC-GEN-FINAL, MAC-VER-FINAL
• PIN-TRANSLATE
• PIN-VERIFY, Calculate IBM Offset, MIGRATE-PIN
• PIN Verify – PVV, Calculate PVV from IBM Offset, Calculate PVV from PIN

Encrypted session key

Field Length Type Description

Format 1 h 90

MK-spec Var K-spec Key specifier for Master key


(formats 0–3, 13, 17, 18, 92).

CV-index 1 h 0 = use values in ZKA documentation;


>0 = use HSM-stored CV values

RND 16 h Random Number (Encrypted Session Key eTK(KS))

The CV values defined in ZKA documentation may be overridden by CV values stored within the HSM.
The following Control Vector values are used when constructing a format 90 host stored key specifier. Key values for
each type are defined below.

Type CV1 CV2

MAC 00 00 4D 00 03 41 00 00 00 00 4D 00 03 21 00 00

PAC 00 21 5F 00 03 41 00 00 00 21 5F 00 03 21 00 00

Format 91
The following Key Specifier Format specifies the format for a ZKA-Derived-*KK. This key specifier incorporates the
data required to derive a *KKBLZ as follows:
*KKBLZ = e*KGK1 (BLZ | BLZ) | e*KGK2 (BLZ | BLZ)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 52
CHAPTER 1 Function Construction - Luna EFT

The key specifier may be used in the functions that contain a '*KK-spec' field, i.e. 'ZKA-PIN-VER – ecPVN method '
and 'ZKA-Calculate PVN – from encrypted PIN'

ZKA-Derived-*KK

Field Length Type Description

Format 1 h 91

*KGK1-spec Var K-spec Key specifier for *KGK1


(formats 0-3, 13, 17, 18)

*KGK2-spec Var K-spec Key specifier for *KGK2


(format 0-3, 13, 17, 18)

BLZ 4 h 00000000 - FFFFFFFF

Format 92
The following Key Specifier Format specifies the format for a ZKA-MK2 key. This key specifier is used to reference an
MK in the MK2 table.
A value of X'FF' in any of the 'h' field or a value of 9999 in the 'd' field indicates that the field value has not been
specified. The permissible omitted fields are indicated in the usage context of the key specifier.
Specification of Sub-type Number, Version Number and Generation Number unambiguously references a specific
record in the MK2 table.
Alternatively (for example), Version Number and / or Generation Number may be set to X'FF' and / or Expiry Date may
be set to 9999 to indicate that a search of the table should be performed. The search criteria are specified in the context
where the key specifier is used.

MK2 reference

Field Length Type Description

Format 1 h 92

Sub-type 1 h = hex 00 – 63, or FF

Version Number 1 h = hex 00 – 63, or FF

Generation Number 1 h = hex 00 – 63, or FF

Expiry Date 2 d mmyy, where mm = BCD 01 – 31 and yy = BCD 00 – 99;


or mmyy = 9999

Format 93
ZKA encrypted session key

Field Length Type Description

Format 1 h 93

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 53
CHAPTER 1 Function Construction - Luna EFT

ZKA encrypted session key

Field Length Type Description

MK Var K-spec ZKA Master Derivation Key


(formats: 0-3, 13, 92)

Derivation Data 16 h Unique-per-terminal data

CV-index 1 h 0 = use values in ZKA documentation


>0 = use HSM-stored CV values

RND 16 h Random Number


(Encrypted Session Key eTK(KS))

ATM-unique ZKA keys are generated by applying the SECCOS method (based on the ISO-10118-2/MDC-2 hash) of
key derivation (i.e. using a Master Key (KGK) as Master Derivation Key and a 16-byte terminal ID value as derivation
data).
The Derivation Data comprises 8 bytes of Terminal ID (16 alphanumeric EBCDIC characters) padded with 8 bytes of
‘00’, but this will not be checked and any value will be accepted – unless instructed otherwise.
Following are the details of SECCOS method implementation:
• Produce MDC-2 hash of Derivation Data (Refer sec 8.4.1 “Algorithm for the derivation of a card individual key from
a master key” of [68])
• Decrypt the hash data using ZKA Master Derivation key
• The resultant will be used as a Master/ Key Encryption Key that encrypts RND

Format 1A
The following Key Specifier Format (1A) specifies the format for carrying a KM-encrypted PIN.
The Domain Master Key (KM) and its variants are typically used to protect other keys. Modern usage of the KM has
involved the ‘key specifier’ function field. Consistent with this usage, the KM-encrypted PIN comprises a formatted PIN
Block that is encrypted using a dedicated variant of KM and managed within this key specifier, designed for this
purpose.
Prior to encryption, the PIN is formatted into an ISO format 3 PIN Block.
The ISO format 3 PIN Block is ECB-encrypted using a dedicated variant of KM, and therefore the resulting ciphertext
Block has a length of 8 bytes.
Use of ISO format 3 implies that the 12-digit Account Number Block (ANB) must be supplied when the PIN is
generated, and whenever the KM-encrypted PIN is subsequently used.
KM variant 27 is used for PIN-Block encryption to produce a KM-encrypted PIN for host storage. The hexadecimal
constant associated with KMv27 is X’74’.

KM-encrypted PIN

Field Length Type Description

Format 1 h 1A

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 54
CHAPTER 1 Function Construction - Luna EFT

KM-encrypted PIN

Field Length Type Description

Type 1 h = 01

KM-Id 1 h For the AMB HSM, identifies the KM used, otherwise


must be zero.

eKMv27(PIN) 8 h Encrypted PIN Block.

Format 1B (Key Specifier Format for TLS Master Secret and Pre-master Secret Keys)
A new key specifier is used for the host storage of the TLS master secret and pre-master secret keys. The new key
specifier is as follows:

Encrypted PMS or MS - CBC

Field Length Type Description

Format 1 h 1B

Encrypted Secret 48 x eKMv39(Secret)

Format 1C (Key Specifier Format for Advanced Encryption Standard (AES) Support)
A new Key Specifier is required in order to support AES keys. This key specifier incorporates a KM-encrypted key,
while providing details of the KM used for encryption and of the incorporated key.

Encrypted key – Algorithm included

Field Length Type Description

Format 1 h 1C

KM-index 1 h Index into the HSM-stored KM table

Key Type 1 h Variant id

Algorithm 1 h Algorithm
01 = DES/3DES
02 = AES
E0 = SEED

Key length 1 h Key length


01 = 64 bits
02 = 128 bits
03 = 192 bits
04 = 256 bits

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 55
CHAPTER 1 Function Construction - Luna EFT

Encrypted key – Algorithm included

Field Length Type Description

Padding 1 h 01 = trailing zeroes


02 = trailing random

Mode of operation 1 h Mode of Operation


01 = ECB
02 = CBC

eKMv(Key) Var h Encrypted key – using a variant of KM at specified index

KM-index Index of KM. Index must be greater than 1 and less than 17. Details regarding type (algorithm and
length) of KM is stored in the mode file.

Key Type Key type of encrypted key

Algorithm Algorithm used by encrypted key to encrypt/decrypt data.


01 : DES/3DES
02 : AES
E0 : SEED

Key length Length of encrypted key.


01 : 64 bits.
02 : 128 bits.
03 : 192 bits.
04 : 256 bits.

Padding Padding is required by algorithms to maintain a block size (for example, 128-bit block size for
SEED & AES and 8 byte block size for 3DES).
01 : trailing zeros.
02 : trailing random.

Mode of operation Refers to mode of operation applied while decrypting/ encrypting key with KM. For more details
refer to the section below, KM Encryption Conditions.

eKMv(Key) Encrypted key.

KM Encryption Conditions
1. When KM is AES - Following conditions must hold when KM is AES:
o AES-192 and DES/3DES (single and triple length) KM-encrypted keys will need to be padded prior
to encryption, as block length for AES is 128-bit or 16 bytes.
o A mode of operation needs to be selected for encryption/decryption of AES-192 and AES-256 KM-
encrypted keys.
Where a standard key block is employed (for example, TR-31) these considerations may be addressed in the standard.
Otherwise padding and modes will either use a default specified here, or employ user selections as allowed for here.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 56
CHAPTER 1 Function Construction - Luna EFT

Note: TR-31 does not currently allow for the use of AES as a key block protection key.

2. When KM is TDES – Following condition must hold when KM is TDES:

A mode of operation needs to be selected for encryption/decryption of keys which have length greater than 8 bytes or 64
bits.

Key Specifier Usage


The key specifier is widely used in newly developed host functions. The type of key being accessed by the key
specifier will most likely always be implicit in the function design. For example, in one place a key specifier might be for
a terminal master key, in another place it could be for PIN verification key, and in yet another it could be for a PIN
encrypting key. This is identical to the current situation with indexes to HSM-stored keys.
The function field therefore always identifies the type of key that the key specifier is for. It will not always be appropriate
for a given key type to be HSM-stored or host-stored. Nevertheless, a key specifier is still useful, e.g., to provide a
choice of formats for specifying an index to a HSM-stored key.

Key Specifier Key Applicability Usage Criteria

00 , 01, 02, 03 HSM-stored keys Used when specifying an index to a HSM


stored key.

04 , 05, 06, 07 KM encrypted keys Used for a host function to access and use a
key (PPK) in the User Store. The key
specifier identifies the index of the location in
the key store.

08 Explicit Key Type Identification Used when specifying explicit key type.

10 Host-stored keys Used to specify single-length, host stored


keys that are encrypted using ECB.

11 Host-stored keys Used to specify double-length, host stored


keys that are encrypted using ECB.
Note that this key specifier should only be
used to supply host stored keys that are
known to have been generated using these
legacy functions. New functions use CBC to
encrypt double-length keys.

12 Host-stored keys Used to specify triple-length, host stored keys


that are encrypted using ECB.
Note that this key specifier should only be
used to supply host stored keys that are
known to have been generated using these
legacy functions. New functions use CBC to
encrypt triple-length keys.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 57
CHAPTER 1 Function Construction - Luna EFT

Key Specifier Key Applicability Usage Criteria

13 Host-stored keys Used to specify double-length, host stored


keys that are encrypted using CBC.

14 Host-stored keys Used to specify triple-length, host stored keys


that are encrypted using CBC.

15 Host-stored keys Supports the storage of key attributes.

16 Host-stored keys Incorporates algorithms and other parameters


associated with the key.

17 Host-stored keys Supports a complete ANSI TR-31 Key Block.


Variants of the KM are used as the encryption
key and the MAC key for host stored keys.
Variants of the KTM are used as the
encryption key and the MAC key for terminal
destined keys.

18 Host-stored keys Supports an ANSI TR-31 Key Block using


binary fields instead of ASCII. This uses less
storage space and provides support for some
fields not defined in TR-31 (for example,
HMAC-SHA-1 algorithm).
This key specifier format definition allows for
a Binary Key Block to be converted to a TR-
31 key Block (or vice versa) with no change to
the value of the MAC.

19 Host-stored keys Supports a CAP Bitmap. The CAP Bitmap


specifier is an authenticated data structure
containing a payload in the clear.

20 Host-stored keys Supports a Derived Unique Key per


Transaction (DUKPT).

50 Host-stored keys Calculates a unique-per-card derived key. It is


used to derive KKEK so that the key may be
used to encrypt a key or sensitive data to be
sent to the card.

51 Host-stored keys Calculates a unique-per-card derived session


key. It is used to derive SKUENC, SKUMAC in
support of the mutual authentication of the
card being personalized and its host.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 58
CHAPTER 1 Function Construction - Luna EFT

Key Specifier Key Applicability Usage Criteria

52 Host-stored keys Required to accommodate AES and the


derivation scheme defined in GlobalPlatform
SCP03.
KMC must be AES host stored key and can
53 Host-stored keys be of 128-bit or 192-bit or 256-bit length.
TDES encrypting keys will not allowed to
encrypt AES derived keys.

80 Host-stored keys Support the host-storage of RSA public and


private keys. A public key is stored in a clear
81 form, with or without an authentication value,
while a private key is stored encrypted by a
82 variant of KM.

83 Host-stored keys Incorporates an encrypted public key

90 Host-stored keys Specifies the format for a ZKA Random


Number. This key specifier incorporates the
data required to produce a clear PAC or MAC
session key.
It can also be used as an alternative format in
a PPK-spec or MPK-spec request field in
standard functions.

91 Host-stored keys Specifies the format for a ZKA-Derived-*KK.


This key specifier incorporates the data
required to derive a *KKBLZ

92 Host-stored keys Specifies the format for a ZKA-MK2 key. This


key specifier is used to reference an MK in the
MK2 table.

93 Host-stored keys Used to generate ATM-unique ZKA keys

1A Host-stored keys Specifies the format for carrying a KM-


encrypted PIN

1B Host-stored keys Used for the host storage of the TLS master
secret and pre-master secret keys.

1C Host-stored keys Used to support AES keys. This key specifier


incorporates a KM-encrypted key, while
providing details of the KM used for
encryption and of the incorporated key.
TDES encrypting keys will not allowed to
encrypt AES derived keys.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 59
CHAPTER 1 Function Construction - Luna EFT

PIN Block Formats


Supported PIN Block Formats
The format of a PIN Block is specified in a single-byte field. The valid values for the field and the associated meanings
are shown in the following table.

Format Name Description

01 ANSI Identical to existing PIN-TRAN Format 1 – ANSI format; AS2805 Part 3 format 0; ISO 9564-1
Format 0.

02 Docutel 2 Contains 1-digit PIN length, 4 to 6-digit PIN and a user-defined padding string of 9 digits. If
the PIN has 4 or 5 digits, it is initially padded to the right with 2 or 1 zero digits to total 6 digits.

03 IBM 3624 Identical to existing PIN-TRAN Format 3.

08 Docutel Identical to existing Docutel 5100 Format 8


(used in D51-PIN-TRAN, etc.)

09 ZKA The input PIN Block may be ISO Format 0 or an ISO Format 1

10 ISO 0 Identical to Format 01 above.

11 ISO 1 ISO 9564-1:2003 Format 1

12 ISO 2 ISO 9564-3: 2003 Format 2

13 ISO 3 ISO 9564-1: 2002 Format 3

A particular function may not support all of the formats identified above. The specification of each function identifies
which formats it supports.

Note: Functions that translate PIN, output PIN block format can be 09 only if input PIN block
format is 09.

The HSM needs to support all PIN blocks formats that are used within the industry. Many users do not require support
for some of these formats. Therefore, each PIN block format can be enabled or disabled.
The default condition for each PIN block format is as follows:

PIN Block Format Enabled Disabled

ISO-0 x

ISO-1 x

ISO-2 x

ISO-3 x

IBM 3624 x

Docutel x

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 60
CHAPTER 1 Function Construction - Luna EFT

A console operation allows the user to enable support for just those PIN block formats that are required.

Restrictions on reformatting
In those PIN translate functions that support the reformatting of the PIN block from one format to another,
disassociation of the PIN from the Account Number is prevented by the following restrictions on the reformatting that is
supported.
The table below lists the restrictions on PIN block reformatting based on the default PIN block format settings
(enabled/disabled). A console operation allows the user to modify the PIN block reformatting rules.

PIN Block Format Reformatting supported (non PCI mode) Reformatting supported
(PCI mode)

ISO-0 / ANSI ISO-0, ISO-3 ISO-0, ISO-3

ISO-1 ISO-0, ISO-1, ISO-3 ISO-0, ISO-1, ISO-3

ISO-2* ISO-0, ISO-1, ISO-2, ISO-3 none

ISO-3 ISO-3 ISO-0, ISO-3

IBM 3624* ISO-0, ISO-1, ISO-3, IBM 3624 none

Docutel ATM* ISO-0, ISO-1, ISO-3, Docutel ATM none

Docutel ATM 2* ISO-0, ISO-1, ISO-3, Docutel ATM 2 none

*PIN block formats ISO-2, IBM 3624, Docutel ATM, and Docutel ATM 2 are disabled by default. Hence, PIN block
reformatting support will not be allowed. The user needs to enable these PIN block formats in order to support
reformatting.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 61
CHAPTER 2
Function Construction - AMB

Encryption Notation
The notation used for encryption and decryption is as follows:
• eK(D) where data D is encrypted under the key K.
• dK(D) where data D is decrypted with the key K.
• e*K(D) where data D is encrypted under the double length key K, as specified in AS2805.6.1:2001.
• d*K(D) where data D is decrypted with the double length key K, as specified in AS2805.6.1:2001.

Host Function Overview


Each function involves a host request being sent to Luna EFT, followed by a response being sent back to the host. The
message content of each function is described in this guide, and is independent of the selected communications
protocol. Message formatting procedures appropriate to each available protocol.
A host request message starts with a Function Code followed by function-dependent binary data. These data may be
fixed or variable length depending on the function. Functions requiring variable length data include the length of the
variable field in a one-byte length parameter. Where a function requires multiple fields in a message, there is no
delimiter between fields.
A Luna EFT response message starts with the Function Code from the host request message followed by a one-byte
Return Code. Appendix A lists the assignments for the Return (Error) Code. If the Error Code returned is non-zero, there
is no data following the Error Code. Otherwise, the response data follows the Error Code.

Common Function Processing

Function Code Checking


Before a request is processed, Luna EFT will ensure that the function code is:
Valid (that is, function codes as listed in the Function Summary).
Enabled by the console operator. If not, the request is rejected with an error code as defined in Appendix A.
Luna EFT also checks for the following:
• The request message length is correct for the function.
• The key format specifiers used are valid for the function.
• The varying length data fields are in the correct length and multiple range for the specified function. If not, the
request is to be rejected with an error code.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 62
CHAPTER 2 Function Construction - AMB

Public Key Functions

DEA 2 Keys
The prime components generated in the DEA 2 key generation process conform to the minimum requirements outlined
in Australian Standard AS2805.5.3:1985.

Verification Code – DEA 2 keys (PVC)


The KVC for a public key (PVC) is formed as described in AS2805 part 6.1 as follows:
• The modulus and public exponent are each expressed as whole bytes, most significant byte first, with no length
field and no leading zero bytes.
• The modulus and exponent are concatenated in that order.
• The SHA1 digest of that data is calculated.
The first 64 bits of the SHA1 digest will be the PVC of the key.

DEA 2 Key Presentation and Hashing

DEA 2 key format


A DEA 2 key is stored as modulus followed by exponent as format 41. The fields containing the modulus and exponent
are of the same length and this length is a multiple of 8 bytes. Both modulus and exponent, where required, are right-
justified and padded with leading zero bytes.

Format 41 Clear text DEA 2 keys


A stored, clear text DEA2 key is preceded by a size field (of length one byte) which indicates the number (n) of 8-byte
blocks in the modulus. The exponent will also have this number of blocks, so the length in bytes of the attached DEA 2
key will be 16n + 1 bytes. A key specifier field applies – see Format 41 under key specifiers formats.

Number of 8 byte blocks Modulus Exponent


in Modulus

Byte 0 = LEN n Byte 1 – 8n Byte (8n+1) – 16n

Format 42 Encrypted DEA 2 keys


A DEA 2 key of size n consists of 2n 8-byte blocks. It is encrypted under KM by encrypting the result of concatenating
the blocks using the DEA 3 CBC mode with an IV of all zeros. The encrypted blocks are preceded by a 1-byte KM
identifier and a size field (of length one byte). A key specifier field applies – see Format 42 under key specifiers formats.

KM Encrypted DEA 2 Key Block Format - Format 42


A DEA 2 key, encrypted by KM is formatted as type 42. It consists of a size field (of length one byte) which indicates
the number (n) of 8-byte blocks in the modulus followed by (16 x n) + 1 bytes of data where n is the number of 8 byte
blocks that construct a DEA 2 key as specified above.
For example with a 1024 bit DEA 2 key n equals 16, and the total length of the key is 258 bytes.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 63
CHAPTER 2 Function Construction - AMB

HASH Block Format (key data)


When signing data (that is, key data) using a private key SKs of length ‘ns’ 8-byte blocks, the hash value of the data
being signed is inserted into a data block as shown below. The resulting data block is then input to the private key
transformation.

Length Type Content Description

8*ns-63 h 0 Leading zeros

1 h FF Tag

20 B160 Hash SHA-1 hash


value

42 h 0 Trailing zeros

Format for DEA2 encrypting DEA3 keys


When encrypting data (that is, key data) using a public key PK of length ‘n’ 8-byte blocks, the data to be encrypted is
inserted into a data block as shown below. The resulting data block is then input to the public key transformation.

Length Type Content Description

8*n-63 h 0 Leading zeros

1 h 0 Tag

16 B128 KEKs Cross Domain


Send Key

46 h 0 Trailing zeros

Note: This format is used in functions C610, C620, C710 and C720

Plaintext Data Representation

DEA 2 Text Block - DFormat 1


Data presented for DEA2 encryption must be presented in blocks of size equivalent to the DEA 2 key size used. The
data will be presented in a formatted data block as follows.
In the following table n represents the number of eight byte blocks containing the modulus.

Byte Bits Description

0 7-6 00 = Always less than modulus

5-1 00001 = block format 1

0 0 = no padding used
1 = padding used

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 64
CHAPTER 2 Function Construction - AMB

Byte Bits Description

1 Normally zero unless an identity transform (concealing) would


have occurred

2 Number n of 8 byte blocks in the modulus of the key encrypting


this data

3-4 Checksum of bytes 5 through 8n-1

Var (5 to 8n-1) Up to 8n-5 bytes of data, left justified. If data is less than (8n-5)
bytes, append random pad bytes and pad byte count in byte 8n-1.
The pad count includes byte 8n-1

Note:
- 8n represents the size of the modulus of the DEA 2 key that encrypts the DFormat 1 text
block. The size of the key will always be provided by a separate field (for example, see
functions C600, C610, C700, C710).
- DFORMAT1 always refers to data that is to be encrypted by an asymmetric key (either for
encryption or signing) and that the result of this operation is specified as an S-Block.

Data byte significance


The leftmost byte of a block (byte 0) is the most significant byte and the rightmost byte (for example, byte 63) is the
least significant byte.

Data padding
A short data sequence is padded to the right with random bits, and a pad count.

Checksum calculation
The checksum is calculated as the 16-bit sum of bytes 4 to 8n-1 with a rotate left of 1 bit to the working total before each
byte is added in.

DEA 2 Key Types


Types of DEA 2 keys used in Luna EFT are listed in the table below. The General Purpose DEA 2 key pairs are
generated by Luna EFT but are then host stored as required. They are used for general purpose DEA 2 functions
(including Interchange).
The manufacturer (MAN) and terminal cryptographic unit (TCU) DEA 2 key pairs are used for the initialization of
terminals and/or PIN pads. The manufacture will be the manufacturer of the terminal or PIN pad.

Type Name Functions where used

SCM Security Control Module GETPUBLIC


NODEKEKSEND
NODEKEKREC

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 65
CHAPTER 2 Function Construction - AMB

Type Name Functions where used

GP General Purpose GETDEA2PAIR


NODEKEKSEND-EXPORT
NODEKEKREC-EXPORT

MAN Terminal Manufacturer TCUPUBLICREC

TCU Terminal TCUPUBLICREC


INITIALKEYREC

Function Message Formats


Each request message consists of three fields in the following order:
A two-byte function code.
A two-byte message identifier that allows unique identification of a message. Message identifiers used in host requests
are application dependent.
Luna EFT returns this field (in the response) as received (in the request) from the host. The message-id can be used in
multi-threading operations to match the response with the corresponding request. The contents are not defined but
could for example be an application identifier plus a rolling counter.
The data used by the function (if any).
Each request message shall produce a corresponding response message, which consists of up to four fields in the
following order:
The function code from the request message.
The message identifier from the request message.
A one-byte return code.
The data comprising the results of the request. If the return code is non-zero, no data shall be sent in the response
message.

Function Field Description


Within each function description, the message (request and response) is described in terms of its fields. Each field is
described under the following headings:

Length
This is the length of the field in bytes. A varying length field, as defined in “Variable Length Fields in Function Request
and Response Messages” (page Error! Bookmark not defined.), is indicated by “Var”.

Attribute
Following is the list of defined attributes:
B - represents a binary digit (bit). Fields must be grouped in multiples of eight (8) bits.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 66
CHAPTER 2 Function Construction - AMB

Bin - represents a binary number of length 2, 4 or 8 bytes. The number is in the big-endian representation with the most
significant bit first (on the left) and the least significant bit last (on the right).
h - represents a hexadecimal digit (0 to 9, and A to F). Fields must be grouped in multiples of two (2). Actual value(s)
must be in the content field.
d - represents a BCD digit.
x - represents an 8 bit field of unspecified format.
B64 - represents a data block of 64 bits.
B128 - represents a data block of 128 bits.
B160 - represents a data block of 160 bits
B512 - represents a data block of 512 bits.
K-Spec - represents a key specifier consisting of one of the formats specified earlier in this chapter.
D-Spec - represents a 64-bit encrypted data value preceded by a one byte KM index.
S-Block - represents a variable length, DEA 2 encrypted, data block. Clear text Data blocks are in DFORMAT1 format.

Content
This contains one of the following types of entries:
Nothing (indicating that the field needs no further explanation).
Explicit hexadecimal values (eg. function codes).
Cryptographic expressions, which are references to encrypted keys or data.
Abbreviated field names.

Description
This contains a simple explanation of the field contents.

Nomenclature
The nomenclature used for keys and operations conforms to Australian Standard AS2805.6.1:2001. In this document
keys can be single (64-bit), double (128-bit) and triple (192-bit) length and this is context dependent in the different
functions.

Variable Length
This section describes the method for specifying the actual length of a variable-length data field in a Luna EFT function
request or response. The method utilizes a length prefix that in itself has a variable length. The length prefix forms an
essential part of the variable-length data field.
The actual length of the length prefix is specified by the most significant bits of the most significant byte within the
prefix. The remaining bits within the most significant byte form part (or all, in the single-byte case) of the value of the
length prefix.

Length of length prefix (bytes) Length indicator bits in most significant byte

1 0…

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 67
CHAPTER 2 Function Construction - AMB

Length of length prefix (bytes) Length indicator bits in most significant byte

2 10…

3 110 …

4 1110 …

The encoding defined above results in the following ranges of values for the length prefixes, and ranges of lengths for
the corresponding data values:

Length of length prefix Values in length prefix Bytes in data value

(bytes) (hex) (hex) (dec)

1 00 – 7F 00 – 7F 0 – 127

2 8000 – BFFF 0000 – 3FFF 0 – 16383

3 C00000 – DFFFFF 000000 – 1FFFFF 0 – 2097151

4 E0000000 – EFFFFFFF 00000000 – 0FFFFFFF 0 – 268435455

The following points apply to the Mark II implementation of the method.


• A variable-length data value and its associated length prefix form a single field in a function request or request
message, with an indicated length of ‘Var’. Therefore, there is no need to indicate the length as a separate field.
• The length prefix indicates the length of the data portion of the field, i.e. the length prefix is not included in the
length. The specified length is a number of bytes.
• The length prefix is independent of the attributes and contents of the data value.
• For multi-byte length prefixes, the byte order in the field is least significant byte first (that is, little endian. This is in
line with the general rule for all multi-byte integer fields in Luna EFT functions.
• All new variable-length fields will use this method; the existing method of using a one-byte length field to specify the
number of eight-byte blocks in the following variable-length field will not be propagated.
• The method as defined above is open-ended, and therefore could be extended to a length prefix of more than four
bytes. However, the HSM supports a maximum of four bytes for a length prefix. It is not envisaged that 4 bytes
would ever be needed to specify a length, but the user has the option to use a four-byte value even if it is not
required.
• For variable-length fields in response messages, the length prefix consists of the minimum number of bytes
required to express the data length of the field.
• A variable-length field with a data length of zero is represented entirely by a length prefix containing the value zero
(for example, X’00’ or X’8000’). A zero-length field is useful where a field is not optional, but is not used.

Example Field Formats


The following examples illustrate how a variable-length field containing 27 data bytes could be represented using a
length prefix of differing lengths.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 68
CHAPTER 2 Function Construction - AMB

One byte length


1B d1 d2 d3 ...... ..... ...... d25 d26 d27

Two byte length


80 1B d1 d2 d3 ...... ..... ...... d25 d26 d27

Three byte length


C0 00 1B d1 d2 d3 ...... ..... ...... d25 d26 d27

Four byte length


E0 00 00 1B d1 d2 d3 ...... ..... ...... d25 d26 d27

Key Specifier
Most host functions perform transformations using cryptographic keys, which are stored either within hardware security
module secure memory (HSM stored) or in the host database in encrypted form (host stored). Traditionally, the choice
of whether a key should be HSM stored or host stored has been on a per-key-type basis and has been fixed in the
function design.
New functionality now implements the capability for that choice to be at the discretion of the user (or host software
provider); it also permits the possibility to Luna EFT store (HSM store) some keys of a key type and to host store other
keys of that same key type.
To support this capability, a ‘key specifier’ is defined which is a variable format field, built into host function request and
response messages. The key specifier provides access to a key - either by value (an encrypted key from, or for, host
storage) or by reference (an index to a Luna EFT key table). Being variable format, a key specifier field is variable length
(see above).
Although the key specifier introduces extra flexibility for the user, there need be no extra complexity for the host
programmer, who simply selects the appropriate key specifier format for the particular key, and then treats that instance
of the key specifier as a fixed length, fixed format field.
Key specifier formats associate the following properties with a key:
• Key length
• Mode of Operation (for example, ECB, CBC) used to encrypt the key.
• Algorithm used to encrypt the key
• Algorithm used in the function for which this key is the cryptographic key.
• Whether the key is host or Luna EFT stored
Key specifiers are present in both request and response messages and need to be stored with the key for future use on
the host system. Any keys that are to be sent to terminals or other sites that do not require it should have the key
specifier field stripped by the application before transmission.
Support for key specifiers is detailed within each function definition, specifying which formats are valid for each key
field in the request and response.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 69
CHAPTER 2 Function Construction - AMB

Note: Key-specifier formats can be enabled or disabled through the console in the same way
as functions. The initial state for all format specifiers with the exception of 33 is enabled.

Format Description KM Index

00 Index - short / BCD -

01 Index - short / binary -

02 Index - long / BCD -

03 Index - long / binary -

20 Encrypted key - single length - 64-bit ü

21 CBC encrypted key - double length - 128-bit ü

22 CBC Encrypted key - triple length - 192 bits ü

23 ECB encrypted key - double length - 128-bit ü

24 Encrypted key - Future algorithm with KM index (1)

25 HMAC-SHA-1 double length - 128-bit ü

30 Encrypted key - single-length -64-bit -

31 CBC Encrypted key - double-length – 128-bit -

32 CBC Encrypted key – triple length – 192-bit -

33 ECB Encrypted key - double-length - 128-bit -

34 Encrypted key - Future Algorithm (1)

41 Clear text DEA 2 Public key -

42 Symmetric Encrypted DEA 2 key ü

80 - CF Manufacturer Use

D0 - FF Proprietary Use

(1) Reserved for future use

Variants
Variants of keys are used to provide functional separation as described in Australian Standard AS2805.6.1 Key
Management – Principles 1988. Custom variants 21, 22 and 23 are calculated as described in Australian Standard
AS2805.6.3 Key Management – Session Keys – Node to Node 1988, Clause 6.5. All other variants are calculated as
described in AS2805.6.1:1988. The constants used are defined in the table below.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 70
CHAPTER 2 Function Construction - AMB

In order to provide additional separation between 64-bit, 128-bit and 192-bit DEA keys and DEA2 keys the standard has
been extended as described below. In the case of CBC mode DEA keys the varianted key is obtained by an XOR
operation of the base key with the Variant Constant.
64-bit DEA keys: The variant constant is obtained by repeating the Variant Byte from the following table, to obtain the
same length as the key being varianted. This is the method used in formats 20 and 30.
That is, VC = 8 * (VB), KVn = K xor VC
128-bit DEA keys: The variant constant is obtained by repeating the Variant Byte from the following table, to obtain the
same length as the key being varianted. This is the method used in formats 23 and 33.
That is, VC = 8 * (VB), KVn = K xor VC
128-bit CBC mode DEA keys: The Variant Byte (VB) is concatenated with the constant X’C0’ to form a 2-byte (16-bit)
field. This field is repeated 8 times to form the Variant Constant (VC). Used in Formats 21, 25, and 31.
That is, VC = 8 * (VB || X’C0’), KVn = K xor VC
192-bit CBC mode DEA keys: The Variant Byte (VB) is concatenated with the constant X’30’ to form a 2-byte (16-bit)
field. This field is repeated 12 times to form the Variant Constant (VC). Used in Formats 22, 32.
That is, VC = 12 * (VB || X’30’), KVn = K xor VC
DEA2 keys: The variant constant (VC) is obtained by repeating the variant byte.
That is, VC = VB || VB || … || VB

KM and KEK Variants


KM Variant* Old Variant Used to Protect
Variant Byte

24 ü 1 X'24' KMACs, KMAC

28 ü 2 X'28' KPEs, AWK

22 ü 3 X'22' KDs

48 ü 4 X'48' KMACr, KCVV

42 ü 5 X'42' KPEr, KPP, IWK

44 ü 6 X'44' KDr, KCA,

82 ü 7 X'82' KEKs, KEK1, KEK2, KT, KI

84 ü 8 X'84' KEKr, , KA, KIA

A0 ü X’A0’ SKGP, SKMAN, SKTCU (ex


44)

AC ü X’AC’ PKGP, PKTCU, PKMAN


(ex84)

88 9 X'88' PPSN, PPASN, MACRES

AA 10 X'AA' ATM master key (A)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 71
CHAPTER 2 Function Construction - AMB

KM Variant* Old Variant Used to Protect


Variant Byte

A6 11 X'A6' ATM comms key (B)

12 21 X'12' Terminal Keys

14 22 X'14’ KPVV

18 23 X'18' KPV, DT

06 40 X’06’ KEK (single length key)

E4 E4 X’E4’ KTK

30 X’30’ IMKAC

36 X’36’ IMKSMI

3A X’3A’ IMKSMC

3C X’3C’ IMKDAC

50 X’50’ IMKIDN

7E X’7E’ IMKcvc

20 X’20’ CSCK

En X’En’ Proprietary Use

* ü Also a KEK variant

Note: The variant of KM used to encrypt data (e.g. PPSN, PPASN, MACRES) is formed in the
same way as described above for KM variants used to encrypt keys. However, in this case the
length of the data is used to select the variant formation schema.

Visa Variant
Visa variant 1 (Vv1) is used in the support of the Visa Dynamic Key Exchange protocol. It consists of a variant byte of
x'08', which without extension, is modulo 2 added to the first (most significant) byte of each part (8 byte) of DEA 3 key
to derive the varianted key.

The ‘Key specifier’ Function Field


Most host functions perform transformations using cryptographic keys, which are stored either within hardware security
module secure memory (HSM stored) or in the host database in encrypted form (host stored). Traditionally, the choice
of whether a key should be HSM stored or host stored has been on a per-key-type basis and has been fixed in the
function design.
New functionality now implements the capability for that choice to be at the discretion of the user (or host software
provider); it also permits the possibility to Luna EFT store (HSM store) some keys of a key type and to host store other
keys of that same key type.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 72
CHAPTER 2 Function Construction - AMB

To support this capability, a ‘key specifier’ is defined which is a variable format field, built into host function request and
response messages. The key specifier provides access to a key - either by value (an encrypted key from, or for, host
storage) or by reference (an index to a Luna EFT key table). Being variable format, a key specifier field is variable length
(see above).
Although the key specifier introduces extra flexibility for the user, there need be no extra complexity for the host
programmer, who simply selects the appropriate key specifier format for the particular key, and then treats that instance
of the key specifier as a fixed length, fixed format field.
Key specifier formats associate the following properties with a key:
Key length
Mode of Operation (for example, ECB, CBC) used to encrypt the key.
Algorithm used to encrypt the key
Algorithm used in the function for which this key is the cryptographic key.
Whether the key is host or Luna EFT stored
Key specifiers are present in both request and response messages and need to be stored with the key for future use on
the host system. Any keys that are to be sent to terminals or other sites that do not require it should have the key
specifier field stripped by the application before transmission.
Support for key specifiers is detailed within each function definition, specifying which formats are valid for each key
field in the request and response.

Note: Key-specifier formats can be enabled or disabled through the console in the same way
as functions. The initial state for all format specifiers with the exception of 33 is enabled.

Key Specifier Formats

Key Specifier Formats for Luna EFT Stored Keys


The following key specifier formats provide access to keys stored in tables (or files) within HSM Secure Memory. The
formats incorporate an index which identifies the required key in a table; the particular table to access is implicit in the
function definition.
All the formats support index values from zero to the maximum value which fits in the field. Restrictions in the values
are applied by other considerations, such as physical capacity of Secure Memory.

Format 00
Index - short / BCD

Length Type Content Description

1 h 00 Format Code

1 d 00 - 99 Index value in BCD

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 73
CHAPTER 2 Function Construction - AMB

Format 01
Index - short / binary

Length Type Content Description

1 h 01 Format Code

1 x 00 - FF Index value in binary

Format 02
Index - long / BCD

Length Type Content Description

1 h 02 Format Code

2 d 0000 - 9999 Index value in BCD

Format 03
Index - long / binary

Length Type Content Description

1 h 03 Format Code

2 x 0000 - FFFF Index value in binary

Key Specifier Formats for Host Stored Keys


The following key specifier formats incorporate encrypted key values. Formats for single-length (64-bit), double-length
(128-bit) and triple-length (192-bit) keys are specified. Both single and multiple Domain Master Keys (KM) are
supported.
The field lengths shown assume DEA keys, appropriate to current functionalities. The algorithm, key length and mode
of operation are prescribed by the key specifier. To determine the exact operation of the function, attributes are taken
first from the Key specifier, second from the explicit function specification and third from the default function
specification.
Unless otherwise specified in the format or function definition, the algorithm used to encrypt the key will be the same
one used to process data using that key. For example, a format 21 key will use the DEA algorithm to encrypt data using
a 128-bit key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 74
CHAPTER 2 Function Construction - AMB

Format 20
DEA Encrypted key – 64-bit with KM index

Length Type Content Description

1 h 20 Format Code

1 x i KM Index

8 x eKMi(K) Encrypted key

Format 21
DEA CBC Encrypted key – 128-bit with KM index

Length Type Content Description

1 h 21 Format Code

1 x i KM index (Range 00-FF)

16 x eKMi(K) Encrypted key

Format 22
DEA CBC Encrypted key – 192-bit with KM index

Length Type Content Description

1 h 22 Format Code

1 x i KM index (Range 00-FF)

24 x eKMi(K) Encrypted key

Format 23
DEA ECB Encrypted key – 128-bit with KM index

Length Type Content Description

1 h 23 Format Code

1 x i KM index (Range 00-FF)

16 x eKMi(K) Encrypted key

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 75
CHAPTER 2 Function Construction - AMB

Format 24
Encrypted key – Future algorithm with KM index

Length Type Content Description

1 h 24 Format Code

1 x 00 - FF Algorithm
01 = Invalid
02 = 3 DES
03 = AES
En = National
Fn = Proprietary

1 x 00 - FF Key length
01 = Invalid
02 = 128
03 = 192
04 = 256

1 x 00 - 0F Block Length
01 = 64
02 = 128
03 = 192
04 = 256

1 h 00 - 0F Mode of Operation
01 = ECB
02 = CBC
03 = CFB
04 = OFB

1 x i KM Index (Range 00-FF)

Var x eKMi(K) Encrypted key

Format 25
HMAC-SHA1 key – 128-bit with KM index

Length Type Content Description

1 h 25 Format Code

1 x i KM Index (Range 00-FF)

16 x eKMi(KMAC) DEA CBC Encrypted MAC key

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 76
CHAPTER 2 Function Construction - AMB

Note: Format 25 is used for the HMAC-SHA-1 algorithm as defined in AS2805 Part 4.2:1985,
Algorithm 2, using the hash algorithm SHA-1 defined in AS2805 Part 13.2:2000.

Format 30
DEA Encrypted Key – 64-bit

Length Type Content Description

1 h 30 Format Code

8 x eKEK(K) Encrypted key

Format 31
DEA CBC Encrypted key – 128-bit

Length Type Content Description

1 h 31 Format Code

16 x eKEK(K) Encrypted key

Format 32
DEA CBC Encrypted key – 192-bit

Length Type Content Description

1 h 32 Format Code

24 x eKEK(K) Encrypted key

Format 33
DEA ECB Encrypted key – 128-bit

Length Type Content Description

1 h 33 Format Code

16 x eKEK(K) Encrypted key

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 77
CHAPTER 2 Function Construction - AMB

Format 34
Encrypted key – Future Algorithm

Length Type Content Description

1 h 34 Format Code

1 h 01 - 0F Algorithm
01 = Invalid
02 = 3DES
03 = AES
En = National Allocation
Fn = Proprietary Allocation

1 h 00 - 0F Key Length
01 = Invalid
02 = 128
03 = 192
04 = 256

1 h 00 - 0F Block Length
01 = 64 bit
02 = 128 bit
03 = 192 bit
04 = 256 bit

1 h 00 - 0F Mode of Operation
01 = ECB
02 = CBC
03 = CFB
04 = OFB

Var x eKEK(K) Encrypted key

Format 41
Cleartext key – DEA 2

Length Type Content Description

1 h 41 Format Code

1 x n Number (n) of 8-byte blocks in modulus

16*n x PK Clear text DES 2 Public Key

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 78
CHAPTER 2 Function Construction - AMB

Format 42
Encrypted key – DEA 2 with KM index

Length Type Content Description

1 h 42 Format Code

1 x n Number of 8-byte blocks in modulus

1 x i KM index (Range 00-0F)

Variable length x eKMi(PK) DEA CBC Encrypted DEA2 key. Either the public key OR the Private key
field OR eKMi
(SK)

Use of key specifiers in host functions


Key specifiers are widely used in newly developed host functions. The type of key being accessed by the key specifier
is implicit in the function design. For example, in one place a key specifier may be for a terminal master key, in another
place it could be for PIN verification key, and in yet another it could be for a PIN encrypting key. This is identical to the
current situation with indexes to Luna EFT stored keys.
The function field therefore always identifies the type of key that the key specifier is for. Different formats can be used
to identify different algorithms. Each function specifies which key formats are valid for each key field.
It will not always be appropriate for a given key type to be Luna EFT stored or host stored. Nevertheless, a key specifier
is still useful. For example, to provide a choice of formats for specifying an index to an Luna EFT stored key.

RSA Public Key System


When a Luna EFT is initialized, no RSA key pair is available, but the device begins to generate a key pair in the
background immediately, storing it when generated.

RSA Block Format Conventions


Only two formats are currently defined. The variable 'n' is the relevant modulus size in bytes which is typically 64 bytes
(512 bits) but can have other values for customized functions.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 79
CHAPTER 2 Function Construction - AMB

Block Format 1
Byte Bits Description

0 7-6 00 = Always less than modulus

5-1 00001 = block format 1 with 2 byte checksum calculated on


0 to n-4 bytes of data

0 0 = no padding used
1 = padding used

1 Normally zero unless an identity transform would have occurred

2-3 Checksum of bytes 4 through n-1

4 to n-1 Up to n-4 bytes data, left justified. If data is less than n-4 bytes, append
random pad bytes and pad byte count in byte n-1. The pad count includes byte
n-1

The checksum is calculated as the 16-bit sum of bytes 4 to n-1 with a rotate left of 1 bit to the working total before each
byte is added in.

Block Format 2
Byte Bits Description

0 7-6 00 = Always less than modulus

5-1 00010 = block format 2, n-2 bytes of data without checksum

0 0 = no padding used
1 = padding used

1 Normally zero unless an identity transform would have occurred

2 to n-1 Up to n-2 bytes data, left justified. If data is less than n-2 bytes, append
random pad bytes and pad byte count in byte n-1. The pad count includes byte
n-1

P-Key - Clear RSA Public Key


The 128 byte field is formatted as modulus, then as exponent, each right justified and zero filled to make up 64 bytes.

e.g. 512 bit key length: Bytes 1 to 64 Modulus

Bytes 65 to 128 Exponent

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 80
CHAPTER 2 Function Construction - AMB

e.g. 464 bit key length: Bytes 1 to 8 Zero Padding

Bytes 9 to 64 Modulus

Bytes 65 to 72 Zero Padding

Bytes 73 to 128 Exponent

R-key - Encryption of RSA Secret or Public Keys by a *KM


Where a Secret Key (SK) or Public Key (PK) is enciphered by a *KM the method used is CBC encipherment using an
Initialization Vector of all zeros. The Public or Secret Key is formatted as a P-Key described above.

Note: In CBC encipherment using a double-length key, the CBC mode of operation is applied
to the 'triple encipherment' block cipher. Triple encipherment of a block consists of
encipherment by the left half of the key, followed by decipherment by the right half of the key
and a further encipherment by the left half of the key.

P-Block - an RSA public key pair enciphered by another public key pair using format 2
The (usually128 byte) field is made up of two halves:
cPKB ( PKA modulus in format 1) followed by:
cPKB ( PKA exponent in format 1)
The PKA modulus and exponent can be either right justified and zero filled before formatting or they can be shorter, so
that they require justification after they are deciphered.

Note: The enciphered public key pair modulus (PKAmod) has to be at least 4 bytes smaller
than the enciphering modulus (PKBmod).

Q-block - an RSA public key pair enciphered by another public key pair using format 2
The (usually 128 byte) field is made up of two halves:
cPKB ( PKA modulus in format 2) followed by:
cPKB ( PKA exponent in format 2)
The PKA modulus and exponent can be either right justified and zero filled before formatting or they can be shorter, so
that they require justification after they are deciphered.

Note: The enciphered public key pair modulus (PKAmod) must be at least 2 bytes smaller than
the enciphering modulus (PKBmod).

D-block - data enciphered by one RSA public key, then signed by another RSA public key
of the same size
The procedure for producing an encrypted signature of a data block of up to n-4 bytes is:
Transform the data block into a ‘n’ byte signature using the first key and format 1.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 81
CHAPTER 2 Function Construction - AMB

Split the signature into a left part of n-2 bytes and a right part of 2 bytes.
Prefix the left part of the signature with 2 bytes defined by format 2. The resulting n byte block (which is always less
than the modulus of the second key) is encrypted.
Concatenate the result of the encryption (n bytes) and the right part of the signature (2 bytes) to form the encrypted
signature (n+2 bytes).

E-block - data enciphered by one RSA public key then signed by another larger RSA pub-
lic key
The field consists of: cPKB ( (cPKA ( data in format 1 ) ) in format 2 )

Note: The first enciphering public key pair modulus (PKAmod) has to be at least 2 bytes
smaller than the second enciphering modulus (PKBmod). The data size has to be at least 4
bytes smaller than the first enciphering public key pair modulus (PKAmod).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 82
CHAPTER 3
The Metafunction

Message Meta-function Format


The meta-function message format provides a transparent mechanism for implementing extensions to the current host
message format.

Note: Currently, only SafeNet’s ProtectToolkit EFT product makes use of the meta-function
format. Metafunction support can be enabled or disabled via the console under the Device
Administration/Function Control menu.

The meta-function is presented as a special function code called the Meta-function Indicator (E3). If the Meta-function
Indicator is found in the message, the Luna EFT knows that the message came encapsulated. It then extracts the
normal request message frame, processes it in the usual manner and then puts the meta-function back around the
response message before sending the reply.

Request Message
Comms Meta-function Meta-function Version Type specific Comms
Header Indicator Type data … trailer

Response Message
Comms Meta-function Meta-function Version Response Type specific Comms
Header Indicator Type Code data … trailer
(= 00)

Meta-function Error Response Message


Comms Meta-function Meta-function Version Response Type specific Comms
Header Indicator Type Code data … trailer
(<> 00)

A meta-function request could incorporate a normal request message as a variable-length field within its request data
(i.e. type specific data) or it could contain another meta-function as the variable-length field.
Two Meta-function types are presently defined. If the byte following the Meta-function Indicator byte is not one of the
defined types, the HSM returns a Meta-function Error Response message with Response Code = 01.
The Version field allows the format of the meta-function to change over time in a manner that provides backward
compatibility.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 83
CHAPTER 3 The Metafunction

The Response Code field allows for error reporting for the meta-function header fields. This translates to a meta-
function with a variable-length field that has a zero length (instead of containing the request). So the return code would
be ‘Invalid field length’

META-FUNCTION-SUPPORT (E3)

Request Length Type Description

E3 1 h Function Code

Reserved Byte 1 h Reserved currently 00

Meta-function ID 1 h Meta-function type identifier

Version 1 h Meta-function type version

Message Id 4 x A Message Id used by ProtectToolkit EFT

Data Field Var x Normal request message


( or meta-function request)

Response Length Type Description

E3 1 h Function Code

Reserved Byte 1 h Reserved currently 00

Meta-function ID 1 h Meta-function type identifier

Version 1 h Meta-function type version

Return Code 1 h A return code that indicates the status of the sent function

Message Id 4 x A message Id used by ProtectToolkit EFT

Data Field Var x Normal request message


(or Meta-function request)

The meta-function message format provides a transparent mechanism for implementing extensions to the current host
message format. When used with SafeNet’s ProtectToolkit EFT product, it provides a unique message identifier for all
messages.

Reserved Byte Currently restricted to 00

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 84
CHAPTER 3 The Metafunction

Meta-function ID Meta-function type 00


The Message ID and Data field are not used when meta-function type = 00.
No processing of data is performed. This meta-function is intended for use as a heartbeat
function when used with ProtectToolkit EFT.
Meta-function type 01
The Message ID and Data Fields are used when meta-function type = 01. The meta-function is
used to encapsulate other functions.

Version Currently restricted to 01


The version field allows for the format of the meta-function to evolve over time in a manner that
will support backward compatibility.

Return Code (response only)


The return code indicates the status of the sent message.

Message ID A four byte message ID, which uniquely identifies each meta-function message, is used to
map responses with their corresponding request message.
Not used when Meta-function Id = 00

Data The data field is a var field which in the request contains the encapsulated message request
and in the response contains the encapsulated response.
Not used when Meta-function Id = 00

Return Codes
00 - OK
01 - Invalid meta-function Id
02 - Invalid version number
03 - Invalid data field length

Note: If an error occurs in the E3 Function the encapsulated message is not run and no return
data will be presented.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 85
CHAPTER 4
Function Library

The following table lists all the supported host functions.

Function Group Function Function Name Description


Code

Admin EEBF29 GET-KVC Verifies the existence and obtains the KVC
of keys stored in the Secure Memory.

A8 CALCULATE-CSC Calculates CSC values and returns them


AMEX
to the host.

A9 CREATE-CSCK Causes a random *CSCK to be generated


and returned to the host encrypted under
HSM's *KM variant 6.

AA EXPORT-CSCK Causes a key to be returned encrypted


under a *KIS (ZMK) specified by the index
provided in the KIS specifier.

AB IMPORT-CSCK Causes a key to be returned encrypted


under HSM's KM variant 6 for storage on
the host database.

EE0501 CALC-CSC Calculates CSC values according to CSC


algorithm passed to it and returns them to
the host.

EE0502 VERIFY-CSC Derives CSC values from Expiry date,


PAN and Service Code and verify with
given CSC Value.

000F CALC-CSC-1 Calculates CSC values to support CSC


algorithm v2.0.

0010 VERIFY-CSC-1 Verifies the given CSC value.

EE4003 TERM-AUTH-1 Performs a first step authentication


Remote ATM
between a FEP and EFT using EFT EMV
Initialization
Certificate.

EE4004 TERM-AUTH-2 Performs a second step authentication


between a FEP and EFT using EFT
cryptogram.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 86
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE4005 INIT-KEY-EXCH Performs initial key exchange mechanism


between FEP and EFT.

EE4006 PAN-KEY-EXCH Performs PAN key exchange mechanism


between FEP and EFT.

EE4007 SIGN-FEP-PUB-KEY Creates the certificate for the FEP public


key using the private key of the CA.

EE4008 IMP-ENC-PUB-KEY Generates an authenticated and secured


public RSA key using an unauthenticated
and unsecured RSA public key

EE9001 GENERATE-RSA-KEY- Generates an RSA key pair (PK, SK) with


PAIR the specified modulus length and public
exponent and returns the keys for host
storage.

EE9003 IMPORT-PUBLIC-KEY Produces a key specifier incorporating an


authenticated public key.

EE9004 IMPORT-PUBLIC-KEY- Verifies the signature on the public key


CERTIFICATE certificate and returns the public key in an
authenticated key specifier.

EE9005 SIGN-DATA Signs the data using the private key and
signature algorithm indicated, and returns
the digital signature.

EE9006 VERIFY-SIGNED-DATA Verifies the signature on a signed


message.

EE9007 GENERATE-MD5-HASH Returns the result of MD5 hashing the


supplied data.

EE9008 GENERATE-SHA-HASH Returns the result of SHA hashing the


supplied data.

EE9009 PUBLIC-KEY- Performs RSA operation using public key


OPERATIONS as encrypt/recover/key transport specified
by the mode of operation.

EE9010 PRIVATE-KEY- Performs RSA Private key Operations as


OPERATIONS decrypt/sign as specified in the mode of
operation.

EE9011 IMPORT-EMV- Verifies an EMV certificate.


CERTIFICATE

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 87
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE9012 KEY-RETRIEVE- Performs key retrieval operation with the


OPERATION help of supplied data.

EE9101 GENERATE-KEY- Generates a random double length key for


DIEBOLD initialization of an Diebold ATM.

EE9102 VERIFY-ATM- Verifies the signature on the PKCS#7


RESPONSE-DIEBOLD messages.

EE9201 GENERATE-KTM-NCR Generates a random double length KTM for


initialization of an NCR ATM.

EE9202 CREATE-X509- Creates an X509 DER encoded certificate.


CERTIFICATE

EE9203 IMPORT-TRANSPORT- Decrypts the padded KTM using RSA's


KEY private key.

EE9204 CREATE-CSR Returns certificate signing request signed


using SHA256 and PKCS1v1.5.

EE9205 OAEP-ENCRYPT Performs RSA OAEP encryption of KTM


using public key.

3B00 AB-KEY-GEN Generates a random ATM A-key and B-


key.

3B10 C-KEY-GEN Generates a new random ATM


Communications key and returns it
encrypted under KMvA6, KMv22, KMv44
and the old communications key.

3B20 M-KEY-GEN Generates a random ATM Master Key and


returns it encrypted under KMv42, KMvAA
and the ATM A-key.

5530 GENERATE-MAC-NDC- Calculates the MAC for a given message


ATM to be transmitted to an NDC+ ATM.

5630 VERIFY-MAC-NDC-ATM Compares a reference MAC.

C6B0 LOAD-PUBLIC-KEY Enciphers a public key under the


(NDC) appropriate variant of KM for storage.

C6C0 SIGN-PUBLIC-KEY Self-signs a public key with the


(NDC) corresponding secret key.

C6D0 VERIFY-EPP (NDC) Verifies the signature of the encrypting PIN


pad serial number.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 88
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

C720 NODE-KEK-SEND (NDC) Generates a random ATM A-key and


prepares it for transfer to an ATM.

C800 VERIFY-CERTIFICATE Verifies the certificates received from an


ATM and extract the public keys from
them.

C810 SIGN-PUBLIC-PKCS10 Self-signs a public key with the


corresponding secret key, for use in a
certification request to be sent to a
certification authority.

C850 CONSTRUCT-TOKEN- Generates a random KTK, enciphers it with


B1 an ATM’s public encipherment key, and
builds a key token B1 signed by the host’s
private signature key.

C860 VERIFY-TOKEN-A2 Verifies the key token A2 by verifying the


signature with the ATM’s public verification
key and checking the contents of the
token.

EE0640 GEN-KM-ENC-PIN Generates a random PIN of the specified


KM-encrypted PIN length and creates a format 1A key
specifier.

EE0641 PRINT-KM-ENC-PIN Prints a KM-encrypted PIN.

EE0642 VER-KM-ENC-PIN Verifies a transaction PIN by comparing it


with a KM-encrypted reference PIN.

EE0643 TRANS-KM-ENC-PIN Translates a PIN from encryption using


PPK to encryption using KM.

EE0644 MIGRATE-KM-ENC-PIN Re-encrypts a KM-encrypted PIN from the


old KM to the current KM.

EE2000 EMV-AC-GEN Generates an Application Cryptogram (TC,


EMV
AAC or ARQC).

EE2001 EMV-AC-VERIFY Verifies an application cryptogram (TC,


AAC or ARQC).

EE2002 EMV-DAC-GEN Generates a Data Authentication Code


(DAC).

EE2003 EMV-DAC-VERIFY Verifies a Data Authentication Code


(DAC).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 89
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE2004 EMV-ICC-DN-GEN Generates a ICC Dynamic Number.

EE2005 EMV-ICC-DN-VERIFY Verifies a ICC Dynamic Number.

EE2006 EMV-ARPC-GEN Generates an Authorization Response


Cryptogram.

EE2007 EMV-SCRIPT-CRYPTO Performs the cryptographic processing


required for Secure Messaging.

EE2016 EMV-PIN-CHANGE- Performs PIN unblock/change processing.


UNBLOCK

EE2017 EMV-PIN-CHANGE- Performs PIN unblock/change processing


UNBLOCK-EMV-2000 as specified by EMV 2000.

EE2018 EMV-VERIFY-AC-GEN- Verifies an Application Cryptogram (AC) or


ARPC generates an ARPC, or does both.

EE2019 EMV-AC-GEN-MULTI Generates an Application Cryptogram (TC,


AAC or ARQC).

EE2020 EMV-SCRIPT-CRYPTO- Performs the encryption and MACing for


MULTI Issuer Scripts that use secure messaging.

EE2021 EMV-PIN-CHANGE- Performs PIN unblock/change processing


UNBLOCK-MULTI that use secure messaging.

EE2022 EMV-VERIFY-AC-GEN- Generates AC and/or ARPC and verify AC


ARPC-AES for AES implementation of ICC cards.

EE2023 EMV-AC-GEN-MULTI- Generates AC for AES implementation of


AES ICC cards.

EE2024 EMV-SCRIPT-CRYPTO- Encrypt and authenticate data for AES


MULTI-AES implementation of ICC cards for post
issuance script updates.

EE2025 EMV-PIN-CHANGE- This function change and unblock PIN with


UNBLOCK-MULTI-AES respect t to AES keys for EMV processing.

EF2010 EMV-VERIFY-AC-EMV- Verifies an Application Cryptogram (TC,


2000 AAC, ARQC) that has been produced by
an ICC.

EF2011 EMV-VERIFY-AC-VISA This function verifies an Application


Cryptogram (TC, AAC, ARQC) that has
been produced by an ICC, as specified by
Visa.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 90
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EF2012 EMV-GENERATE-ARPC Calculates an ARPC for transmitting to an


ICC.

EF2013 EMV-SCRIPT-CRYPTO- Performs the cryptographic processing


EMV-2000 required for Secure Messaging.
The ICC Session Key is derived using the
method specified in the EMV 2000
specification.

EF2014 EMV-SCRIPT-CRYPTO- Performs the cryptographic processing


VISA required for Secure Messaging.
The ICC session keys are derived using
the method specified by Visa.

EF2015 EMV-PIN-CHANGE- Performs PIN unblock/change processing


UNBLOCK-VISA as specified by VISA.

EE3030 GETPUBLICKEY Returns a public key and its PVC (Public


Key Exchange
key verification code).

EE3031 KIS-SEND Randomly generates a key for use as an


Interchange key and encrypts it under the
Domain Master Key and the public key.

EE3032 KIR-REC Recovers an interchange key, which has


been transferred from another HSM as part
of the Interchange Sending Key transfer
procedure.

EE3033 NODEPROOF Generates the random number to be


forwarded to the remote node as part of the
internodal proof-of-endpoint processing.

EE3034 NODERESP Performs the response part of the


internodal proof-of endpoint processing.

EE040B DUKPT-KEY-MAILER Derives the initial key for a DUKPT PIN


Key Mailer
Entry Device.

EE0E01 KEY-MAILER Generates random keys and prints them in


parts or component form.

63 PIN-TRAN-3624 Translates both the format and the


encryption key of a PIN Block which is
PIN
supplied encrypted by a HSM stored PIN
Verification Key (PVK).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 91
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

64 KB-PIN-VER Performs the verification of a PIN in an


AS/ANSI formatted PIN Block using the
IBM 3624 method.

69 VAR-KB-PIN-VER Verifies an AS/ANSI formatted PIN.

EE0601 MIGRATEPIN Migrates a PIN from one 3624 PVK to


another.

EE0602 PIN-TRAN-2 Performs translation of both the PIN Block


format and the PIN encryption key.

EE0603 PIN-VER-IBM-MULTI Performs the verification of a PIN using the


IBM 3624 Offset method.

EE0604 PIN-OFF Generates an Offset for a formatted PIN.

EE0605 PVV-VER Performs the verification of a PIN using the


Visa PVV method.

EE0606 PVV-CALC-3624 Calculates a Visa PVV from a PIN’s IBM


Offset data.

EE0607 PVV-CALC Calculates a Visa PVV for a PIN and also


provides the length of the PIN.

EE0609 PIN-FROM-OFF Calculates a PIN from a supplied IBM


3624 Offset.

EE0621 FUEL-CARD-PIN-VER Verifies a formatted PIN using fuel card


algorithm.

EE0645 TRANSLATE- Translates encrypted sensitive data (key


SENSITIVE-DATA or PIN data) for sending to an IC card.

SECKEY EE0628 GEN-TERMINAL-KEY Generates a key for sending to a terminal


using an industry standard secure key
block

EE0615 PIN-TRANS-SEED-DES Translates the PIN block from SEED


SEED
encryption to DES.

EE0804 ENCIPHER-3 Enciphers the supplied Data using a


session key (DPK) supplied within a key
specifier.

EE0805 DECIPHER-3 Deciphers the supplied encrypted data


using a session key (DPK) supplied within
a key specifier.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 92
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE0806 ENCIPHER-KTM1 Enciphers the supplied KTM using a


session key (DPK) supplied within a key
specifier.

01 HSM-STATUS Activates the self-tests and returns the


System
results to the host.

E3 META-FUNCTION- Provides a transparent mechanism for


SUPPORT implementing extensions to the current
host message format.

EE0003 HSM-STATUS-REV2 Activates the self-tests and returns the


results to the host include AES processor
status.

EE0002 GEN-RANDOM Generates and returns a random number of


the specified length.

EE0202 GET-KEY-DETAILS Provides non-sensitive details of a host


stored key that is stored in simple KM-
encrypted format.

EE0619 ADVANCED-RANDOM- Generates a random key of any key type


KEY-GENERATION and encrypts under the respective KM
variant.

11 ESTABLISH-KM Moves the current KM to the old KM and


KM Migration
moves the new KM to the current KM.

12 KM-MIGRATE Migrates host keys form the old KM to the


current KM.

13 ERASE-OLD-KM Erase the old KM.

21 RETRIEVE-KEY Retrieves a key from the transfer table for


Transfer Functions
host storage.

22 STORE-KEY Takes a host-stored key and stores it in the


transfer table.

47 D51-PPK-GEN Generates a random PIN Protect Key


(PPK) and associated encrypted
EFT
verification constant for a Docutel 5100
ATM.

49 M-DPK-GEN Generates a random communications key


(DPK) for an IBM 3624 Consumer
Transaction Facility

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 93
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE0200 KEY-IMPORT Migrates a key from encryption under an


Interchange Receive Key (KIR) to
encryption under the Domain Master Key
(KM).

EE0201 KEY-EXPORT Migrates a key from encryption under the


Domain Master Key (KM) to encryption
under an Interchange Send Key (KIS).

EE0205 KEY-IMPORT-AES Used to import AES Keys.

EE0206 KEY-EXPORT-AES Used to export AES Keys.

EE0400 IT-KEY-GEN Generates a set of random session keys


for an EFT terminal.

EE0401 NT-KEY-GEN Generates a set of new random Session


Keys for an EFT Terminal.

EE0406 TERM-VER-2 Verifies the validity of an EFT terminal.

EE0408 BDKGEN Generates a random double or triple length


DUKPT Base Derivation Key and returns it
for Host storage in a Format 13 or 14 Key
Specifier.

EE0409 DERIVE-KEY Derives a key with the help of supplied


data and derivation key.

EE040A IPEK-DERIVE Derives the initial key for a DUKPT PIN


Entry Device.

EE040C IPEK-DERIVE-2 Derives the initial key for a DUKPT PIN


Entry Device by KTM.

EE9013 IMPORT-RSA-PRIVATE- Imports an encrypted RSA key private


KEY key.

EE9014 TRANSLATE-DATA- Translates sensitive data encrypted under


RSA-TO-RSA one RSA key to another RSA key.

EE0402 II-KEY-GEN Generates a set of random initial


Interchange
interchange Session Keys.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 94
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE0403 II-KEY-RCV Takes a set of Interchange Session Keys


that has been encrypted under variant x of
the Interchange Receive Key indicated by
the supplied key specifier, and re-encrypts
them under the appropriate variant of the
*KM, for storage within the host.

EE0404 NI-KEY-GEN Generates a set of new random Session


Keys for an Interchange.

EE0405 NI-KEY-RCV Allows a Session Key rollover for the


interchange.

EE040D MAM-ACTIVATE Accepts a challenge generated by a


Magtek MagTek terminal and creates an encrypted
reply.

EE040E MAM-DEACTIVATE Accepts a challenge generated by a


MagTek terminal and creates an encrypted
reply

73 KB-MAC-GEN Generates a 32-bit Message


MAC Authentication Code (MAC) for the
supplied DATA using the Base Key (KBn).

EE0700 MAC-GEN-UPDATE Generates and verifies MAC, whereby a


message authentication Block (OCD) is
generated for the supplied DATA, using the
supplied MAC Protect Key (MPK).

EE0701 MAC-GEN-FINAL Generates MAC using the supplied MAC


Protect Key (MPK).

EE0702 MAC-VER-FINAL Verifies that the MAC is valid for the


supplied DATA using the supplied MAC
Protect Key (MPK).

EE0703 APACS-MAC-VER- Verifies the MAC for a terminal request


REQUEST message.

EE0704 APACS-MAC-GEN Generates the MAC for a terminal


response message.

EE0705 APACS-MAC-VER- Verifies the MAC for a terminal confirm


CONFIRM message.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 95
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE0712 MAC-GEN-UPDATE-AES Generates and verifies MAC, whereby a


message authentication Block (OCD) is
generated for the supplied DATA (whose
length is multiple of 16 bytes), using the
supplied MAC Protect Key (MPK).

EE0713 MAC-GEN-FINAL-AES Generates MAC using the supplied AES


MAC Protect Key (MPK).

EE0714 MAC-VER-FINAL-AES Verifies that the MAC is valid for the


supplied DATA using the supplied
AES MAC Protect Key (MPK).

84 B-ENCIPHER-ECB Encrypts the supplied DATA under the B-


Data Management key (BK) of the HSM stored 3624 Terminal
Key Set.

85 B-DECIPHER-ECB Decrypts the supplied encrypted DATA


using the B-key (BK) of the HSM stored
3624 Terminal Key Set.

EE0800 ENCIPHER-2 Enciphers the supplied data using a host-


stored session key (DPK) supplied within a
key specifier.

EE0801 DECIPHER-2 Deciphers the supplied data using a host-


stored session key (DPK) supplied within a
key specifier.

EE0807 DECIPHER-4 Enciphers the supplied data using a host-


stored session key (DPK) supplied within a
key specifier (format 20 only).

EE0808 ENCIPHER-AES Enciphers the supplied data using a host-


stored AES session key (DPK) supplied
within a key specifier.

EE0809 DECIPHER-AES Deciphers the supplied data using a host-


stored AES session key (DPK) supplied
within a key specifier.

EE0810 BPS-DECIPHER Deciphers the supplied data using a


Format Preserving Encryption algorithm
called BPS.

EE0811 BPS-ENCIPHER Enciphers the supplied data using a


Format Preserving Encryption algorithm
called BPS.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 96
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE0802 CVV-GENERATE Calculates the Card Verification Value


VISA (CVV) from the CVK key specifier and
CVV data.

EE0803 CVV-VERIFY Verifies the Card Verification Value (CVV)


from the CVK key specifier and CVV data.

A0 MT-KPE-GEN Generates a random PIN Encryption Key


MasterCard
(KPE)

A1 MT-KPE-RCV Allows a received PIN Encryption Key


(KPE) that has been encrypted under the
Key Exchange Key (KEKn) indicated by
the supplied Index (MT-Index), to be further
encrypted under Domain Master Key (KM)
Variant1 for storage within the host.

A2 MT-PIN-TRAN Translates a PIN Block from encryption


under a host stored PIN Protect Key (PPK)
to encryption under a HSM stored PIN
Encryption Key (KPE)

A3 MT-PIN-VER Performs the verification of a PIN in an


AS/ANSI formatted PIN Block, using the
IBM 3624 method.

A7 MT-PIN-VER-PVV Performs the verification of a PIN in an


AS/ANSI formatted PIN Block, using the
PVV method

PSMAIL EE0E02 LOAD-PS Loads a PostScript File into HSM memory.

EE0E03 PRINT-PS Substitutes known strings in the Postscript


file for user supplier strings and sends the
file to printer.

PIN Generation EE0E04 PIN-GENERATE Generates a random PIN returned


encrypted under a specified PIN Protect
Key (PPK).

PIN Printing EE0E05 PIN-PRINT Prints a PIN supplied encrypted under a


specified PIN Protect Key (PPK).

E2 PIN-MAIL Generates a PIN that has a length equal to


PIN Mailer
PINLEN.

EE0E06 PIN-MAIL-2 Enhanced version of host-function E2.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 97
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

PIN Charset EE0E07 LOAD-CHARSET Load the character sets for PINn printing in
words for displaying in user-defined
character sets.

EF0701 VCEPS-VER-S1-GEN-S2 Verifies the S1 MAC produced by the CEP


VCEPS card and generates the S2 MAC for
sending to the CEP card.

EF0702 VCEPS-VER-SN Verifies the MAC produced by the CEP


card or PSAM.

EF0703 VCEPS-GEN-SN Generates the MAC for Sn data for sending


to CEP card.

EF0704 VCEPS-MAC-VER-LSAM Verifies the MAC calculated by the LSAM.

EF0F01 VCEPS-GEN-HASH-CEP Calculates the hash result for the given


hash data.

EE4100 WRITE-USER-STORE- Stores a valid DES key encrypted under


User Storage
KEY the domain master key (KM) in the HSM.

EE4101 READ-USER-STORE- Retrieves a pre-stored DES key encrypted


KEY under the domain master key (KM) from
the HSM.

EE4102 WRITE-USER-STORE- Stores user data of maximum 128 bytes in


DATA the HSM.

EE4103 READ-USER-STORE- Retrieves user stored data from the HSM.


DATA

EE0608 PIN-TRAN-8 Allows translation of both the PIN block


format and the PIN encryption key,
EMV Issuer
extending PIN-TRAN-2, adding ISO
Format 2 PIN block.

EE2040 GENERATE-ISSUER- Generates the issuer key pair and returns


KEY-PAIR the keys for host storage.

EE2041 SELF-CERT-ISSUER- Creates the Self-certified Issuer Public


PUBLIC-KEY Key

EE2042 VERIFY-CA-PUBLIC- Verifies the Self-certified Europay-


KEY-MC MasterCard Public Key

EE2043 VERIFY-ISSUER-PK- Verifies the signature, form, and content of


CERT-MC an Issuer Public Key Certificate

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 98
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE2044 SELF-SIGN-ISSUER-PK- Creates the Self-Signed Issuer Public Key


VISA Data

EE2045 VERIFY-CA-PK-VISA Validates the 'Self-Signed Visa CA Public


Key Certificate

EE2046 VERIFY-ISSUER-PK- Verifies the signature, form, and content of


CERT-VISA an Issuer Public Key Certificate

EE2047 VERIFY-DETACHED- Validates the Issuer Public Key Detached


CERT-VISA Signature

EE2048 GENERATE-ICC- Generates an ICC key pair and calculates


KEYPAIR the digital signature for the ICC Public Key
Certificate.

EE2049 VERIFY-ICC- Verifies an ICC Certificate


CERTIFICATE

EE204A DERIVE-ICC-MASTER- Derives a unique-per-card, 16-byte, ICC


KEY Master Key.

EE204B SIGN-ICC-STATIC-DATA Calculates a digital signature for the ICC


Static Application Data using an Issuer
Private Key.

EE204C VERIFY-ICC-STATIC- Verifies an ICC's Static Data and the


DATA associated digital signature, using an
Issuer Public Key.

EE204D VERIFY-ICC-DYNAMIC- Verifies an ICC's Dynamic Application


DATA Data and the associated digital signature,
using an ICC Public Key.

EE204E RSA-ENCIPHER-PIN Calculates a card's PIN, format it, and


then encrypt it using the card's ICC PIN
Encipherment Public Key.

EE204F GENERATE-RANDOM- Generates a random PIN for storing in an


PIN-EMV ICC.

EE2050 EXPORT-PIN-EMV Reproduces a previously generated PIN,


formats it in ANSI PIN block and encrypts
the block for secure transport.

EE2051 KTK-KEY-EXPORT Re-encrypts a host stored encrypted


3DES key under a specified KTK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 99
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE2052 DERIVE-NEW-ICC-KEY- Derives a new ICC key set and returns it


SET encrypted under K1_KEK.

EE2053 DERIVE-NEW-ICC-KEY Derives a new ICC key and returns it


encrypted under KEK.

EE2054 GENERATE-DCV Generates a Data Check Value (DCV)


based on the data passed in the function
and returns it.

EE2058 GENERATE-ICC-CRT- Generates CRT parameters and calculates


KEYPAIR the digital signature for the ICC Public Key
Certificate.

EE205A GENERATE-ICC-CRT- Generates an RSA key pair for an EMV


KEYPAIR-PKCS ICC, encrypts private key and calculates
digital signature for the Public Key
Certificate.

EE0210 ZKA-IMPORT-MK Translates an ECB- or CBC-encrypted MK


ZKA to encryption by variant of the Domain
Master Key for host storage.

EE0610 ZKA-PIN-TRANS Performs translation of both the PIN Block


format and the PIN encryption key.

EE0611 ZKA-PIN-VER Performs the verification of a PIN using the


ecPVN method.

EE0612 ZKA-CALC-PVN Calculates the PVN for a PIN and also


provides the length of the PIN.

EE0613 ZKA-PIN-TRANS-1 Performs translation of both the PIN block


format and the PIN encryption key.

EE0710 ZKA-MAC-GEN Generates a random encrypted MAC key,


RND, and uses the clear MAC key to
generate a MAC for the provided data.
The value of RND may be inserted in the
data prior to calculating the MAC.

EE0711 ZKA-MAC-GEN-1 Generates a random encrypted MAC key,


RND, and uses the clear MAC key to
generate a MAC for the provided data.
The values of RND, Version Number and
Generation Number may be inserted in the
data prior to calculating the MAC.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 100
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

PAYPASS EE0010 CVC3-GENERATE Generates Card verification code.

EE0011 CVC3-VERIFY Verifies CVC3 with the help of generated


CVC3 and supplied CVC3.

EE0012 DERIVE-CVC3-KD-IV Derive Data Key CVC3 and IVCVC3 for


Trace 1 and Trace 2.

EE0013 CREATE-ADDI-ICC- Create ICC certificate with different SDA


CERTIFICATE data.

EE0015 dCVV-GENERATE Generates CVV for the virtual mag stripe


data (CVV Data).

EE0015 dCVV-VERIFY Verifies Card Verification Value with the


help of generated CVV and supplied CVV.

EE3102 KEY-PACKAGE-STATUS Returns the status of any Export Key


Netkey
Packages currently stored in the HSM.

EE3103 EXPORT-KEY- Extracts the current Export Key Package


PACKAGE out of the HSM.

EE3104 IMPORT-KEY-PACKAGE Load an Export Key Package to the HSM


from the host.

EE6000 TLS-PRE-MASTER-KEY- Generates a random pre-master key to


TLS
GENERATION used with the TLS v1.0.

EE6001 TLS-PRE-MASTER-KEY- Exports a pre-master key under a RSA key


SEND to be sent to a TLS enabled server.

EE6002 TLS-PRE-MASTER-KEY- Imports a pre-master key encrypted under


RECEIVE a RSA key to domain master key.

EE6003 TLS-MASTER-KEY- Derives a TLS master key from a pre-


DERIVATION master key and returns it for host storage.

EE6004 TLS-ENCRYPTION- Derives TLS encryption and MAC keys


AND-MAC-KEY- and initialization vectors for both client and
DERIVATION server.

EE2059 GP-MUTUAL- Supports the mutual authentication of an


AUTHENTICATION ICC card and the off-card entity by
Global Platform
verification of the card cryptogram and
generation of the host cryptogram.

EE2060 GP-CALC-CARD- Generates the card cryptogram that is part


CRYPTOGRAM of the mutual authentication of an ICC card
and the off-card entity.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 101
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE2061 GP-SECURE- Performs the cryptographic processing


MESSAGING- required for Secure Messaging.
COMMAND

EE2062 GP-SECURE- Performs the cryptographic processing


MESSAGING- required for secure messaging of a
RESPONSE response message received from the card.

EE2063 GP-SCP10-SESSION- Decrypts or derives up to 5 keys, inserts


KEY-TRANSPORT them at specified offsets in a plaintext key
block and encrypts the block using
RSAES-PKCS-v1.5 and the provided RSA
public key.

EE2064 GP-SCP10-CALC-HASH- Calculates the hash of a block containing


OF-KEY the session keys and a challenge.

EE2065 GP-MUTUAL- Supports the mutual authentication of an


AUTHENTICATION- ICC card and the off-card entity by
SCP03 verification of the card cryptogram and
generation of the host cryptogram using
AES algorithm.

EE2066 GP-SECURE- Performs the cryptographic processing


MESSAGING- required for Secure Messaging.
COMMAND-SCP03

EE3000 OBM-GET-PUBLIC-KEY Retrieves a Public Key from the HSM


stored RSA Key Pair table in secure
OBM
memory and returns it in a clear form in a
key specifier.

EE3001 OBM-GEN-RANDOM- Generates and returns a random number of


NUMBER the specified length.

EE3002 OBM-VERIFY-PIN-3624 Extracts the PIN from a RSA-encrypted


PIN block and verifies the PIN using the
3624 Offset method.

EE3003 OBM-CHANGE-PIN-3624 Extracts the old PIN and new PIN from
RSA-encrypted PIN block, verifies the old
PIN and calculates a PIN offset for the
new PIN.

EE3004 OBM-SET-PIN Extracts the (numeric or alpha-numeric)


PIN from RSA-encrypted PIN block and
calculates a Reference TPV for storage
and subsequent use in PIN verification.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 102
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE3005 OBM-VERIFY-PIN-HASH Extracts the (numeric or alpha-numeric)


PIN from RSA-encrypted PIN block, and
verifies the PIN by using the extracted PIN
to calculate a transaction TPV and
comparing the result with the Reference
TPV

EE3006 OBM-CHANGE-PIN- Extracts the old PIN and new PIN from
HASH RSA-encrypted PIN block, verifies the old
PIN and calculates a TPV for the new PIN.

EE3008 OBM-PRINT-PIN Generates a random (numeric or alpha-


numeric) PIN, prints the PIN along with
specified data on an attached serial printer,
and returns a reference TPV for storage
and subsequent verification of the PIN.

EE3009 OBM-MIGRATE-PIN- Calculates the reference PIN from the


3624-TPV keys and data of the 3624 Offset method,
then calculates a Reference TPV for
storage and subsequent use in PIN
verification.

EE3016 OBM-GET-PRINT- Generates 8 bytes of random data, also


TOKEN known as a Print Token

EE3017 OBM-GENERATE- Generates a random (numeric or alpha-


RANDOM-PIN numeric) PIN and returns it encrypted
under the specified PPK for printing at a
remote location.

EE3018 OBM-PRINT- Decrypts an encrypted OBM Print PIN


ENCRYPTED-PIN Block, verifies the Print Token and prints
the PIN along with the specified data on an
attached serial printer.

EE3019 OBM-TRANSLATE-PIN Decrypts an OBM RSA-encrypted, format


12 PIN Block, changes the PIN Block
format to that specified by the output PIN
Block format and returns it encrypted by
the specified PPK.

EE3020 OBM-SET-PIN-TPV Extracts the numeric PIN from a PPK-


encrypted PIN Block and calculates a
reference TPV for storage and subsequent
use in PIN verification.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 103
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE3021 OBM-GENERATE- Generates a random (numeric or alpha-


RANDOM-PIN-2 numeric) PIN and returns the PIN
encrypted under the specified PPK for
printing at a remote location.
It excludes the characters in the PIN, as
supplied in the Restricted Characters
field.

EE3022 OBM-DECRYPT-DATA- Recovers the user data from the cipher


RSA text.

EE3023 OBM-DECRYPT-DATA- Processes an RSA-encrypted key block,


SYMMETRIC recovering the parameters of the
symmetric algorithm from the ciphertext.

EF0616 PIN-GENERATION Generates a 5 digit PIN according to IBM


GNET
3624 method.

EF0617 AUTH-PARAM- Computes the Authentication Parameter


GENERATE for the input encrypted 5 digit PIN block.

EF0618 RANDOM-KEY- Allows the random generation of any key


GENERATION type and encryption under the respective
KM variant.

EE3050 CHECK- Validates the authentication code involving


Cloud Based
AUTHENTICATION- encrypted data.
Payments
CODE

EE3051 DERIVE-CLOUD-CMK Derives card master keys for contactless


and remote payments on cloud.

EE3052 DERIVE-CBP-SESSION- Derives session keys and restricted use


KEYS keys for contactless and remote payments
on cloud.

EE3053 VALIDATE-CLOUD-AC- Verifies the application cryptogram for


GENERATE-ARPC cloud based payments.

EE3054 VALIDATE-CBP-CVC3 Verifies the CVC3 generated for magstripe


cards used in cloud based payments.

EE3055 CALCULATE-IDN Derives IDN number for cloud based


payments.

EE3056 PROTECT-CLEAR- Encrypts the clear mobile PIN.


MOBILE-PIN

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 104
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE3057 PROTECT- Translates the encrypted mobile PIN from


ENCRYPTED-MOBILE- one set of protection key to another.
PIN

EE3058 CHECK-CLEAR- Verifies the encrypted mobile PIN with


MOBILE-PIN clear mobile PIN.

EE3059 CHECK-ENCRYPTED- Verifies the provided mobile PIN against


MOBILE-PIN the reference mobile PIN.

EE3060 IMPORT-RSA-ENC-KEY Translates a key from encryption under an


asymmetric key to encryption under AES
Domain Master Key.

EE3061 EXPORT-KEY-2 Translates a key from encryption under


Domain Master Key to encryption under
specified KEK.

EE305A DERIVE-MOBILE- Derives mobile session keys from the


SESSION-KEY mobile master keys.

EE305B WEB-SERVICE- Used for both encryption and


MESSAGE authentication for sending message as
well as verification and decryption of
received message.

EE305C PROTECT-DC-FILE Prepare the file containing keys used for


AC generation in cloud based payments.

EE305D CCM-ENCRYPT Used for enciphering in CBC-Counter


mode.

EE305E CCM-DECRYPT Used for deciphering using CBC-Counter


mode.

EE305F RNS-MESSAGE Prepares Remote Notification Service


Message and provide DPK encrypted
Session Id to be used in CBP as derivation
and verification data.

EE080A VFPE-ENCRYPT Used to encrypt data in a format preserving


Visa Data Secure
way.

EE080B VFPE-DECRYPT Used to decrypt data in a format preserving


way.

EE080C TRANSLATE-DATA- Translate data for point to point encryption.


P2PE

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 105
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

EE080D TRANSLATE-VFPE- Used to translate data from a source


DATA-TO-ALPHABET formatted data to Visa format preserving
encryption alphabet binary string.

EE080E TRANSLATE-VFPE- Used to translate data from a Visa format


ALPHABET-TO-DATA preserving encryption alphabet binary
string to target formatted binary string.

EF0E02 PRV-GENERATION Generates a PIN Reference Value (PRV).


CardProcess
EF0E03 PRV-VERIFICATION Verifies a PIN Reference Value (PRV).

0001 HSM-STATUS Notifies the host of exception conditions at


HouseKeeping
Luna EFT.

0002 HSM-STATUS-EXTN Notifies the host of exception conditions at


(0002) Luna EFT.

0005 FUNCTION-STATUS Returns information on individual


(0005) functions.

0006 KM-STATUS Returns information on the usage of


Master key versions.

0007 FORMAT-STATUS Returns information on the usage of Key


Specifier (K-spec) formats.

000F CALC-CSC-1 Calculates CSC values to support CSC


algorithm v2.0.

0010 VERIFY-CSC-1 Verifies the CSC value.

0015 SET-CLOCK Sets the date and time in Luna EFT.

0016 GET-CLOCK Gets the date and time from Luna EFT.

0020 MD5-GENERATOR Returns the MD5 hash value of the input


data, to a maximum length as specified by
the supplier.

0021 SHA1-GENERATOR Returns the SHA1 hash value of the input


data, to a maximum length as specified by
the supplier.

3130 TERMKEYINIT-6.4 Randomly generates a set of initial keys


and data for an Australian Standard
Key Management
AS2805.6.4 2001 terminal (*KEK1, *KEK2,
PPASN).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 106
CHAPTER 4 Function Library

Function Group Function Function Name Description


Code

4501 VISA-RECEIVE Deciphers a set of double length session


keys received, from a Visa Interchange.

4502 KEK-GEN-VISA Derives a KEKr for use in a VISA Dynamic


Key Exchange Interchange.

4503 VISA-RECEIVE-IWK Deciphers a double-length Issuer Working


Key received from a Visa Interchange.

4504 VISA-RECEIVE-AWK Deciphers a double-length Acquirer


Working Key received from a Visa
Interchange.

B510 SPONSOR-KEY-GEN Generates a random Cross Acquirer Key


Remote Initialization
(KCA) and a housekeeping key (KMACH).

B570 RAND-GEN Generates a 64 bit random number.

B580 INITIAL-KEY-REC Returns the initial key (KI), PIN Pad


Identification Number, Date-Time-Stamp,
Random Number and user data from the
Initialize Request Message.

C6A0 LOAD-PUBLIC-KEY Encrypts a public key under the


Public Key
appropriate variant of KM for storage.

C710 NODE-KEK-REC- Generates a random Cross Domain Send


EXPORT Key (KEKs).

Chess D002 CHESS-KEK-RECEIVE- Translates the encryption key of the *KEK


6.3 from the Key Transport Key (*KTK) to
variants of a Domain Master Key (*KM) for
host storage on the CKDS.

E100 AUTHENTICATION- Generates an Authentication Parameter


Miscellaneous PARAMETER-GEN according to Australian Standard
AS2805.6.2 1988.

E550 PPID-ENCRYPT This function is the reverse of the function


E540 – VERIFY PPID.

Japan PIN EF0601 JAPPINTRAN Allows translation of PIN block format and
PIN encryption key.

Clear PIN EE0600 CLEAR-PIN-ENCRYPT Formats a clear PIN into an ANSI PIN
Block and encrypts it using the supplied
PPK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 107
CHAPTER 4 Function Library

AB-KEY-GEN (3B00)
This function generates a random ATM A-key and B-key.

Request Length Type Description

3B00 2 h Function Code

Msg ID 2 x Message Identifier

KL 1 x Key length:
1 = Single
2 = Double
3 = Triple

KTKi Var K-Spec Index of KTK (Format 00 - 03)

Response Length Type Description

3B00 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKMvAA(A) Var K-Spec ATM A-key (Format 20, 21 or 22)

eKTK(A) Var B64/B128/ ATM A-key


B192

eKMvA6(B) Var K-Spec ATM B-key (Format 20, 21 or 22)

eKTK(B) Var B64/B128/ ATM A-key


B192

The A-key is returned encrypted under KMVAA and the Transport Key. The B-key is returned encrypted under KMVA6
and the Transport Key.

Note: This function supersedes the host function 3600.

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 108
CHAPTER 4 Function Library

ADVANCED-RANDOM-KEY-GENERATION (EE0619)
This host function generates random key according to key format details and returns it in key format key-spec.

Request Length Type Description

EE0619 3 h Function Code

FM 1 h Function Modifier (FM=00)

Key format 1 h Key format


(Formats: 10,11,12,13,14,17,18,1C)

Key details Var h Key Block structure. Optional.

Response Length Type Description

EE0619 3 h Function Code

rc 1 h Return Code

eKM(Key) Var Key-spec Random key in key format

Following keys are supported as AES keys:-


DPK, MPK, PPK, KIS, KIR, KI, KTM, BDK, IMKAC, IMKSMI, IMKSMC, IMKDAC, IMKIDN, KTK, PTK, IMKCL,
IMKRP

Key Details
Key detail field contains following details pertaining to 1C key format.

KM-index 1 h Index of KM

Key Type 1 d Variant id.

Algorithm 1 h Algorithm

Key length 1 h Key length

Padding 1 h Padding to be used in generated key

Mode of operation 1 h Mode of Operation

In case of format 10-14, key details contains key type of derived key.

Key detail field contains following details pertaining to 17 and 18 key format.

KM-index 1 h Index of KM (1-16)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 109
CHAPTER 4 Function Library

Key Type 1 d Variant id.


For key type = KI, use the following Key Usage, Mode of Use and Algorithm.

Key Usage Mode of Use Algorithm

K0, K1 B,D,E,N D,T,A

For other Luna EFT keys, see TR-31 Key Usage and Mark II Key Types.

Key length 1 h Key length


01 = Single Length DES key
02 = Double Length TDES key or 128 bit AES key
03 = Triple Length TDES key or 192 bit AES key
04 = 256 bit AES key
Algorithm is determined by algorithm field in KBS

KBS Var h Key Block Structure. Optional.


Must be provided when key in response is needed in key block format.

Key Block Structure

Key Block Structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h Any allowed value for the key to be generated.

Algorithms 1 h Any allowed value

Mode of use 1 h Any allowed mode of use for key usage

Key Version No. 2 h Any allowed value

Exportability 1 h Any allowed value

Padding Indicator 1 h 00 = Do not pad


03 = Pad to triple length

Number of optional 1 h 0x00-0x03 (Decimal 00 to 03 Max)


fields

Optional field 0 … n Var h Number of optional field as defined in above filed. First byte of
optional field will be treated as Optional Block ID.

Note:
- While transferring keys in Key Block between two terminals, this function does not generate

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 110
CHAPTER 4 Function Library

keys for Variant ID 11, as this variant is for terminal keys (KIS/KIR).
- Also, random keys cannot be generated with variants (11, 25 & 26) using key spec 10,
11,12,13 and 14.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 111
CHAPTER 4 Function Library

APACS-MAC-GEN (EE0704)
Request Length Type Description

EE0704 3 h Function Code

FM 1 h Function Modifier (FM=x0)

KTi Var K-spec Key specifier for KT containing eKMv5(KT) (Formats: 10,
11, 13)

AB 8 h Concatenation of A and B

eKMv12(macres) 8 h Encrypted request MAC residue.

AP Data 8 h Data block for calculation of Authorization Parameter

Data Var h Data to be MAC'd.

Response Length Type Description

EE0704 3 h Function Code

rc 1 h Return Code

MAC 4 h Message Authentication Code

eKMv12(macres) 8 h Encrypted response MAC residue

KTo Var K-spec Key specifier for KT containing eKM5(KT) (Formats:


10,11,13)

This function generates the MAC for a terminal response message. The MAC calculation includes the request MAC
residue and the Authorization Parameter. The function also derives an updated KT. It returns the response MAC residue
for processing with the confirm message.

Processing Steps
1. Derive MAC key using KTi, A and B. Refer, 10.5.2 and 10.8 in [43].
2. Calculate the authorization parameter using the MAC key and AP Data. Refer, 10.7.3 in [43].
3. Form an extended message by prefixing the request MAC residue and suffixing the authorization parameter to the
Data. Refer, 10.2.3 in [43].
4. Calculate the MAC for extended message. Refer, 10.2.2 and 10.8.5 in [43].
5. Extract the response MAC residue from the MAB, pad, and encrypt using KMv12. Refer, 10.2.2 in [43].
6. Derive the updated KTo using the existing KTi, the request MAC residue and the response MAC residue. Refer,
10.6.1 and 10.8.4 in [43].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 112
CHAPTER 4 Function Library

APACS-MAC-VER-CONFIRM (EE0705)
Request Length Type Description

EE0705 3 h Function Code

FM 1 h Function Modifier

KT Var K-spec Key specifier for KT containing eKMv5(KT) (Formats: 10,


11, 13)

AB 8 h Concatenation of A and B

MAC 4 h Message Authentication Code

eKMv12(macres) 8 h Encrypted response MAC residue

Data Var h Data to be MAC'd.

Response Length Type Description

EE0705 3 h Function Code

rc 1 h Return Code

This function verifies the MAC for a terminal confirm message. The MAC calculation includes the response MAC
residue.

Note: For initialization and host storage, KT is managed identically to a KTM. Hence, the
existing facilities for initialization of a KTM may be used to initialize a KT. For host storage, the
KT is encrypted using variant 5 of KM.

Processing Steps
1. Derive MAC key using KT, A and B. Refer, 10.5.2 and 10.8 in [43].
2. Form an extended message by prefixing the response MAC residue to the Data. Refer, 10.2.3 in [43].
3. Calculate the MAC for the extended message. Refer, 10.2.2 and 10.8.5 in [43].
4. Compare the calculated MAC with the MAC value in the function request. Exit with error code 08, if the comparison
fails.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 113
CHAPTER 4 Function Library

APACS-MAC-VER-REQUEST (EE0703)
Request Length Type Description

EE0703 3 h Function Code

FM 1 h Function Modifier (FM=x0)

KT Var K-spec Key specifier for KT containing eKMv5(KT) (Formats: 10,


11, 13)

AB 8 h Concatenation of A and B

MAC 4 h Message Authentication Code

Data Var h Data to be MAC'd

PIN flag 1 h 0 = no PIN


1 = Aquirer PIN

CD 8 h If PIN flag = 1; Concatenation of C and D.


else field present but ignored

Response Length Type Description

EE0703 3 h Function Code

rc 1 h Return Code

eKMv12(macres) 8 h Encrypted request MAC residue

PPK Var K-spec If PIN flag = 0 – zero-length field


If PIN flag = 1 – encrypted PIN Protect Key: eKMv1(PPK)
(Formats: 10, 11, 13)

This function verifies the MAC for a terminal request message. It returns the MAC residue for processing with the
response message. When the message includes an encrypted PIN, the function also derives the PPK required for use
in a PIN translate or PIN verify function.

Note: For initialization and host storage, KT is managed identically to a KTM. Hence, the
existing facilities for initialization of a KTM may be used to initialize a KT. For host storage, the
KT is encrypted using variant 5 of KM.

Processing Steps
1. Derive MAC key using KT, A and B. Refer, 10.5.2 and 10.8 in [43].
2. Calculate the MAC for Data. Refer, 10.2.2 and 10.8.5 in [43].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 114
CHAPTER 4 Function Library

3. Compare the calculated MAC with the MAC value in the function request. Exit with error code 08, if the
comparison fails
4. Extract MAC residue from MAB, pad, and encrypt using KMv12. Refer, 10.2.2 in [43].
5. If PIN flag = 1, derive PIN Processing Key (PIN Protect Key) using KT, A, B, C and D. Encrypt the key using
KMv1. The length of the PPK will be the same as the length of KT. Refer, 10.5.5 and 10.8.3 in [43].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 115
CHAPTER 4 Function Library

AUTH-PARAM-GENERATE (EF0617)
Request Length Type Description

EF0617 3 h Function Code

FM 1 h Function Modifier

PPK Var K-Spec Key specifier for PPK


(Formats: 0 - 3, 10, 11, 12, 13, 14, 17, 18)

ePPK(PIN) 8 h Encrypted PIN Block, 5 digit PIN

Issuer Domestic Code 5 d Issuer ABI code (domestic identifier for Italian bank) -
ASCII

Card Secure Code 8 d Card Secure Code - ASCII

PAN Data 12 d PAN Number - ASCII

DPK-Spec Var K-Spec Key specifier for DPK


(Formats: 0 - 3, 10, 11, 12, 13, 14, 17, 18)

Response Length Type Description

EF0617 3 h Function Code

rc 1 h Return Code

AP Value 8 ASCII Encrypted form if AP encryption key identifier specified,


Or otherwise returned in plain text ASCII
ePDK
(Data)

This function computes the Authentication Parameter for the input encrypted PIN Block. The function decrypts the PIN
Block and uses the authentication parameter algorithm with the input ABI code, Card Secure Code and PAN data to
compute the Authentication Parameter. The returned Authentication Parameter is optionally enciphered using the
provided key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 116
CHAPTER 4 Function Library

BDKGEN (EE0408)
Request Length Type Description

EE0408 3 h Function Code

FM 1 h Function Modifier (FM=x0)

Key Length 1 h Length of BDK


02 = Double Length
03 = Triple Length

KBS Var h Key Block structure. Optional.


KBS must contain key usage corresponding to BDK and
valid mode of use and algorithm.

Response Length Type Description

EE0408 3 h Function Code

rc 1 h Return Code

BDK Var K-Spec Key specifier incorporating encrypted BDK key


(Formats: 11, 12, 13, 14, 17, 18)

This function generates a BDK. For subsequent use with other functions, the generated BDK key is encrypted by the
associated variant of the Domain Master Key.

Notes
– The key specifiers 13, 14 under the Response, are generated when using the Legacy option.
– The key specifiers 11, 12, 13, 14 under the Response, are generated based on the chosen operation on console
and FM. See, section Function Modifier Values.
Derived Unique Key per Transaction (DUKPT) is a key management method which uses a unique key for each
transaction, and prevents the disclosure of any past key used by the transaction-originating HSM (i.e. terminal PIN
pad).
This method relies on the use of a 'base derivation' key or BDK present only in the HSM of the first receiving node that
cryptographically processes that transaction. The unique Transaction Keys used by the HSM of a terminal are
transformations of an injected, unique-per-terminal Initial Key which is derived from the BDK. The transaction keys can
be calculated by the HSM of the receiving node using only the BDK and non-secret data transmitted by the terminal as
part of each transaction. With this method each transaction-originating HSM uses a unique key for each transaction,
yet never contains any information which would allow the determination of any key previously used by the HSM –
except by an exhaustive key search, nor of any key which has been or will be used by any other transaction-originating
HSM.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 117
CHAPTER 4 Function Library

B-DECIPHER-ECB (85)
Request Length Type Description

85 1 h Function Code

Blocks 1 h No. of 8 byte Blocks

TKSI 1 d Terminal Key Set Index

eBK(Data) bks*8 B64 Must be multiple of 8 bytes

Response Length Type Description

85 1 h Function Code

rc 1 h Return Code

Data bks*8 h Clear Data

This function decrypts the supplied encrypted DATA using the B-key (BK) of the HSM stored 3624 Terminal Key Set as
indicated by the specified index (TKSI), and using the DES in Electronic Code Book mode.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 118
CHAPTER 4 Function Library

B-ENCIPHER-ECB (84)
Request Length Type Description

84 1 h Function Code

Blocks 1 h No. of 8 byte Blocks

TKSI 1 d Terminal Key Set Index

Data bks*8 h Must be multiple of 8 bytes

Response Length Type Description

84 1 h Function Code

rc 1 h Return Code

eBK(Data) bks*8 B64 Data encrypted under Base Key

This function encrypts the supplied DATA under the B- key (BK) of the HSM stored 3624 Terminal Key Set as indicated
by the specified index (TKSI), using the DES in Electronic Code Book mode.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 119
CHAPTER 4 Function Library

BPS-DECIPHER (EE0810)
Request Length Type Description

EE0810 3 h Function Code

FM 1 h Function Modifier

DPK Var K-spec BPS DPK


(Formats: 20)

F 1 h BPS Function
0 = Specified with key.

w 1 h Number of rounds
0 = Specified with key.

s 2 h Cardinality of s-integer

len 2 h Number of s-integers in the s-integer string eDPK(Data).

n 1 h Number of bits for s-integer representation in eDPK(Data)


and IV.

Tweak Hash Algorithm 1 h 0 = Null


1 = SHA-1
2 = SHA-256

IV Var h Initialisation Vector for BPS-CBC mode


(zero-length field if not used).

Tweak Data Var h When Tweak hash algo = 0 then, 8 bytes or 0 (implying 8
bytes of zeros)
When Tweak hash algo is 1 then, minimum length
supported by SHA1
When Tweak hash algo is 2 then, minimum length
supported by SHA256

eDPK(Data) Var h BPS-encrypted data

Response Length Type Description

EE0810 3 h Function Code

rc 1 h Return Code

Data Var h Deciphered data

This function performs the decryption of BPS-encrypted data using a derived key. The DPK is derived as a UKD
(Unique Key per Device) or DUKPT-KPE, as defined in the key specifier.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 120
CHAPTER 4 Function Library

Each s-integer in eDPK (Data) and IV is represented as a number of bits as specified by n. For example, decimal digits
could be represented in 4 bits (packed BCD) or in 8 bits (unpacked BCD or ASCII), and alpha-numerics (for example, s
= 61) could be represented in 6 or 8 bits. In all cases superfluous, high-order bits, i.e. where n > (log2(s) – rounded up),
are discarded without checking. The s-integers output from the decipher operation will be coded on the number of bits
specified in n.
The s-integer fields in eDPK (Data) and Data are left-justified in the byte-array. For example, if n = 4 and len is odd,
there will be a trailing 4-bit padding value.
If len > maxb, the CBC operating mode will be used (as defined in [70]). In this case, IV may incorporate maxb s-
integers or may be a zero-length field implying an IV of s-integers each with a value of zero. If len ≤ maxb then IV must
be a zero-length field.

Processing Steps
1. Check that F and w = 0. Different values may be allowed in the future where the information is not specified with
the key.
2. Check that s has a value of 10 or 61.
3. Check that n has a value as follows:
If s = 10, n = 4 or 8; if s = 61, n = 6 or 8.
If tweak hash algorithm is None, then tweak data can be 8 bytes or a zero-length field implying 8 bytes of
zeroes.
If tweak hash algorithm is not None, then tweak data must have at least the minimum length supported by the
identified hash algorithm.
4. Derive the DPK using the format 20 key specifier, which must incorporate a key specifier with format 0-3 or 15 in
order to access the BPS-BDK and associated parameters.
5. BPS-decrypt eDPK(Data) using the derived DPK, s, len, and IV .
6. Set each s-integer in decrypted result as n bits, with leading zero bits if required. Left-justify the padded s-integers
in the byte-array Data.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 121
CHAPTER 4 Function Library

BPS-ENCIPHER (EE0811)
Request Length Type Description

EE0811 3 h Function Code

FM 1 h Function Modifier

DPK Var K-spec BPS DPK


(Formats: 20)

F 1 h BPS Function
0 = Specified with key

w 1 h Number of rounds
0 = Specified with key

s 2 h Cardinality of s-integer

len 2 h Number of s-integers in the s-integer string Data

n 1 h Number of bits for s-integer representation in Data and IV

Tweak Hash Algorithm 1 h 0 = Null


1 = SHA-1
2 = SHA-256

IV Var h Initialisation Vector for BPS-CBC mode


(zero-length field if not used).

Tweak Data Var h When Tweak hash algo = 0 then, 8 bytes or 0 (implying 8
bytes of zeros)
When Tweak hash algo is 1 then, minimum length
supported by SHA1
When Tweak hash algo is 2 then, minimum length
supported by SHA256

Data Var h Plaintext data

Response Length Type Description

EE0811 3 h Function Code

rc 1 h Return Code

eDPK(Data) Var h BPS-encrypted data

This function performs the BPS encryption of data using a derived key. This function is not necessarily required, but
may be useful for testing purposes.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 122
CHAPTER 4 Function Library

C-KEY-GEN (3B10)
This function generates a new random ATM Communication key and returns it encrypted under KMvA6, KMv22,
KMv44 and the old communication key.

Request Length Type Description

3B10 2 h Function Code

Msg ID 2 x Message Identifier

KL 1 x Key length:
1 = Single
2 = Double
3 = Triple

eKMvA6(C) Var K-Spec Old communication key


(Format 20, 21 or 22)

CM 1 x Cipher mode:
0 = ECB
1 = CBC

Response Length Type Description

3B10 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKMvA6(C’) Var K-Spec ATM C-key (Format 20, 21 or 22)

eKMv22(C’) Var K-Spec ATM C-key (Format 20, 21 or 22)

eKMv44(C’) Var K-Spec ATM C-key (Format 20, 21 or 22)

eC(C’) Var B64/B128/ ECB or CBC encrypted ATM C-key


B192

Note: This function supersedes the host function 3610.

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 123
CHAPTER 4 Function Library

CALC-CSC (EE0501)
Request Length Type Description

EE0501 3 h Function code

FM 1 h Function Modifier (FM=00)

CSC Algo 1 h 00 = CSC v1.0


01 = CSC v2.0

CSCK-Spec Var K-Spec Key specifier for CSCK


(Formats: 0 – 3, 11, 13, 17, 18)

Expiry date/Unpredictable 2 d Any random Number


Number

PAN 8 d The account block

ServiceCode 2 d Service code


Must be 0000 for CSC Algo = 00

Response Length Type Description

EE0501 3 h Function code

rc 1 h Return code

CSC string 6 h Packed 5, 4 or 3 digit CSCs

This host function calculates CSC values to support CSC algorithm v2.0. The function generates CSC values
according to the algorithm given in CSC algo field, and returns them to the host.

The calculation of CSC function returns 6 bytes CSC packed string in an order as follows:
5CSC, 4CSC and 3CSC ( a packed representation of the 5,4 and 3 digit CSCs)
The function supersedes host function A8.

FM Function Modifier = 00

CSC Algo CSC Algorithm used to calculate CSC values


00 = CSC v1.0
01 = CSC v2.0

CSCK Spec Key Specifier for CSC Key. Formats: 0-3, 11, 13, 17, 18

Expiry Date/ Any Random Number, as specified in Table 37 of Page 69, in American Express Hardware
Unpredictable Security Module (HSM) Function Requirements.pdf , October 2010.
Number

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 124
CHAPTER 4 Function Library

PAN 15 digit Permanent account number. Leading nibble must be 0.

Service Code Service code to derive CSC string. Left most nibble must be 0.
The possible range is 000-999 as given in section 4.6.4 of Reference [47] and Page 3-20 of
Reference [46].
Must be 0000 in case of CSC v1.0

CSC String Packed 5,4,3 digits CSC

Processing Steps
1. Get PAN and Expiry Date and form Card Data as detailed in the section 4.6.2 of Reference [46].
2. Depending upon the CSC algorithm, form account block and encrypt it with the CSC key and derive 12-nibble CSC
string as detailed in section 4.6.2 & 4.6.3 of Reference [46].

Note: It is the application’s responsibility to provide correct Service code and there is no check
for correctness in host function.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 125
CHAPTER 4 Function Library

CALC-CSC-1 (000F)
This host function calculates CSC values to support CSC algorithm v2.0. The function generates CSC values
according to the algorithm given in CSC algo field, and returns them to the host.

Request Length Type Description

000F 2 h Function code

Msg Id 2 x Message Identifier

CSC Algo 1 h 00 = CSC v1.0


01 = CSC v2.0

CSCK-Spec Var K-Spec Key specifier for CSCK


(Formats 21, 23)

Expiry date/Unpredictable 2 d Any random Number


Number

PAN 8 d The account block

ServiceCode 2 d Service code


Must be 0000 for CSC Algo = 00

Response Length Type Description

000F 2 h Function code

Msg Id 2 x Message Identifier

rc 1 h Return code

CSC string 6 h Packed 5, 4 or 3 digit CSCs

The calculation of CSC function returns 6 bytes CSC packed string in an order as follows:
5CSC, 4CSC and 3CSC ( a packed representation of the 5,4 and 3 digit CSCs).

CSC Algo CSC Algorithm used to calculate CSC values


00 = CSC v1.0
01 = CSC v2.0

CSCK Spec Key Specifier for CSC Key. Formats: 21, 23

Expiry Date/ Any Random Number, as specified in Table 37 of Page 69, in American Express Hardware
Unpredictable Security Module (HSM) Function Requirements.pdf , October 2010.
Number

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 126
CHAPTER 4 Function Library

PAN 15 digit Permanent account number.


Leading nibble must be 0

Service Code Service code to derive CSC string.


Left most nibble must be 0.
The possible range is 000-999 as given in section 4.6.4 of Reference [17], and page 3-20 of
Reference [16].
Must be 0000 in case of CSC v1.0

CSC String Packed 5,4,3 digits CSC

This host function is used for Australian Major Bank (AMB).

Processing Steps
1. Get PAN and Expiry Date and form Card Data as detailed in the section 4.6.2 of reference [16].
2. Depending upon the CSC algorithm, form account block and encrypt it with the CSC key and derive 12-nibble CSC
string as detailed in section 4.6.2 & 4.6.3 of reference [16].

Note: It is the application’s responsibility to provide correct Service code and there is no check
for correctness in host function.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 127
CHAPTER 4 Function Library

CALCULATE-CSC (A8)
Request Length Type Description

A8 1 Function code

CSCK-Spec Var K-Spec Key specifier for CSCK


(Formats: 0 - 3, 11, 13, 17 and 18)

CardData 8 h The account Block

Response Length Type Description

A8 1 h Function code

rc 1 h Return code

CSC 6 h Packed 3, 4 or 5 digit CSCs

This function calculates CSC values and returns them to the host. Six bytes are returned. This is a packed
representation of the 3, 4 or 5 digit CSCs. The CSCs are returned in the previously mentioned order.

CardData This is the account Block derived from the PAN and expiry date as defined by American Express.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 128
CHAPTER 4 Function Library

CALCULATE-IDN (EE3055)
This function is used to derive IDN number for cloud based payments.

Request Length Type Description

EE3055 3 h Function Code

FM 1 h Function Modifier = 00

Number of IDN 1 h Number of IDN values to be generated.


Must not exceed 128.

IDN Calculation Method 1 h 00 = MCBP

IDN Data Var h This is initial value for IDN

KM55(CMKCLIDN) Var K-Spec Encrypted CMKCLIDN


Formats: 11, 13, 17, 18, 1C

Response Length Type Description

EE3055 3 h Function Code

rc 1 h Return Code

IDN Var h ICC Dynamic Number

Processing Steps
1. Decrypt CMKCLIDN from KM55(CMKCLIDN)
2. Read first two bytes of IDN data.
3. Repeat steps ahead for iteration up to number of IDN value and then exit with resultant concatenated IDNs.
4. Use IDN generation algorithm as defined in reference [83], [84], [85] of Mark II, to generate IDN for current iterative
value of IDN data.
5. Append the response buffer with IDN for current iteration.
6. Increment the value of IDN data by 1.
7. Increment IDN data and go to step 3 for next iteration.

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 129
CHAPTER 4 Function Library

CCM-DECRYPT (EE305E)
This function is used for deciphering using CBC-Counter mode.

Request Length Type Description

EE305E 3 h Function Code

FM 1 h Function Modifier = 00

CCMK-Spec Var K-Spec Key Spec for CCMK


Formats: 0-3, 1C

Encryption Method 1 h 00 = CCM

Padding Mode 1 h 02 = None

MAC length 1 h MAC length in bytes (must be >= 4)


Max value = 16

SV Var h Starting Variable (nonce).


Must be present.

Data A Var h Data authenticated but not encrypted.


Can be zero length

CipherText C Var h Data authenticated and encrypted

D2 offset 2 h Offset for encrypted data

Output Format D2 1 h Data may need to be


- exported in plain text
- exported and encrypted under a local key
0 = D2 absent
1 = Encrypted Data

D3 offset 2 h Offset for data after encrypted data

Output Format Var h Additional parameters for output format.


Parameters See values in Output Format below.

Response Length Type Description

EE305E 3 h Function Code

rc 1 h Return Code

D1 Var h The data recovered from the Cipher text C.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 130
CHAPTER 4 Function Library

D2 Var h If Output Format D2


= 01: DPK encrypted data

D3 Var h Clear Data

Data fields for Output Format

Output Format = 1

Field Length Type Description

Key Type 1 h 00 = DPK


48 = CCMK

DPK/CCMK-Spec Var K-Spec Key Spec for Key Type


Formats:
DPK: 0-3, 11, 12, 13, 14, 17, 18, 1C
CCMK: 0-3, 1C

Encryption Mode 1 h 0 = ECB


1 = CBC
2 = CTR

IV/SV Var h In case of ECB this must be zero length field.


In CBC this is IV
In CTR this is SV

Padding Mode 1 h 0 = RFU


1 = Always
(See Padding Mode described in reference [83], [84],
[85] of Mark II)
2 = None

Processing Steps
1. Extract CCMK
2. Pass Cipher text C, SV, CCMK and A to algorithm for CCM (Counter with CBC-MAC) for decrypting data received
(reference [83], [84], [85] of Mark II) for processing.
3. Extract D1, D2 and D3 as D = D1 || D2 || D3, where D is decrypted text and separation for D2 & D3 done via D2
offset and D3 offset
4. Based on key usage, encrypt D2 using provided key details.
5. Return D1, D2 and D3.

Note: DES not supported in CTR decryption mode.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 131
CHAPTER 4 Function Library

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 132
CHAPTER 4 Function Library

CCM-ENCRYPT (EE305D)
This function is used for enciphering in CBC-Counter mode.

Request Length Type Description

EE305D 3 h Function Code

FM 1 h Function Modifier = 00

CCMK-Spec Var K-Spec Key Spec for CCMK


Formats: 0-3, 1C

Encryption Method 1 h 0 = CCM

MAC length 1 h MAC length in bytes (must be >= 4)


Max value = 16

Padding Mode 1 h 02 = None

SV Var h Starting Variable (nonce).


If not present (or empty), the function will generate and use
a random value.
Length of SV should be 11 bytes when randomly generated.

Data A Var h Can be a zero length field.


Additional authenticated data not to be encrypted (as
defined for AES-CCM)

Data D1 Var h Can be zero length field.


1st part of the data to encrypt, provided in clear text (if
present)

D2 Type 1 h 0 = No data
1 = Data

D2 Var h D2 should contain fields as defined in table below

D3 Var h Can be zero length field.


Clear data to be added after D2

Response Length Type Description

EE305D 3 h Function Code

rc 1 h Return Code

Ciphertext C Var h Data authenticated and encrypted

Starting Variable Var h Starting Variable

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 133
CHAPTER 4 Function Library

Data fields for D2 Type value

D2 Type Value = 1

Field Length Type Description

Key Type 1 h 00 = DPK


48 = CCMK

DPK/CCMK-Spec Var K-Spec Key Spec for the key type


Formats:
CCMK: 0-3, 1C
DPK: 0-3, 11, 12, 13, 14, 17, 18, 1C

Decryption Mode 1 h 0 = ECB


1 = CBC
2 = CTR

IV/SV Var h In case of ECB, this must be a zero length field.


In CBC this is IV
In CTR this is SV

Padding Mode Dec 1 h 0 = RFU


1 = Always
(See Padding Mode described in reference [83], [84],
[85] of Mark II)
2 = None

eDPK/CCMK(data) Var h Encrypted Data

Processing Steps
1. Extract CCMK.
2. If SV is not provided, generate a random 11 byte number.
3. Decrypt D2 using provided key details.
4. Concatenate D1, D2 and D3 as D = D1 || D2 || D3.
5. Pass D, SV, CCMK and A to Algorithm for CCM (Counter with CBC-MAC) for protecting data transmission
(reference [83], [84], [85] of Mark II) for processing.
6. Return Cipher text C and the initial SV sent to algorithm for processing.

Note: DES not supported in CTR decryption mode.

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 134
CHAPTER 4 Function Library

CHECK-AUTHENTICATION-CODE (EE3050)
This function is used to validate the Authentication Code involving encrypted data.

Request Length Type Description

EE3050 3 h Function Code

FM 1 h Function Modifier = 00

Decryption Mode 1 h = 00: ECB


= 01: CBC

IV Var h Initialization vector.


In case of ECB, this must be a zero length field.

N 1 h Length of Session ID in eDPK(Session_ID)

DPK Spec Var K-Spec Key to decrypt Session_ID under DPK


Formats: 0-3, 11, 12, 13, 14, 17, 18,1C
(In case of format 17, 18, valid values for DPK are:
Key Length - Double length, Triple length
Algorithm - T)

eDPK(Session_ID) Var h DPK Encrypted Session ID

D1 Var h Data Element 1

D2 Var h Data Element 2

Method 1 h Method used to derive authentication code


00 = SHA256

CMSMPA_AUTH Var h Authentication code to be validated

Response Length Type Description

EE3050 3 h Function Code

rc 1 h Return Code
00 = Success
08 = Validation failed

Processing Steps
1. Decrypt Session ID using DPK Spec, Decryption Mode, IV, eDPK (Session_ID)
2. After decryption, remove as many check for N and extract N leftmost bytes from decrypted data. This will be
Session_ID

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 135
CHAPTER 4 Function Library

3. Follow the steps as provided in Algorithm for Deriving the Authentication Code (reference [83], [84], [85] of Mark II)
by using D1, D2, Session_ID
4. Compare the authentication codes calculated and provided (=CMSMPA_AUTH).
5. If the supplied and calculated values are same, the return code will be 00, else 08.

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 136
CHAPTER 4 Function Library

CHECK-CLEAR-MOBILE-PIN (EE3058)
This function is used to verify the encrypted mobile PIN with clear mobile PIN.

Request Length Type Description

EE3058 3 h Function Code

FM 1 h Function Modifier = 00

Mobile PIN Var h Clear Mobile PIN (Length 4-8 digits)

Reference Mobile PIN Var h Structure for Encrypted Mobile PIN


Details Encrypted Mobile PIN Details

Response Length Type Description

EE3058 3 h Function Code

rc 1 h Return Code

Encrypted Mobile PIN Details

Encrypted Mobile PIN Details

Field Length Type Description

MPPK –spec Var K-spec Key specifier to denote the MPPK to be used to
decrypt Mobile PIN
Formats: 0-3, 11, 13, 17, 18, 1C

eMPPK(Mobile Var h Encrypted Mobile PIN


PIN)

Decryption Mode 1 h 00 = ECB


01 = CBC

IV Var h If the encryption method is CBC, use IV.


In case of ECB this must be a zero length field.

Padding Mode 1 h 0 = Conditional


1 = Always
(See Padding Mode described in reference [83], [84],
[85] of Mark II

PF 1 h = 00. PIN block format (ISO-3)

ANB 6 h Account number

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 137
CHAPTER 4 Function Library

Processing Steps
1. Check Mobile PIN value for length >=4 and <=8. Any length outside the range is error condition.
2. Decrypt the encrypted Mobile PIN
a. Decrypt MPPKref
b. Decrypt eMPPKref (Mobile PIN) or referenced mobile PIN using Encryption Mode ref, Ivref and
PaddingModeRef and get decrypted PIN block
c. Using ANB, derive Mobile PIN
d. Proceed to step 3
3. Compare the PIN from step 1 and step 2. If the two are same, return success, else return standard PIN errors.

Note: For preparing/comprehending PIN Block format 3, refer to EE0602.

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 138
CHAPTER 4 Function Library

CHECK-ENCRYPTED-MOBILE-PIN (EE3059)
This function is used to verify the provided mobile PIN against the reference mobile PIN.

Request Length Type Description

EE3059 3 h Function Code

FM 1 h Function Modifier = 00

Incoming Mobile PIN Var h Structure for Encrypted Mobile PIN (Incoming)
Details Encrypted Mobile PIN Details

Reference Mobile PIN Var h Structure for Encrypted Mobile PIN (Reference)
Details Encrypted Mobile PIN Details

Response Length Type Description

EE3059 3 h Function Code

rc 1 h Return Code

Encrypted Mobile PIN Details

Encrypted Mobile PIN Details

Field Length Type Description

MPPK –spec Var K-spec Key specifier to denote the MPPK to be used to
decrypt Mobile PIN
Formats: 0-3, 11, 13, 17, 18, 1C

eMPPK(Mobile Var h Encrypted Mobile PIN


PIN)

Decryption Mode 1 h 00 = ECB


01 = CBC

IV Var h If the encryption method is CBC, use IV.


In case of ECB this must be a zero length field.

Padding Mode 1 h 0 = Conditional


1 = Always
(See Padding Mode described in reference [83], [84],
[85] of Mark II.

PF 1 h = 00. PIN block format (ISO-3)

ANB 6 h Account number

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 139
CHAPTER 4 Function Library

Processing Steps
1. Compare for ANB.
ANB in Incoming Mobile PIN details should match ANB in Reference Mobile PIN details.
2. Decrypt the Incoming Mobile PIN
a. Decrypt MPPKImp
b. Decrypt mobile PIN block using Decryption Mode Imp, IVImp (if needed) and PaddingModeImp
c. Using ANB, derive mobile PIN
d. Proceed to step 2
3. Decrypt the Reference Mobile PIN
a. Decrypt MPPKref
b. Decrypt eMPPKref (Mobile PIN) or referenced mobile PIN using Encryption Mode ref, Ivref and
PaddingModeRef and get decrypted PIN block
c. Using ANB, derive mobile PIN
d. Proceed to step 3
4. Compare the PIN from step 1 (derived if encrypted, else clear) and from step 2. If the two are same, success is
retured, else standard PIN errors.

Note: For preparing/comprehending PIN Block format 3, refer to EE0602

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 140
CHAPTER 4 Function Library

CHESS-KEK-RECEIVE-6.3 (D002)
This function translates the encryption key of the *KEK from the Key Transport Key (*KTK) to variants of a Domain
Master Key (*KM) for host storage on the CKDS.

Request Length Type Description

D002 2 h Function Code

Msg ID 2 x Message Identifier

KTK Index 1 h Index of Key Transport Key

e*KTKv7(*KEKr) 16 x Enciphered KEK receive key

e*KTKv8(*KEKs) 16 x Enciphered KEK send key

Response Length Type Description

D002 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 h Return Code

e*KMv7(*KEKs) 17 D-Key Re-enciphered KEK send key

e*KMv8(*KEKr) 17 D-Key Re-enciphered KEK receive key

KVC(*KEKs) 3 x KVC of KEK send key

KVC(*KEKr) 3 x KVC of KEK receive key

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 141
CHAPTER 4 Function Library

CLEAR-PIN-ENCRYPT (EE0600)
This function accepts a clear PIN, formats it into an ANSI PIN Block and encrypts the PIN Block using the supplied
PPK.

Request Length Type Description

EE0600 3 h Function Code

FM 1 h Function Modifier

PIN-Len 1 h Number of digits in PIN field

PIN Var d Clear PIN

ANB 6 d Account Number Block

PPK-Spec Var K-Spec Key specifier for PPK


(Formats: 0 - 3, 10, 11, 13, 12, 14, 17, 18, 20, 90)

Response Length Type Description

EE0600 3 h Function Code

rc 1 h Return Code

ePPK(PIN) 8 h Encrypted output PIN

FM = 00. Must be set to zero.

PIN-Len Identifies the number of digits in the PIN, in the range 4 – 12.

PIN Clear PIN consisting of from 4 to 12 digits, packed 2 digits per byte. If PIN-len is odd, the digits must
be left justified in the PIN field with one trailing decimal pad digit.

PPK-Spec Key specifier for the PPK (eKMv1 - Format 0-3, 10, 11, 12, 13, 14, 17, 18, 20 or 90).

ANB 12 PAN digits of the Account Number Block used to format the ANSI PIN Block.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 142
CHAPTER 4 Function Library

CONSTRUCT-TOKEN-B1 (C850)
This function generates a random KTK, enciphers it with an ATM’s public encipherment key, and builds a key token B1
signed by the host’s private signature key. This function required to support Remote Key transport on Diebold ATMs.

Request Length Type Description

C850 2 h Function Code

Msg ID 2 x Message Identifier

IHOST Var x Host Identifier

IATM Var x ATM Identifier

rATM Var x Random number sent by ATM in token A1

KMVAC(EATM) Var K-spec ATM public encipherment key (format 42)

KMVA0(SHOST) Var K-spec host private signature key (format 42)

Response Length Type Description

C850 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

KTB1 Var x ASN.1 Key token B1 to be sent to ATM

rHOST Var x ASN.1 Random number put in token B1

eKMvAA(A) Var K-spec ASN.1 Random A-Key put in token B1 (format 21)

This host function is used for Australian Major Bank (AMB).


This function has been amended in line with the APCA Errata dated 9 July, 2009, in which the response field eKMV82
(KTKs) was changed to eKMVAA(KTKs). However, as variant AA protects an ATM Master Key (A), the function
definition above describes the amended response field as eKMVAA(A) consistent with the functions with which the
encrypted key will be used.
DEA2 keys must have a 256 byte modulus length and a public key exponent value of 0x10001.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 143
CHAPTER 4 Function Library

CREATE-ADDI-ICC-CERTIFICATE (EE0013)
Request Length Type Description

EE0013 3 h Function Code

FM 1 h Function Modifier

SI Var K-Spec Key Specifier for Issuer Private Key.


Key Type = Certificate, Data Signature
(Formats: 0-3, 82)

PI Var K-Spec Key Specifier for Issuer Public Key.


Key Type = Certificate, Data Signature
(Formats: 0-3, 81)

ICC Public Key Certificate Var h Output from EE2048 or EE2058.


Digital signature for the public key certificate. The field
length is equal to the length NI of the modulus of SI

ICC Public Key Var h A variable-length data element. This field is only present if
Remainder NIC > N – 42 and consists of the NIC – NI + 42 least
significant bytes of the ICC Public Key.

ICC Public Key Exponent Var h A variable-length data element provided by the issuer. ICC
Public Key Exponent equal to 3 or 216 + 1.

Static Data to be Var h Static data to be authenticated as specified in Part II of


Authenticated Book 3 of these specifications.

Response Length Type Description

EE0013 3 h Function Code

rc 1 h Return Code

Additional ICC Public Key Var h Digital signature for the public key certificate. The field
Certificate length is equal to the length NI of the modulus of SI

This function creates an ICC certificate with different SDA data than the certificate previously created by function
EE2048 or EE2058.
The function extracts the data from original certificate, adds data provided in the request message and creates the
additional certificate incorporating the new SDA data.

Processing Steps
1. Extract the required certificate data fields from ICC Public Key Certificate (i.e. fields up to and including ‘ICC
Public Key or Leftmost Digits of the ICC Public Key’.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 144
CHAPTER 4 Function Library

2. Append ICC Public Key Remainder, ICC Public Key Exponent and Static Data to be Authenticated to form
the certificate data (MSG).
3. Calculate the hash value (h) of resulting certificate data.
4. Concatenate a header byte (B), the left part of certificate data (MSG1), the hash result (h) and the trailer byte (E) to
form X = B || MSG1 || h || E.
5. Sign X using the Issuer Private Key provided in SI to give Additional ICC Public Key Certificate.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 145
CHAPTER 4 Function Library

CREATE-CSCK (A9)
Request Length Type Description

A9 1 h Function code

CSCK-Storage Indicator 1 h This field specifies whether the key is to be stored in the
host database or in HSM secure memory. Currently only the
value 0 is supported which means storage on the host.

*KBS Var h Key Block structure. Optional and present only if CSCK
needed in TR-31 Key Block Form for host- storage.

Response Length Type Description

A9 1 h Function code

rc 1 h Return code

CSCK-Spec Var K-Spec Key specifier for CSCK


(Format: 11, 13, 17, 18)

KVC 3 h Key verification code of CSCK

This function causes a random *CSCK to be generated and returned to the host encrypted under the *KM variant 6.
*KBS : KBS must be present if global settings require key in TR-31 key block.

Notes
– The key specifier 11 under the Response, are generated when using the Legacy option.
– The key specifiers 11, 13 under the Response, are generated based on the chosen operation on console and
FM.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 146
CHAPTER 4 Function Library

CREATE-CSR (EE9204)
Request Length Type Description

EE9204 3 h Function Code

FM 1 h Function Modifier

PK Var K-Spec Key specifier containing the public key.


(Formats 0-3, 80, 81)

SK Var K-Spec Key specifier containing the private key.


(Format: 0-3, 82
Key Type: Data Signature)

CSR Struct PU CSR input parameters

Hash Function 1 h 01: SHA-256

Signature Algo 1 h 01: RSA

Padding Mode 1 h 01: PKCS#1 v1.5 method

Response Length Type Description

EE9204 3 h Function Code

rc 1 h Return Code

Certificate Request Var h PKCS#10 CSR

CSR Input Parameters


Field Length Type Description

Common Name Var h Name of the certificate

Country Var h Country Name

State Var h State Name

Locality Var h Locality Name

Organization Var h Organization Name

OrganizationUnitName Var h Organization Unit Name

Email Var h Email Id

This function performs the following steps:

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 147
CHAPTER 4 Function Library

1. Creates a RSA key pair using PK/SK.


2. Creates a CSR using CSR input parameters.
3. Embeds the Public Key (PK) in CSR.
4. Signs the CSR using Private Key (SK) [ Digest: SHA-256 and Padding: PKCS#1 v1.5].
5. Appends the resulting signature (in ASN.1 format) to the rest of the CSR.
6. Converts the whole CSR back to PEM format and return in response.
NOTES:
• Country Name must only be two characters.
• Maximum length of fields is as in the table below:

Field Name Max Length Supported

Common Name 64

State 128

Locality 128

Organization Name 64

Organization Unit Name 64

Email Id 128

• Common Name is the only mandatory field in CSR PU. Rest all other fields are optional.
• Digest used while creating the certificate is SHA256. No other value is supported.
• While using HSM stored keys, index of Public Key (PK) should be same as index of Private Key (SK).
• The final CSR generated by the function should be verifiable by openssl req command.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 148
CHAPTER 4 Function Library

CREATE-X509-CERTIFICATE (EE9202)
Request Length Type Description

EE9202 3 h Function Code

FM 1 h Function Modifier

Output Certificate Format 1 h New certificate format


00 = DER encoded
01-255 = RFU

Public Key Exponent Var h =3 or 216 + 1

Key Type 2 h Indicates the valid usage for the private key

bit key type

2 Key Transport

Bit 0 is the least significant (rightmost) bit.

User Data Var h Data to be stored in key specifier of Private Key (May be
zero length field)

Certificate Request Struct PU X509 certificate input parameters

Response Length Type Description

EE9202 3 h Function Code

rc 1 h Return Code

Private Key Var K-Spec Key Specifier containing the private key (SK) encrypted by
a KM variant.
(Format: 82)

Certificate File Var h Content of DER encoded X.509 RSA certificate

This function returns a new DER encoded X.509 certificate along with RSA’s private key.

Certificate Request field format


Field Length Type Description

Version 1 h Version Number (01, 02)

Common Name Var h Name of the certificate

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 149
CHAPTER 4 Function Library

Field Length Type Description

Key Length 2 h Key Length ( 1024 or 2048)


In network byte order (big endian)

Validity Period 2 d Validity Period in number of days


(Range 1-3650 days)
In network byte order (big endian)

Serial Number Var h Certificate Serial Number

Country Var h Country Name

State Var h State Name

Locality Var h Locality Name

Organization Var h Organization Name

OrganizationUnitName Var h Organization Unit Name

Email Var h Email Id

NOTES:
• Country Name must only be two characters.
• Maximum length of fields is as in the table below:

Field Name Max Length Supported

Common Name 64

State 128

Locality 128

Organization Name 64

Organization Unit Name 64

Email Id 128

Serial Number 20

• Version Number, Common Name, Key length and Validity Period are the only mandatory fields in Certificate
Request PU. Rest all other fields are optional.
• Key Length’s allowed values are 1024 and 2048.
• Validity Period should be less than 3650 days. Also, if Current Date + Validity period (days) crosses 19-01-2038:
Error Code 0x04 FN_INVALID_FIELD_CONTENT is returned.
• Digest used while creating the certificate is SHA1.
• Key Type and User Data would be returned within Format 82 of Private Key.
• Key Type can only be “Key Transport”. No other value is supported.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 150
CHAPTER 4 Function Library

• Version Number 01 will not support Serial Number as input in Certificate Request, whereas Version Number 02 will
support Serial Number as input in Certificate Request. The version number field in the function specification does
not refer to X.509 certificate version.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 151
CHAPTER 4 Function Library

CVC3-GENERATE (EE0010)
Request Length Type Description

EE0010 3 h Function Code

FM 1 h Function Modifier

IMKCVC Var K-Spec Issuer Master Key


(Formats: 0 - 3, 11, 13, 17,18)

PAN Data Var h PAN || PAN Sequence No.

IV Mode 1 h = 0: IV Data contains 2-byte IVCVC3.


= 1: IV Data contains Track 1 or 2 data.

IV Data Var x IVCVC


or
Static part of Track 1 or 2 data used to calculate IVCVC3.

UN 4 x Unpredictable Number

ATC 2 x Application Transaction Counter

Response Length Type Description

EE0010 3 h Function Code

rc 1 h Return Code

CVC3 2 h Card Verification Code

This function generates a CVC3 using the method specified in reference [41] of Mark II.

Processing Steps
1. Derive KDCVC3 using IMKCVC and PAN Data.
2. If IV Mode = 0, IVCVC3 = IV Data
If IV Mode = 1, calculate IVCVC3 using KDCVC3 and IV Data.
3. Calculate CVC3 using KDCVC3, IVCVC3, UN and ATC.
4. Return the calculated CVC3 in the response.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 152
CHAPTER 4 Function Library

CVC3-VERIFY (EE0011)
Request Length Type Description

EE0011 3 h Function Code

FM 1 h Function Modifier

IMKCVC Var K-Spec Issuer Master Key


(Formats: 0 - 3, 11, 13, 17, 18)

PAN Data Var h PAN || PAN Sequence No.

IV Mode 1 h = 0: IV Data contains 2-byte IVCVC3.


= 1: IV Data contains Track 1 or 2 data.

IV Data Var x IVCVC


or
Static part of Track 1 or 2 data used to calculate IVCVC3.

UN 4 x Unpredictable Number

ATC 2 x Application Transaction Counter

CVC3 2 h Card Verification Code

Response Length Type Description

EE0011 3 h Function Code

rc 1 h Return Code

This function generates a CVC3 and compares it with the value of the transaction CVC3 provided in the request.

Processing Steps
1. Calculate CVC3 identically to processing steps 1 – 3 in function CVC3-GENERATE (EE0010)
2. Compare the calculated value of CVC3 with CVC3 in the request.
Return the result of the comparison in the response. A Return Code of 00 indicates CVC3 verification, and a Return
Code of 08 indicates verification failure.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 153
CHAPTER 4 Function Library

CVV-GENERATE (EE0802)
Request Length Type Description

EE0802 3 h Function Code

FM 1 h Function Modifier (FM=00)

CVK-Spec Var K-Spec Card Verification Key specification


(Formats: 0-3, 11, 13, 17, 18)

CVV-Data 16 h Card Verification Value Data

Response Length Type Description

EE0802 3 h Function Code

rc 1 h Return Code

CVV 2 h Card Verification Value

This function generates a Card Verification Value (CVV) by the Visa method for card data (CVV-data).

FM = 00. Must be set to zero.

CVK-Spec A key specifier which incorporates an index to a HSM-stored double length or key pair CVV or a host-
stored double-length CVV.

CVV-Data The data from which the CVV is generated. It is up to the host to format the field correctly and to do
any required range checking on the data. This field is normally populated in packed BCD format.
The data to be formed is dependent on which scheme you are following and is governed by respective
standard. For instance, the values used by Visa for the Card Verification Value (CVV) are PAN, Expiry
Date, and Service Code. See Reference A [91] for details on CVV calculation (as per Visa).

CVV The three digit Card Verification Value. The three digits are left aligned and right padded with the
hexadecimal digit "F".

Note: This function is equivalent to function CVV-GEN (9B) but incorporates a key specifier to
access the CVK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 154
CHAPTER 4 Function Library

CVV-VERIFY (EE0803)
Request Length Type Description

EE0803 3 h Function Code

FM 1 h Function Modifier (FM=00)

CVK-Spec Var K-Spec Card Verification Key Index


(Formats: 0-3, 11, 13, 17, 18)

CVV-Data 16 h Card Verification Value Data

CVV 2 h Card Verification Value

Response Length Type Description

EE0803 3 h Function Code

rc 1 h Return Code

This function verifies card data (CVV-data) deriving a CVV for that data and validating it against the CVV in the request.

FM = 00. Must be set to zero.

CVK-Spec A key specifier which incorporates an index to a HSM-stored double length or key pair CVV or a
host-stored double-length CVV.

CVV-Data The data from which the CVV is generated. It is up to the host to format the field correctly and to do
any required range checking on the data. This field is normally populated in packed BCD format.
The data to be formed is dependent on which scheme you are following and is governed by
respective standard. For instance, the values used by Visa for the Card Verification Value (CVV) are
PAN, Expiry Date, and Service Code. See Reference A [91] for details on CVV calculation (as per
Visa).

CVV The digit byte Card Verification Value. The three digits are left aligned and right padded with the
hexadecimal digit "F".

A Return Code of 00 indicates CVV verification, and a Return Code of 08 indicates verification failure.

Note: This function is equivalent to function CVV-VER (9C) but incorporates a key specifier to
access the CVK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 155
CHAPTER 4 Function Library

D51-PPK-GEN (47)
Request Length Type Description

47 1 h Function Code

n 1 d KTM Index

Response Length Type Description

47 1 h Function Code

rc 1 h Return Code

eKTMn(PPK) 8 B64 PIN Protect Key

eKMv1(PPK) 8 B64 PIN Protect Key

ePPK(VCon) 8 B64 Verification Constant

This function generates a random PIN Protect Key (PPK) and associated encrypted verification constant for a Docutel
5100 ATM.
For transmitting to the ATM, the generated key is returned encrypted by the Terminal Master Key (KTMn) indicated by
the specified index (KTM-index).
For host storage and subsequent use with the PIN Management Functions, the generated key is returned encrypted
under the KM Variant 1.
The verification constant (VCon) of X'0123456789ABCDEF' is encrypted by the generated key and the result is
returned for transmission to the ATM.

Note: This function only supports use of the first 99 KTMs.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 156
CHAPTER 4 Function Library

dCVV-GENERATE (EE0014)
Request Length Type Description

EE0014 3 h Function Code

FM 1 h Function Modifier

IMKCVC-Spec Var K-spec Key specifier for IMKCVC


(Formats 0–3, 11, 13, 17, 18)

PAN Data Var h PAN || PAN Sequence No

CVV Data 16 h

Response Length Type Description

EE0014 3 h Function Code

rc 1 h Return Code

CVV 2 h Card Verification Value

This function generates a CVV for the virtual mag stripe data (CVV Data).

FM Function Modifier. Must be set to zero.

IMKCVC-spec A key specifier which incorporates an index to a HSM-stored double length key or a host-stored
double-length key.

PAN Data PAN || PAN Sequence No.


Length in range 6 -16 bytes, representing 12 -32 digits.

CVV Data The data from which the CVV is generated. It is up to the host to format the field correctly and to do
any required range checking on the data. This field is normally populated in packed BCD format.
The data to be formed is dependent on which scheme you are following and is governed by
respective standard. For instance, the values used by Visa for the Card Verification Value (CVV) are
PAN, Expiry Date, and Service Code. See Reference A [91] for details on CVV calculation (as per
Visa).

CVV The three-digit Card Verification Value. The three digits of packed BCD are left- aligned and right-
padded with the hexadecimal digit ‘F’.

Note: IMKcvc key will be used as MDK(Master Derivation Key).

Processing Steps
1. Recover IMK using IMK-spec.
2. Derive MK (UDK) using IMK and PAN Data. (The algorithm is identical to MK Method = 00 in function EE2018.)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 157
CHAPTER 4 Function Library

– Prepare PAN Data:

Length Processing

<16 digits Left-padded with zeros.

=16 digits Used as is.

>16 digits Hashed and decimalized.

– Derive MK:
MK1 = DES3(IMKCVC)[PAN Data]
MK2= DES3(IMKCVC)[PAN Data XOR (‘FF’||‘FF’||‘FF’||‘FF’||‘FF’||‘FF’||‘FF’||‘FF’)]
MK= (MK1 || MK2)
3. Calculate CVV using MK and CVV Data. (The method is identical to that in function EE0802.)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 158
CHAPTER 4 Function Library

dCVV-VERIFY (EE0015)
Request Length Type Description

EE0015 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMKCVC-spec Var K-spec Key specifier for IMKCVC


(Formats 0–3, 11, 13, 17, 18)

PAN Data Var h PAN || PAN Sequence No.

CVV Data 16 h

CVV 2 h Card Verification Value

Response Length Type Description

EE0015 3 h Function Code

rc 1 h Return Code

This function verifies the virtual mag stripe data (CVV Data), calculating a CVV for that data and comparing it with the
CVV in the request.

FM Function Modifier. Must be set to zero.

IMKCVC-spec A key specifier which incorporates an index to a HSM-stored double length key or a host-stored
double-length key.

PAN Data PAN || PAN Sequence No.


Length in range 6 -16 bytes, representing 12 -32 digits.

CVV Data The data from which the CVV is generated. It is up to the host to format the field correctly and to do
any required range checking on the data. This field is normally populated in packed BCD format.
The data to be formed is dependent on which scheme you are following and is governed by
respective standard. For instance, the values used by Visa for the Card Verification Value (CVV) are
PAN, Expiry Date, and Service Code. See Reference A [91] for details on CVV calculation (as per
Visa).

CVV The three-digit Card Verification Value. The three digits of packed BCD are left- aligned and right-
padded with the hexadecimal digit ‘F’.

Note: IMKcvc key will be used as MDK (Master Derivation Key).

Processing Steps
1. Recover IMKCVC using IMKCVC-spec.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 159
CHAPTER 4 Function Library

2. Derive MK (UDK) using IMKCVC and PAN Data. (The algorithm is same as Function EE0014)
3. Calculate CVV1 using MK and CVV Data. (CVV1 is calculated using the method specified in reference [42] of
Mark II ).
4. Compare CVV1 with CVV and return result. A Return Code of 00 indicates CVV verification, and a Return Code of
08 indicates verification failure.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 160
CHAPTER 4 Function Library

DECIPHER-2 (EE0801)
Request Length Type Description

EE0801 3 h Function Code

FM 1 h Function Modifier

DPK-Spec Var K-Spec Key specifier for DPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 20, 50, 51)

CM 1 h Cipher Mode
00 = ECB
01 = CBC

ICV 8 h Input Chaining Value

eDPK(Data) Var h Ciphertext

Response Length Type Description

EE0801 3 h Function Code

rc 1 h Return Code

OCV 8 h Output Chaining Value

Data Var h Deciphered data

This function deciphers the supplied data using a host-stored session key (DPK) supplied within a key specifier.
The function performs single-DES or triple-DES decipherment, as determined by the length of the supplied key, and
supports both Electronic Code Book (ECB) and Cipher Block Chaining (CBC) modes of operation. The function
supports decipherment of large messages (or data files) either by one call to the function or by multiple calls. For CBC
decipherment using multiple calls, chaining values must be maintained between calls.

DPK-Spec Key specifier incorporating a single or double or triple length host-stored or HSM-stored DPK.

CM Specifies the mode of operation for the decipherment:


0 - Electronic Code Book (ECB)
1 - Cipher Block Chaining (CBC)

ICV Chaining value for CBC decipherment. For decipherment of a message or file using one call, or on the
first call of a multi-call decipherment, this field should be set to the required value of the Initialization
Vector (IV). On subsequent calls of a multi-call decipherment, the field should be set to the value of
the OCB provided by the previous call.
For ECB decipherment, this field will be ignored.

eDPK(Data) Ciphertext to be deciphered. Must be a multiple of 8 bytes long.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 161
CHAPTER 4 Function Library

OCV Chaining value for CBC decipherment. For decipherment of a message or file using a multi-call
decipherment, the value in this field should be used as the ICV in the next call.
For ECB decipherment, this field will be set to zero.

Data Deciphered plaintext data.

Note:
- This function supercedes functions 81, 83.
- When the function modifier is missing, the function returns error code 24, missing function
code.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 162
CHAPTER 4 Function Library

DECIPHER-3 (EE0805)
Request Length Type Description

EE0805 3 h Function Code

FM 1 h Function Modifier (FM=00)

DPK-Spec Var K-Spec Key specifier for DPK


(Formats: 0-3, 10, 11, 12, 13, 14, 16, 17, 18)

CM 1 h Cipher Mode
00 = ECB
01 = CBC

ICV Var h Input Chaining Value

eDPK(Data) Var h Ciphertext

Response Length Type Description

EE0805 3 h Function Code

rc 1 h Return Code

OCV Var h Output Chaining Value

Data Var h Deciphered data

This function deciphers the supplied data using a session key (DPK) supplied within a key specifier.
The function performs DES or SEED decryption, as determined by the DPK key specifier and supports both Electronic
Code Book (ECB) and Cipher Block Chaining (CBC) modes of operation. The function supports decipherment of large
messages (or data files) either by one call to the function or by multiple calls. For CBC decipherment using multiple
calls, chaining values must be maintained between calls.

FM = 00. Must be set to zero.

DPK-Spec Key specifier incorporating a single-length or double-length or triple –length host-stored or HSM-stored
DPK. This field determines the encryption method.
DES – formats 00 – 03 (DES/TDES keys only), 10, 11, 12, 13, and 14, 17, and 18 .
SEED1 – formats 00 – 03 (SEED keys only) 16, 17 and 18.

CM Specifies the mode of operation for the decipherment:


0 - Electronic Code Book (ECB)
1 - Cipher Block Chaining (CBC)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 163
CHAPTER 4 Function Library

ICV Chaining value for CBC decipherment. For decipherment of a message or file using one call, or on the
first call of a multi-call decipherment, this field should be set to the required value of the Initialization
Vector (IV). On subsequent calls of a multi-call decipherment, the field should be set to the value of
the OCB provided by the previous call.
For ECB decipherment, the contents of this field will be ignored.
For DES processing this field must be 8 bytes in length while for SEED processing this field must be
16 bytes in length.

eDPK(Data) Ciphertext to be deciphered. For DES processing this field must be a multiple of 8 bytes long while for
SEED processing it must be a multiple of 16 bytes.

OCV Chaining value for CBC decipherment. For decipherment of a message or file using a multi-call
decipherment, the value in this field should be used as the ICV in the next call.
For ECB decipherment, the contents of this field will be set to zero.
For DES processing this field will be 8 bytes in length, while for SEED processing this field will be 16
bytes in length.

Data Deciphered plaintext data.

Note: When the function modifier is missing, the function returns error code 24, missing
function code.

1SEED: A national security standard of Korea (KICS Korean Information Communication Standard) since June 2002.
SEED Algorithm: A 128-bit block cipher that has been widely used in Korea for confidential services such as e-
commerce, e-mail, financial service, data storage, electronic toll collection, VPN and digital rights management.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 164
CHAPTER 4 Function Library

DECIPHER-4 (EE0807)
Request Length Type Description

EE0807 3 h Function Code

FM 1 h Function Modifier

DPK Var K-Spec Key specifier for DPK


(Formats: 20)

CM 1 h Cipher Mode
00 = ECB
01 = CBC

ICV 8 h Input Chaining Value

eDPK(Data) Var h Ciphertext

Response Length Type Description

EE0807 3 h Function Code

rc 1 h Return Code

OCV 8 h Output Chaining Value

Data Var h Deciphered Data

This function decrypts the encrypted magnetic-stripe data, encrypted using the Magtek DUKPT algorithm.
The function is similar to the function DECIPHER-2 (EE0801), however, it incorporates support only for DPK derived
using the DUKPT key specifier (format 20 only). The DPK is derived using the ANS X9.24-1 algorithm for deriving a
PIN encrypting key.

DPK Key specifier incorporating a single or double length host-stored or HSM-stored DPK.

CM Specifies the mode of operation for the decipherment:


0 - Electronic Code Book (ECB)
1 - Cipher Block Chaining (CBC)

ICV Chaining value for CBC decipherment. For decipherment of a message or file using one call, or on the
first call of a multi-call decipherment, this field should be set to the required value of the Initialization
Vector (IV). On subsequent calls of a multi-call decipherment, the field should be set to the value of
the OCB provided by the previous call.
For ECB decipherment, this field will be ignored.

eDPK(Data) Ciphertext to be deciphered. Must be a multiple of 8 bytes long.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 165
CHAPTER 4 Function Library

OCV Chaining value for CBC decipherment. For decipherment of a message or file using a multi-call
decipherment, the value in this field should be used as the ICV in the next call.
For ECB decipherment, this field will be set to zero.

Data Deciphered plaintext data.

Note:
- The function is disabled by default.
- The DPK is derived using the ANS X9.24-1 algorithm for deriving a PIN encrypting key.
- This function ignores the value assigned to the “Derived Key Type” field of the Format 20.
Though the function will accept the values as: 0x02 or 0x12, this value will be internally ignored
while deriving the PIN-encryption key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 166
CHAPTER 4 Function Library

DECIPHER-AES (EE0809)
Request Length Type Description

EE0809 3 h Function Code

FM 1 h Function Modifier

DPK Var K-spec Key specifier for DPK


(Formats: 52, 53, 1C)

CM 1 h Cipher Mode
00 = ECB
01 = CBC

ICV 16 h Input Chaining Value

eDPK(Data) Var h Ciphertext

Response Length Type Description

EE0809 3 h Function Code

rc 1 h Return Code

OCV 16 h Output Chaining Value

Data Var h Deciphered data

This function deciphers the supplied data using a host-stored session key (DPK) supplied within a key specifier. The
function performs AES decipherment and supports both Electronic Code Book (ECB) and Cipher Block Chaining (CBC)
modes of operation.
The function supports decipherment of large messages (or data files) either by one call to the function or by multiple
calls. For CBC decipherment using multiple calls, chaining values must be maintained between calls.

DPK-Spec Key specifier incorporating 128-bit or 192-bit or 256-bit AES host-stored key DPK.

CM Specifies the mode of operation for the decipherment:


00 = Electronic Code Book (ECB)
01 = Cipher Block Chaining (CBC)

ICV Chaining value for CBC decipherment. For decipherment of a message or file using one call, or on
the first call of a multi-call decipherment, this field should be set to the required value of the
Initialization Vector (IV). On subsequent calls of a multi-call decipherment, the field should be set to
the value of the OCB provided by the previous call. For ECB decipherment, this field will be ignored.

eDPK(Data) Cipher text to be deciphered. Must be a multiple of 8 bytes long.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 167
CHAPTER 4 Function Library

OCV Chaining value for CBC decipherment. For decipherment of a message or file using a multi-call
decipherment, the value in this field should be used as the ICV in the next call.
For ECB decipherment, this field will be set to zero.

Data Deciphered plaintext data.

Note: In EE0808 and EE0809, only AES encryption/decryption is allowed hence 52, 53 and 1C
format must contain AES keys only.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 168
CHAPTER 4 Function Library

DERIVE-CBP-SESSION-KEYS (EE3052)
This function is used to derive Session Keys and Restricted Use Keys for Contactless and Remote Payments on
cloud.

Request Length Type Description

EE3052 3 h Function Code

FM 1 h Function Modifier = 00

Card Key Type 1 h 00 = CMKCLMD


01 = CMKCLUMD
02 = CMKRPMD
03= CMKRPUMD

CMKxx-Spec Var K-Spec Key spec to derive CMK


Formats: 11, 13, 17, 18, 1C

KVC Method 1 h 01 = left 6 digits of eK(0)

Number of SK_SUK 1 h Number of SK or SK and SUK pair


The number of SK must not exceed 128.
The number of SUK must not exceed 64.

Session Key Method 1 h 00 = CSK (Common Session Key Derivation)


01 = VISA LUK Derivation

Session Key Data Var h Session key data for deriving Session Key (SK) (alias
Limited Use Key (LUK))

Encryption Mode for SK 1 h 00 = ECB


01 = CBC

IVSK Var h Initialization Vector


In case of ECB, this must be a zero length field.

KTK-spec Var K-Spec Key Specifier for Key Transport Key to encrypt SK
Formats: 0-3, 11, 12, 13, 14, 17, 18

Following fields must be present if Card Key Type = {01, 03}

SUK Derivation Method 1 h = 00


See algorithm for deriving single use keys, as described in
reference [83], [84], [85] of Mark II.

Derivation Data for SUK Var h Derivation data to be used to derive SUK from SK
Refer Encrypted Mobile PIN Details

Encryption Mode for SUK 1 h 00 = ECB


01 = CBC

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 169
CHAPTER 4 Function Library

IVSUK Var h Initialization Vector


In case of ECB, this must be a zero length field.

KTK-Spec Var K-Spec Key Specifier for Key Transport Key to encrypt SUK
Formats: 0-3, 11, 12, 13, 14, 17, 18

Response Length Type Description

EE3052 3 h Function Code

rc 1 h Return Code

Following fields to be present n times where n = number of SK_SUK

eKTK(SK) Var h Encrypted SK

KVC Var h KVC for SK

Following fields to be present only if Card Key Type = {01, 03}

eKTK(SUK) Var h Encrypted SUK

KVC Var h KVC for SUK

For SUK Derivation Method = 00, use the structure Encrypted Mobile PIN Details

Encrypted Mobile PIN Details

Encrypted Mobile PIN Details

Field Length Type Description

MPPK–spec Var K-spec Key specifier to denote the MPPK to be used to


decrypt Mobile PIN
Formats: 0-3, 11, 13, 17, 18, 1C

eMPPK(Mobile Var h Encrypted Mobile PIN


PIN)

Decryption Mode 1 h 00 = ECB


01 = CBC

IV Var h If the encryption method is CBC, use IV


In case of ECB, this must be a zero length field

Padding Mode 1 h 0 = Conditional


1 = Always
(See Padding Mode described in reference [83], [84],
[85] (MCBP) or [86], [87], [88] (VCBP) of Mark II)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 170
CHAPTER 4 Function Library

Encrypted Mobile PIN Details

Field Length Type Description

PF 1 h = 00
PIN block format (ISO-3)

ANB 6 h Account number

Processing Steps
1. Retrieve Card Master Key from CMKxx. Here, xx belongs to {CLMD, CLUMD, RPMD, RPUMD}.
2. Extract KTK for encrypting SK from KTK-spec.
3. If Card Key Type = {01, 03}, then extract KTK for SUK from KTK spec.
4. Repeat following steps for number of SK_SUK times and exit after that.
5. Derive the Session Key from specified Session Key Method using the Session Key data.
To derive SK, use 2 byte ATC from Session Key Data.
If Session Key Method = 01, derive SK (alias LUK) using CMKxx and LUK derivation data, reference [86], [87], [88]
of Mark II. Please note that the 8th nibble will be ignored.
6. Extract KVC as per KVC method.
7. Encrypt derived Session Key using KTK, Encryption Mode for SK and IVSK.
8. Append encrypted SK with KVC in response.
9. If Card Key Type = {01, 03}, then proceed to step 10 for SUK derivation, else step 15 for next iteration.
10. Decrypt Mobile PIN using encrypted Mobile PIN details.
11. Derive SUK using clear Mobile PIN and SK by following the processing steps as defined in reference [83], [84], [85]
of Mark II.
12. Extract KVC as per KVC method.
13. Encrypt derived SUK by KTK extracted from KTK spec, using Encryption Mode for SUK and IVSUK.
14. Append encrypted SUK with KVC in temporary response buffer for SUK.
15. Increment ATC by 1 and proceed for next iteration from step 2. In case of LUK, increment counter value by 1
(allowed values are 0-99).
16. Merge the response buffers for array of SKs with response buffer for array of SUKs and publish the response.

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 171
CHAPTER 4 Function Library

DERIVE-CLOUD-CMK (EE3051)
This function is used to derive Card Master Keys for contactless and remote payments on cloud.

Request Length Type Description

EE3051 3 h Function Code

FM 1 h Function Modifier = 00
Function modifier reserved for possible future use.

Card Key Type 1 h 00 = CMKCLMD


01 = CMKCLUMD
02 = CMKRPMD
03 = CMKRPUMD
04 = CMKCLIDN
This identifies which Card Master Key to derive and the
steps to be varied in algorithm processing for it.

IMKxx-Spec Var K-Spec Issuer Master Key


Formats: 0-3, 11, 13, 17, 18
xx = {CL, RP, IDN}
IMK keys as of now will only be supported for double length
DES keys.

Derivation Method 1 h 00 = MCBP method


01 = VCBP method

CMK Derivation Data Var h PAN with seq/mod seq number as the key to be derived
requires.
No specific check in HSM.

CMK Format 1 h Formats: 11, 13, 17, 18, 1C

Key Details Var h Key details to encrypt

KVC Method 1 h 01 = left 6 digits of eK(0)

Key Type 1 h 00 = Encryption under key type not required


35 = KTK

Following field to be present if key type other than 00

Encryption Mode 1 h 00 = ECB


01 = CBC
12 = TR-31 Key Block

IV Var h Initialization Vector


For ECB and TR-31, this field must be zero length.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 172
CHAPTER 4 Function Library

Key-Spec Var h Key spec for input key specified in key type field above to
encrypt CMKxx
xx in CMKxx refers to Card Key Type (CLMD, CLUMD,
RPMD, RPUMD, CLIDN)
Formats: 0-3, 11, 12, 13, 14, 17, 18

Following fields must be present if Encryption Method = 12, i.e., outgoing key ekeytype (MK) needed in TR-31 key
block format and key type other than 00.

KBS Var h Key block structure to define TR-31 package of eKTK


(CMKxx)

Response Length Type Description

EE3051 3 h Function Code

rc 1 h Return Code

KVC Var h Key Verification Code (of clear CMK)

eKMvx(CMK) Var K-Spec Encrypted CMK (with KMvx)


Formats: 11, 13, 17, 18, 1C

Following field to be present if keytype is not 0

eKeyType(CMK) Var h Encrypted CMK

Key Details

Format 1C
Key detail field contains following details pertaining to 1C key format.

KM-index 1 h Index of KM

Key Type 1 d Variant id.

Algorithm 1 h Algorithm

Key length 1 h Key length

Padding 1 h Padding to be used in generated key

Mode of operation 1 h Mode of Operation

Format 10-14
In case of format 10-14, key details contain key type of derived key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 173
CHAPTER 4 Function Library

Format 17-18
Key detail field contains following details pertaining to 17 and 18 key format.

KM-index 1 h Index of KM
= 00

Key Type 1 d Variant id.

Key length 1 h Key length


01 = Single Length
02 = Double Length
03 = Triple Length

KBS Var h Key Block structure. Optional.


Must be provided when key in
response is needed in key block
format.

Where KBS is Key Block Structure, as mentioned below.

Key Block Structure

Field Length Type Description

KBS identifier 1 h = 0x00


Format

Key Block Version 1 h Must be ‘B’


ID

Key Usage 2 h Any allowed value for the key to be generated

Algorithms 1 h Any allowed value

Mode of use 1 h Any allowed mode of use for key usage

Key Version No. 2 h Any allowed value

Exportability 1 h Any allowed value

Padding Indicator 1 h 00 = Do not pad


03 = Pad to triple length

Number of optional 1 h 0x00-0x03 (Decimal 00 to 03 Max)


fields

Optional field 0 … n Var h Number of optional field as defined in above filed.


First byte of optional field will be treated as Optional
Block ID.

Processing Steps
1. Extract IMKxx from IMKxx-Spec depending upon card key type field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 174
CHAPTER 4 Function Library

– If Card Key Type = {00,01}, extract IMKCL


– If Card Key Type = {02,03}, extract IMKRP
– If Card Key Type = {04}, extract IMKIDN
2. Calculate the ICC Card Master Key (CMKxx) using the Issuer Master Key extracted in step 1, CMK derivation data
and Card Key Type as per the MCBP derivation method specified in reference [83], [84], [85] of Mark II.
For VCBP derivation method, reference [86], [87], [88] of Mark II.
Card key type implies which CMKxx is to be derived.
3. Calculate the KVC for CMKxx and return in KVC (CMKxx) and publish it as KVC output parameter.
4. Generate eKMvx (CMK).
vx to be replaced by CMKxx placeholders.
Format for publishing this is specified in CMK format. See Key details pertaining to a specified format (the required
data for packaging in specified format using key details field)
5. If Key type is 35, calculate eKTK(CMKxx) using Encryption Mode, IV and KBS (if KTK encrypted key to be
published in TR-31)

Note:
- xx in CMKxx refers to Card Key Type - CLMD, CLUMD, RPMD, RPUMD, CLIDN
- xx in IMKxx refers to CL, RP, IDN

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 175
CHAPTER 4 Function Library

DERIVE-CVC3-KD-IV (EE0012)
Request Length Type Description

EE0012 3 H Function Code

FM 1 H Function Modifier

IMKCVC Var K-Spec Key Specifier for Issuer Master Key.


(Formats: 0-3, 11, 13)

PAN Data 8 H Formatted PAN and PAN Sequence No.

KTK-Spec Var K-Spec Key Specifier for Key Transport Key.


(Formats: 0-3,11,12,13,14, 17, and 18)

Encryption Method 1 H 00 = ECB


01 = CBC
02 = TR-31 Key Block format

KVC method 1 H 01 = left 6 digits of eK(0)

IV Data 1 Var H Static part of Track 1 data used to calculate


IVCVC3TRACK1
(Or zero-length field.)

IV Data 2 Var h Static part of Track 2 data used to calculate IVCVC3


TRACK2
(Or zero-length field.)

Following fields must be present if Encryption Method =02 i.e. Outgoing Key needed in TR-31Key block format.

Key Usage 2 h Valid value ‘D0’,’C0’

Algorithms 1 h ‘T’ X’54.

Mode of use 1 h Valid value ‘E’,’D’,’B’,‘N’

Key version number 2 h Key version number.

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte.

Key Block Version / 1 h xy, where


Padding Indicator x = Key block version
y = Padding indicator
x = 0 (TR-31 Key block Version A)
1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)
Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 176
CHAPTER 4 Function Library

Request Length Type Description

Number of optional fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Optional field 1 … n Var h

Response Length Type Description

EE0012 3 h Function Code

rc 1 h Return Code

eKTK(KDCVC3) or 16 h Encrypted ICC Derived Key for CVC3 Generation.


eKKEK(KDCVC3) Or Or
Or Var Encrypted ICC Derived Key in TR-31 Key Block format.
eKTK(KB) or
eKKEK(KB)

Kvc(KDCVC3) Var h Key Verification Code

IVCVC3TRACK1 2 h

IVCVC3TRACK2 2 h

This function derives a unique-per-card, 16-byte, ICC CVC3 Data Key, DKCVC3. Optionally, it also calculates the 2-
byte IVCVC3 for Track 1 and Track 2.
The following table shows valid values of key usage, algorithms and mode of use.

Key Usage Algorithms Mode of Use

‘D0’,’C0’ ‘T’ ‘E’,’D’,’B’,’N’

Processing Steps
1. Derive KDCVC3 using IMKCVC and PAN Data.
2. Encrypt KDCVC3 using KTK or derived KKEK
3. Calculate kvc(KDCVC3).
4. If len(IV Data 1) > 0
calculate IVCVC3TRACK1
5. If len(IV Data 2) > 0
calculate IVCVC3TRACK2

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 177
CHAPTER 4 Function Library

DERIVE-ICC-MASTER-KEY (EE204A)
Request Length Type Description

EE204A 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMK-Spec Var K-Spec Key Specifier for Issuer Master Key.


(Formats: 0-3, 11, 13, 17,18)

IMK Type 1 h 01 = AC
02 = SMI
03 = SMC
04 = IDN

PAN Data 8 h Formatted PAN and PAN Sequence No.

KTK-Spec Var K-Spec Key Specifier for Key Transport Key.


(Formats: 0-3, 11, 12, 13, 14, 17, 18, 50, 51)

Encryption Method 1 h 00 = ECB


01 = CBC
11 = Pad+CBC
12 = TR-31 Key Block

KVC method 1 h 01 = left 6 digits of eK(0)

Following fields must be present if Encryption Method = 12 i.e. Outgoing Key


eKTK(MK) or eKKEK(MK) needed in TR-31Key block format.

Key version number 2 h Key Version Number

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte.

Key Block Version / 1 h xy, where


Padding Indicator x = Key block version
y = Padding indicator
x = 0 (TR-31 Key block Version A
1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)
Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Number of optional fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Optional field 1…n Var h

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 178
CHAPTER 4 Function Library

Response Length Type Description

EE204A 3 h Function Code

rc 1 h Return Code

eKTK(MK) or 16/24 h Encrypted ICC Master Key


eKKEK(MK) Or Or
Or Var Encrypted ICC Master Key in TR-31 key
eKTK(KB) or Block format.
eKKEK (KB)

kvc(MK) Var h Key Verification Code

This function derives a unique-per-card, 16-byte, ICC Master Key. Depending on the type of IMK referenced, the
derived key may be one of the following: MKAC, MKSMI, MKSMC or MKIDN.
Although the derivation method provided in the EMV2000 specification [5] is not mandated, the payment system
specifications all incorporate that same method. Therefore, this function is appropriate for Europay, MasterCard or Visa
implementations.

Function Modifier Reserved for possible future use; must be set to zero.

IMK-Spec Key specifier for the Issuer Master Key (Formats 0 – 3, 11. 13, 17, 18). The Key specifier
describes the location of the key to be loaded from the ESM.

IMK Type 1 byte flag to represent the Issuer Master Key sub-type.

PAN Data PAN data, used to derive MK, which is then used with KTK to produce eKTK(MK).

KTK-Spec Key specifier for the Key Transport Key (KTK) (Formats 0 - 3, 11, 12, 13, 14, 17, 18, 50, 51).

Encryption Method ECB , CBC , CBC with padding encryption methods represented using 00 , 01 or 11
respectively.

Return Code Contains zero for success.

eKTK(MK) The return KTK-encrypted MK.

eKKEK(MK) The return derived KKEK-encrypted MK.

KVC(MK) The return Key Verification Code (KVC) computed for the MK.

Processing Steps
1. Calculate the ICC Master Key (MK) using the Issuer Master Key and supplied PAN Data, according to the method
specified in A1.4 of [5].
2. Encrypt MK with KTK or the derived KKEK using the method specified by Encryption Method.

If KTK-Spec incorporates a format 50 key specifier, the MK is returned encrypted by the derived key KKEK.
3. Calculate the KVC for MK and return in kvc(MK).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 179
CHAPTER 4 Function Library

For Encryption Method = 11, the derived key will be padded as shown in following table. The 24-byte plaintext padded
block will be encrypted using the CBC mode of operation. This will produce a 24-byte encrypted key which will be
returned in the response.

Length (bytes) 1 16 1 6

Content 0x10 Derived Master Key 0x80 00 00 00 00 00 00

Function usage
The function is called during card initialization: the encrypted key would be passed to the card personalization system.

Notes
– Encryption Method = 12, Key Type field will be used to identify TR-31 Key usage.
– Key usage field must be matched to correct Key Type value.
– Encryption Method = 12, Response eKTK(MK) or eKKEK(MK) will be Var type field.
Following Table explained key usage, mode of use and algorithms fields to form TR-31 Key Block format key.

Key Type Key Usage Algorithms Mode of Use

01 = AC ‘E0’ ‘T’ ‘N’

02 = SMI ‘E2’

03 = SMC ‘E1’

04 = IDN ‘E4’

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 180
CHAPTER 4 Function Library

DERIVE-KEY (EE0409)
Request Length Type Description

EE0409 3 h Function Code

FM 1 h Function Modifier (FM=x0)

Derivation key Var K-Spec Key specifier


(Formats: 10, 11, 12, 13, 14)

Derivation method 1 h 00 - ECB


01 - CBC

Key Type 1 d Indicates the KM-variant

Derivation Data Var h Data to used for derivation

Response Length Type Description

EE0409 3 h Function Code

rc 1 h Return Code

Derived Key Var K-Spec Key specifier formats for Derived Key
(Formats: 10, 11, 12, 13, 14)

This function performs a key derivation operation in such a manner that the supplied derivation key is used to encrypt
the supplied derivation data. The result will be another single, double or triple DES key that is Derived Key.

FM The Host Key Protection using function modifier can be in the range of x0,
where x= 0, 1, or 2.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 181
CHAPTER 4 Function Library

Derivation key Key specifier incorporating a single, double and triple length host-stored key.
The key type of the derivation key may be 40, 41, 42, 43 and 44 depending on the Key Type
field.

Key Type field Key type of Derivation Key field

00, 40 40

01, 41 41

02, 42 42

03, 43 43

04, 44 44

05, 45 45

Derivation method This would be used to derive the key.


00 - ECB
01 - CBC

Key Type Indicates the key type of the key to be derived.

00: DPK 40: DK-DPK

01: PPK 41: DK-PPK

02: MPK 42: DK-MPK

03: KIS 43: DK-KIS

04: KIR 44: DK-KIR

05: KTM 45: DK-KTM

Derivation Data This field supplies the proprietary data which will be used to derive the key. The length of the
derivation data can be 8, 16 and 24 byte to derive the single, double or triple length key.
NOTE: A DES key (8 bytes) cannot be used to derive a triple DES key (16 or 24 bytes).

Derived Key Key specifier incorporating a single, double, and triple length derived key for host storage.

Processing Steps
1. Encrypt the derivation data by derivation key in the supplied ‘Derivation method’. The resultant value will be the
derived key.
Derived key specifier will be created based on the derived key length, ‘Key Type’ and the chosen mode of operation
on the console.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 182
CHAPTER 4 Function Library

DERIVE-MOBILE-SESSION-KEY (EE305A)
This function is used to derive mobile session keys from the mobile master keys.

Request Length Type Description

EE305A 3 h Function Code

FM 1 h Function Modifier = x0

Method 1 h Method used to derive the Session key from the Master Key

= 00: For MCBP v1.0


= 01: For Generic Method

eKM57(MKDK-1) Var K-Spec Format 1C


The MKDK to derive encryption key

eKM57(MKDK-2) Var K-Spec Format 1C


The MKDK to derive authentication key

Format Specifier for DPK 1 h = 1C

Key details 1 Var h Key details for DPK


Refer to Key details for DPK used in Format 1C

Format Specifier for MPK 1 h = 1C

Key details 2 Var h Key Details for MPK


Refer to Key details for MPK used in Format 1C

Derivation Data Var h eDPK(Session_ID)


Derivation Data for Mobile Session Keys
For Method = 00, this will contain encrypted Session_ID
For Method = 01, this will contain Derivation Data in clear
(In this case values of IV, N and DPK Spec will be ignored)

Following fields to be present only if Method = 00

Decryption Mode 1 h = 00: ECB


= 01: CBC

IV Var h Initialization vector.


In case of ECB, this must be a zero length field.

N 1 h Length of Session ID in eDPK(Session_ID)

DPK Spec Var K-Spec Key to decrypt Session_ID under DPK


Format: 0-3, 11, 12, 13, 14, 17, 18, 1C
(In case of format 17, 18, valid values for DPK are:
Key Length - Double length, Triple length
Algorithm - T)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 183
CHAPTER 4 Function Library

Response Length Type Description

EE305A 3 h Function Code

rc 1 h Return Code

eKMv0(DPK) Var K-Spec Encrypted Mobile Session Key for confidentiality


Format 1C

eKMv2(MPK) Var K-Spec Encrypted Mobile Session Key for authentication


Format 1C

Processing Steps
1. Decrypt MKDK-1 to get Mobile Master Key for encryption.
2. Decrypt MKDK-2 to get Mobile Master Key for authentication.
3. If Method = 00, decrypt the derivation data using IV, Decryption Method and DPK Spec. Extract N leftmost bytes
to get derivation data in clear.
For Method = 01, Session ID is available in clear.
4. Derive the Mobile Session key (as defined in reference [83], [84], [85] of Mark II) passing MKDK-1 to get DPK
(Mobile Session Key for Encryption).
5. Derive the Mobile Session key (as defined in reference [83], [84], [85] of Mark II) passing MKDK-2 to get MPK
(Mobile Session Key for Authentication).
6. Encrypt them with required KM variant and publish the results in eKMv0 (DPK) and eKMv2 (MPK) using format 1C.
Use key details 1 to derive DPK (derived in step 4) and key details 2 to derive MPK (derived in step 5).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 184
CHAPTER 4 Function Library

DERIVE-NEW-ICC-KEY (EE2053)
Request Length Type Description

EE2053 3 h Function code

FM 1 h Function Modifier (FM=00, 01)

KEK Var K-Spec Key Specifier for KEK (Format: 11, 13, 50, 51)
(derived from KMC)

Key Var K-Spec Key Specifier for Key (Format: 11, 13, 50, 51)
(for format 50 and 51, Key is derived from KMC; for format
11 and 13, Key refers to a host-stored KMC)

Following fields must be present if FM =01 i.e. Outgoing Key ( eKEK(Key)) needed in TR-31 Key Block Format.

Key version number 2 h Key version number

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte.

Key Block Version / 1 h xy, where


Padding Indicator x = Key block version
y = Padding indicator
x = 0 (TR-31 Key block Version A)
1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)

Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Number of Optional Fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Optional field 1…n Var h

Response Length Type Description

EE2053 3 h Function Code

rc 1 h Return Code

eKEK(Key) 16 h Key encrypted under KEK


Or Or Or
eKEK(KB) Var Key encrypted in TR-31 Key Block Format

KVC (Key) 3 h KVC for Key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 185
CHAPTER 4 Function Library

This function is provided to support the management of the Card Management Key (KMC) and the associated derived
card keys. It derives a new ICC key – Key – derived from the KMC.
KEK utilizes the format 50 key specifier which incorporates a 16 byte ‘Card unique derivation data’ field.
The KVC is calculated by encrypting all zero data with the key and then using the leftmost 3 bytes.

KEK- For formats 11 or 13 references a host stored KMC. For formats 50 or 51, the decryption key is derived
spec: from a stored KMC.

The following table shows valid key usage, algorithms and mode of use for derived Key.

Key Usage Algorithms Mode of Use

‘K0’ ‘T’ ‘N’

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 186
CHAPTER 4 Function Library

DERIVE-NEW-ICC-KEY-SET (EE2052)
Request Length Type Description

EE2052 3 h Function Code

FM 1 h Function Modifier (FM=00, 01)

K1KEK Var K-Spec Key Specifier for K1KEK (Format: 50, 51)
(derived from KMC1 )

K2xxx Var K-Spec Key Specifier for K2xxx (Format: 50, 51)
(derived from KMC2)

Following fields must be present if FM =01 i.e. Outgoing Keys needed in TR-31Key Block Format.

TR-31 fields for K2ENC

Key Usage 2 h Valid value 'DO'

Algorithms 1 h ‘T’ X’54.

Mode of use 1 h Valid value ‘‘E’,’D’,’B’,‘N’

Key version number 2 h Key version number

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte.

Key Block Version / 1 h xy, where


Padding Indicator x = Key block version
y = Padding indicator
x = 0 (TR-31 Key block Version A)
1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)
Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Number of Optional Fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Optional field 1…n Var h

TR-31 fields for K2MAC

Key Usage 2 h Valid value ‘M0’, ‘M1’, ’M2’, ’M3’, ’M4’, ’M5’

Algorithms 1 h ‘T’ X’54.

Mode of use 1 h Valid value ‘N’

Key version number 2 h Key version number.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 187
CHAPTER 4 Function Library

Request Length Type Description

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte.

Padding Indicator 1 h 00 = Do not pad


03 = Pad to triple length

Number of optional fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Optional field 1…n Var h

TR-31 fields for K2KEK

Key Usage 2 h Valid value 'KO'

Algorithms 1 h ‘T’ X’54.

Mode of use 1 h Valid value ‘‘E’,’D’,’B’,‘N’

Key version number 2 h Key version number

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte.

Key Block Version / 1 h xy, where


Padding Indicator x = Key block version
y = Padding indicator
x = 0 (TR-31 Key block Version A)
1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)
Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Number of Optional Fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Optional field 1…n Var

Response Length Type Description

EE2052 3 h Function Code

rc 1 h Return Code

eK1KEK(K2ENC) 16 h New KENC encrypted by old KKEKOr


Or New KENC encrypted by old KKEK in TR-31 Key Block
Var Format

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 188
CHAPTER 4 Function Library

Response Length Type Description

eK1KEK(K2MAC) 16 h New KMAC encrypted by old KKEK


Or Or
Var New KMAC encrypted by old KKEK in TR-31 Key Block
Format

eK1KEK(K2KEK) 16 h New KKEK encrypted by old KKEK


Or Or
Var New KKEK encrypted by old KKEK in TR-31 Key Block
Format

This function is provided to support the management of the Card Management Key (KMC) and the associated derived
card keys.
This function derives a new ICC key set – K2KEK, K2MAC and K2ENC – derived from the new KMC, denoted KMC2. The
keys are returned individually encrypted by K1KEK, which is derived from the old KMC, denoted KMC1.
K1KEK and K2xxx utilize the format 50 key specifier which incorporates a 16-byte ‘Card-unique derivation data’ field. The
eighth byte and the sixteenth byte (numbering from one at the left) must be set to specified values that indicate the key
type of the derived key, as specified in Reference [32], and as follows:
01 = KENC
02 = KMAC
03 = KKEK
The format 50 key specifier must have ‘Card method’ set to 01 and 02. This indicates that the ‘Card-unique derivation
data’ will be ECB-encrypted to derive the card keys.

K1KEK Key specifier for K1KEK (derived from KMC1). The specifier must have the appropriate bytes set to 03, so
that a valid (old) K1KEK is derived.

K2xxx Key specifier for K2xxx (derived from KMC2). The specifier must have the appropriate bytes set to 01, so
that a valid (new) K2ENC is derived. After deriving the K2ENC, the two bytes are firstly overwritten with 02
and the K2MAC is derived, then they are overwritten with 03 and the K2KEK is derived.

Notes
FM = 01, output key eK1KEK(K2ENC), eK1KEK(K2MAC), eK1KEK(K2KEK) requested in TR-31 Key block format. Fields
mentioned to prepare Key block format keys must be present.
Following table described other fields used in order to prepare TR-31 Key Block key.

Key Key Usage Algorithms Mode of use

K2ENC ’D0’ ‘T’ ‘E’,’D’,’B’,‘N’

K2MAC ‘E2’, ‘M0’, ‘T’ ‘N’


‘M1’,’M2’,’M3’,
’M4’,’M5’

K2KEK ‘K0’ ‘T’ ‘E’,’D’,’B’


,‘N’

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 189
CHAPTER 4 Function Library

DUKPT-KEY-MAILER (EE040B)
Request Length Type Description

EE040B 3 h Function Code

FM 1 h Function Modifier (FM=00,01)

IK Var K-spec Key specifier to derive Initial Key


(Format 20)

nA 1 h Number of text fields for env. ‘A’

Line No. 1 h

Column No. 1 h

Data Var h

nB 1 h Number of text fields for env. ‘B’

Line No. 1 h

Column No. 1 h

Data Var h

Response Length Type Description

EE040B 3 h Function Code

rc 1 h Return Code

This function derives the initial key for a DUKPT PIN Entry Device. The key is printed in component form on two
envelopes (A and B) for subsequent entry into the device. The function is controlled by an associated set of console
operations that determine various printing options.

FM Function Modifier = 00, 01.


Note: If FM = 01, Request, nB, moves to a position under nA in chart above.

IK A format-20 key specifier that provides the BDK and KSN used to derive the initial key for PIN Entry
Device. The Encryption Counter part of the KSN (i.e. the least significant 21 bits) must be zeroes

nA Number of text fields to print on the ‘A’ envelope (max.10).

Line No. This is the number of the line on which the ‘Data’ is to be printed. It must be in the range of 1 to 40.

Column No. This is the number of the column from which the ‘Data’ is to be printed. It must be in the range of 1 to
120.

Data This is a variable length field that contains the ASCII data to be printed.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 190
CHAPTER 4 Function Library

nB Number of text fields to print on the ‘B’ envelope (max.10).

Note: Each optional item to be printed is defined by appending a set of the fields ‘Line no.’,
‘Column no.’, and ‘Data’ to the host request. Each ‘Data’ character must be printed within the
area defined by the size of the key mailer envelope. Also, each ‘Data’ character must not
overprint any other defined area (including other defined ‘Data’ areas).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 191
CHAPTER 4 Function Library

EMV-AC-GEN (EE2000)
Request Length Type Description

EE2000 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMKAC –Spec Var K-Spec Key specifier for IMKAC(Formats: 0–3, 11, 13, 17,18)

APANB 8 h Application PAN Block

RN 8 h Random Number

AC-Data Var h Application Cryptogram Data

Response Length Type Description

EE2000 3 h Function Code

rc 1 h Return Code

AC 8 h Application Cryptogram

This function generates an Application Cryptogram (TC, AAC or ARQC) as defined in ref. [1] of Mark II.

FM = 00. Reserved for possible future use; must be set to zero.

IMKAC –Spec Key specifier which provides access to the IMKAC.


Formats 0 – 3, and 11, 13, a7 and 18 are accepted.

APANB Application PAN Block as defined in ref. [1] of Mark II.


The HSM performs no checking on the contents of this field.

RN Random number for creating the ICC Session Key as defined in ref. [1] of Mark II. The HSM
performs no checking on the contents of this field.

AC Data Data used to calculate the TC, AAC or ARQC, as specified in ref. [1] of Mark II. The HSM performs
no checking on the contents of this field. This field must be a multiple of eight bytes.

The return code (rc) for this function indicates the success or failure of the function call. See Error Codes for a complete
listing of return codes.

Processing Steps
1. Derive the ICC Master Key (MKAC) using the Issuer Master Key and APANB, according to the method specified in
2.7.1 of reference[1] of Mark II.
2. Derive the ICC Session Key (SK) using the derived MKAC and RN, according to the method specified in 2.7.2 of
reference [1] of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 192
CHAPTER 4 Function Library

3. Calculate the Application Cryptogram using SK and the data provided in AC-Data, according to the method
specified in figure 2.3 of reference [1] of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 193
CHAPTER 4 Function Library

EMV-AC-GEN-MULTI (EE2019)
Request Length Type Description

EE2019 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMKAC Var K-Spec Key specifier for IMKAC


(Formats: 0–3, 11, 13, 17 and 18)

MK Method 1 h 00 = Common
01 = SECCOS.

MK Data Var h Data used with IMKAC to derive MKAC. The contents of this
field are dependent on the value of MK Method.

AC Key Method 1 h AC Key Method = 00 – 06, 08

AC Key Data Var h Data used with MKAC to derive the session key SKAC. The
contents of this field are dependent on the value of AC Key
Method.

AC Method 1 h AC Method = 00 – 03, see AC Method.

AC Data Var h Data on which the AC is calculated.

Response Length Type Description

EE2019 3 h Function Code

rc 1 h Return Code

AC 8 h Application Cryptogram – ARQC, TC or AAC.

This function generates an Application Cryptogram (AC). The AC can be an ARQC, a TC or an AAC.
The function is sufficiently flexible to meet the AC Generation requirements of all processing variations used in different
EMV implementations. The function therefore supports several methods in each processing step.
Each step involves a key, a method and some data, where the specific method determines the format of the related
data. In the first step an initial key is provided in a key specifier, but subsequent steps use a key from a previous step.
The function treats each processing step independently, so does not treat any combination of methods as invalid.
However many combinations of methods would not coincide with the processing performed by any issued EMV card.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 194
CHAPTER 4 Function Library

MK Method The following values of MK Method are supported:

Value Implementation Reference

00 Common [1-8]

01 SECCOS [34]

Value 00
Field Length Type Description

PAN Data 6-16 h PAN || PAN Sequence No.

MK Data is a variable-length field that contains the concatenation of the PAN and PAN Sequence
Number. The function processing of the MK Data to form an 8-byte field is, in summary, as follows:

Length Processing

<16 digits Left-padded with zeros.

=16 digits Used as is.

>16 digits Hashed and decimalized.

Value 01
Field Length Type Description

CID 8-32 h Card Identification Number

AC Key The following values of AC Key Method are supported:


Method
Value Implementation Reference

00 SKAC = MKAC VSDC 1.3.2 [39]

01 SKD function using ATC and UN M/Chip 2.1 [31], SECCOS [34]

02 Tree of keys using ATC, IV, h and b EMV 4.0 [5]

03 Tree of keys using ATC. Fixed IV, h EMV 4.1 CCD [35]
and b.

04 Xor using ATC AEIPS [37], J/Smart [38]

05 SKD Function SECCOS [34]

06 Encrypt ATC As in 6.1.2 of [48]

08 Derived from MK, TSN and ATC As in 3.2.1.3 of [80]

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 195
CHAPTER 4 Function Library

Value 00
Field Length Type Description

Null 0

Value 01
Field Length Type Description

ATC 2 h Application Transaction Counter

UN 4 h Unpredictable Number

Value 02
Field Length Type Description

ATC 2 h Application Transaction Counter

IV 16 h Initialization Vector

h 1 h Height of tree of keys

b 1 h Branch factor of tree of keys

Value 03
Field Length Type Description

ATC 2 h Application Transaction Counter

Value 04
Field Length Type Description

ATC 2 h Application Transaction Counter

Value 05
Field Length Type Description

R 8 h Random Number

The random number (R) is combined with MKAC to form SKAC as described in clauses 2.7.2 and
2.8 of [7]. The identical transformation is also described in the SECCOS specifications [34] and in
the EMVCo Bulletin No 46 [36].

Note: Method 05 is similar to method 01, but is more flexible.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 196
CHAPTER 4 Function Library

Value 06
Field Length Type Description

ATC 2 h Application Transaction Counter

ATC is padded and encrypted using MKAC to form a double-length SKAC as described in 11.1.3.1
of [48].

Note: Derivation of a single-length session key will not be supported.

Value 08
Field Length Type Description

TSN 4 h Transaction Serial Number

ATC 2 h Application Transaction Counter

Derived from MK, TSN and ATC as in clause 3.2.1.3 of [80].

AC Method The following values of AC Method are supported:

Value ISO/IEC 9797-1 Alternatives Reference

Algorithm Pad Method

00 1 1

01 1 2 EMV [5]

02 3 1 VSDC [39], AEIPS [37], J/Smart [38]

03 3 2 EMV [5], M/Chip [31], SECCOS [34]

Usage of Methods
The following table is a matrix of the common combinations of methods. A call to the function would typically use the
methods identified across a single row of the table.

Implementation Methods

MK AC Key AC

AEIPS 00 00 02

EMV 4.0 00 02 01, 03

EMV 4.1 00 02, 03 01, 03

EMV 4.1 CCD 00 03 01, 03

J/Smart 00 04 02

M/Chips 2.1 00 01 03

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 197
CHAPTER 4 Function Library

Implementation Methods

MK AC Key AC

SECCOS 01 01 03

VSDC 1.3.2 00 00 02

NSICCS 00 08 03

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 198
CHAPTER 4 Function Library

EMV-AC-GEN-MULTI-AES (EE2023)
This function is used to generate AC for AES implementation of ICC cards.

Request Length Type Description

EE2023 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMKac Var K-spec Key specifier for IMKac


(Formats: 0–3,17,18)

MK Method 1 h 00 = Common for EMV AES (EMV 4.3)


01 = SECCOS AES (SECCOS 7.1)

MK Data Var h Data used with IMKac to derive MKac.


The contents of this field are dependent on the value of MK
Method.

MK Key length 1 h 00 = Same as key length for IMKxx


01 = 16 byte
02 = 24 byte
03 = 32 byte
The validity of derivation has to be checked with respect to
derivation from both EMV and SECCOS.

AC Key Method 1 h AC Key Method


00 = EMV AES (EMV 4.3)
01 = SEECOS AES (SECCOS 7.1)

AC Key Data Var h Data used with MKac to derive the Session key SKac.
The contents of this field are dependent on the value of AC
Key Method.

AC Method 1 h AC Method = 05

AC Data Var h Data on which the AC is calculated

Response Length Type Description

EE2022 3 h Function Code

rc 1 h Return Code

AC Var h Application Cryptogram - ARQC, TC or AAC

• IMKxx will be used along with MK data length and method to derive card master/unique key. For EMV, refer section
A1.4, option C of Reference A [95]. For SECCOS, refer section 8.4.1.2 of Reference A [98].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 199
CHAPTER 4 Function Library

• Card Master Key along with AC key data and AC key method to be used to derive Session key. For EMV, refer
section A1.3.1 of Reference A [95]. For SECCOS, refer chapter 8 of Reference A [98].
• Session Key will be used over AC data and/or ARPC data to compute cryptograms. Refer section A1.2.2 of
Reference A [95].
• Compute an ARQC as described in section 2 8.1.2 of Reference A [95] to verify the Transaction ARQC. Then an
ARPC must be computed as described in section 8.2.2 of Reference A [95].

MK Method The following values of MK Method are supported:

Value Implementation Reference

00 Common AES EMV 4.3 (Reference A [94-97])

01 SECCOS SECCOS 7.1 (Reference A [98] section 8.4.1.2)

Value 00
Field Length Type Description

Derivation 16 h PAN || PAN Sequence No.


Data

Value 01
Field Length Type Description

Derivation 16-40 h Card Identification Number (CID)


Data

AC Key Method The following values of AC Key Method are supported:

Value Implementation Reference

00 EMV Common Session Key EMV 4.3 Section A1.3.1

01 SECCOS Session Key SECCOS 7.1 (Reference A [98]


section 8.4.2)

Value 00
Field Length Type Description

R 16 h Random Number
Recommended value for EMV 4.3 AES; 2bytes of ATC appended with 14 bytes of 0x00

Value 01
Field Length Type Description

R 16 h Application Transaction Counter


Recommended value for SECCOS7.1; same as for EMV 4.3 AES

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 200
CHAPTER 4 Function Library

AC Method The following values of AC Method are supported:

Value ISO/IEC 9797-1 Reference


Alternatives

Algorithm Pad Method

05 5 4 EMV 4.3 (Reference A [94-97])

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 201
CHAPTER 4 Function Library

EMV-AC-VERIFY (EE2001)
Request Length Type Description

EE2001 3 h Function Code

FM 1 h Function Modifier (FM=00,01 or 04)

IMKAC-Spec Var K-Spec Key specifier for IMKAC (Formats: 0–3, 11, 13, 17 and 18)

APANB 8 h Application PAN Block

RN 8 h Random Number

AC/CAP Token 8/Var h If FM = 00 this field contains the 8-byte Application


Cryptogram (AC).
If FM = 01 or 04 the field contains the variable length CAP
token

AC-Data Var h Data used in the calculation of the Application Cryptogram.


Must be a multiple of 8 bytes.

Bitmap Var K-Spec Only available when FM = 01 or 04


Authenticate field from IPB
(Formats: 0 - 3, 19).

Transaction Data Var h Only present when FM = 04


Data signed to produce CAP Token.
Must be a multiple of eight bytes.

Response Length Type Description

EE2001 3 h Function Code

rc 1 h Return Code

This function verifies an application cryptogram (TC, AAC or ARQC) as defined in Reference [1] of Mark II.

FM = 00. When the = 00 is set to 00 the Bitmap field is not included. When the = 00 is set to 01 or 04
the Bitmap field is included. The setting of this field also effects the AC/CAP Token and the
Transaction Data fields. For details see the descriptions in the table above.

IMKAC –Spec Key specifier which provides access to the IMKAC.


Formats 0 - 3, 11, 13, 17, and 18 are accepted.

APANB Application PAN Block as defined in Reference [1] of Mark II. The HSM performs no checking on
the contents of this field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 202
CHAPTER 4 Function Library

RN Random number for creating the ICC Session Key as defined in Reference [1] of Mark II. The HSM
performs no checking on the contents of this field.

AC Application Cryptogram (TC, AAC or ARQC) Calculated by ICC as defined in reference [1] of Mark
II. This field is 8 bytes in length. This field is present when FM = 00.

CAP Token CAP Token (AAC or ARQC) that has been produced by an EMV ICC. This field is a Var field. This
field is present when FM = 01 or 04. When the function is used with FM = 01 or 04 support is
provided for a variable-length Application Cryptogram created as indicated by the set bits in the
Bitmap field. This modification supports the Chip Authentication Program as specified in [reference
[31] of Mark II].
The CAP Token field contains the bits of the Application Cryptogram to be verified as indicated by
the Bitmap (see below). If the length (in bits) of this field is greater than the number of bits that are
set to 1 in the Bitmap field, then the significant bits must be left-justified and padded to the right
with zero bits.

AC-Data Data used to calculate the TC, AAC or ARQC, as specified in reference [1] of Mark II. The HSM
performs no checking on the contents of this field. This field must be a multiple of eight bytes.

Bitmap The Bitmap field is a key specifier field. It specifies a HSM stored or host stored portion of the
Issuer Proprietary Bitmap (IPB) that relates to the Shortened AC. This field is not available when
FM is set to 00. The number of set bits must be ≤16 and ≥ 64 (note: there is no requirement that the
number of set bits is a multiple of 8).

Transaction Data signed to produce CAP Token. Only present when FM = 04. Must be a multiple of eight bytes.
Data

See EMV Function Examples for examples of request and response packages for this function.
The return code (rc) for this function indicates the success or failure of the function call. See Error Codes for a complete
listing of return codes.

Processing Steps
1. Derive the ICC Master Key (MKAC) using the Issuer Master Key and APANB, according to the method specified in
2.7.1 of reference [1] of Mark II.
2. Derive the ICC Session Key (SK) using the derived MKAC and RN, according to the method specified in 2.7.2 of
reference [1] of Mark II.
3. Calculate the Application Cryptogram using SK and the data provided in AC-Data, according to the method
specified in figure 2.3 of reference [1] of Mark II.
4. When FM=01, select only the bits indicated by the set bits in the bitmap to generate the reference Application
Cryptogram.
5. Compare the values of the calculated Application Cryptogram and that supplied in AC.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 203
CHAPTER 4 Function Library

EMV-ARPC-GEN (EE2006)
Request Length Type Description

EE2006 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMKAC-Spec Var K-Spec Key specifier for IMKAC(Formats: 0–3, 11, 13, 17 and 18)

APANB 8 h Application PAN Block

ARPC-Data 8 h Authorization Response Cryptogram Data

Response Length Type Description

EE2006 3 h Function Code

rc 1 h Return Code

ARPC 8 h Authorization Response Cryptogram

This function generates an Authorization Response Cryptogram as defined in reference [1] of Mark II.

FM = 00. Reserved for possible future use; must be set to zero.

IMKAC –Spec Key specifier which provides access to the IMKAC.


Formats 0 - 3, 11, 13, 17 and 18 are accepted.

APANB Application PAN Block as defined in reference [1] of Mark II. The HSM performs no checking on
the contents of this field.

ARPC Data Authorization Response Cryptogram Data, used for calculating the ARPC as defined in reference
[1] of Mark II.

The return code (rc) for this function indicates the success or failure of the function call. See Error Codes for a complete
listing of return codes.

Processing Steps
1. Derive the ICC Master Key (MKAC) using the Issuer Master Key and APANB, according to the method specified in
2.7.1 of reference [1] of Mark II.
2. Calculate the ARPC using the MKAC and the data provided in ARPC-DATA according to the method specified in
figure 2.4 of reference [1] of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 204
CHAPTER 4 Function Library

EMV-DAC-GEN (EE2002)
Request Length Type Description

EE2002 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMKDAC –Spec Var K-Spec Key specifier for IMKDAC (Formats: 0–3, 11, 13, 17 and 18)

APANB 8 h Application PAN Block

Response Length Type Description

EE2002 3 h Function Code

rc 1 h Return Code

DAC 2 h Data Authentication Code

This function generates a Data Authentication Code (DAC) as defined in reference [1] of Mark II.

FM = 00. Reserved for possible future use; must be set to zero.

IMKDAC –Spec Key specifier which provides access to the IMKDAC


Formats 0 - 3, 11, 13, 17 and 18 are accepted.

APANB Application PAN Block as defined in reference [1] of Mark II. The HSM performs no checking on
the contents of this field.

The return code (rc) for this function indicates the success or failure of the function call. See Error Codes for a complete
listing of return codes.

Processing Steps
1. Derive the DAC using the Issuer Master Key and APANB, according to the method specified in 2.9 of reference [1]
of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 205
CHAPTER 4 Function Library

EMV-DAC-VERIFY (EE2003)
Request Length Type Description

EE2003 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMKDAC –Spec Var K-Spec Key specifier for IMKDAC


(Formats: 0–3, 11, 13, 17,18)

APANB 8 h Application PAN Block

DAC 2 h Data Authentication Code

Response Length Type Description

EE2003 3 h Function Code

rc 1 h Return Code

This function verifies a Data Authentication Code (DAC) as defined in reference [1] of Mark II.

FM = 00. Reserved for possible future use; must be set to zero.

IMKDAC –Spec Key specifier which provides access to the IMKDAC.


Formats 0 – 3, 11, 13, 17 and 18 are accepted.

APANB Application PAN Block as defined in reference [1] of Mark II. The HSM performs no checking on
the contents of this field.

DAC DAC(Data Authentication Code) calculated by ICC as defined in reference [1] of Mark II.

The return code (rc) for this function indicates the success or failure of the function call. See Error Codes for a complete
listing of return codes.

Processing Steps
1. Derive the DAC using the Issuer Master Key and APANB, according to the method specified in 2.9 of reference [1]
of Mark II.
2. Compare the values of the calculated Data Authentication Code and that supplied in DAC.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 206
CHAPTER 4 Function Library

EMV-GENERATE-ARPC (EF2012)
Request Length Type Description

EF2012 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMKAC-Spec Var K-Spec Key specifier for Issuer Master Key.


(Formats: 0–3, 11, 13, 17,18)

PAN Data 8 h Formatted PAN and PAN Sequence No.

IV 16 h Initialization Vector

h 1 h Height of tree of keys.

b 1 h Branch factor of tree of keys.

ATC 2 h Application Transaction Counter.

ARPC Data 8 h Authorization Response Cryptogram Data

Response Length Type Description

EF2012 3 h Function Code

rc 1 h Return Code

ARPC 8 h Authorization Response Cryptogram.

This function calculates an ARPC for transmitting to an ICC.


The ICC Session Key is derived using the method specified in the EMV2000 specification, reference [5] of Mark II.

FM = 00. Reserved for possible future use; must be set to zero.

IMKAC –Spec Key specifier which provides access to the IMKAC.


Formats 0 - 3, 11, 13, 17 and 18 are accepted.

PAN Data Formatted PAN and PAN Sequence No.

IV Initialization Vector

h Height for tree of keys

b Branch factor of tree of keys

ATC Application Transaction Counter (min = 01; max = FFFF)

ARPC Data Authorization Response Cryptogram Data, used for calculating the ARPC as defined in [1].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 207
CHAPTER 4 Function Library

Processing Steps
1. Derive the ICC Master Key (MKAC) using the Issuer Master Key and PAN Data, according to the method specified
in A1.4 of reference [5] of Mark II.
2. Derive the ICC Session Key (SK) using the derived MKAC, IV, h, b and ATC, according to the method specified in
A1.3 of reference [5] of Mark II.
3. Calculate the ARPC using SK and ARPC Data according to the method specified in 8.2 of reference [5] of Mark II.

Note: ARPC Data should contain the value Y, which is the XORed combination of the ARQC
and the ARC.

Function usage
The function is used during online transactions. It can also be used during card initialization to test a card.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 208
CHAPTER 4 Function Library

EMV-ICC-DN-GEN (EE2004)
Request Length Type Description

EE2004 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMKIDN-Spec Var K-Spec Key specifier for IMKIDN


(Formats: 0–3, 11, 13, 17,18)

APANB 8 h Application PAN Block

IDN Data 8 h ICC Dynamic Number Data

Response Length Type Description

EE2004 3 h Function Code

rc 1 h Return Code

IDN 2 h ICC Dynamic Number

This function generates a ICC Dynamic Number as defined in reference [1] of Mark II.

FM = 00. Reserved for possible future use; must be set to zero.

IMKIDN – Key specifier which provides access to the IMKIDN.


Spec Formats 0 - 3, 11, 13, 17 and 18 are accepted.

APANB Application PAN Block as defined in reference [1] of Mark II. The HSM performs no checking on the
contents of this field.

IDN Data Data for calculating IDN, as specified in reference [1] of Mark II.

The return code (rc) for this function indicates the success or failure of the function call. See Error Codes for a complete
listing of return codes.

Processing Steps
1. Derive the ICC Master Key (MKIDN) using the Issuer Master Key and APANB, according to the method specified in
2.7.1 of reference [1] of Mark II.
2. Calculate the IDN using the MKIDN and the data provided in IDN Data, according to the method specified in 2.10 of
reference [1] of Mark II.

Note: IDN Data should contain the value which is the ICC Application Transaction Counter
(ATC) and the Unpredictable Number (UN).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 209
CHAPTER 4 Function Library

EMV-ICC-DN-VERIFY (EE2005)
Request Length Type Description

EE2005 3 h Function Code

FM 1 h Function Modifier (FM=00)

IMKIDN-Spec Var K-Spec Key specifier for IMKIDN(Formats: 0–3, 11, 13, 17,18)

APANB 8 h Application PAN Block

RN 8 h Random Number

IDN 2 h ICC Dynamic Number

Response Length Type Description

EE2005 3 h Function Code

rc 1 h Return Code

This function verifies a ICC Dynamic Number as defined in reference [1] of Mark II.

FM = 00. Reserved for possible future use; must be set to zero.

IMKIDN –Spec Key specifier which provides access to the IMKIDN


Formats 0 – 3, 11, 13, 17 and 18 are accepted.

APANB Application PAN Block as defined in reference [1] of Mark II. The HSM performs no checking on
the contents of this field.

RN Random number for calculating data of IDN as defined in reference [1] of Mark II.

IDN Calculated ICC Dynamic Number as defined in reference [1] of Mark II.

The return code (rc) for this function indicates the success or failure of the function call. See Error Codes for a complete
listing of return codes.

Processing Steps
1. Derive the ICC Master Key (MKIDN) using the Issuer Master Key and APANB, according to the method specified in
2.7.1 of reference [1] of Mark II.
2. Calculate the IDN using the MKIDN and the data provided in IDN Data, according to the method specified in 2.10 of
reference [1] of Mark II.
3. Compare the values of the calculated ICC Dynamic Number and that supplied in IDN.

Note: IDN Data should contain the value which is the ICC Application Transaction Counter
(ATC) and the Unpredictable Number (UN).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 210
CHAPTER 4 Function Library

EMV-PIN-CHANGE-UNBLOCK (EE2016)
Request Length Type Description

EE2016 3 h Function Code

FM 1 h Function Modifier (FM=00)

P2 1 h Function Flag
00 = PIN UnBlock only
01 = PIN Change – delta Block
02 = PIN Change – non-delta PIN

Scheme 1 h 01 = MasterCard
02 = Visa 1.4 PIN
03 = Visa 1.3 PIN
04 = CPA

IMKSMI Var K-Spec Key specifier for IMKSMI (Formats: 0–3, 11, 13, 17,18)

IMKSMC Var K-Spec Key specifier for IMKSMC (Formats: 0–3, 11, 13, 17,18)

IMKAC Var K-Spec Key specifier for IMKAC (Formats: 0–3, 11, 13, 17,18)

PAN Data Var h Formatted PAN and PAN Sequence Number

Session Key Data Var h Session Key Data

ePPK(PIN1) 8 h Encrypted PIN Block (Existing PIN)

ePPK(PIN2) 8 h Encrypted PIN Block (New PIN)

PPK Var K-Spec Key specifier for PPK


(Formats: (Formats: 0–3, 10, 11, 12, 13, 14, 17,18)

PF 1 h PIN Block Format


(Formats: 10, 13)

ANB 6 d Account Number Block

Script-Data Position 2 h Script-Data Position

Script Data Var h Script Data

Response Length Type Description

EE2016 3 h Function Code

rc 1 h Return Code

New PIN Data Var h Encrypted New PIN Data. The output PIN block format is
ISO-2

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 211
CHAPTER 4 Function Library

Response Length Type Description

MAC 8 h Message Authentication Code

This function provides the cryptographic processing for an issuer script which will unBlock or change the offline
reference PIN stored in an EMV’96-based card. It calculates the MAC and, if required, the encrypted new PIN data.

P2 Identifies the required processing:


00 : PIN UnBlock only
01 : PIN Change – delta Block
02 : PIN Change – non-delta PIN

PAN Data Formatted PAN and PAN Sequence No. This field is used with IMK to derive unique integrity
and confidentiality keys. Currently the Var field must be 8 bytes.

Session Key Data If Scheme = 01 (MasterCard), then Session Key Data contains an 8-byte random number.
If Scheme = 02 (Visa) then Session Key Data contains a 2-byte ATC. This field should be
used to calculate session integrity and confidentiality keys.
If Scheme = 04 (CPA) then Session Key Data must have 8-bytes of diversification value that
can be used to derive a session key as per section A1.3.1 of SU-46_New Session Key
Derivation algorithm w CVN 5_PU.pdf.

ePPK(PIN1) If the Function Flag (P2) = 01, this field is decrypted to get the existing PIN

ePPK(PIN2) Decrypted to recover the new PIN

PF ISO formats 0 and 3. This field is used to get the new PIN and, if appropriate, the existing PIN

ANB This field is used to get the new PIN and, if appropriate, the existing PIN

Script-Data Position For P2 = 01 or 02, this points to the start byte in Script-Data where the encrypted PIN data will
be copied. A Script-Data Position of zero points to the start of Script-Data. This field is big
endian.

Script-Data Script-Data Used to calculate the MAC.


If the last (or only) data Block is less than 8 bytes it is padded to the right with a hexadecimal
80. If this data Block is still less than 8 bytes it is right filled with 1 byte hexadecimal zeros
until it is 8 bytes. The script data length must be greater than or equal to the sum of offset and
the length of encrypted New PIN data.

New PIN Data Encrypted New PIN Data in ISO-2 format.


If FM = 1 it is formatted as a standard Var field.
If FM = 0 then the field is only present when P2 = 01 or 02. The contents of the field when
present is pure data, 16 bytes in length.

MAC Message authentication code.

The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 212
CHAPTER 4 Function Library

EMV-PIN-CHANGE-UNBLOCK-EMV-2000 (EE2017)
Request Length Type Description

EE2017 3 h Function Code

FM 1 h Function Modifier (FM=00)

P2 1 h Function Flag
00 = PIN UnBlock only
01 = PIN Change – delta Block
02 = PIN Change – non-delta PIN

Scheme 1 h 01 = MasterCard
02 = Visa 1.4 PIN
03 = Reserved. (American Express)

IMKSMI Var K-Spec Key specifier for IMKSMI (Formats: 0–3, 11, 13, 17,18)

IMKSMC Var K-Spec Key specifier for IMKSMC (Formats: 0–3, 11, 13, 17,18)

IMKAC Var K-spec Reserved. (Key specifier for IMKAC)

PAN Data Var h Formatted PAN and PAN Sequence No.

IV 16 h Initialization Vector

h 1 h Height of tree of keys

b 1 h Branch factor of tree of keys

ATC 2 h Application Transaction Counter

ePPK(PIN1) 8 h Encrypted PIN Block (Existing PIN)

ePPK(PIN2) 8 h Encrypted PIN Block (New PIN)

PPK Var K-Spec Key specifier for PPK


(Formats: 0–3, 10, 11, 12, 13, 14, 17,18)

PF 1 h PIN Block Format


(Formats: 10, 13)

ANB 6 d Account Number Block

Script-Data Position 2 h Script-Data Position

Script-Data Var h Script Data

Response Length Type Description

EE2017 3 h Function Code

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 213
CHAPTER 4 Function Library

Response Length Type Description

rc 1 h Return Code

New PIN data Var h Encrypted New PIN data

MAC 8 h Message Authentication Code

This function provides the cryptographic processing for an issuer script which will unBlock or change the offline
reference PIN stored in an EMV2000-based card. It calculates the MAC and, if required, the encrypted new PIN data.
The key specifiers 11, 13 (IMKSMI/IMKSMC/IMKAC) and 10, 11, 13 (PPK) under the Request, are generated based on
the chosen operation on console and FM.

P2 Identifies the required processing:


00: PIN UnBlock only
01: PIN Change – delta Block
02: PIN Change – non-delta PIN

PAN Data Formatted PAN and PAN Sequence No. This field is used with IMK to derive unique integrity and
confidentiality keys. Currently the Var field must be 8 bytes.

ePPK(PIN1) If the Function Flag (P2) = 01, this field is decrypted to get the existing PIN

ePPK(PIN2) Decrypted to recover the new PIN

PF ISO formats 0 and 3. This field is used to get the new PIN and, if appropriate, the existing PIN

ANB This field is used to get the new PIN and, if appropriate, the existing PIN

Script-Data For P2 = 01 or 02, this points to the start byte in Script-Data where the encrypted PIN data will be
Position copied. A Script-Data Position of zero points to the start of Script-Data. This field is big endian.

Script-Data Used to calculate the MAC. If the last (or only) data Block is less than 8 bytes it is padded to the
right with a hexadecimal 80. If this data Block is still less than 8 bytes it is right filled with 1 byte
hexadecimal zeros until it is 8 bytes. The script data length must be greater than or equal to the sum
of offset and the length of encrypted New PIN data.

New PIN Data Encrypted New PIN Data.


If FM = 1 it is formatted as a standard Var field.
If FM = 0 then the field is only present when P2 = 01 or 02. The contents of the field when present is
pure data, 16 bytes in length.

MAC Message authentication code.

The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 214
CHAPTER 4 Function Library

EMV-PIN-CHANGE-UNBLOCK-MULTI (EE2021)
Request Length Type Description

EE2021 3 h Function Code

FM 1 h Function Modifier (FM=00)

SC 1 h Select Code
02 = PIN Unblock only
03 = PIN Change

IMKSMI Var K-Spec Key specifier for IMKSMI


(Formats: 0–3, 11, 13, 17,18)

IMKSMC Var K-Spec Key specifier for IMKSMC


(Formats: 0–3, 11, 13, 17,18)

MK Method 1 h 00 = Common
01 = SECCOS.

MK Data Var h Data used with IMKSMx to derive MKSMx . The contents of
this field are dependent on the value of MK Method.

SM Key Method 1 h SM Key Method = 02 – 08

SM Key Data Var h Data used with MKSMx to derive the session key SKSMx .
The contents of this field are dependent on the value of SM
Key Method. When SM Key Method = 07, It must contain 8-
bytes of diversification value to derive session key.

PF Method 1 h PIN formatting method = 01, 02, 11, 12.

PF Data Var h PIN formatting data


(Formats: 10, 11, 12, 13, 14, 17, 18)

PC Method 1 h PIN confidentiality method


00 = Formatting 01 / ECB
01 = Formatting 01 / CBC
02 = Formatting 00 / ECB
03 = Formatting CPA/ CBC

PC Data Var h PIN confidentiality data


Zero-length field.

PI Method 1 h PIN integrity method


00 = Default (Standard MAC)
01 = NSICCS MAC

PI Data Var h PIN integrity data

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 215
CHAPTER 4 Function Library

Response Length Type Description

EE2021 3 h Function Code

rc 1 h Return Code

New PIN data Var h Encrypted New PIN data

MAC 8 h Message Authentication Code

This function is a combination of the designs of functions EE2019 and EE2017 , using the approach to key derivation
from the former with modifications as appropriate, and the encryption / MAC fields specific to PIN Unblock/Change
from the latter.
The subscript SMx is used to denote both SMI and SMC.

FM = 00

SC Identifies the required processing:


2 : PIN Unblock only.
3 : PIN Change

IMKSMI –Spec Key specifier which provides access to the IMKSMI.


Formats 0 - 3, 11, 13, 17, 18 are accepted.

IMKSMC –Spec Key specifier which provides access to the IMKSMC.


Formats 0 - 3, 11, 13, 17 and 18 are accepted.
Note: When SC = 02, this field is not used; it must be a valid variable-length field but its data
portion will not be checked for containing a valid key specifier.

MK Method Methods are supported for deriving the ICC Master Keys. (MKSMX)
00=Common; 01=SECCOS.

MK Data Data used with IMKSMx to derive MKSMx . The contents of this field are dependent on the value of
MK Method.

SM Key Method Methods exist for deriving a Session Key (SKsmx) from the MKSMX.

SM Key Data Data used with MKSMx to derive the session key SKSMx . The contents of this field are dependent
on the value of SM Key Method.

PF Method Methods exist for creating the cleartext PIN block.

PF Data It is a variable-length field that contains zero or more fields incorporating the data required by the
specific PF Method.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 216
CHAPTER 4 Function Library

PC Method PIN confidentiality data. Encrypt the cleartext PIN block using SKSMC to generate the Encrypted
New PIN data.
00 = Formatting 01 / ECB
01 = Formatting 01 / CBC
02 = Formatting 00 / ECB
03 = Formatting CPA/ CBC
PC methods 00 and 01 employ formatting method 01. With this formatting method, a length byte is
prepended to the 8-byte plaintext PIN block and 7 bytes of padding are appended, as follows:

X'08' || <8-byte plaintext PIN block> || X'80000000000000"

This produces a 16-byte result which is then encrypted using the identified encryption mode of
operation (ECB or CBC). The resultant is 16-byte New PIN Data field.
Note: The formatting 01 as described above is currently applicable only when the PF Method
supplied is 11 or 12. As per the enhancement in EE2021:
If “PC Method = 02” and “PF Method = 11 or 12” then,
Formatting 01 is not applicable; instead formatting 00 will be applied.

PC method 02 employs formatting method 00. This is a null formatting method, whereby no further
formatting is applied. The 8-byte plaintext PIN block is encrypted using the ECB mode of operation
and the resultant is 8-byte New PIN Data field.

PC Data PIN confidentiality data . Zero-length field (for Future use).

PI Method PIN integrity method. Supports the following two methods for calculating MAC:
- using SKSMI.
- using clause as specified in 3.1.1.5 of [80]

PI Data It is a variable-length field incorporating the data required by the specific PI method.

New PIN Data Encrypted New PIN Data. It is formatted as a standard Var field. This field is only present when
SC = 03.

MAC Message authentication code.

Note: When SC =02 then fields IMKSMC –Spec , PF Method, PF Data, PC Method is not
used ; they must have a valid length field but there data portion will not be checked .

The function is sufficiently flexible to meet the requirements of all processing variations used in different EMV
implementations. The function therefore supports several methods in each processing step.
Each step involves a key, a method and some data, where the specific method determines the format of the related
data. In the first step an initial key is provided in a key specifier, but subsequent steps use a key from a previous step.
The function treats each processing step independently, so does not treat any combination of methods as invalid.
However many combinations of methods would not coincide with the processing performed by any issued EMV card.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 217
CHAPTER 4 Function Library

PF Method The following values of PF Method are supported:

Value Implementation Reference

01 ISO-1 [40]

02 ISO-2 [7], [40]

11 delta PIN with UDK-A [37], [38], [39]

12 ISO-0 with UDK-A [37], [38], [39]

PF Data It is a variable-length field that contains zero or more fields incorporating the data required by the
specific PF methods.

Value 01
Field Length Type Description
and 02
ePPK(PIN) 8 h Encrypted PIN Block

PPK Var K-Spec Key specifier for PPK (Formats: 0 - 3, 10, 11, 12, 13, 14)

PF 1 h PIN Block Format


(Formats: 10, 13)

ANB 6 d Account Number Block

The method to create cleartext PIN block is :


- Obtain PPK using PPK.
- Decrypt ePPK (PIN) using PPK to obtain cleartext ISO-0 or ISO-3 PIN block.
- Extract PIN from cleartext PIN block using PF and ANB.
- Create a cleartext ISO-1 or ISO-2 PIN block.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 218
CHAPTER 4 Function Library

Value 11
Field Length Type Description

ePPK(PIN1) 8 h Encrypted PIN Block (Current PIN)

ePPK(PIN2) 8 h Encrypted PIN Block (New PIN)

PPK Var K-Spec Key specifier for PPK (Formats: 0 - 3, 10, 11, 12, 13,
14)

PF 1 h PIN Block Format


(Formats: 10, 13)

ANB 6 d Account Number Block

IMKAC Var K-Spec Key specifier for IMKAC


(Formats: 0 - 3, 13)

The method to create Delta PIN is :


- Obtain PPK using PPK.
- Decrypt ePPK(PIN1) using PPK to obtain cleartext ISO-0 or ISO-3 PIN block
- Extract current PIN from cleartext PIN block using PF and ANB.
- Decrypt ePPK (PIN2) using PPK to obtain cleartext ISO-0 or ISO-3 PIN block.
- Extract new PIN from cleartext PIN block using PF and ANB.
- Derive MKAC (i.e. UDK-A) using IMKAC, MK method and MK Data.
- Calculate delta PIN using current PIN, new PIN and UDK-A as described in clause C.11.1 of
[39].

Value 12
Field Length Type Description

ePPK(PIN) 8 h Encrypted PIN Block

PPK Var K-Spec Key specifier for PPK (Formats: 0 - 3, 10, 11, 12, 13,
14)

PF 1 h PIN Block Format


(Formats: 10, 13)

ANB 6 d Account Number Block

IMKAC Var K-Spec Key specifier for IMKAC


(Formats: 0 - 3, 13)

The method to create ISO-0 PIN block is :


- Obtain PPK using PPK.
- Decrypt ePPK (PIN) using PPK to obtain cleartext ISO-0 or ISO-3 PIN block.
- Extract new PIN from cleartext PIN block using PF and ANB.
- Derive MKAC (i.e. UDK-A) using IMKAC, MK method and MK Data.
- Create a cleartext ISO-0 PIN block using the PIN and UDK -A as described in clause C.11.2 of
[39].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 219
CHAPTER 4 Function Library

PI Method The following value of PI Method are supported:

Value Method Reference

00 Default (Standard MAC)

01 NSICCS MAC As in 3.1.1.5 of [80].

PI Data It is a variable-length field that contains zero or more fields incorporating the data required by the
specific PI method.

Value 00 & 01
Field Length Type Description

Script-Data Position 2 h Script-Data Position

Script-Data Var h Script Data

Script-Data For SC = 03, this points to the start byte in Script-Data where the encrypted New PIN data will be
Position copied. A Script-Data Position of zero points to the start of Script-Data. This field is big Endean.

Script-Data Used to calculate the MAC. If the last (or only) data Block is less than 8 bytes it is padded to the
right with a hexadecimal 80. If this data Block is still less than 8 bytes it is right filled with 1 byte
hexadecimal zeros until it is 8 bytes. The script data length must be greater than or equal to the
sum of offset and the length of encrypted New PIN data.

SM Key Method The following values of SM Key Method are supported:

Value Implementation Reference

02 Tree of keys using ATC, IV, h and b EMV 4.0 [5]

03 Tree of keys using ATC. Fixed IV, h EMV 4.1 CCD [35]
and b.

04 Xor using ATC AEIPS [37], J/Smart [38], VSDC [39]

05 SKD Function SECCOS [34]

06 Encrypt ATC 6.1.2 of [48].

07 When SM Key Method=07, then the Section A1.3.1 of SU-46_New Session Key
Session Key Data field must have Derivation algorithm w CVN 5_PU.pdf
8-bytes of diversification value that
can be used to derive a session key

08 Derived from MK, TSN and ATC As in 3.2.1.3 of [80].

SM Key Data is a variable-length field that contains zero or more fields incorporating the data
required by the specific SM Key methods.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 220
CHAPTER 4 Function Library

Value 02
Field Length Type Description

ATC 2 h Application Transaction Counter

IV 16 h Initialization Vector

h 1 h Height of tree of keys

b 1 h Branch factor of tree of keys

The SM Key Data length is 20.


SKSMx is derived from MKSMx and ATC using the parameters IV, h and b, as described in clause
A1.3.1 of [5].

Value 03
Field Length Type Description

ATC 2 h Application Transaction Counter

The SM Key Data length is 2.


SKSMx is derived from MKSMx and ATC using the parameters IV, h and b, as described in clause
A1.3.1 of [35]. The values of IV, h and b are fixed as required by CCD as described in Part IV of
[35].

Value 04
Field Length Type Description

ATC 2 h Application Transaction Counter

The SM Key Data length is 2.


SKSMx is derived from MKSMx and ATC using an exclusive-OR operation, as described in clause
6.2.4.2 of [38].

Value 05
Field Length Type Description

R 8 h Random Number

The SM Key Data length is 8.


The random number (R) is combined with MKSMx to form SKSMx as described in clauses 2.7.2
and 2.8 of [7].The identical transformation is also described in the SECCOS specifications [34]
and in the EMVCo Bulletin No 46 [36].
Note: Method 05 is similar to method 01 (in EE2019) but is more flexible.

Value 06
Field Length Type Description

ATC 2 h Application Transaction Counter

ATC is padded and encrypted using MKSMI or MKSMC to form a double-length SKSMI or SKSMC as
described in 11.1.3.1 of [48].
Note: Derivation of a single-length session key will not be supported.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 221
CHAPTER 4 Function Library

Value 08
Field Length Type Description

TSN 4 h Transaction Serial Number

ATC 2 h Application Transaction Counter

Derived from MK, TSN and ATC as in clause 3.2.1.3 of [80].

Processing steps
1. If SC is 03, derive the ICC MAC Master Key (MKSMC) using the Issuer Master Key (IMKSMC) and MK Data
according to method specified in MK Method.
2. Derive the ICC MAC Session Key (SKSMC) using the derived MKSMC, SM Key Data according to the method
specified in SM Key Method.
3. Derive the ICC Encipherment Master Key (MKSMI) using the Issuer Master Key (IMKSMI) and MK Data, according
to the method specified in MK Method.
4. Derive the ICC Encipherment Session Key (SKSMI) using the derived MKSMI, SM Key Data according to the
method specified in SM Key Method.
5. If SC is 3, create the cleartext PIN block according to the method specified in PF Method.
6. If SC is 3, encrypt cleartext PIN block using SKSMC according to the encryption mode of operation specified in PC
Method. If SC is 3, insert the resulting ciphertext in Script-Data (PI Data) at the position specified by Script-Data
Position (PI Data).
7. Calculate the MAC for Script-Data using SKSMI.

Usage of Methods
The following table is a matrix of the common combinations of methods. A call to the function would typically use the
methods identified across a single row of the table.

Implementation Methods

MK SM Key PF PC PI

AEIPS 00 04 11, 12 02 00

EMV 4.0 00 02 not specified 00, 01 00

EMV 4.1 00 02, 03 not specified 00, 01 00

EMV 4.1 + SUB 46 00 05 not specified 00, 01 00

EMV 4.1 CCD 00 03 not specified 01 00

EMV 4.1 CCD + SUB 46 00 05 not specified 01 00

J/Smart 00 04 11,12 00 00

M/Chip 2.1 00 05 02 02 00

SECCOS 01 05 01, 02 01 00

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 222
CHAPTER 4 Function Library

Implementation Methods

MK SM Key PF PC PI

VSDC 1.3.2 00 04 11, 12 00 00

EMV CPA 00/01 07 02 03 00

NSICCS 00 08 not specified 00, 01 01

Note:
- As indicated in the table above, the AEIPS and M/Chip 2.1 Implementations hold equivalent
values for the PC Method.
- Since, encrypting one block of 8-bytes CBC with an IV of 0 is the same as ECB, the
encryption modes (CBC and ECB) fall equivalent with each other. Hence, even though AEIPS
and M/Chip 1.2 specifies CBC mode, it is equally correct to use ECB.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 223
CHAPTER 4 Function Library

EMV-PIN-CHANGE-UNBLOCK-MULTI-AES (EE2025)
This function is used to change and unblock PIN with respect t to AES keys for EMV processing.

Request Length Type Description

EE2025 3 h Function Code

FM 1 h Function Modifier (FM=00)

SC 1 h Select Code
02 = PIN Unblock only
03 = PIN Change

IMKSMI Var K-Spec Key specifier for IMKsmi


(Formats: 0–3,17,18)

IMKSMC Var K-Spec Key specifier for IMKsmc


(Formats: 0–3,17,18)

MK Method 1 h 00 = Common for EMV AES


01 = SECCOS AES
Refer to MK Method described in the table below.

MK Data Var h Data used with IMKsmx to derive MKsmx. The contents of
this field are dependent on the value of MK Method. Refer to
MK Method described in the table below.

MK Key Length 1 h 00 = Same as key length for IMKxx


01 = 16 byte
02 = 24 byte
03 = 32 byte
The validity of derivation has to be checked with respect to
derivation from both EMV and SECCOS.

SM Key Method 1 h SM Key Method


00 = EMV AES (EMV 4.3)
01 = SEECOS AES (SECCOS 7.1)
Refer to SM Key Method described in the table below.

SM Key Data Var h Data used with MKsmx to derive the session key SKsmx.
The contents of this field are dependent on the value of SM
Key Method.

PF Method 1 h PIN formatting method = 01, 02

PF Data Var h PIN formatting data

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 224
CHAPTER 4 Function Library

Request Length Type Description

PC Method 1 h PIN confidentiality method


00 = Formatting 01 / ECB
01 = Formatting 01 / CBC
02 = Formatting 00 / ECB
03 = Formatting 00/ CBC

PC Data Var h PIN confidentiality data


Zero-length field.

PI Method 1 h PIN integrity method

PI Data Var h PIN integrity data

MAC length 1 h 4-16 bytes MAC length

Response Length Type Description

EE2025 3 h Function Code

rc 1 h Return Code

New PIN data Var h Encrypted New PIN data

MAC Var h Message Authentication Code calculated using SKsmi.

MK Method The following values of MK Method are supported:

Value Implementation Reference

00 Common AES EMV 4.3 (Reference A [94-97])

01 SECCOS SECCOS 7.1 (Reference A [98] Section 8.4.1.2)

Value 00
Field Length Type Description

Derivation 16 h PAN || PAN Sequence No.


Data

Value 01
Field Length Type Description

Derivation 16-40 h Card Identification Number (CID)


Data

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 225
CHAPTER 4 Function Library

SM Key Method The following values of SM Key Method are supported:

Value Implementation Reference

00 EMV Common Session Key EMV 4.3 Section A1.3.1

01 SECCOS Session Key SECCOS 7.1 (Reference A [98]


Section 8.4.2)

Value 00
Field Length Type Description

R 16 h Random Number
Recommended value for EMV 4.3 AES; 2bytes of ATC appended with 14 bytes of 0x00

Value 01
Field Length Type Description

R 16 h Application Transaction Counter


Recommended value for SECCOS7.1; same as for EMV 4.3 AES

PF Method The following values of PF Method are supported:

Value Implementation Reference

01 ISO-1 [40]

02 ISO-2 [7], [40]

PF Data It is a variable-length field that contains zero or more fields incorporating the data required by
the specific PF methods.

Value 01 and 02
Field Length Type Description

ePPK(PIN) 8 h Encrypted PIN Block

PPK Var K-Spec Key specifier for PPK (Formats: 0 - 3, 10, 11, 12, 13, 14)

PF 1 h PIN Block Format (Formats: 10, 13)

ANB 6 d Account Number Block

The method to create cleartext PIN block is :


- Obtain PPK using PPK.
- Decrypt ePPK (PIN) using PPK to obtain cleartext ISO-0 or ISO-3 PIN block.
- Extract PIN from cleartext PIN block using PF and ANB.
- Create a cleartext ISO-1 or ISO-2 PIN block.

PC Method PC method 00 and 01 employs formatting method 01.


PC method 02 and 03 employs formatting method 00.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 226
CHAPTER 4 Function Library

Value 00 and 01 With this formatting method, a length byte is prepended to the 8-byte plaintext PIN block and 7
bytes of padding are appended, as follows:
X'08' || <8-byte plaintext PIN block> || X'80000000000000"
This produces a 16-byte result which is then encrypted using the identified encryption mode of
operation (ECB or CBC). The resultant is 16-byte New PIN Data field.

Value 02 and 03 ISO 9797-1 pad method 4 will be used with 8 byte PIN Block to make it 16 byte plaintext block
before encryption.
The 16-byte plaintext PIN block is encrypted using the encryption mode of operation (ECB or
CBC).

PI Method The following value of PI Method is supported:

Value Implementation Reference

05 ISO 9797-1 Mechanism-5 pad 4

PI Data It is a variable-length field that contains zero or more fields incorporating the data required by
the specific PI method.

Value 05
Field Length Type Description

Script-Data Position 2 h Script-Data Position

Script-Data Var h Script Data

Script-Data Position: For SC = 03, this points to the start byte in Script-Data where the
encrypted New PIN data will be copied. A Script-Data Position of zero points to the start of
Script-Data. This field is big Endean.
Script-Data: Used to calculate the MAC. If the last (or only) data Block is less than 8 bytes it is
padded to the right with a hexadecimal 80. If this data Block is still less than 8 bytes it is right
filled with 1 byte hexadecimal zeros until it is 8 bytes. The script data length must be greater
than or equal to the sum of offset and the length of encrypted New PIN data.

Processing Steps
1. The function derives two keys (Script ENC and Script MAC) to card specific keys and dynamize them for scripting
to session keys. Derive the ICC Encipherment Master Key (MKsmi) using the Issuer Master Key (IMKsmi) and MK
Data, according to the method specified in MK Method. Derive the ICC Encipherment Session Key (SKsmi) using
the derived MKsmi, SM Key Data according to the method specified in SM Key Method.
2. An ISO-PIN-Block-Format-2 PIN Block must be generated and AES-encrpyted with the Script ENC sessionkey. A
AES-CMAC must be computed with the Script MAC sessionkey.
3. The Card specific key is calculated as described in section A1.4, Option C of Reference A [95].
4. The Dynamic session key is calculated as described in section A1.3.1 of Reference A [95].
5. The encryption and mac computation is done as described in section 9.3.1.1 and 9.2.1.1 of Reference A [95].
6. If SC is 3, create the clear text PIN block according to the method specified in PF Method. Encrypt clear text PIN
block using SKsmc according to the encryption mode of operation specified in PC Method. Insert the resulting

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 227
CHAPTER 4 Function Library

cipher text in Script-Data (PI Data) at the position specified by Script-Data Position (PI Data).
7. Calculate the MAC for Script-Data using SKsmi.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 228
CHAPTER 4 Function Library

EMV-PIN-CHANGE-UNBLOCK-VISA (EF2015)
Request Length Type Description

EF2015 3 h Function Code

FM 1 h Function Modifier (FM=00/01)

P2 1 h Function Flag
00 = PIN UnBlock only
01 = PIN Change/UnBlock using PIN
02 = PIN Change/UnBlock using PIN

IMKSMI –Spec Var K-Spec Key specifier for IMKSMI


(Formats: 0–3, 11, 13, 17,18)

IMKSMC –Spec Var K-Spec Key specifier for IMKSMC


(Formats: 0–3, 11, 13, 17,18)

PAN Data 8 h Formatted PAN and PAN Sequence No.

ATC 2 h Application Transaction Counter.

PPK-Spec Var K-Spec Key specifier for PPK


(Formats: 0–3, 10, 11, 12, 13, 14, 17,18)

ePPK(PIN) 8 h Encrypted PIN Block (New PIN)

ANB 6 d Account Number Block

PVK-Spec Var K-Spec Key specifier for PVK


(Formats: 0–3,11, 12, 13, 14, 17,18)

Validation Data 8 h Validation Data

Offset 6 d Offset

PIN Length 1 h PIN Length (Current PIN)

Script-Data Position 2 h Script-Data Position

Script-Data Var h Script Data. Minimum length = 16 bytes

Response Length Type Description

EF2015 3 h Function Code

rc 1 h Return Code

New PIN Data Var h Encrypted New PIN Data

MAC 8 h Message Authentication Code

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 229
CHAPTER 4 Function Library

The purpose of this function is to provide the issuer with the capability either to unBlock the PIN or to simultaneously
change and unBlock the reference PIN.
This function calculates the MAC and if required the encrypted new PIN data.

FM = 00/01. See New PIN Data below for further information.

P2 Identifies the required processing:


00: PIN UnBlock only
01: PIN Change/UnBlock with PIN data generated using the current PIN
02: PIN Change/UnBlock with PIN data generated without using the current PIN

IMKSMI –Spec Issuer Master Key for secure message integrity key specifier.
Formats 0 - 3, 11, 13, 17 and 18 are accepted.

IMKSMC –Spec Issuer Master Key for secure message confidentiality key specifier.
Formats 0 - 3, 11, 13, 17 and 18 are accepted.

PAN Data Formatted PAN and PAN Sequence No.

ATC Application Transaction Counter (min = 01; max = FFFF)

The following three request fields are utilized in the calculation of the new PIN. These fields are only processed when
P2 = 01 or 02.

PPK-Spec Key specifier for PPK. Formats 0 - 3, 10, 11 12, 13, 14, 17, and 18 are accepted.

ePPK(PIN) Formatted PIN encrypted by the PPK.

ANB Account Number Block.

The following four request fields are utilized in the calculation of the current PIN. These fields are only processed
when P2 = 01.

PVK-Spec Key specifier for PVK. Formats 0 - 3 , 11, 12, 13, 14, 17, and 18 are accepted.

Validation Data Validation Data used to calculate the current PIN.

Offset This field consists of 12 digits of offset data. The significant digits are left justified in the field.

PIN length Current PIN length.

Script-Data Position For P2 = 01 or 02, this points to the start byte in Script-Data where the encrypted PIN data will
be copied. A Script-Data Position of zero points to the start of Script-Data. This field is big
endian.

Script-Data Used to calculate the MAC. If the last (or only) data Block is less than 8 bytes it is padded to
the right with a hexadecimal 80. If this data Block is still less than 8 bytes it is right filled with 1
byte hexadecimal zeros until it is 8 bytes. The script data length must be greater than or equal
to the sum of offset and the length of encrypted New PIN data.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 230
CHAPTER 4 Function Library

New PIN Data Encrypted New PIN Data.


If FM = 01 it is formatted as a standard Var field.
If FM = 00 then the field is only present when P2 = 01 or 02. The contents of the field when
present is pure data, 16 bytes in length.

MAC Message authentication code.

Processing Steps
1. Get the value of P2.
2. If the value of P2 is set to ‘01’ perform the following steps -
– Get the current reference PIN from the PVK-Spec, Validation Data, Offset and PIN length fields.
– Derive the ICC Data Encipherment Master Key (MKSMC) using the Issuer Master Key (IMKSMC) and PAN
data, according to the method specified in A1.4 of reference [5] of Mark II. Derive the ICC Data Encipherment
Session Key (SKSMC) using the derived MKSMC and ATC, according to the method specified in B.4 of
reference [9] of Mark II.
– Get the new reference PIN from the ePPK(PIN), PPK-Spec and ANB fields.
– A 16 hexadecimal digit PIN Block is formed as follows
- Take the 8 rightmost digits of the DK A and right justify them in a 16 digit field, zero fill the remaining 8 digits.
- Take a second 16 hexadecimal digit Block, form the unformatted ANSI PIN Block with the new PIN.
- Xor the 2 Blocks of data to form the PIN Block.
– Xor this PIN Block with the current PIN, where the current PIN is left justified in a 16 hexadecimal digit Block
and zero filled. The result is called the “delta PIN”.
– Encrypt the delta PIN with the Data Encipherment SKs according to B.3 (figure B-2) of reference [9] of Mark II
to generate the encrypted new PIN data.
3. If the value of P2 is set to ‘02’ perform the following steps -
– Derive the ICC Data Encipherment Master Key (MKSMC) using the Issuer Master Key (IMKSMC) and PAN
data, according to the method specified in A1.4 of Ref [5]. Derive the ICC Data Encipherment Session Key
(SKSMC) using the derived MKSMC and ATC, according to the method specified in B.4 of reference [9] of
Mark II.
– Get the new reference PIN from the ePPK(PIN), PPK-Spec and ANB fields.
– A 16 hexadecimal digit PIN Block is formed as follows
- Take the 8 rightmost digits of the DK A and right justify them in a 16 digit field, zero fill the remaining 8 digits.
- Take a second 16 hexadecimal digit Block, form an unformatted ANSI PIN Block with the new PIN.
- Xor the 2 Blocks of data to form the PIN Block.
– Encrypt this PIN Block with the Data Encipherment Session Keys according to B.3 (figure B-2) of reference [9]
of Mark II to generate the encrypted new PIN data.
4. Derive the ICC MAC Master Key (MKSMI) using the Issuer Master Key (IMKSMI) and PAN data, according to the
method specified in A1.4 of reference [5] of Mark II. Derive the ICC MAC Session Key (SKSMI) using the derived
MKSMI and ATC, according to the method specified in B.4 of reference [9] of Mark II .
5. Calculate the MAC according to B.2 (figure B-1) of reference [9] using SKSMI. If P2 is equal to ‘00’, the MAC data
is the Script-Data. If P2 is equal to ‘01’ or ‘02’, copy in the encrypted PIN data into the Script-Data at the position

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 231
CHAPTER 4 Function Library

specified by the ‘Script-Data position’ field, use this resulting data as the MAC data.
The function will fail with Error Code 78 if the format 10 PIN block is disabled.

Note:
- Request fields that are not required for processing are present but not used. They must be of
the correct length and format. If the field is a var field it must be a valid variable-length field, its
data portion will not be checked.
- When P2 = ‘00’ the response field ‘New PIN data’ is absent.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 232
CHAPTER 4 Function Library

EMV-SCRIPT-CRYPTO (EE2007)
Request Length Type Description

EE2007 3 h Function Code

FM 1 h Function Modifier (FM=00)

SC 1 h Select Code
01 = Encrypt Command Data Only
02 = Calculate MAC for entire command
03 = Encrypt and Calculate MAC

IMKSMI-Spec Var K-Spec Key specifier for IMKSMI


(Formats: 0–3, 11, 13, 17,18)

IMKSMC-Spec Var K-Spec Key specifier for IMKSMC


(Formats: 0–3, 11, 13, 17,18)

APANB 8 h Application PAN Block

RN 8 h Random Number

Text Var h Plain Text Data


(Must be a multiple of 8 bytes)

Offset 2 h Pointer into Script-Data

Script-Data Var h Script Data


(Must be a multiple of 8 bytes)

Response Length Type Description

EE2007 3 h Function Code

rc 1 h Return Code

eSMC(text) Var h Encrypted data.

MAC 8 h Message Authentication Code

This function performs the cryptographic processing required for Secure Messaging as defined in reference [1] of Mark
II. It is intended to be used to either:
• encrypt the command data;
• calculate a MAC for the command header and command data; or
• encrypt the command data and calculate a MAC for the command header and encrypted command data.

FM = 00. See eSMC(text) below for further information.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 233
CHAPTER 4 Function Library

SC Identifies the required processing:


1 : encrypt (CBC mode) command data only – in ‘Text’ field
2 : calculate a MAC for the entire command – ‘Script-Data field.
3 : Combine 1 and 2, i.e. encrypt the command data, insert the resultant ciphertext into the Script-
Data field and calculate a MAC.

IMKSMI –Spec Key specifier which provides access to the IMKSMI.


Formats 0 – 3, 11, 13, 17 and 18 are accepted.
Note: When SC = 1, this field is not used; it must be a valid variable-length field but its data
portion will not be checked to contain a valid key specifier.

IMKSMC –Spec Key specifier which provides access to the IMKSMC.


Formats 0 – 3, 11, 13, 17 and 18 are accepted.
Note: When SC = 2, this field is not used; it must be a valid variable-length field but its data
portion will not be checked to contain a valid key specifier.

APANB Application PAN Block as defined in reference [1] of Mark II. The HSM performs no checking on
the contents of this field.

RN ARQC/AAC/TC.

Text Script Command Data that is included in the sent Script to ICC.

Offset For SC = 3, points to the start byte in ‘Script-Data’ where the encrypted ‘Text’ will be copied. An
‘Offset’ of zero points to the start of Script-Data. Note this field is always big endian. i.e. the byte
order in this field is most significant byte first.

Script-Data Script Data is sent to ICC. The script data length must be greater than or equal to the sum of
offset and the length of encrypted New PIN data.

eSMC(text) Encrypted text in a variable length field. This is the same length as the specified input “Text” field.
If FM = 0 this is pure data and is not formatted as a Var field. If FM = 1 it is a standard Var field.

Processing Steps
1. If SC is 1 or 3, derive the ICC MAC Master Key (MKSMC) using the Issuer Master Key (IMKSMC) and APANB,
according to the method specified in 2.7.1 of reference [1] of Mark II. Derive the ICC MAC Session Key (SKSMC)
using the derived MKSMC and RN, according to the method specified in 2.7.2 of reference [1] of Mark II.
2. If SC is 2 or 3, derive the ICC Encipherment Master Key (MKSMI) using the Issuer Master Key (IMKSMI) and
APANB, according to the method specified in 2.7.1 of reference reference [1] of Mark II. Derive the ICC
Encipherment Session Key (SKSMI) using the derived MKSMI and RN, according to the method specified in 2.7.2 of
reference [1] of Mark II.
3. If SC is 1 or 3, encrypt Text using SKSMC – CBC mode. If SC is 3, insert the resulting ciphertext in Script-Data at
the position specified by Offset.
4. If SC is 2 or 3, calculate the MAC for Script-Data using SKSMI.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 234
CHAPTER 4 Function Library

EMV-SCRIPT-CRYPTO-EMV-2000 (EF2013)
Request Length Type Description

EF2013 3 h Function Code.

FM 1 h Function Modifier (FM=00,01)

SC 1 h Select Code
01 = Encrypt Command Data Only
02 = Calculate MAC for entire command
03 = Encrypt and Calculate MAC

IMKSMI –Spec Var K-Spec Key specifier for IMKSMI.


(Formats: 0–3, 11, 13, 17,18)

IMKSMC –Spec Var K-Spec Key specifier for IMKSMC.


(Formats: 0–3, 11, 13, 17,18)

PAN Data 8 h Formatted PAN and PAN Sequence No.

IV 16 h Initialization Vector

h 1 h Height of tree of keys

b 1 h Branch factor of tree of keys

ATC 2 h Application Transaction Counter

Mode 1 h Encryption Mode

Text Var h Plain text data.

Offset 2 h Offset

Script-Data Var h Script Data to be sent to ICC


Must be multiple of 8 Bytes

Response Length Type Description

EF2013 3 h Function Code

rc 1 h Return Code

eSKSMC(Text) Var h Encrypted data.

MAC 8 h Message Authentication Code

This function performs the cryptographic processing required for Secure Messaging, i.e. message authentication and /
or message encryption. It is intended to be used to either:
(i) just encrypt the command data;

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 235
CHAPTER 4 Function Library

(ii) just calculate a MAC for the command header and command data; or
(iii) both encrypt the command data and calculate a MAC for the command header and encrypted command data.
The ICC Session Key is derived using the method specified in the EMV2000 specification, s reference [5] of Mark II.

FM = 00/01. See eSKSMC(Text) below for further information.

SC Identifies the required processing:


1: encrypt command data only – in ‘Text’ field
2: calculate a MAC for the entire command – ‘Script-Data field.
3: Combine 1 and 2, i.e. encrypt the command data, insert the resultant ciphertext into the Script-
Data field and calculate a MAC.

IMKSMI –Spec Key specifier which provides access to the IMKSMI.


Formats 0 - 3, 11, 13, 17, and 18 are accepted.
Note: When SC = 01, this field is not used; it must be a valid variable-length field but its data portion
will not be checked to contain a valid key specifier.

IMKSMC –Spec Key specifier which provides access to the IMKSMC.


Formats 0 - 3, 11, 13, 17, and 18 are accepted.
Note: When SC = 02, this field is not used; it must be a valid variable-length field but its data portion
will not be checked for containing a valid key specifier.

PAN Data Formatted PAN and PAN Sequence No.

IV Initialization Vector

h Height for tree of keys

b Branch factor of tree of keys

ATC Application Transaction Counter (min = 01; max = FFFF)

Mode Encryption Mode. 00=ECB; 01=CBC

Text Script Command Data that is included in the sent Script to ICC. (Length must be a multiple of 8.)

Offset For SC = 3, points to the start byte in ‘Script-Data’ where the encrypted ‘Text’ will be copied. An
‘Offset’ of zero points to the start of Script-Data.
This field is big endian. i.e. the byte order in this field is most significant byte first.

Script-Data Script Data is sent to ICC. (Length must be a multiple of 8). The script data length must be greater
than or equal to the sum of offset and the length of encrypted New PIN data.

eSKSMC(Text) Encrypted text in a variable length field. This is the same length as the specified input “Text” field. If
FM = 00 this is pure data and is not formatted the same as a Var field. If FM = 01 it is a standard Var
field.

Processing Steps
1. If SC is 1 or 3, derive the ICC MAC Master Key (MKSMC) using the Issuer Master Key (IMKSMC) and PAN Data,
according to the method specified in A1.4 of reference [5] of Mark II.
2. Derive the ICC MAC Session Key (SKSMC) using the derived MKSMC, IV, h, b and ATC, according to the method
specified in A1.3 of reference [5] of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 236
CHAPTER 4 Function Library

3. If SC is 2 or 3, derive the ICC Encipherment Master Key (MKSMI) using the Issuer Master Key (IMKSMI) and PAN
Data, according to the method specified in A1.4 of reference [5] of Mark II.
4. Derive the ICC Encipherment Session Key (SKSMI) using the derived MKSMI, IV, h, b and ATC, according to the
method specified in A1.3 of reference [5] of Mark II.
5. If SC is 1 or 3, encrypt Text using SKSMC according to the encryption mode of operation specified in Encryption
Mode. If SC is 3, insert the resulting ciphertext in Script-Data at the position specified by Offset.
6. If SC is 2 or 3, calculate the MAC for Script-Data using SKSMI.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 237
CHAPTER 4 Function Library

EMV-SCRIPT-CRYPTO-MULTI (EE2020)
Request Length Type Description

EE2020 3 h Function Code

FM 1 h Function Modifier (FM=00)

SC 1 h Select Code
01 = Encrypt Command Data Only
02 = Calculate MAC for entire command
03 = Encrypt and Calculate MAC

IMKSMI Var K-Spec Key specifier for IMKSMI


(Formats: 0–3, 11, 13, 17,18)

IMKSMC Var K-Spec Key specifier for IMKSMC


(Formats: 0–3, 11, 13, 17,18)

MK Method 1 h 00 = Common
01 = SECCOS.

MK Data Var h Data used with IMKSMx to derive MKSMx . The contents of
this field are dependent on the value of MK Method.

SM Key Method 1 h SM Key Method = 02 – 06, 08

SM Key Data Var h Data used with MKSMx to derive the session key SKSMx .
The contents of this field are dependent on the value of SM
Key Method.

SM Method 1 h Encryption/MAC methods

Text Var h Plain text data.

Offset 2 h Offset

Script-Data Var h Script Data to be sent to ICC


(multiple of 8 bytes)

Response Length Type Description

EE2020 3 h Function Code

rc 1 h Return Code

eSKSMC(Text) Var h Encrypted data.

MAC 8 h Message Authentication Code calculated using SKSMI.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 238
CHAPTER 4 Function Library

This function performs the cryptographic processing required for Secure Messaging, i.e. message authentication and /
or message encryption. It is intended to be used to either:
(i) just encrypt the command data;
(ii) just calculate a MAC for the command header and command data; or
(iii) both encrypt the command data and calculate a MAC for the command header and encrypted command data.
The subscript SMx is used to denote both SMI and SMC.

FM =00

SC Identifies the required processing:


1: encrypt command data only – in ‘Text’ field
2: calculate a MAC for the entire command – ‘Script-Data field.
3: Combine 1 and 2, i.e. encrypt the command data, insert the resultant ciphertext into the Script-
Data field and calculate a MAC.

IMKSMI –Spec Key specifier which provides access to the IMKSMI.


Formats 0 - 3, 11, 13, 17, 18 are accepted.
Note: When SC = 01, this field is not used; it must be a valid variable-length field but its data
portion will not be checked to contain a valid key specifier.

IMKSMC –Spec Key specifier which provides access to the IMKSMC.


Formats 0 - 3, 11, 13, 17, 18 are accepted.
Note: When SC = 02, this field is not used; it must be a valid variable-length field but its data
portion will not be checked for containing a valid key specifier.

MK Method Methods for deriving the ICC Master Keys.(MKSMx )


00=Common ; 01=SECCOS.

MK Data Data used with IMKSMx to derive MKSMx . The contents of this field are dependent on the value of
MK Method.

SM Key Method Methods for deriving a Session Key(SKSMx ) from the MKSMx .

SM Key Data Data used with MKSMx to derive the session key SKSMx . The contents of this field are dependent
on the value of SM Key Method.

SM Method Encryption Mode. 00=ECB Encryption/Standard MAC; 01=CBC Encryption/Standard MAC;


02=ECB Encryption/NSICCS MAC
Note: The MAC is calculated as specified in 3.1.1.5 of [80].

Text Script Command Data that is included in the sent Script to ICC. (Length must be a multiple of 8.)

Offset For SC = 3, points to the start byte in ‘Script-Data’ where the encrypted ‘Text’ will be copied. An
‘Offset’ of zero points to the start of Script-Data.

Script-Data Script Data is sent to ICC. (Length must be a multiple of 8). The script data length must be greater
than or equal to the sum of Offset and the length of encrypted Text.

eSKSMC(Text) Encrypted text in a variable length field. This is the same length as the specified input Text field.

MAC Message Authentication Code.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 239
CHAPTER 4 Function Library

The function is sufficiently flexible to meet the requirements of all processing variations used in different EMV
implementations. The function therefore supports several methods in each processing step.
Each step involves a key, a method and some data, where the specific method determines the format of the related
data. In the first step an initial key is provided in a key specifier, but subsequent steps use a key from a previous step.
The function treats each processing step independently, so does not treat any combination of methods as invalid.
However many combinations of methods would not coincide with the processing performed by any issued EMV card.
See Usage of Methods for a table of the common combinations of methods.

SC The processing that the function must perform is specified in the SC request field, as follows:

Value Process

01 encrypt command data only – in ‘Text’ field

02 calculate a MAC for the entire command – ‘Script-Data field.

03 Combine 1 and 2, i. e. encrypt the command data, insert the resultant ciphertext
into the Script-Data field and calculate a MAC.

All fields in the request message are mandatory. Any field not used in a specific function call
must be in an appropriate format. That is, fixed length fields must have the required length and
variable-length fields must have a valid length. The content in an unused field is ignored,
therefore unused variable-length fields can have a length of zero.
If SC is 1 then IMKSMI is not used .
If SC is 2 then IMKSMC is not used.

MK Method The following values of MK Method are supported:

Value Implementation Reference

00 Common [1-8]

01 SECCOS [34]

Value 00
Field Length Type Description

PAN Data 6-16 h PAN || PAN Sequence No.

MK Data is a variable-length field that contains the concatenation of the PAN and PAN
Sequence Number. The function processing of the MK Data to form an 8-byte field is, in
summary, as follows:

Length Processing

<16 digits Left-padded with zeros.

=16 digits Used as is.

>16 digits Hashed and decimalized.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 240
CHAPTER 4 Function Library

Value 01
Field Length Type Description

CID 8-40 h Card Identification Number

SM Key Method The following values of SM Key Method are supported:

Value Implementation Reference

02 Tree of keys using ATC, IV, h and b EMV 4.0 [5]

03 Tree of keys using ATC. Fixed IV, h and b. EMV 4.1 CCD [35]

04 Xor using ATC AEIPS [37], J/Smart [38], VSDC


[39]

05 SKD Function SECCOS [34]

06 Encrypt ATC 6.1.2 of [48]

08 Derived from MK, TSN and ATC As in 3.2.1.3 of [80]

SM Key Data is a variable-length field that contains zero or more fields incorporating the data
required by the specific SM Key methods.

Value 02
Field Length Type Description

ATC 2 h Application Transaction Counter

IV 16 h Initialization Vector

h 1 h Height of tree of keys

b 1 h Branch factor of tree of keys

The SM Key Data length is 20.


SKSMx is derived from MKSMx and ATC using the parameters IV, h and b, as described in clause
A1.3.1 of [5].

Value 03
Field Length Type Description

ATC 2 h Application Transaction Counter

The SM Key Data length is 2.


SKSMx is derived from MKSMx and ATC using the parameters IV, h and b, as described in clause
A1.3.1 of [35]. The values of IV, h and b are fixed as required by CCD as described in Part IV of
[35].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 241
CHAPTER 4 Function Library

Value 04
Field Length Type Description

ATC 2 h Application Transaction Counter

The SM Key Data length is 2.


SKSMx is derived from MKSMx and ATC using an exclusive-OR operation, as described in clause
6.2.4.2 of [38].

Value 05
Field Length Type Description

R 8 h Random Number

The SM Key Data length is 8.


The random number (R) is combined with MKSMx to form SKSMx as described in clauses 2.7.2
and 2.8 of [7]. The identical transformation is also described in the SECCOS specifications [34]
and in the EMVCo Bulletin No 46 [36].

Note: Method 05 is similar to method 01 (in EE2019) but is more flexible.

Value 06
Field Length Type Description

ATC 2 h Application Transaction Counter

ATC is padded and encrypted using MKSMI or MKSMC to form a double-length SKSMI or SKSMC
as described in 11.1.3.1 of [48].

Note: Derivation of a single-length session key will not be supported.

Value 08
Field Length Type Description

TSN 4 h Transaction Serial Number

ATC 2 h Application Transaction Counter

Derived from MK, TSN and ATC as in clause 3.2.1.3 of [80].

Processing steps
1. If SC is 1 or 3, derive the ICC Encipherment Master Key (MKSMC) using the Issuer Master Key (IMKSMC) and MK
Data according to the method specified in MK Method. Derive the ICC Encipherment Session Key (SKSMC) using
the derived MKSMC and SM Key Data according to the method specified in SM Key Method.
2. If SC is 2 or 3, derive the ICC MAC Master Key (MKSMI) using the Issuer Master Key (IMKSMI) and MK Data,
according to the method specified in MK Method. Derive the ICC MAC Session Key (SKSMI) using the derived
MKSMI and SM Key Data according to the method specified in SM Key Method.
3. If SC is 1 or 3, encrypt Text using SKSMC according to the encryption mode of operation specified in SM Method
(00-ECB, 01-CBC, 02-ECB). If SC is 3, insert the resulting ciphertext in Script-Data at the position specified by
Offset.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 242
CHAPTER 4 Function Library

4. If SC is 2 or 3, calculate the MAC for Script-Data using SKSMI. For SM Method 02 MAC would be calculated as
described in appendix C of [80].

Usage of Methods
The following table identifies the common combinations of methods. A call to the function would typically use the
methods identified across a single row of the table.

Implementation Methods

MK SM Key SM

AEIPS 00 04 01

J/Smart, VSDC 00 04 00

EMV 4.0 / 4.1 00 02 00 or 01

EMV 4.1 CCD 00 03 00 or 01

EMV 4.1 + SU Bulletin 00 05 00 or 01


46

SECCOS 01 05 01

NSICCS 00 08 02

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 243
CHAPTER 4 Function Library

EMV-SCRIPT-CRYPTO-MULTI-AES (EE2024)
This function is used to encrypt and authenticate data for AES implementation of ICC cards for post issuance script
updates.

Request Length Type Description

EE2024 3 h Function Code

FM 1 h Function Modifier (FM=00)

SC 1 h Select Code
01 = Encrypt Command Data Only
02 = Calculate MAC for entire command
03 = Encrypt and Calculate MAC

IMKsmi Var K-Spec Key specifier for IMKsmi


(Formats: 0–3,17,18)

IMKsmc Var K-Spec Key specifier for IMKsmc


(Formats: 0–3,17,18)

MK Method 1 h 00 = Common for EMV AES (EMV 4.3)


01 = SECCOS AES (SECCOS 7.1)
Refer to MK Method described in the table below.

MK Data Var h Data used with IMKsmx to derive MKsmx.


The contents of this field are dependent on the value of MK
Method.

MK Key length 1 h 00 = Same as key length for IMKxx


01 = 16 byte
02 = 24 byte
03 = 32 byte
The validity of derivation has to be checked with respect to
derivation from both EMV and SECCOS.

SM Key Method 1 h SM Key Method


00 = EMV AES (EMV 4.3)
01 = SEECOS AES (SECCOS 7.1)
Refer to SM Key Method described in the table below.

SM Key Data Var h Data used with MKsmx to derive the session key SKsmx.
The contents of this field are dependent on the value of SM
Key Method.

SM Method 1 h Encryption/MAC method


00 = ECB with ISO9797-1 Mechanism 5 Pad 4
01 = CBC with ISO9797-1 Mechanism 5 Pad 4

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 244
CHAPTER 4 Function Library

Request Length Type Description

MAC length 1 h 4-16 bytes MAC length

Text Var h Plain text data.


Text block to be of multiple of 16 bytes.

Offset 2 h For SC = 3, points to the start byte in ‘Script-Data’ where


the encrypted ‘Text’ will be copied.
An ‘Offset’ of zero points to the start of Script-Data.

Script-Data Var h Script Data to be sent to ICC.


The script data length must be greater than or equal to the
sum of Offset and the length of encrypted Text.

Response Length Type Description

EE2024 3 h Function Code

rc 1 h Return Code

eSKSMC(Text) Var h Encrypted data

MAC Var h Message Authentication Code calculated using SKsmi.

MK Method The following values of MK Method are supported:

Value Implementation Reference

00 Common AES EMV 4.3 (Reference A [94-97])

01 SECCOS SECCOS 7.1 (Reference A [98] section 8.4.1.2)

Value 00
Field Length Type Description

Derivation 16 h PAN || PAN Sequence No.


Data

Value 01
Field Length Type Description

Derivation 16-40 h Card Identification Number (CID)


Data

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 245
CHAPTER 4 Function Library

SM Key Method The following values of SM Key Method are supported:

Value Implementation Reference

00 SKD Function EMV 4.3 (Reference A [95] section A1.3.1)

01 SKD SECCOS 7.1 (Reference A [98] section 8.4.2)

Processing Steps
• IMKxx will be used along with MK data length and method to derive card master/unique key. Refer section A1.4,
option C of Reference A [95] for EMV; Refer section 8.4.1.2 of Reference A [98] for SECCOS 7.1.
• Card Master Key along with AC key data and AC key method to be used to derive Session key. Refer section
A1.3.1 of Reference A [95] for EMV and refer chapter 8 of Reference A [98] for SECCOS.
• Session Key will be used over AC data and/or ARPC data to compute cryptograms (Refer section A1.2.2 of
Reference A [95]).
• The encryption and mac computation is done as described in section 9.3.1.1 and 9.2.1.1 of Reference A [95]. This
corresponds to section 13.3 and 13.4 of Reference A [98].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 246
CHAPTER 4 Function Library

EMV-SCRIPT-CRYPTO-VISA (EF2014)
Request Length Type Description

EF2014 3 h Function Code

FM 1 h Function Modifier (FM=00,01)

SC 1 h Select Code
01 = Encrypt Command Data Only
02 = Calculate MAC for entire command
03 = Encrypt and Calculate MAC

IMKSMI –Spec Var K-Spec Key specifier for IMKSMI.


(Formats: 0–3, 11, 13, 17,18)

IMKSMC –Spec Var K-Spec Key specifier for IMKSMC.


(Formats: 0–3, 11, 13, 17,18)

PAN Data 8 h Formatted PAN and PAN Sequence No.

ATC 2 h Application Transaction Counter.

Text Var h Plain text data.


Must be multiple of 8 Bytes

Offset 2 h Offset

Script-Data Var h Script Data to be sent to ICC.


Must be multiple of 8 Bytes

Response Length Type Description

EF2014 3 h Function Code

rc 1 h Return Code

eSKSMC(Text) Var h Encrypted data

MAC 8 h Message Authentication Code

This function performs the cryptographic processing required for Secure Messaging, i.e. message authentication and /
or message encryption. It is intended to be used to either: (i) just encrypt the command data; (ii) just calculate a MAC
for the command header and command data; or (iii) both encrypt the command data and calculate a MAC for the
command header and encrypted command data.
The ICC session keys are derived using the method specified by Visa in reference [8] of Mark II.

FM = 00/01. See eSKSMC(Text) below for further information.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 247
CHAPTER 4 Function Library

SC Identifies the required processing:


1 : encrypt command data only (ECB mode) – in ‘Text’ field
2 : calculate a MAC only - for the entire command in Script-Data field.
3 : Combine 1 and 2, i.e. encrypt the command data, insert the resultant ciphertext into the Script-
Data field and calculate a MAC.

IMKSMI –Spec Key specifier which provides access to the IMKSMI.


Formats 0 - 3, 11, 13, 17 and 18 are accepted.
Note: When SC = 01, this field is not used; it must be a valid variable-length field but its data
portion will not be checked to contain a valid key specifier.

IMKSMC –Spec Key specifier which provides access to the IMKSMC.


Formats 0 - 3, 11, 13, 17 and 18 are accepted.
Note: When SC = 02, this field is not used; it must be a valid variable-length field but its data
portion will not be checked to contain a valid key specifier.

PAN Data Formatted PAN and PAN Sequence No.

ATC Application Transaction Counter (min = 01, max = FFFF)

Text Script Command Data that is included in the sent Script to ICC. (Length must be a multiple of 8.)

Offset For SC = 03, points to the start byte in ‘Script-Data’ where the encrypted ‘Text’ will be copied. An
‘Offset’ of zero points to the start of Script-Data.
This field is big endian. i.e. the byte order in this field is most significant byte first.

Script-Data Script Data is sent to ICC. (Length must be a multiple of 8). The script data length must be greater
than or equal to the sum of offset and the length of encrypted New PIN data.

eSKSMC(Text) Encrypted text in a variable length field. This is the same length as the specified input “Text” field.
If FM = 00 this is pure data and is not formatted the same as a Var field. If FM = 01 it is a standard
Var field.

Processing Steps
1. If SC is 1 or 3, derive the ICC MAC Master Key (MKSMC) using the Issuer Master Key (IMKSMC) and PAN Data,
according to the method specified in A1.4 of reference [5] of Mark II. Derive the ICC MAC Session Key (SKSMC)
using the derived MKSMC and ATC, according to the method specified in B.4 of reference [8] of Mark II.
2. If SC is 2 or 3, derive the ICC Encipherment Master Key (MKSMI) using the Issuer Master Key (IMKSMI) and PAN
Data, according to the method specified in A1.4 of reference [5]. Derive the ICC Encipherment Session Key
(SKSMI) using the derived MKSMI and ATC, according to the method specified in B.4 of reference [8] of Mark II.
3. If SC is 1 or 3, encrypt Text using SKSMC – ECB mode. If SC is 3, insert the resulting ciphertext in Script-Data at
the position specified by Offset.
4. If SC is 2 or 3, calculate the MAC for Script-Data using SKSMI.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 248
CHAPTER 4 Function Library

EMV-VERIFY-AC-EMV-2000 (EF2010)
Request Length Type Description

EF2010 3 h Function Code.

FM 1 h Function Modifier = 00, 01 or 04

IMKAC-Spec Var K-Spec Key specifier for IMKAC


(Formats: 0–3, 11, 13, 17,18)

PAN Data 8 h Formatted PAN and PAN Sequence No.

IV 16 h Initialization Vector

h 1 h Height for tree of keys.

B 1 h Branch factor of tree of keys.

ATC 2 h Application Transaction Counter

AC/ CAP Token 8/Var h If FM = 00 this field contains the 8-byte Application
Cryptogram (AC).
If FM = 01 or 04 the field contains the variable length CAP
token

AC Data Var h Data used in the calculation of the Application Cryptogram.


Must be a multiple of 8 bytes.

Bitmap Var K-Spec Only available when FM = 01 or 04


Authenticate field from IPB
(Formats 0 - 3, 19).

Transaction Data Var h Only present when FM = 04


Data signed to produce CAP Token.
Must be a multiple of eight bytes.

Response Length Type Description

EF2010 3 h Function Code

rc 1 h Return Code

This function verifies an Application Cryptogram (TC, AAC, ARQC) that has been produced by an ICC.
The ICC Session Key is derived using the method specified in the EMV2000 specification in reference [5] of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 249
CHAPTER 4 Function Library

FM = 00.
When the FM is set to 00 the Bitmap fields are not included.
When the FM is set to 01 or 04, the Bitmap field is included.
The setting of this field also affects the AC/CAP Token and the Transaction Data fields. For details
see the descriptions in the table above.

IMKAC –Spec Key specifier which provides access to the IMKAC.


Formats 0 – 3, 11, 13, 17 and 18 are accepted.

PAN Data Formatted PAN and PAN Sequence No.

IV Initialization Vector

h Height for tree of keys

b Branch factor of tree of keys

ATC Application Transaction Counter (min = 01; max = FFFF)

AC Application Cryptogram (TC, AAC or ARQC) Calculated by ICC as defined in reference [1] of Mark
II. This field is 8 bytes in length. This field is present when FM = 00.

CAP Token CAP Token (AAC or ARQC) that has been produced by an EMV ICC. This field is a Var field.
This field is present when FM = 01 or 04. When the function is used with FM = 01 or 04 support is
provided for a variable-length Application Cryptogram created as indicated by the set bits in the
Bitmap field. This modification supports the Chip Authentication Program as specified in reference
[31] of Mark II. The CAP Token field contains the bits of the Application Cryptogram to be verified as
indicated by the Bitmap (see below). If the length (in bits) of this field is greater than the number of
bits that are set to 1 in the Bitmap field, then the significant bits must be left-justified and padded to
the right with zero bits.

AC Data Data used in the calculation of the Application Cryptogram. Must be a multiple of eight bytes).

Bitmap The Bitmap field is a key specifier field. It specifies an HSM stored or host stored portion of the
Issuer Proprietary Bitmap (IPB) that relates to the Shortened AC. This field is not available when FM
is set to 00. The number of bits set must be ≤16 and ≥ 64 (note: there is no requirement that the
number of bits set is a multiple of 8).

Transaction Data signed to produce CAP Token. Only present when FM = 04. Must be a multiple of eight bytes.
Data

See EMV Function Examples for examples of request and response packages for this function.

Processing Steps
1. Derive the ICC Master Key (MKAC) using the Issuer Master Key and PAN Data, according to the method specified
in A1.4 of reference [5] of Mark II.
2. Derive the ICC Session Key (SK) using the derived MKAC, IV, h, b and ATC, according to the method specified in
A1.3 of reference [5] of Mark II.
3. Calculate the Application Cryptogram using SK and the data provided in AC Data, according to the method
specified in A1.2 of reference [5] of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 250
CHAPTER 4 Function Library

4. When FM=01, select only the bits indicated by the set bits in the bitmap to generate the reference Application
Cryptogram.
5. Compare the values of the calculated Application Cryptogram and that supplied in AC.

Function usage
The function is used during on-line transactions and batch processing of off-line transactions, or during card initialization
to test a card.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 251
CHAPTER 4 Function Library

EMV-VERIFY-AC-GEN-ARPC (EE2018)
Request Length Type Description

EE2018 3 h Function Code

FM 1 h Function Modifier (FM=00)

Action 1 h 01 = Verify AC only.


02 = Generate ARPC only.
03 = Verify AC and generate ARPC.

IMKAC Var K-Spec Key specifier for IMKAC


(Formats: 0–3, 11, 13, 17,18)

MK Method 1 h 00 = Common 01 = SECCOS.

MK Data Var h Data used with IMKAC to derive MKAC. The contents of this
field are dependent on the value of MK Method.

AC Key Method 1 h AC Key Method = 00-06 and 08, see details

AC Key Data Var h Data used with MKAC to derive the session key SKAC. The
contents of this field are dependent on the value of AC Key
Method.

AC Method 1 h AC Method = 00 - 03, see details.

AC Data Var h Data on which the AC is calculated.

AC 8 h Application Cryptogram - ARQC, TC or AAC.

ARPC Key Method 1 h 00 = same key as derived for AC.


01 = key = MKAC.

ARPC Key Data Var h Zero-length field.

ARPC Method 1 h 01 = Method 1


02 = Method 2

ARPC-Data Var h Data on which the ARPC is calculated.

Response Length Type Description

EE2018 3 h Function Code

rc 1 h Return Code

ARPC Var h 4 or 8 byte ARPC Or zero-length field.

This function can be used to

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 252
CHAPTER 4 Function Library

• verify an Application Cryptogram (AC),


• generates an ARPC
• both verify an Application Cryptogram (AC) and generate an ARPC
The AC can be an ARQC, a TC or an AAC.
The function is sufficiently flexible to meet the requirements of all processing variations used in different EMV
implementations. The function therefore supports several methods (see Usage of Methods) in each processing step.
Each step involves a key, a method and some data, where the specific method determines the format of the related
data. In the first step an initial key is provided in a key specifier, but subsequent steps use a key from a previous step.
The function treats each processing step independently, so does not treat any combination of methods as invalid.
However many combinations of methods would not coincide with the processing performed by any issued EMV card.
See Usage of Methods for a table of the common combinations of methods.

Action The processing that the function must perform is specified in the Action request field, as
follows:

Value Action

01 Verify AC only

02 Generate ARPC only

03 Verify AC and Generate ARPC

All fields in the request message are mandatory. Any field not used in a specific function call
must be in an appropriate format. That is, fixed length fields must have the required length and
variable-length fields must have a valid length. The content in an unused field is ignored,
therefore unused variable-length fields can have a length of zero.

MK Method The following values of MK Method are supported:

Value Implementation Reference

00 Common [1-8]

01 SECCOS [34]

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 253
CHAPTER 4 Function Library

Value 00
Field Length Type Description

PAN Data 6-16 h PAN || PAN Sequence No.

MK Data is a variable-length field that contains the concatenation of the PAN and PAN
Sequence Number. The function processing of the MK Data to form an 8-byte field is, in
summary, as follows:

Length Processing

<16 digits Left-padded with zeros.

=16 digits Used as is.

>16 digits Hashed and decimalized.

Value 01
Field Length Type Description

CID 8-32 h Card Identification Number

AC Key Method The following values of AC Key Method are supported:

Value Implementation Reference

00 SKAC = MKAC VSDC 1.3.2 [39]

01 SKD function using ATC and UN M/Chip 2.1 [31], SECCOS [34]

02 Tree of keys using ATC, IV, h and b EMV 4.0 [5]

03 Tree of keys using ATC. Fixed IV, h and b. EMV 4.1 CCD [35]

04 Xor using ATC AEIPS [37], J/Smart [38] ,

05 SKD Function SECCOS [34]

06 Encrypt ATC As in 6.1.2 of [48]

08 Derived from MK, TSN and ATC As in 3.2.1.3 of [80]

Value 00
Field Length Type Description

Null 0

Value 01
Field Length Type Description

ATC 2 h Application Transaction Counter

UN 4 h Unpredictable Number

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 254
CHAPTER 4 Function Library

Value 02
Field Length Type Description

ATC 2 h Application Transaction Counter

IV 16 h Initialization Vector

h 1 h Height of tree of keys

B 1 h Branch factor of tree of keys

Value 03
Field Length Type Description

ATC 2 h Application Transaction Counter

Value 04
Field Length Type Description

ATC 2 h Application Transaction Counter

Value 05
Field Length Type Description

R 8 h Random Number

The random number (R) is combined with MKAC to form SKAC as described in clauses 2.7.2
and 2.8 of [7]. The identical transformation is also described in the SECCOS specifications and
in the EMVCo Bulletin No 46.

Note: Method 05 is similar to method 01, but is more flexible.

Value 06
Field Length Type Description

ATC 2 h Application Transaction Counter

ATC is padded and encrypted using MKAC to form a double-length SKAC as described in
11.1.3.1 of [48].

Note: Derivation of a single-length session key will not be supported.

Value 08
Field Length Type Description

TSN 4 h Transaction Serial Number

ATC 2 h Application Transaction Counter

Derived from MK, TSN and ATC as in clause 3.2.1.3 of [80]

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 255
CHAPTER 4 Function Library

AC Method The following values of AC Method are supported:

Value ISO/IEC 9797-1 Reference


Alternatives

Algorithm Pad Method

00 1 1

01 1 2 EMV [5]

02 3 1 VSDC [39], AEIPS [37], J/Smart [38]

03 3 2 EMV [5], M/Chip [31], SECCOS [34]

ARPC Key Method The following values of ARPC Key Method are supported:

Value Implementation Reference

00 SKARPC = SKAC All except M/Chip 2.1

01 SKARPC = MKAC M/Chip 2.1 [31]

ARPC Method The following values of ARPC Method are supported:

Value Implementation Reference

01 Method 1 All

02 Method 2 EMV 4.1 [35]

Value 01
Field Length Type Description

ARC 2 h Authorization Response Code

Value 02
Field Length Type Description

CSU 4 h Card Status Update

PAD 0-8 h Proprietary Application Data

Usage of Methods
The following table is a matrix of the common combinations of methods. A call to the function would typically use the
methods identified across a single row of the table.

Implementation Methods

MK AC Key AC ARPC Key ARPC

AEIPS 00 00 02 00 01

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 256
CHAPTER 4 Function Library

Implementation Methods

MK AC Key AC ARPC Key ARPC

CUPIC 00 06 03 00 01

EMV 4.0 00 02 01, 03 00 01

EMV 4.1 00 02, 03 01, 03 00 01, 02

EMV 4.1 CCD 00 03 03 00 02

EMV 4.2 00 01 01, 03 00 01, 02

EMV 4.2 CCD 00 01 03 00 02

J/Smart 00 04 02 00 01

M/Chip 2.1 00 01 03 01 01

NSICCS 00 08 03 00 01

SECCOS 01 01 03 00 01

VSDC 1.3.2 00 00 02 00 (or 01) 01

M/Chip 4.0 As M/Chip 2.1 or EMV 4.0

VSC 1.4.0 As VSDC 1.3.2 or EMV 4.0

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 257
CHAPTER 4 Function Library

EMV-VERIFY-AC-GEN-ARPC-AES (EE2022)
This function is used to generate AC and/or ARPC and verify AC for AES implementation of ICC cards.

Request Length Type Description

EE2022 3 h Function Code

FM 1 h Function Modifier (FM=00)

Action 1 h 01 = Verify AC only


02 = Generate ARPC only
03 = Verify AC and generate ARPC

IMKac Var K-spec Key specifier for IMKac


(Formats: 0–3,17,18)

MK Method 1 h 00 = Common for EMV AES (EMV 4.3)


01 = SECCOS AES (SECCOS 7.1)
Refer to MK Method described in the table below.

MK Data Var h Data used with IMKac to derive MKac.


The contents of this field are dependent on the value of MK
Method.

MK Key length 1 h 00 = Same as key length for IMKxx


01 = 16 byte
02 = 24 byte
03 = 32 byte
The validity of derivation has to be checked with respect to
derivation from both EMV and SECCOS.

AC Key Method 1 h AC Key Method


00 = EMV AES (EMV 4.3)
01 = SEECOS AES (SECCOS 7.1)
Refer to AC Key Method described in the table below.

AC Key Data Var h Data used with MKac to derive the Session key SKac.
The contents of this field are dependent on the value of AC
Key Method.

AC Method 1 h AC Method = 05

AC Data Var h Data on which the AC is calculated

AC Var h Application Cryptogram - ARQC, TC or AAC


This shall be 8 byte for AC Key Method = 00, 01

ARPC Key Method 1 h 00 = same method used for AC key derivation.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 258
CHAPTER 4 Function Library

Request Length Type Description

ARPC Key Data Var h Zero length field

ARPC Method 1 h 01 = Method 1


02 = Method 2
Referred in section 8.2 of Reference A [95] with respect to
AES.

ARPC Data Var h Data on which the ARPC is calculated.


For ARPC Method 1, the data should be length 8 byte
(inclusive of ARC).
For EMV 4.3 AES, method 1 will be 2 byte ARC
concatenated with 6 bytes of 0x00.
For ARPC Method 2, the data can be any length except that
it will not contain ARQC. ARQC has to be used from AC
field. This ARQC will be prepended with the ARPC data for
ARPC calculation.

Response Length Type Description

EE2022 3 h Function Code

rc 1 h Return Code

ARPC Var h ARPC or zero-length field

MK Method The following values of MK Method are supported:

Value Implementation Reference

00 Common AES EMV 4.3 (Reference A [94-97])

01 SECCOS SECCOS 7.1 (Reference A [98] section 8.4.1.2)

Value 00
Field Length Type Description

Derivation 16 h PAN || PAN Sequence No.


Data

Value 01
Field Length Type Description

Derivation 16-40 h Card Identification Number (CID)


Data

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 259
CHAPTER 4 Function Library

AC Key Method The following values of AC Key Method are supported:

Value Implementation Reference

00 EMV Common Session Key EMV 4.3 (Reference A [95]


section A1.3.1)

01 SECCOS Session Key SECCOS 7.1 (Reference A [98]


section 8.4.2)

Value 00
Field Length Type Description

R 16 h Random Number
Recommended value for EMV 4.3 AES; 2bytes of ATC appended with 14 bytes of 0x00

Value 01
Field Length Type Description

R 16 h Application Transaction Counter


Recommended value for SECCOS7.1; same as for EMV 4.3 AES

AC Method The following values of AC Method are supported:

Value ISO/IEC 9797-1 Reference


Alternatives

Algorithm Pad Method

05 5 4 EMV 4.3 (Reference A [94-97])

Processing Steps
• IMKxx will be used along with MK data length and method to derive card master/unique key. For EMV, refer to the
section A1.4, option C of Reference A [95]. For SECCOS, refer to the section 8.4.1.2 of Reference A [98].
• Card Master Key along with AC key data and AC key method to be used to derive Session key. For EMV, refer to
the section A1.3.1 of Reference A [95] and for SECCOS, refer to chapter 8 of Reference A [98].
• Session Key will be used over AC data and/or ARPC data to compute cryptograms. Refer to the section A1.2.2 of
Reference A [95].
• Compute an ARQC as described in section 8.1.2 of Reference A [95] to verify the Transaction ARQC. Then an
ARPC must be computed as described in section 8.2.2 of Reference A [95].
• For ARPC computation, refer to section 8.2.1 of Reference A [95] for method 1 and 8.2.2 of Reference A [95] for
method 2 but with respect to AES.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 260
CHAPTER 4 Function Library

EMV-VERIFY-AC-VISA (EF2011)
Request Length Type Description

EF2011 3 h Function Code

FM 1 h Function Modifier (FM = 00 or 01)

IMKAC-Spec Var K-Spec Key specifier for Issuer Master Key.


(Formats: 0–3, 11, 13, 17,18)

PAN Data 8 h PAN Sequence No.

AC/Shortened AC 8/Var h Application Cryptogram/ Shortened Application Cryptogram


When FM = 00 this field contains the AC and is 8 bytes in
length;
When FM = 01 this field contains the Shortened AC and is a
Var field)

AC Data Var h Application Cryptogram Data


(Must be a multiple of eight bytes).

Bitmap Var K-Spec Only available when FM = 01


Authenticated field from IPB
(Formats: 0–3, 19)

Response Length Type Description

EF2011 3 h Function Code

rc 1 h Return Code

This function verifies an Application Cryptogram (TC, AAC, ARQC) that has been produced by an ICC.
The ICC Master Key is used directly to calculate the Application Cryptogram, as specified by Visa in reference [8].

FM When Function Modifier = 00 the Bitmap field is not included.


When Function Modifier = 01 the Bitmap field is included.

IMKAC –Spec Key specifier which provides access to the IMKAC.


Formats 0 - 3, 11, 13, a7 and 18 are accepted.

PANData Formatted PAN and PAN Sequence No.

AC Application Cryptogram (TC, AAC or ARQC) Calculated by ICC as defined in reference [1] of Mark
II. This field is 8 bytes in length. This field is present when FM = 00.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 261
CHAPTER 4 Function Library

Shortened AC Shortened Application Cryptogram (AAC or ARQC) that has been produced by an EMV ICC. This
field is a Var field. This field is present when FM=01.When the function is used with FM = 01
support is provided for a variable-length Application Cryptogram created as indicated by the set bits
in the Bitmap field. This modification supports the Chip Authentication Program as specified in
reference [31] of Mark II. The Shortened AC field contains the bits of the Application Cryptogram to
be verified as indicated by the Bitmap (see below). If the length (in bits) of this field is greater than
the number of bits that are set to 1 in the Bitmap field, then the significant bits must be left-justified
and padded to the right with zero bits.

AC Data Data used in the calculation of the Application Cryptogram (must be a multiple of eight bytes).

Bitmap The Bitmap field is a key specifier field. It specifies a HSM stored or host stored portion of the Issuer
Proprietary Bitmap (IPB) that relates to the Shortened AC. This field is not available when FM is set
to 00. The number of set bits must be ≤16 and ≥ 64 (note: there is no requirement that the number of
set bits is a multiple of 8).

See EMV Function Examples for examples of request and response packages for this function.

Processing Steps
1. Derive the ICC Master Key (MKAC) using the Issuer Master Key and supplied PAN Data, according to the method
specified in A1.4 of reference [5] of Mark II.
2. Calculate the Application Cryptogram using MKAC and the data provided in AC Data, according to the method
specified in A1.2 of reference [5] of Mark II.
3. When FM = 01, select only the bits indicated by the set bits in the bitmap to generate the reference Application
Cryptogram.
4. Compare the values of the calculated Application Cryptogram and that supplied in AC.

Function usage
The function is used during online transactions and batch processing of offline transactions, or during card initialization
to test a card.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 262
CHAPTER 4 Function Library

ENCIPHER-2 (EE0800)
Request Length Type Description

EE0800 3 h Function Code

FM 1 h Function Modifier (FM=00)

DPK-Spec Var K-Spec Key specifier for DPK


(Formats: 0–3, 10, 11, 12, 13, 14, 17,18, 20, 50, 51)

CM 1 h Cipher Mode
00 = ECB
01 = CBC

ICV 8 h Input Chaining Value

Data Var h Data to be enciphered

Response Length Type Description

EE0800 3 h Function Code

rc 1 h Return Code

OCV 8 h Output Chaining Value

eDPK(Data) Var h Ciphertext

This function enciphers the supplied data using a host-stored or HSM-Stored session key (DPK) supplied within a key
specified.
The function performs single-DES or triple-DES encipherment, as determined by the length of the supplied key, and
supports both Electronic Code Book (ECB) and Cipher Block Chaining (CBC) modes of operation. The function
supports encipherment of large messages (or data files) either by one call to the function or by multiple calls. For CBC
encipherment using multiple calls, chaining values must be maintained between calls.

DPK-Spec Key specifier incorporating a single or double or triple length host-stored or HSM-stored DPK.

CM Specifies the mode of operation for the encipherment:


0 - Electronic Code Book (ECB)
1 - Cipher Block Chaining (CBC)

ICV Chaining value for CBC encipherment. For encipherment of a message or file using one call, or on the
first call of a multi-call encipherment, this field should be set to the required value of the Initialization
Vector (IV). On subsequent calls of a multi-call encipherment, the field should be set to the value of the
OCB provided by the previous call.
For ECB encipherment, this field will be ignored.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 263
CHAPTER 4 Function Library

OCV Chaining value for CBC encipherment. For encipherment of a message or file using a multi-call
encipherment, the value in this field should be used as the ICV in the next call.
For ECB encipherment, this field will be set to zero.

Data Plaintext data to be enciphered. Must be a multiple of 8 bytes long.

Note:
- This function supercedes functions 80, 82.
- When the function modifier is missing, the function returns error code 24, missing function
code.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 264
CHAPTER 4 Function Library

ENCIPHER-3 (EE0804)
Request Length Type Description

EE0804 3 h Function Code

FM 1 h Function Modifier (FM=00)

DPK-Spec Var K-Spec Key specifier for DPK


(Formats: 0–3, 10, 11, 12, 13, 14, 16, 17,18)

CM 1 h Cipher Mode
00 = ECB
01 = CBC

ICV Var h Input Chaining Value

Data Var h Data to be enciphered

Response Length Type Description

EE0804 3 h Function Code

rc 1 h Return Code

OCV Var h Output Chaining Value

eDPK(Data) Var h Ciphertext

This function enciphers the supplied Data using a session key (DPK) supplied within a key specifier.
The function performs DES or SEED encryption, as determined by the DPK key specifier and supports both Electronic
Code Book (ECB) and Cipher Block Chaining (CBC) modes of operation. The function supports encipherment of large
messages (or data files) either by one call to the function or by multiple calls. For CBC encipherment using multiple
calls, chaining values must be maintained between calls.

FM = 00. Must be set to zero.

DPK-Spec Key specifier incorporating a single- or double or triple-length host-stored or HSM –stored DPK.
This field determines the encryption method.
DES - formats 00 – 03 (DES/TDES keys only), 10, 11, 12, 13, 14, 17 and 18
SEED- formats 00 – 03 (SEED keys only), 16, 17, and 18.

CM Specifies the mode of operation for the encipherment for the Response eDPK(Data):
0 - Electronic Code Book (ECB)
1 - Cipher Block Chaining (CBC)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 265
CHAPTER 4 Function Library

ICV Chaining value for CBC encipherment. For encipherment of a message or file using one call, or on the
first call of a multi-call encipherment, this field should be set to the required value of the Initialization
Vector (IV). On subsequent calls of a multi-call encipherment, the field should be set to the value of the
OCB provided by the previous call.
For ECB encipherment the contents of this field will be ignored.
For DES processing this field must be 8 bytes in length while for SEED processing this field must be
16 bytes in length.

OCV Chaining value for CBC encipherment. For encipherment of a message or file using a multi-call
encipherment, the value in this field should be used as the ICV in the next call.
For ECB encipherment, the contents of this field will be set to zero.
For DES processing this field will be 8 bytes in length, while for SEED processing this field will be 16
bytes in length.

Data Plaintext data to be enciphered. For DES processing this field must be a multiple of 8 bytes long while
for SEED processing it must be a multiple of 16 bytes.

Note: When the FM = 00 is missing, the function returns error code 24, missing function code.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 266
CHAPTER 4 Function Library

ENCIPHER-AES (EE0808)
Request Length Type Description

EE0808 3 h Function Code

FM 1 h Function Modifier (FM=00)

DPK Var K-spec Key specifier for DPK


(Formats: 52, 53, 1C)

CM 1 h Cipher Mode
00 = ECB
01 = CBC

ICV 16 h Input Chaining Value

Data Var h Data to be enciphered

Response Length Type Description

EE0808 3 h Function Code

rc 1 h Return Code

OCV 16 h Output Chaining Value

eDPK(Data) Var h Ciphertext

This function enciphers the supplied data using a host-stored session key (DPK) supplied within a key specifier. The
function performs AES encipherment and supports both Electronic Code Book (ECB) and Cipher Block Chaining (CBC)
modes of operation.
The function supports encipherment of large messages (or data files) either by one call to the function or by multiple
calls. For CBC encipherment using multiple calls, chaining values must be maintained between calls.

DPK-Spec Key specifier incorporating 128-bit or 192-bit or 256-bit AES host-stored key DPK.

CM Specifies the mode of operation for the encipherment:


00 = Electronic Code Book (ECB)
01 = Cipher Block Chaining (CBC)

ICV Chaining value for CBC encipherment. For encipherment of a message or file using one call, or on the first
call of a multi-call encipherment, this field should be set to the required value of the Initialization Vector (IV).
On subsequent calls of a multi-call encipherment, the field should be set to the value of the OCB provided by
the previous call.
For ECB decipherment, this field will be ignored.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 267
CHAPTER 4 Function Library

OCV Chaining value for CBC encipherment. For encipherment of a message or file using a multi-call
encipherment, the value in this field should be used as the ICV in the next call.
For ECB decipherment, this field will be set to zero.

Data Plaintext data to be enciphered. Must be a multiple of 16 bytes long.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 268
CHAPTER 4 Function Library

ENCIPHER-KTM1 (EE0806)
Request Length Type Description

EE0806 3 h Function Code

FM 1 h Function Modifier (FM=00)

DPK-Spec Var K-Spec Key specifier for DPK


(Formats: 0–3, 10, 11, 12, 13, 14, 16)

CM 1 h Cipher Mode
00 = ECB
01 = CBC

ICV Var h Input Chaining Value

KTM-Spec Var K-Spec Key specifier for KTM


(Formats: 0–3, 10, 11, 12, 13, 14, 16)

Response Length Type Description

EE0806 3 h Function Code

rc 1 h Return Code

OCV Var h Output Chaining Value

eDPK(KTM) Var h Ciphertext

This function enciphers the supplied KTM using a session key (DPK) supplied within a key specifier.
The function performs DES or SEED encryption, as determined by the DPK key specifier and supports both Electronic
Code Book (ECB) and Cipher Block Chaining (CBC) modes of operation.

FM = 00. Must be set to zero.

DPK-Spec Key specifier incorporating a single-length or double-length or triple-length host-stored or HSM -


stored DPK. This field determines the encryption method.
DES - formats 00 – 03 (DES/TDES keys only), 10, 11, 12, 13, 14.
SEED - formats 00 – 03 (SEED keys only) and 16.

CM Specifies the mode of operation for the encipherment:


0 - Electronic Code Book (ECB)
1 - Cipher Block Chaining (CBC)
For SEED processing this field must be set to 0 (ECB mode), otherwise error 0C will be returned.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 269
CHAPTER 4 Function Library

ICV Chaining value for CBC encipherment. For encipherment of a message or file using one call, or on
the first call of a multi-call encipherment, this field should be set to the required value of the
Initialization Vector (IV). On subsequent calls of a multi-call encipherment, the field should be set to
the value of the OCB provided by the previous call.
For ECB or SEED processing the contents of this field will be ignored.
This field must be 8 bytes in length.

KTM-Spec Key specifier incorporating a single-length or double-length host-stored or HSM -stored KTM. When
DPK-Spec refers to an HSM or host stored SEED key the KTM must be either a double length DES
key or a single length SEED key.

OCV Chaining value for CBC encipherment. For encipherment of a message or file using a multi-call
encipherment, the value in this field should be used as the ICV in the next call. For ECB or SEED
processing, this field will be set to zero. This field will be 8 bytes in length.

eDPK(KTM) KTM key encrypted with DPK according to the algorithm specified.

Notes
– This function is an insecure one as it allows KTMs to be encrypted by DPKs. Its use is not recommended by
SafeNet.
– This function currently supports SEED encryption using ECB mode. It does not support SEED CBC mode.
– This function is not included as standard. It will only be available if selected as an order time option when
purchasing a HSM. Please contact SafeNet if you require this functionality or further details.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 270
CHAPTER 4 Function Library

ERASE-OLD-KM (13)
Request Length Type Description

13 1 h Function Code

Response Length Type Description

13 1 h Function Code

rc 1 h Return Code

This function is used to erase the old KM. It is enabled/disabled by a console operation.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 271
CHAPTER 4 Function Library

ESTABLISH-KM (11)
Request Length Type Description

11 1 h Function Code

Response Length Type Description

11 1 h Function Code

rc 1 h Return Code

This function is used to move the current KM to the old KM and move the new KM to the current KM.
This function can be enabled/disabled by a console operation.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 272
CHAPTER 4 Function Library

EXPORT-CSCK (AA)
Request Length Type Description

AA 1 h Function code

CSCK-Spec Var K-Spec Key specifier for CSCK


(Format: 11, 13)

KIS/KI-Spec Var K-Spec Key specifier KIS (ZMK).


(Formats: 0–3, 08 (for KI only))

Response Length Type Description

AA 1 h Function code

rc 1 h Return code

eKIS(CSCK) 16 h Encrypted CSCK


or
eKI(CSCK)

KVC 3 h Key verification code of CSCK

This function causes a key to be returned encrypted under a KIS/KI (ZMK) specified by the index provided in the KIS/KI
specifier.

Notes
– Bidirectional Interchange key “KI” will be allowed only in format 08 in the request. Also, within format 08 only
format 0-3 will be allowed for KI.
– If KI will be received in the request, the CSCK in the response will be encrypted by KI. Therefore, the
Encrypted CSCK in the response will be either:
eKI(CSCK) if KI was received in the request field KIS/KI Spec.
eKIS(CSCK) if KIS was received in the request field KIS/KI Spec.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 273
CHAPTER 4 Function Library

EXPORT-KEY-2 (EE3061)
This function is used to translate a key from encryption under Domain Master Key to encryption under specified KEK.

Request Length Type Description

EE3061 3 h Function Code

FM 1 h Function Modifier = 00

KEK Type 1 h KEK Key type


KTK = 35

KEK-Spec Var K-Spec Key specifier for KEK


Allowed format for KTK = 1C

Mode of Encryption 1 h Encryption mode for encryption of output Key: eKEK (Key).
00 = ECB
01 = CBC
02 = CTR

IV/SV Var h Initialization Vector/ Starting Variable.


For ECB mode this is a zero length field.
For CBC mode this is IV.
For CTR mode this is SV.

Padding Mode 1 h 00 = Conditional


01 = Always
02 = None
(See Padding Mode, described in reference [83], [84], [85]
of Mark II)

Key Type 1 h Key to be encrypted under KEK.


Allowed Key Type is MKDK = 57

Key-Spec Var K-Spec Key Specifier containing eKMx(Key)


Allowed format for MKDK = 1C

KVC method 1 h 01 = Standard KVC Method (6 leftmost nibbles)

Response Length Type Description

EE3061 3 h Function Code

rc 1 h Return Code

eKEK(Key) Var h Key encrypted under KEK

KVC Var h KVC of exported key

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 274
CHAPTER 4 Function Library

Processing Steps
1. Extract clear KEK Key.
2. Extract clear key, to be encrypted under KEK.
3. Calculate extracted clear key’s KVC.
4. Using encryption parameters received in request, encrypt extracted clear key under KEK.
5. Return the KEK encrypted key along with its KVC in response.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 275
CHAPTER 4 Function Library

EXPORT-KEY-PACKAGE (EE3103)
Request Length Type Description

EE3103 3 h Function Code

FM 1 h Function Modifier (FM=00)

Control 1 h Representing start or Continuation of this download


= 01: Get Next Segment
= 02: Acknowledge

ReadOffset 4 h Offset into Key Package where this read will start

Length 2 h Number of bytes to read

Response Length Type Description

EE3103 3 h Function Code

rc 1 h Return Code

Package Segment Var h Next segment of Package or empty (depending on control)

This function extracts the current Export Key Package out of the HSM (if any). Developers should first call the KEY-
PACKAGE-STATUS function to determine if an Export Key Package is loaded and how large it is.
The Key Package is a (potentially) large image that is held inside the HSM. The image is created manually by the
administrator and Key Export Officer using Console operations. There is no way to create a Export Key Package from
Host functions.
After the image is extracted the host application may calculate and verify the CRC and then Acknowledge the
successful download by calling the function with Control=Acknowledge. The HSM will respond by 1) removing the
‘Pending’ flag from all HSM stored keys that are copied into the Key Package and 2) deleting the Key Package. Key
Packages can be transmitted across the network and imported into a remote HSM.

Control 01 - get specified segment of Key Package


02 - Acknowledge successful download

ReadOffset This field indicates the offset from the beginning of the Key Package where the next read
should start. For the first read, this field should have a value of zero. This field is ignored if
Control=’Acknowledge’

Length This field indicates the number of bytes to be extracted with this function call. This field is
ignored if Control=’Acknowledge’;

Package Segment This field holds the segment retrieved from the Key Export image. The number of bytes
extracted is indicated within the Var field, and may be less than the Length indicated in the
request (e.g. end of file or buffer length limitation). The field will be empty if
Control=’Acknowledge’

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 276
CHAPTER 4 Function Library

EXPORT-PIN-EMV (EE2050)
Request Length Type Description

EE2050 3 h Function Code

FM 1 h Function Modifier (FM=00)

PVK-Spec Var K-Spec Key Specifier for PVK and Dec. Table
(Formats: 0–3,11, 12, 13, 14, 17,18)

Validation Data. 8 h Data (usually a part of the PAN) used in the calculation of
the reference PIN.

Offset 6 h PIN offset data.

PIN Length 1 h Number of digits in PIN.

ANB 6 h Account Number Block

PIN Data Var h Data to incorporate with PIN in encrypted result

Encryption Method 1 h 00 = ECB


01 = CBC

PTK-Spec Var K-Spec Key Specifier for PIN Transport Key - HSM stored
(Formats: 0–3, 11, 12, 13, 14, 17,18)

Response Length Type Description

EE2050 3 h Function Code

rc 1 h Return Code

ePTK(PIN+PIN data) Var h Encrypted PIN and associated data.

This function reproduces a previously generated PIN, formats it in an ANSI PIN block and encrypts the block for secure
transport.

Function Modifier Reserved for possible future use; must be set to zero.

PVK-Spec Key specifier for PIN Verification Key (PVK) (Formats 0 - 3, 11, 12, 13, 14, 17, 18).

Validation Data 8 bytes of PAN data used to recreate the reference PIN.

Offset 6 byte offset that is used to recreate the reference PIN. The offset is in bcd format – big
endian.

PIN Length Valid ISO PIN length.

ANB The Account Number Block is used in the formation of the ANSI PIN block.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 277
CHAPTER 4 Function Library

PIN_Data Variable length data from the host function request that is appended to the generated PIN
block, without a leading variable length prefix before being encrypted and returned in the
response as ePTK(PIN+PIN data).

Encryption Method ECB and CBC encryption methods represented using 00 or 01 respectively.

PTK-Spec Key specifier for PIN Transport Key (PTK) (formats 0 - 3, 11, 12, 13, 14, 17, 18). The PTK
is used to encrypt the return export PIN.

Return Code Contains zero for success.

ePTK(PIN+PIN data) The return PTK-encrypted data block which contains the generated PIN and the
appended PIN data.

The function will fail with Error Code 78 if ANSI/ISO-0 PIN block format that is disabled.
The function performs a check that the ANB field and the Validation field contain a number of consecutive digits in
common. The number of digits to check is in the range 0 to 12, as may be specified using a console operation, and
defaults to 8. If the number of digits to check has been set to 0 the check is disabled. If the check fails, the function will
fail with Return Code 79.

Processing Steps
1. Reproduce the PIN, using the PVK, Decimalization Table, PAN and Offset.
2. Format the PIN and append the variable length PIN_data from the host function request so that the block of data as
input to encryption looks like:
– PIN
– VarLen || PIN_Data
3. Block of data as input to encryption method : [PIN || PIN_Data]
4. Encrypt the data_block containing the PIN and PIN Data using the PIN Transport Key.

Function usage
Called during card initialization: the encrypted PIN would be passed to the card personalization system. It could also be
passed to a separate PIN-mailing device.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 278
CHAPTER 4 Function Library

FORMAT-STATUS (0007)
This request returns information on the usage of key specifier (K-spec) formats.

Request Length Type Description

0007 2 h Function Code

MsgID 2 x Message Identifier

FC 1 x Format Code

Response Length Type Description

0007 2 h Function Code

MsgID 2 x Message Identifier

rc 1 x Return Code

fc 1 x Format Code

dd 1 x Day (current)

mm 1 x Month (current)

yyyy 2 x Year (current)

hh 1 x Hour (current)

mm 1 x Minutes (current)

ss 1 x Seconds (current)

fs 1 x Format status. 0=enabled, 1=disabled, 2=invalid

Function Code 2 x Function that last used this Format

CLM 4 bin Calls in last minute using this format

CL10M 4 bin Calls in last 10 minutes using this format

CLRES 4 bin Calls since last reset (mod 2**32) using this format

dd 1 x Day last used

mm 1 x Month last used

yyyy 2 x Year last used

hh 1 x Hour last used

mm 1 x Minutes last used

ss 1 x Seconds last used

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 279
CHAPTER 4 Function Library

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 280
CHAPTER 4 Function Library

FUEL-CARD-PIN-VER (EE0621)
Request Length Type Description

EE0621 3 h Function Code

FM 1 h Function Modifier (FM=00)

ePPK(PIN) 8 B64 Encrypted PIN Block

PPK Spec Var K-Spec Key specifiers for PPK


Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 20, 90

PF 1 h PIN Block Format

ANB 6 h Account Number Block

FPVK -Spec Var K-Spec Key Specifier for FPVK


Formats: 0-3, 10, 11,13, 17, 18

Card Number 8 h Rightmost 16 digits of the card number – including the


check digit

Offset 2 h Existing 4 digit offset for PIN

Response Length Type Description

EE0621 3 h Function Code

rc 1 h Return Code

This function performs the verification of a PIN using fuel card algorithm (DKV) [71]. The PIN is supplied in encrypted
form, using any of the PIN Block formats.

PPK-Spec May be any valid key specifier for a PPK. Consequently, the function supports an encrypted PIN
Block encrypted using a single-length or double-length or triple-length HSM-stored or host-stored
key.

PF Supports PIN formats: 01, 02, 03, 08, 09, 10, 11 and 13

ANB Account Number Block, which are the right most 12 digits of the Primary Account Number (PAN).

Card Number Rightmost 16 digits of the card number – including the check digit

Offset 4 digits of offset data.

The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 281
CHAPTER 4 Function Library

FUNCTION-STATUS (0005)
This request returns information on individual functions.

Request Length Type Description

0005 2 h Function Code

Msg ID 2 x Message Identifier

Func Code 2 x Function Code to be checked

Response Length Type Description

0005 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

fc 2 x Function Code checked

dd 1 x Day (current)

mm 1 x Month (current)

yyyy 2 x Year (current)

hh 1 x Hour (current)

mm 1 x Minutes (current)

ss 1 x Seconds (current)

fs 1 x Function status
0 = active
1 = inactive
2 = invalid

KM Index 1 x KM index last used by function

CLM 4 bin Calls in last minute

CL10M 4 bin Calls in last 10 minutes

CLRES 4 bin Calls since last reset mod 2**32

dd 1 x Day last used

mm 1 x Month last used

yyyy 2 x Year last used

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 282
CHAPTER 4 Function Library

Response Length Type Description

hh 1 x Hour last used

mm 1 x Minutes last used

ss 1 x Seconds last used

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 283
CHAPTER 4 Function Library

GENERATE-DCV (EE2054)
Request Length Type Description

EE2054 3 h Function code

FM 1 h Function Modifier (FM=00)

eDEKi(Data) Var h Encrypted Data.


(Must be a multiple of 8 bytes)

DEKi-Spec Var K-Spec Key Specifier for PPK or KTK


(Formats: 0 - 3, 10, 11, 12, 13, 14, 17, 18, 50, 51)

Key Type 1 BCD 01 = PPK


35 = KTK

Mode 1 h 00 = ECB
01 = CBC

Response Length Type Description

EE2054 3 h Function Code

rc 1 h Return Code

dcv(Data) 8 h Data Check Value

This function generates a Data Check Value (DCV) based on the data passed in the function and returns it.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 284
CHAPTER 4 Function Library

GENERATE-ICC-CRT-KEYPAIR (EE2058)
Request Length Type Description

EE2058 3 h Function Code

FM 1 h Function Modifier (FM = 00, 01, 02 or 03)


Determines which format of eKKEK(mod of Sxx ) is returned.

SI-Spec Var K-Spec Key Specifier for Issuer Private Key.


Key Type = Certificate, Data Signature
(Formats: 0-3, 82)

Certificate Data Var h ICC Public Key Data, as specified in Table 7 or Table 19 in
[5]. (The ICC Public Key modulus will be inserted during
function processing.)

KTK-Spec Var K-Spec Key Specifier for Key Transport Key.


(Formats: 0-3, 11, 12, 13, 14, 17, 18, 50, 51)

Encryption Method 1 h 00 = ECB


01 = CBC

PXX Flag 1 h Indicates whether to provide PXX in a key specifier.


00 = Don't return PXX
01 = Do return PXX

User Data Var h Data to be stored in key specifier for PK


(May be a zero length field)

Response Length Type Description

EE2058 3 h Function Code

rc 1 h Return Code

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 285
CHAPTER 4 Function Library

Response Length Type Description

eK(P) Var h Encrypted CRT parameters of ICC Private Key. Each field
eK(X) is individually encrypted and, dependent on the
request fields, comprises:
eKKTK(X)
eK(Q) Var h
or
eKKEK(X)
or
eK(PQ) Var h eKKEK(X | padding)
or
eKKEK(len | X | padding)
eK(DP1) Var h Each field length will be the next multiple of eight that is
equal to or larger than half the length Nxx of the modulus of
Sxx + 1.
eK(DQ1) Var h In case of eKKTK(X) and eKKEK(X), the CRT parameter will
be right justified and, if necessary, padded to the left with
zeroes.

ICC Public Key Certificate Var h Digital signature for the public key certificate. The field
length is equal to the length NI of the modulus of SI

ICC Public Key Var h As specified in Table 7 in [5].


Remainder

Pxx Var K-Spec Key Specifier for Pxx


Key Type = Data Signature, PIN Encryption
(Format: 81)

This function generates the CRT parameters and calculates the digital signature for the ICC Public Key Certificate.

Notes
– In this description, the subscript 'XX' is used to denote either 'IC' or 'PE'.
– If the length of the modulus is not a multiple of 128 bits (16 bytes) then the CRT parameters will not be a
multiple of 64 bits in length, and so will require padding prior to encryption. Ex - If modulus length is 1984 bits
then the CRT parameters comprising 992 bits (124 bytes), will be padded to left with 4 bytes of zeroes.

Function Modifier If set to 0, format of mod of Sxx is (mod of Sxx )


If set to 1, format of mod of Sxx is (len : mod of Sxx : padding)
If set to 2, format of mod of Sxx is (len : mod of Sxx : padding) and padding method is followed as
specified in [33] .
If set to 3, format of mod of Sxx is (mod: padding) and the padding method followed is Data ||
0x80 || 00 00 00 00 00 00 00

SI-Spec Key specifier for the Issuer Private Key SK (Formats 0 - 3, 82). The Key specifier in formats 0 - 3
describes the location of the key to be loaded from the ESM. The Key specifier in format 82
describes the complete Issuer SK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 286
CHAPTER 4 Function Library

Certificate Data Variable length ICC PK certificate data as specified by EMV. Used to build the signature
together with the generated SK

KTK-Spec Key specifier for the Key Transport Key (KTK) (Formats 0 - 3, 11, 12, 13, 14, 17, 18, 50. 51,
Encrypted with KMV35).

Encryption ECB and CBC encryption methods represented using 00 or 01 respectively.


Method

PXX Flag 1 byte flag to represent whether to return a built PK Key specifier.

User Data Variable length user data for input to the PK/SK generation process. User data is inserted into
the clear PK and clear component of the SK. When no user data is being supplied, this field is 1
byte in length with a value of zero to represent a zero length variable field.

Return Code Contains zero for success.

eK(P)

eK(Q)
The return encrypted CRT parameters. If FM = 1 or 2, the encrypted block containing a 1 byte
length concatenated with the modulus of Sxx concatenated with 7 bytes of padding, will be
eK(PQ)
returned.
eK(DP1) When FM=2, padding method shall be followed as specified in [33] .
When FM=3 , the encrypted block containing “0x80 00 00 00 00 00 00 00 “ is concatenated with
eK(DQ1) the modulus of Sxx .

ICC Public Key Signature for the ICC PK certificate.


Certificate

ICC Public Key Variable length right-most digits of the ICC PK. Only present when (ICC_modLen > (ISS_
Remainder modLen - 42)). Length equals (ICC_modLen - (ISS_ModLen + 42)) or 1 (value=0, when no
remainder present).

PXX Key specifier for the return Public Key (Format 81). The Key specifier describes the complete
PK.
The return PK Key specifier is only present when PXX flag = 1.
When Pxx Flag=0, this field would contain '00'.

If S = md mod n, where m is the data to be signed, d is the private key exponent, and n is private key modulus
composed of two prime numbers p and q then P, Q, PQ, DP1 and DQ1 will be:
P, the prime factor p
Q, the prime factor q
PQ = q-1 mod p
DP1 = d mod (p - 1)
DQ1 = d mod (q - 1)
When all five components (P, Q, PQ, DP1and DQ1) of the key are set, the key is initialized and ready for use.

Processing Steps
1. Generate the ICC Public Key (PXX) and ICC Private Key (SXX), with a modulus of length NXX as specified in ICC
Public Key Length in Certificate Data. The ICC Public Key Exponent is as specified in Certificate Data.
2. Insert the generated ICC Public Key modulus into Certificate Data.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 287
CHAPTER 4 Function Library

3. Calculate the hash result for the Certificate Data using the hash algorithm indicated by Hash Algorithm Indicator in
Certificate Data. [Currently, SHA-1 is the only approved hash algorithm, and is indicated by a value of hex '01'.]
4. Build the signature block using the calculated hash result and the leftmost bytes of Certificate Data, as defined in
A2.1.2 in [5].
5. Sign the signature block using SI and its associated asymmetric algorithm. [Currently, RSA is the only approved
asymmetric algorithm.]
6. Return the signature in ICC Public Key Certificate.
7. Return the rightmost part of the ICC Public Key modulus in ICC Public Key Remainder.
8. Encrypt the CRT parameters using the KEK specified by KEK-Spec and using the specified Encryption Method.
Return the result in eKTK(P), eKTK(Q), eKTK(PQ), eKTK(DP1) and eKTK(DQ1).

If KTK-Spec incorporates a format 50 key specifier, the CRT parameters are returned encrypted by the derived key
KKEK.
9. If indicated by PXX Flag, return PXX in a format 81 key specifier.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 288
CHAPTER 4 Function Library

GENERATE-ICC-CRT-KEYPAIR-PKCS (EE205A)
Request Length Type Description

EE205A 3 h Function Code

FM 1 h Function Modifier (FM=00)

SI-Spec Var K-spec Issuer Private Key.


(Key specifier formats: 0 - 3, 82)
Key Type = Certificate, Data Signature

Certificate Data Var h ICC Public Key Data, as specified in Table 7 or Table 19 in
[5]. (The ICC Public Key modulus will be inserted during
function processing.)

KTK Var K-spec Key Transport Key.


(Key specifier formats: 0 - 3, 11, 12, 13, 14,17,18, 50, 51)

Encryption Method 1 h 00 = ECB


01 = CBC

PXX Flag 1 h Indicates whether to provide PXX in a key specifier.


00 = Don't return PXX.
01 = Do return PXX.

User Data Var h Data to be stored in key specifier for PK


(May be a zero length field)

Response Length Type Description

EE205A 3 h Function Code

rc 1 h Return Code

eKTK(Sxx) Var h Encrypted ICC Private Key


eKTK(Sxx)
or
eKKEK(Sxx)

ICC Public Key Certificate Var h Digital signature for the public key certificate. The field
length is equal to the length NI of the modulus of SI

ICC Public Key Var h As specified in Table 7 in [5].


Remainder

Pxx Var K-Spec Pxx


(Key specifier format: 81)
Key Type = Data Signature, PIN Encryption

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 289
CHAPTER 4 Function Library

This function generates an RSA key pair for an EMV ICC, encrypts the private key and calculates the digital signature
for the Public Key Certificate. The function calculates the CRT parameters for the private key and, prior to encryption,
formats the private key as an ASN.1 type RSAPrivateKey as specified in section 11.1.2 of PKCS #1 v2.0 standards
[55].
The returned private key allows for its use by either using the mod/exp method or CRT method.

Note: The function fields, and associated processing, are as for function EE2058, with the
format of the returned encrypted private key being the sole difference.

All fields of the RSAPrivateKey structure, will be completed as follows:

Field Valid value? Value

Version y 0

Modulus y N

publicExponent y E

privateExponent y D

prime1 y P

prime2 y Q

exponent1 y d mod (p-1)

exponent2 y d mod (q-1)

Coefficient y (inverse of q) mod p

The padding required to produce a multiple of 8 bytes for encryption, will be appended to the right as described in
section 10.3 (Note 2 ) of PKCS#7 [69]
Example:
Assuming the length to be multiple of k (8) octets, Pad the input at the trailing end with k - (l mod k) octets all having
value k - (l mod k), where l is the length of the input.
In other words, the input is padded at the trailing end with one of the following strings:
01 — if l mod k = k-1
02 02 — if l mod k = k-2
×
×
×
k k…k k — if l mod k = 0

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 290
CHAPTER 4 Function Library

GENERATE-ICC-KEYPAIR (EE2048)
Request Length Type Description

EE2048 3 h Function Code

FM 1 h Function Modifier (FM = 00, 01, 02 or 03)


Determines which format of eKKEK(mod of Sxx ) is returned.

SI-Spec Var K-Spec Key Specifier for Issuer Private Key.


Key Type = Certificate, Data Signature
(Formats: 0 - 3, 82)

Certificate Data Var h ICC Public Key Data, as specified in Table 7 or Table 19 in
[5]. The ICC Public Key modulus will be inserted during
function processing.

KTK-Spec Var K-Spec Key Specifier for Key Transport Key.


(Formats: 0 - 3, 11, 12, 13, 14, 17, 18, 50, 51)

Encryption Method 1 h 00 = ECB


01 = CBC

PXX Flag 1 h Indicates whether to provide PXX in a key specifier.


00 = Don't return PXX
01 = Do return PXX

User Data Var h Data to be stored in key specifier for PK


(May be a zero length field)

Response Length Type Description

EE2048 3 h Function Code

rc 1 h Return Code

eKTK (mod of Sxx ) Var h Encrypted modulus of ICC Private Key.


or The field length will be the next multiple of eight that is equal
eKKEK(mod of Sxx ) to or larger than the length Nxx of the modulus of Sxx + 1.
or In case of eKTK(X) and eKKEK(X), the modulus will be left
eKKEK(mod of Sxx | justified and, if necessary, padded to the right with the
padding) padding bytes based on the value of FM.
or
eKKEK(len | mod of Sxx |
padding)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 291
CHAPTER 4 Function Library

Response Length Type Description

eKTK(exp of Sxx ) Var h Encrypted private exponent of ICC Private Key.


or The field length will be the next multiple of eight that is equal
eKKEK(exp of Sxx ) to or larger than the length Nxx of the exponent of Sxx + 1.
or
eKKEK(exp of Sxx | In case of eKTK(X) and eKKEK(X), the private exponent will
padding) be left justified and, if necessary, padded to the right with
or the padding bytes based on the value of FM.
eKKEK(len | exp of Sxx |
padding)

ICC Public Key Certificate Var h Digital signature for the public key certificate. The field
length is equal to the length NI of the modulus of SI

ICC Public Key Var h As specified in Table 7 in [5].


Remainder

Pxx Var K-Spec Key Specifier for Pxx


Key Type = Data Signature, PIN Encryption
(Format: 81)

This function generates an ICC key pair (PIC / SIC or PPE / SPE) and calculates the digital signature for the ICC Public
Key Certificate. The key pair may be used in Dynamic Data Authentication and / or PIN Encipherment.

Note: In this description, the subscript 'XX' is used to denote either 'IC' or 'PE'.

Function Modifier If set to 0, format of mod of Sxx is (mod of Sxx )


If set to 1, format of mod of Sxx is (len : mod of Sxx : padding)
If set to 2, format of mod of Sxx is (len : mod of Sxx : padding) and padding method
is followed as specified in [33].
If set to 3, format of mod of Sxx is (mod: padding) and the padding method followed
is Data || 0x80 || 00 00 00 00 00 00 00

SI-Spec Key specifier for the Issuer Private Key SK (Formats 0 - 3, 82).
The Key specifier in formats 0 - 3 describes the location of the key to be loaded from
the ESM.
The Key specifier in format 82 describes the complete Issuer SK.

Certificate Data Variable length ICC PK certificate data as specified by EMV. Used to build the
signature together with the generated SK

KTK-Spec Key specifier for the Key Transport Key (KTK) (Formats 0 - 3, 11, 12, 13, 14, 17, 18,
50, 51. Encrypted with KMV35).

Encryption Method ECB and CBC encryption methods represented using 00 or 01 respectively.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 292
CHAPTER 4 Function Library

PXX Flag 1 byte flag to represent whether to return a built PK Key specifier.

User Data Variable length user data for input to the PK/SK generation process. User data is
inserted into the clear PK and clear component of the SK. When no user data is
being supplied, this field is 1 byte in length with a value of zero to represent a zero
length variable field.

Return Code Contains zero for success.

eKTK(mod of Sxx ) The return encrypted modulus of Sxx . If FM = 1, or FM = 2, the encrypted block
or containing a 1 byte length concatenated with the modulus of Sxx concatenated with
eKKEK(mod of Sxx ) 7 bytes of padding, will be returned.
or When FM=3 , the encrypted block containing “0x80 00 00 00 00 00 00 00 “is
eKKEK(mod of Sxx | padding) concatenated with the modulus of Sxx .
or
eKKEK(len | mod of Sxx |
padding)

eKTK(exp of Sxx ) The return encrypted exponent of Sxx. If FM = 1, or FM=2 the encrypted block
or containing a 1 byte length concatenated with the exponent of Sxx concatenated
eKKEK(exp of Sxx ) with padding bytes returned.
or When FM=3 then “0x80 00 00 00 00 00 00 00 “ is concatenated with the exponent of
eKKEK(exp of Sxx | padding) Sxx .
or
eKKEK(len | exp of Sxx |
padding)

ICC Public Key Certificate Signature for the ICC PK certificate.

ICC Public Key Remainder Variable length right-most digits of the ICC PK. Only present when (ICC_modLen >
(ISS_modLen - 42)). Length equals (ICC_modLen - (ISS_ModLen + 42)) or 1
(value=0, when no remainder present).

PXX Key specifier for the return Public Key (Format 81). The Key specifier describes the
complete PK. The return PK Key specifier is only present when PXX flag = 1.

Processing Steps
1. Generate the ICC Public Key (PXX) and ICC Private Key (SXX), with a modulus of length NXX as specified in ICC
Public Key Length in Certificate Data. The ICC Public Key Exponent is as specified in Certificate Data.
2. Insert the generated ICC Public Key modulus into Certificate Data.
3. Calculate the hash result for the Certificate Data using the hash algorithm indicated by Hash Algorithm Indicator in
Certificate Data. [Currently, SHA-1 is the only approved hash algorithm, and is indicated by a value of hex '01'].
4. Build the signature block using the calculated hash result and the leftmost bytes of Certificate Data.
5. Sign the signature block using SI and its associated asymmetric algorithm. [Currently, RSA is the only approved
asymmetric algorithm].
6. Return the signature in ICC Public Key Certificate.
7. Return the rightmost part of the ICC Public Key modulus in ICC Public Key Remainder.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 293
CHAPTER 4 Function Library

8. Encrypt the ICC Private Key using the KEK specified by KEK-Spec and using the specified Encryption Method.
Return the result in eKTK(mod of S ) and eKTK(exp of SIC). If KTK-Spec incorporates a format 50 key
IC
specifier, the private key is returned encrypted by the derived key KKEK.
9. If indicated by PXX Flag, return PXX in a format 81 key specifier.

Function usage
The function is used during card initialization. The public key certificate and the encrypted private key would be passed
subsequently to the card personalization system.
In addition to being provided in a certificate, PXX can optionally be provided in a key specifier, for subsequent use during
testing of the card.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 294
CHAPTER 4 Function Library

GENERATE-ISSUER-KEY-PAIR (EE2040)
Request Length Type Description

EE2040 3 h Function Code

FM 1 h Function Modifier (FM=00)

Key Length 2 h Modulus size in bytes: 64 ≤ m ≤ 248.

Exponent Var h Exponent of public key.


= 3 or 216 + 1.

User Data Var h Data to be stored in key specifier for SK


(May be a zero length field)

Response Length Type Description

EE2040 3 h Function Code

rc 1 h Return Code

PI-Spec Var K-Spec Key specifier containing the public key.


Key Type = Certificate, Data Signature
(Format: 81)

SI-Spec Var K-Spec Key specifier containing the private key encrypted by a KM
variant.
Key Type = Certificate, Data Signature
(Format: 82)

This function generates an issuer key pair and returns the keys for host storage.

Function modifier Reserved for possible future use; must be set to zero.

Key Length Modulus size in bytes for input to the PK/SK generation process.

Exponent Variable length exponent type for input to the PK/SK generation process.
Field length before prefix byte is 1 or 3.

User Data Variable length user data for input to the PK/SK generation process.
User data is inserted into the clear PK and clear component of the SK.
When no User data is being supplied, this field is 1 byte in length with value of zero to represent a
zero length variable field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 295
CHAPTER 4 Function Library

Return Code 00 indicates that the generation has completed successfully. The PI-Spec and SI-Spec fields are
present as described below.
3A indicates that the generation has not yet completed. The generation of the key pair may take a
few seconds to complete. The EE2040 request should be re-issued periodically (every 3 seconds)
until either 00 (success) or non-zero-value-other-than-3A (failure) return code has been received.
The PI-Spec and SI-Spec fields are not present.
Non-zero-value-other-than-3A indicates failure. See Error Codes in this guide for further details.
The PI-Spec and SI-Spec fields are not present.

PI-Spec Key specifier for the Issuer Public Key (format 81). The Key specifier describes the complete
Issuer PK.

SI-Spec Key specifier for the Issuer Private Key (format 82). The Key specifier describes the complete
Issuer SK. The encrypted component of SK, eKMv20(SK), is encrypted using KM variant 20.

Processing Steps
1. Generate an RSA key pair of the specified length and with the specified public exponent.
2. Return the generated keys.

Function usage
The function may be used as an alternative to the equivalent console operation. If the console operation is used, the key
pair will be stored in HSM secure memory.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 296
CHAPTER 4 Function Library

GENERATE-KEY-DIEBOLD (EE9101)
Request Length Type Description

EE9101 3 h Function Code

FM 1 h Function Modifier (FM=x0)

IHOST Var h Identifier of Host

IATM Var h Identifier of ATM

rATM Var h ATM random nonce

eATM Var K-Spec Key specifier for ATM Public Key.


(Format: 81,
Key Type: Key Transport)

sHOST Var K-Spec Key specifier for Host Private Key.


(Format: 82,
Key Type: Data Signature)

Key Len 1 h 01 = Single


02 = Double

Key Type 1 h 05 = KTM

KBS Var h Key Block structure. Optional and must be present if 1KS-
Spec required in TR-31 Key block format .

Response Length Type Description

EE9101 3 h Function Code

rc 1 h Return Code

KTB1 Var h Key token B1

rHOST Var h Host random nonce

KKTM Var K-Spec Key specifier for generated key – as determined by Key len
(Formats: 10, 11, 12, 13, 14, 17, 18)

This function generates a random double-length KTM for initialization of a Diebold ATM. The generated key is returned
in encrypted form in a key specifier for host storage. Also, cryptograms are returned that are suitable for transfer to the
NCR ATM, i.e. the encrypted key Block and the digital signature of the encrypted key Block.

Notes
– The key specifiers 10, 11 under the Response, are generated when using the Legacy option.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 297
CHAPTER 4 Function Library

– The key specifiers 10, 11, 13 under the Response, are generated based on the chosen operation on console
and FM. See, section Function Modifier Values.
– 2048 length public keys only.
– The formats of the encrypted key Block and signature are as described in RSAES-PKCS1-v1_5 and RSASSA-
PKCS1-v1_5 in [Reference [21] of Mark II].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 298
CHAPTER 4 Function Library

GENERATE-KTM-NCR (EE9201)
Request Length Type Description

EE9201 3 h Function Code

FM 1 h Function Modifier (FM=x0)

SK-HSM Var K-Spec Key specifier for HSM Private Key.


(Format: 82)

PK-EPP Var K-Spec Key specifier for EPP Public Key.


(Format: 81)

KBS Var h Key Block structure. Optional.

Response Length Type Description

EE9201 3 h Function Code

rc 1 h Return Code

KTM-Spec Var K-Spec Key specifier for generated KTM.


(Format: 11, 13, 17, 18)

[KTM]PK-EPP Var h Encrypted key Block

([KTM]PK-EPP) Var h Signed encrypted key Block


*SK-HSM

KVC(KTM) 3 h NCR Key Verification Value (KVV)

This function generates a random double-length KTM for initialization of an NCR ATM. The generated key is returned in
encrypted form in a key specifier for host storage. Also, cryptograms are returned that are suitable for transfer to the
NCR ATM, i.e. the encrypted key Block and the digital signature of the encrypted key Block.
The formats of the encrypted key Block and signature are as described in sections 4.3 and 4.4 of [Reference [20] of
Mark II].
The key specifier 13 under the Response, are generated when using the Legacy option.
The key specifiers 11, 13 under the Response, are generated based on the chosen operation on console and FM. See
section, Function Modifier Values.

Notes
– 2048 length public keys only.
– As per NCR standards, this function support only public exponent 65537.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 299
CHAPTER 4 Function Library

GENERATE-MAC-NDC-ATM (5530)
This function will calculate the MAC for a given message to be transmitted to an NDC+ ATM. The MAC shall be
computed in accordance with the NDC+ PRM (PRM 5.1-9).

Request Length Type Description

5530 2 h Function Code

Msg ID 2 x Message Identifier

eKMv24(KMACs) Var K-Spec MAC Send Key (format 21)

ICV 8 B64 Input chaining value if required or zeros

Data Var x Data

Response Length Type Description

5530 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

MACdata 8 x Computed MAC

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 300
CHAPTER 4 Function Library

GENERATE-MD5-HASH (EE9007)
Request Length Type Description

EE9007 3 h Function Code

FM 1 h Function Modifier (FM=00)

Mode 1 h 00 = Only
01 = Initial
02 = Intermediate
03 = Last

Bit Count 8 h For chaining: initially zero, then as returned in previous call.

Hash Value 16 h For chaining: initially zero, then as returned in previous call.

Data Var h Data to be hashed.

Response Length Type Description

EE9007 3 h Function Code

rc 1 h Return Code

Bit Count 8 h Cumulative bit count

Hash Value 16 h MD5 hash value

This function returns the result of MD5 hashing the supplied data.

Function usage (in context of Remote ATM Initialization)


The function can be used to obtain the hash of a public key. The public key might be as generated by the Generate RSA
key pair function or as received from a CA.
Three examples are as follows:
– Calculate a hash as part of importing a public key. The hash is used at the HSM console to obtain a fingerprint
for the public key. The fingerprint and key are then used together to obtain a MAC for the public key. (See
Authentication of Public Keys).
– Calculate a hash for sending to the CA with the public key.
– Calculate a hash to provide to the ATM operator that confirms the validity of the certificate.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 301
CHAPTER 4 Function Library

GENERATE-RANDOM-PIN-EMV (EE204F)
Request Length Type Description

EE204F 3 h Function Code

FM 1 h Function Modifier (FM=00)

PVK-Spec Var K-Spec Key specifier for PVK and Dec. Table
(Formats: 0-3, 11, 12, 13, 14, 17, 18)

Validation Data 8 h Data (usually a part of the PAN) used in the calculation of
the reference PIN.

PIN Length 1 h Number of digits in the generated PIN.

ANB 6 h Account Number Block

PIN Data Var h Data to incorporate with PIN in encrypted result

Encryption Method 1 h 00 = ECB


01 = CBC

PTK-Spec Var K-Spec Key Specifier for PIN Transport Key


(Formats: 0 - 3, 11, 12, 13, 14, 17, 18)

Response Length Type Description

EE204F 3 h Function Code

rc 1 h Return Code

Offset 6 h PIN offset data.

ePTK(PIN+PIN data) Var h Encrypted PIN and PIN data.

This function generates a random PIN for storing in an ICC, formats it in an ANSI PIN block, encrypts it for secure
transport to a separate PIN-issuing device, and calculates 3624 offset data for use in subsequent online PIN
verification.

Function Modifier Reserved for possible future use; must be set to zero.

PVK-Spec Key specifier for PIN Verification Key (PVK) (Formats 0 - 3, 11, 12. 13, 14, 17, 18).

Validation Data 8 bytes of PAN data used to recreate the reference PIN.

PIN Length Valid ISO PIN length.

ANB The Account Number Block is used in the formation of the ANSI PIN block.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 302
CHAPTER 4 Function Library

PIN Data Variable length data from the host function request that is appended to the generated PIN
block, without a leading variable length prefix before being encrypted and returned in the
response as ePTK(PIN+PIN data).

Encryption Method ECB and CBC encryption methods represented using 00 or 01 respectively.

PTK-Spec Key specifier for PIN Transport Key (PTK) (Formats 0 - 3, 11, 12, 13, 14, 17, 18). Encrypted
with KMV36

Return Code Contains zero for success.

Offset 6 byte offset that is used to recreate the reference PIN. The offset is in bcd format – big endian.
With the validation data and PIN length, the PIN can be recalculated.

ePTK(PIN+PIN The return PTK-encrypted data block which contains the generated PIN and the appended PIN
data) data.

Processing Steps
1. Generate a random PIN with the required number of digits.
2. Using the PVK, Decimalization Table and PAN, calculate the 3624 offset for the PIN.
3. Format the PIN and append the variable length PIN_data from the host function request so that the block of data as
input to encryption looks like:
a. PIN
b. PIN_Data
Block of data as input to encryption method : [PIN || PIN_Data]
4. Encrypt the data_block containing the PIN and PIN Data using the PIN Transport Key.

Function usage
Called during card initialization: the encrypted PIN would be passed to the card personalization system. It could also be
passed to a separate PIN-mailing device.
The function will fail with Error Code 78 if ANSI/ISO-0 PIN block format that is disabled.
The function performs a check that the ANB field and the Validation field contain a number of consecutive digits in
common. The number of digits to check is in the range 0 to 12, as may be specified using a console operation, and
defaults to 8. If the number of digits to check has been set to 0, the check is disabled. If the check fails, the function will
fail with Return Code 79.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 303
CHAPTER 4 Function Library

GENERATE-RSA-KEY-PAIR (EE9001)
Request Length Type Description

EE9001 3 h Function Code

FM 1 h Function Modifier (FM=00)

Key Type 2 h Indicates the valid usage for the private key

bit key type

0 --- not valid ---

1 Data Signature

2 Key Transport

4 Data Protect

Bit 0 is the least significant (rightmost) bit.

Modulus Length 2 h Modulus size in bytes.


The maximum modulus length is 2048 bits.

Public Exponent Var h = 3 or 65537 (216+1).

User Data Var h Data to be stored in key specifier for SK. (May be zero-
length field.)

Response Length Type Description

EE9001 3 h Function Code

rc 1 h Return Code

PK Var K-Spec Key specifier containing the public key (PK). (Format: 80)

SK Var K-Spec Key specifier containing the private key (SK) encrypted by
a KM variant.
(Format: 82)

This function generates an RSA key pair (PK, SK) with the specified modulus length and public exponent and returns
the keys for host storage.
The Key Type is stored in the key specifier for the private key (SK) and may be used to restrict usage of the private key.
The public key is deemed unauthenticated so it is returned in a Format 80 key specifier.

Processing Steps
1. Generate an RSA key pair of the specified type and length, and with the specified public exponent.
2. Ensure that the modulus is compatible with the specified public exponent.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 304
CHAPTER 4 Function Library

3. Return the generated keys in the appropriate key specifiers.

Function usage
The public key may subsequently need to be authenticated for local use (see Authentication of Public Keys), and/or
sent to a CA for insertion into a Public Key Certificate.

Function usage (in context of Remote ATM Initialization)


The key pair may be used as the 'Host Key Pair' used in the Remote ATM Initialization protocols. The ATM
manufacturers use the following nomenclature for this key pair.

PK SK

Diebold vHOST sHOST

NCR PK-HSM SK-HSM

NCR

The generated PK-HSM must be taken to NCR using a secure channel and will be signed using SK-NCR giving (PK-
HSM)*SK-NCR. The signed public key can be verified using the Import public key certificate function
Diebold

The generated vHOST must be submitted to the CA in a message self-signed by sHOST.

Function usage (in context of Remote ATM Initialization)


Diebold

The Host public key must be submitted to the CA in a self-signed message. Although the message format is not within
the scope of the Diebold specifications it is probable that this function will be suitable.

PK SK

Diebold vHOST sHOST

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 305
CHAPTER 4 Function Library

GENERATE-SHA-HASH (EE9008)
Request Length Type Description

EE9008 3 h Function Code

FM 1 h Function Modifier (FM=00)

Algorithm 1 h 00 = SHA-1
01 = SHA-224
02 = SHA-256
03 = SHA-384
04 = SHA-512

Mode 1 h 00 = Only
01 = Initial
02 = Intermediate
03 = Last

Bit Count 8 h For chaining: initially zero, then as returned in previous call.

Hash Value Var h For chaining: initially zero, then as returned in previous call.

Data Var h Data to be hashed.

Response Length Type Description

EE9008 3 h Function Code

rc 1 h Return Code

Bit Count 8 h Cumulative bit count

Hash Result Var h SHA hash value

This function returns the result of SHA hashing the supplied data.

Function usage (in context of Remote ATM Initialization)


The function can be used to obtain the hash of a public key. The public key might be as generated by the Generate RSA
key pair function or as received from a CA.
Three examples are as follows:
– Calculate a hash as part of importing a public key. The hash is used at the HSM console to obtain a fingerprint
for the public key. The fingerprint and key are then used together to obtain a MAC for the public key. (See
Authentication of public keys)
– Calculate a hash for sending to the CA with the public key.
– Calculate a hash to provide to the ATM operator that confirms the validity of the certificate.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 306
CHAPTER 4 Function Library

GEN-KM-ENC-PIN (EE0640)
Request Length Type Description

EE0640 3 h Function Code

FM 1 h Function Modifier (FM=00)

PIN Len 1 h Length of PIN ( 04 - 12)

ANB 6 h Account Number Block

Response Length Type Description

EE0640 3 h Function Code

rc 1 h Return Code

PIN-Spec Var K-Spec KM-encrypted PIN Block


(Format: 1A)

This function generates a random PIN of the specified length and creates a format 1A key specifier, as defined in
Function Construction.
The function will fail with Error Code 78 if PIN block format ISO-3 is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 307
CHAPTER 4 Function Library

GEN-RANDOM (EE0002)
Request Length Type Description

EE0002 3 h Function Code

FM 1 h Function Modifier (FM=00)

Random No. Len 1 h = 01 – FF (1 – 255)

Response Length Type Description

EE0002 3 h Function Code

rc 1 h Return Code

Random No. Var h Random number with length as specified in Length of


Random Number

This function generates and returns a random number of the specified length.
The return code (rc) for this function indicates the success or failure of the function call. See Error Codes for a complete
listing of return codes.

Processing Steps
1. Generates a random number with the number of bytes as specified in Length of Random Number.
2. Returns the generated number in the Response field Random Number.

Note: The generated random number is not 'massaged' in any way, e.g. the bytes are not
adjusted for odd parity as is sometimes required for DES keys.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 308
CHAPTER 4 Function Library

GEN-TERMINAL-KEY (EE0628)
Request Length Type Description

EE0628 3 h Function Code

FM 1 h Function Modifier (FM=x0)

KTM Var K-Spec Key specifier for KTM


(Formats: 0 - 3, 11, 12, 13, 14)

Crypto Algorithm 1 h 01 = 3DES


03 = HMAC-SHA-1

Key Length 2 h Number of bits in a key.


= 128
= 160
= 192

Key Type 1 h 01 = PPK


02 = MPK
05 = KTM

Terminal Key format 1 h Format of key to be distributed


01 = ECB encrypted key
05 = Verifone key Block(GISKE)

Host Key format 1 h Format of key specifier for host storage


01 = Encrypted key
02 = Binary key Block(TR-31)

KVC format 1 h 00 = Not required


01 = 3 byte standard KVC

Version Identifier 1 h ‘A’ (for GISKE)


‘2’ (for Verifone)
00 (for binary key Block)

Key Usage 2 h Valid values are described in the field description following
this table.

Mode of use 1 h ‘E’ (Encrypt only),


00 (Null),
D (As per Verifone Key Block – VPN 22986 Rev D)
G (As per Verifone Key Block – VPN 22986 Rev D)

Key version number 2 h ‘00’ (for Verifone)


0000 (Null)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 309
CHAPTER 4 Function Library

Request Length Type Description

Exportability 1 h ‘N’ (for Verifone)


00 (Null)

Padding indicator 1 h For DES/3DES only


00 = Do not pad
02 = Pad to double-length
03 = Pad to triple length

Number of optional fields 1 h Always zero (00)

Optional field 1 … n Var h Not present

Response Length Type Description

EE0628 3 h Function Code

rc 1 h Return Code

Terminal key Var h Encrypted key or key Block to send to terminal

Host key Var K-Spec Key specifier incorporating an encrypted key or a key Block
(as indicated by Host key format in the request)
Formats: (11, 13, 18)

KVC Var h Key Verification Code

This function generates a key for sending to a terminal and is sent KTM encrypted. The generated key can also be sent
to a host KM encrypted for storage. A KVC for the generated key may also be requested for the response.

Note:
- The key specifiers 13, 18 under the Response, are generated when using the Legacy option.
- The key specifiers 11, 13 under the Response, are generated based on the chosen operation
on console and FM. See section, Function Modifier Values.

The generated key may be provided in simple encrypted form or incorporated in a secure key Block. See references
[25], [26] and [27] for details on secure key Block formats.

FM = x0
The Host Key Protection using Function Modifier can be in the range of x0, where x= 0 , 1, or
2.

KTM The key specifier used to protect the key being generated.
Valid values are key specifier formats 0-3, 11 12, 13 (3DES only), and 14.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 310
CHAPTER 4 Function Library

Crypto algorithm Identifies the cryptographic algorithm used to generate the key.
Valid values are:
‘01’=3DES. May only be used if the specified KTM is a 3DES key
‘03’=HMAC-SHA-1. May only be used if the specified KTM is a 3DES key

Key length Specifies the length of the key to be generated. Valid key lengths for each supported
algorithm are as follows:
3DES - 128
HMAC-SHA-1 - 128, 160, 192

Key type Specifies the key type. Key types supported for each algorithm are as follows:
Algorithm 3DES - PPK, MPK
Algorithm HMAC-SHA-1 - MPK

Terminal key format Identifies the format in which the key is to be transmitted to the terminal. Valid formats are as
follows:
‘01’ - ECB encrypted using a variant of KTM,
‘05’ - Verifone key Block (based on GISKE)

Host key format Identifies the format in which the key is to be stored on the host. Formats are as follows:
‘01’ - CBC encrypted using a variant of KM and supports 3DES key only. The key is returned
in a format 13 key specifier
‘02’ - binary key Block in a format 18 key specifier

KVC format Key verification code standard format

Version identifier ‘2’ - for Verifone key Block


00 (Null) - for binary key Block

Key usage, For Key usage, ‘00 to 60’ for MPK and ‘K0’ for KTM is supported.
Mode of use, Note that the highlighted values are valid for Verifone key block only.
Key version number The fields Key usage, Mode of use, and Key version number must be specified to create a
secure key Block. Valid combinations of these three fields for each key type are as follows:

Key type Key usage Mode of use Key version number

MPK M0 C,G,N,V 00

PPK P0 N 00

KTM K0 D, G 00

NOTE: Other key Block fields will be created using Algorithm, Key Length and key type host
function request fields.

Exportability ‘N’ (not exportable) - for Verifone key Block. 00 (Null) - for Binary key Block.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 311
CHAPTER 4 Function Library

Padding indicator For DES/3DES only , indicates how the encrypted key field (in the key Block) should be
padded so that its length is indistinguishable, as follows:
00 - do not pad
Note: The function field Padding Indicator is not applicable in Verifone key block and will be
ignored.

Optional fields These support the optional fields of key Blocks. Currently not implemented.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 312
CHAPTER 4 Function Library

GET-CLOCK (0016)
This function gets the date and time from Luna EFT.

Request Length Type Description

0016 2 h Function Code

Msg ID 2 x Message Identifier

Response Length Type Description

0016 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

CCYYMMDD 15 d Date and time to be set for Luna EFT.


Thhmmss

This host function is used for Australian Major Bank (AMB).


The date and time is provided in the CCYYMMDDThhmmss format. This is the basic format for a complete
representation of calendar date and local time as specified in paragraph 5.4.1 of AS/NZS 3802:1997 Data elements and
interchange format - Information interchange - Representation of dates and times.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 313
CHAPTER 4 Function Library

GET-KEY-DETAILS (EE0202)
Request Length Type Description

EE0202 3 h Function Code

FM 1 h Function Modifier (FM=00)

Key Spec Var K-Spec Key specifier for the host stored key
(Formats: 10,11,12,13, 14,15,16,17,18,20,50, 93)
1C (support only CCMK and MKDK)

Key Type 1 d Indicates the KM-variant with which the key K is encrypted

KVC Type 1 h 0x00: Standard


0x01: MDC2 KVC (Only for PPK and MPK)
0x02: SHA256
0x03: ZL8

Response Length Type Description

EE0202 3 h Function Code

rc 1 h Return Code

Parity 1 h For DES/3DES keys, indicates whether the key has odd,
even or mixed parity.
For AES keys, value is set to zero.

KVC Var h KVC for the host stored key.

This function provides non-sensitive details of a host stored key that is stored in simple KM encrypted form.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 314
CHAPTER 4 Function Library

Key For key specifiers that contain an authenticated key Block incorporating the key type, this field must be set to
Type zero (i.e. for key specifier formats 15, 17 and 18).
For key specifier incorporating encryption counter as zero in KSN (i.e. for key specifier format 20), the KVC
shall be calculated on initial key and key type shall be ignored.
Otherwise, following keytypes shall be used with format 20 key specifier to calculate KVC on transaction
keys.
00: DPK
01: PPK
02: MPK
For key specifier formats 10, 11, 13, 14, 16 and 50 this field indicates the KM-variant with which the key is
encrypted as follows:

00: DPK 07: KPV,DT 24: BDK 36: PTK 48: CCMK 55:
01: PPK 08: KPVV 30: IMKAC 37: KMC 49: IMKCL CMKCLIDN
02: MPK 09: KCVV 31: IMKSMI 38: IMK-CVC 50: IMKRP 56: MPPK
03: KIS 10:KI 32:IMKSMC 40:DK-DPK 51: CMKCLMD 57: MKDK
04: KIR 16: ZKA KGK 33: IMKDAC 44:DK-KIR 52: CMKCLUMD
05: KTM 17: ZKA KKBLZ 34: IMKDN 41:DK-PPK 53: CMKRPMD
06: CSCK 18: ZKA MK 35: KTK 42:DK-MPK 54: CMKRPUMD
43: DK-KIS

KVC Specifies the method used to calculate the KVC. Values supported are :
Type 0x00 for standard method
0x01 for MDC2 Method (This value is only valid when the key passed to the function is PPK or MPK)
0x02: SHA256
0x03: ZL8

Parity For DES/3DES keys, this field indicates whether the plain text key has odd, even or mixed parity, as follows:
01: Odd parity
02: Even parity
03: Mixed parity
For AES keys, value is set to zero.

KVC For DES/3DES keys, the field contains the 3-byte 'standard ' KVC
If the KVC type is 0x01 the MDC2 method for KVC calculation will be used. The KVC returned will be a 16
byte hexadecimal value.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 315
CHAPTER 4 Function Library

GET-KVC (EEBF29)
This function allows an operator to verify the existence and obtain the KVC of keys stored in the Secure Memory of the
HSM device.
KVC methods vary depending on the key type.

Request Length Type Description

EEBF29 3 h Function Code

FM 1 x Function Modifier = 00
00 = Get details on specified Key or
01 = Get details on next HSM-stored key.
(For example, if FM = 01, index is 01 and the HSM key is stored at
index 1; and if index 2 , 3 is empty and index 4 has a key, in this case
GetKVC will find KVC for key at index 4.)

Key Type 2 h Key Type (decimal)

01: KIS 17: IMK_AC 32: MDK 47: KMSC2


02: KIR 18: IMK_SMI 33: KTPV 48: KMDEB
03: BDK 19: IMK_SMC 34: ZKA_MK2 49: MTMK
04: PPK 20: IMK_DAC 35: ZKA_KTK 50: IMK_CVC
05: MPK 21: IMK_IDN 36: ZKA_KK 52: KTK
06: DPK 22: CAP_ 37: ZKA_MK 53: PTK
BITMAP
07: KTM 38: ZKA_KGK 54: KMC
23: KEK_KPE
08: PVK 39: 3624_KTM 55: FPVK
24: DMK
09: KM 40: 3624_BK 56: CCMK
25: PMK
10: 41: CSCK 57: IMKCL
TRANSFER1 26: MBTS
42: KMISS 58: IMKRP
11: KI 27: VSK
43: KMCRE 59: MPPK
12: KKL 28: ZCMK
44: KMCIP
13: PVVK 29: AWK
45: KMAUTH
14: CVVK 30: IWK
46: KMSC1
15: DPVT 31: PGK

KVC Type 2 h KVC Algorithm


01 = KR4
02 = ZL6
03 = ZL4
04 = SHA-1
05 = MDC2
06 = SHA256
07 = ZL8

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 316
CHAPTER 4 Function Library

Request Length Type Description

Index 2 h Index into table of specified Key


As for KM,
00 = Old KM,
01 = Current KM,
02 = New KM

Response Length Type Description

EEBF29 2 h Function Code

rc 1 x Return Code

KeyLen 2 h Key length (in bytes) of specified key


Allowed values - 8, 16, 24, 32

KeyType 2 h Key Table Type


If Transfer Table was specified then this is the type of the
key in the Transfer Table

Index 2 h Index of the specified key as passed in the request.

KVC Var h KVC of clear key (size depends on KVC method)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 317
CHAPTER 4 Function Library

GETPUBLICKEY (EE3030)
Request Length Type Description

EE3030 3 h Function Code

FM 1 h Function Modifier (FM=00)

PK-Spec Var K-Spec Key specifier for HSM Public key pair.
(Formats: 0 - 3)

Response Length Type Description

EE3030 3 h Function Code

rc 1 x Return Code

n 1 x Length of PK HSM as in number of 8 byte Blocks within the


modulus

PVC(PKi HSM) 20 x Verification Code

PKi HSM Var K-Spec Key specifier for HSM stored public key
(Format: 80)

This function returns an HSM stored public key and its PVC.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 318
CHAPTER 4 Function Library

GP-CALC-CARD-CRYPTOGRAM (EE2060)
Request Length Type Description

EE2060 3 h Function Code

FM 1 h Function Modifier

Session S-ENC Var K-spec Key specifier for derivation of Session S-ENC from KMC.
(Formats: 50, 51), (KMC: 0 - 3, 13, 17, 18)

Host Challenge 8 x

Card Challenge 8 x

Response Length Type Description

EE2060 3 h Function Code

rc 1 h Return Code

Card Cryptogram 8 x

This function generates the card cryptogram that is part of the mutual authentication of an ICC card and the off-card
entity. The function includes the derivation of the card static keys and session keys used in the calculation of the
cryptogram.
The function supports both SCP01 and SCP02. In the latter, the Card Challenge would comprise the concatenation of a
2-byte sequence counter and a 6-byte challenge.

Processing Steps
1. Derive card session S-ENC using KMC and data in a format50 or 51 key specifier, as explained in sections D.3.1
and E.4.1 of [37].
2. Calculate card cryptogram using session S-ENC, Host Challenge and Card Challenge, as explained in sections
D.3.2.1 and E.4.2.1 of [37].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 319
CHAPTER 4 Function Library

GP-MUTUAL-AUTHENTICATION (EE2059)
Request Length Type Description

EE2059 3 h Function Code

FM 1 h Function Modifier

Session S-ENC Var K-spec Key specifier for derivation of Session S-ENC from KMC.
(Formats: 50, 51), (KMC: 0 - 3, 13, 17, 18)

Host Challenge 8 x

Card Challenge 8 x

Card cryptogram 8 x

Response Length Type Description

EE2059 3 h Function Code

rc 1 h Return Code

Host Cryptogram 8 x

This function supports the mutual authentication of an ICC card and the off-card entity by verification of the card
cryptogram and generation of the host cryptogram. The function includes the derivation of the card static keys and
session keys used in the calculation of the cryptograms.
The function supports the Secure Channel Protocols, SCP01 and SCP02. In SCP02, the Card Challenge would
comprise the concatenation of a 2-byte sequence counter and a 6-byte challenge.

Processing Steps
1. Derive card session S-ENC using KMC and data in a format50 or 51 key specifier, as explained in sections D.3.1
and E.4.1 of [37].
2. Calculate and verify card cryptogram using session S-ENC, Host Challenge and Card Challenge, as explained in
sections D.3.2.1 and E.4.2.1 of [37].
3. If step 2 is successful, calculate host cryptogram using session S-ENC, Host Challenge and Card Challenge, as
explained in sections D.3.2.2 and E.4.2.2 of [37].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 320
CHAPTER 4 Function Library

GP-MUTUAL-AUTHENTICATION-SCP03 (EE2065)
Request Length Type Description

EE2065 3 h Function Code

FM 1 h Function Modifier (FM=00)

Session S-ENC Var K-spec Key specifier for derivation of Session S-ENC from KMC.
(Formats: 52, 53)

Host Challenge 8 x Host random unique data for each secure channel session

Card Challenge 8 x Card random unique data for each secure channel session

Card cryptogram 8 x 8 byte card cryptogram for card authentication

Response Length Type Description

EE2065 3 h Function Code

rc 1 h Return Code

Host Cryptogram 8 x 8 byte host cryptogram for host authentication

This function supports the SCP03 mutual authentication of an ICC card and the off-card entity by verification of the card
cryptogram and generation of the host cryptogram.
The function includes the derivation of the card static keys and session keys used in the calculation of the cryptograms.

Processing Steps
1. Derive card session S-ENC using KMC and data in a format-52 or -53 key specifier (as in section 4.1.5 of [75]).
2. Calculate and verify card cryptogram using session S-ENC, Host Challenge and Card Challenge (as in section
6.2.2 of [75]).
3. If step 2 is successful, calculate host cryptogram using session S-ENC, Host Challenge and Card Challenge (as in
section 6.2.3 of [75]).
Only left most 8 bytes of output from CMAC will be used as Cryptogram.

Note: Encrypted data (concatenation of Host challenge and Card challenge) will not be padded
prior to encryption, as it was in EE2059.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 321
CHAPTER 4 Function Library

GP-SCP10-CALC-HASH-OF-KEY (EE2064)
Request Length Type Description

EE2064 3 H Function Code

FM 1 H Function Modifier (FM=00)

Number of Session Keys 1 H 01 – 05

Session C-DEK 1 D Key Type for command session key 3


35 – KTK
36 – PTK

RFU 1 D Key Type for response session key 3

Session S-ENC Var K-spec Key specifier for session key 1 Keys for Command
(Formats: 11, 12, 13, 14, 17,
18, 50, 51)

Session S-MAC Var K-spec Key specifier for session key 2 Keys for Command
(Formats: 11, 12, 13, 14, 17,
18, 50, 51)

Session DEK Var K-spec Key specifier for session key 3 Keys for Command
(Formats: 11, 12, 13, 14, 17,
18, 50, 51)

Session S-ENC Var K-spec Key specifier for session key 1 Keys for Response
(Formats: 11, 12, 13, 14, 17,
18, 50, 51)

Session S-MAC Var K-spec Key specifier for session key 2 Keys for Response
(Formats: 11, 12, 13, 14, 17,
18, 50, 51)

RFU Var K-spec Key specifier for session key 3 Keys for Response

Offset 1 1 H Start position in block for session key 1

Offset 2 1 H Start position in block for session key 2

Offset 3 1 H Start position in block for session key 3

Offset 4 1 H Start position in block for session key 1

Offset 5 1 H Start position in block for session key 2

RFU 1 H Start position in block for session key 3

Hash Method 1 H 01 = SHA-1

Plaintext Block Var H Block containing 'empty' CRTs (or empty space) and
challenge

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 322
CHAPTER 4 Function Library

Response Length Type Description

EE2064 3 H Function Code

rc 1 H Return Code

Hash result Var H

This function calculates the hash of a block containing the session keys and a challenge.
The function decrypts or derives up to 5 keys, inserts them at specified offsets in the plaintext block and calculates the
hash of the block. The keys must be the same values as calculated in session key transport function (EE2063) but the
block format is different.
If less than 5 keys are required, any unused key specifier fields should be set to a zero-length Var field and the
associated offset field should be set to zero.
The Plaintext Block must be sufficiently large to accommodate the specified session keys.

Processing Steps (explained in reference [37]


1. Decrypt or derive the specified session keys – up to 5 double- or triple-length 3DES keys.
2. Insert (by overwrite) each session key into the Plaintext Block at the specified offset.
3. Calculate the hash of the plaintext block.

Function Usage
The function can be used in entity authentication of both the card and the OCE.
1. In OCE authentication, the block would contain empty CRT and the card challenge. The resulting hash may then be
formatted and RSA-signed for sending to the card in the EXTERNAL AUTHENTICATE command (see F.4.1 in
[37]). The digital signature can be calculated using RSASSA-PKCS-V1_5 in the EE9005 host function.
2. In card authentication, the block would contain empty space and the OCE challenge. The resulting hash may then
be formatted and used in the EE9006 host function to verify the signature from the card.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 323
CHAPTER 4 Function Library

GP-SCP10-SESSION-KEY-TRANSPORT (EE2063)
Request Length Type Description

EE2063 3 h Function Code

FM 1 h Function Modifier (FM=00)

Number of Session Keys 1 h 01 – 05

Key Type C-DEK 1 d Key Type for session C-DEK key


35 - KTK
36 - PTK

RFU 1 d Key Type for session R-DEK key

Session S-ENC Var K-spec Key specifier for session key 1 Keys for Command
(Formats: 11, 12, 13, 14, 17, 18,
50, 51)

Session S-MAC Var K-spec Key specifier for session key 2 Keys for Command
(Formats: 11, 12, 13, 14, 17, 18,
50, 51)

Session DEK Var K-spec Key specifier for session key 3 Keys for Command
(Formats: 11, 12, 13, 14, 17, 18,
50, 51)

Session S-ENC Var K-spec Key specifier for session key 1 Keys for Response
(Formats: 11, 12, 13, 14, 17, 18,
50, 51)

Session S-MAC Var K-spec Key specifier for session key 2 Keys for Response
(Formats: 11, 12, 13, 14, 17, 18,
50, 51)

RFU Var K-spec Key specifier for session key 3 Keys for Response

Offset 1 1 h Start position in block for session key 1

Offset 2 1 h Start position in block for session key 2

Offset 3 1 h Start position in block for session key 3

Offset 4 1 h Start position in block for session key 1

Offset 5 1 h Start position in block for session key 2

RFU 1 h Start position in block for session key 3

Encryption Method 1 h 01 = RSAES_PKCS_v1.5

Plaintext Block Var h Block containing 'empty' CRTs

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 324
CHAPTER 4 Function Library

Request Length Type Description

PK Var K-spec Key specifier for public key


(Format 81, RSA Key Type: Key Transport)

Response Length Type Description

EE2063 3 h Function Code

rc 1 h Return Code

ePK(key block) Var h RSA-encrypted key block.

This function decrypts or derives up to 5 keys, inserts them at specified offsets in a plaintext key block and encrypts
the block using RSAES-PKCS-v1.5 [40] and the provided RSA public key. The function supports the PERFORM
SECURITY OPERATION (decipher) command of SCP10 (see F.4.6 in [37].
If less than 5 keys are required, any unused key specifier fields should be set to a zero-length Var field and the
associated offset field should be set to zero.
The Plaintext Block must be sufficiently large to accommodate the specified session keys but must be at least 11
bytes smaller than the modulus of the public key.

Processing Steps (explained in reference [37])


1. Decrypt or derive the specified session keys – up to 5 double- or triple-length 3DES keys.
2. Insert (by overwrite) each session key into the Plaintext Block at the specified offset.
3. Add the leading bytes to form a valid PKCS#1v1.5 block.
4. Encrypt the resulting data block using PK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 325
CHAPTER 4 Function Library

GP-SECURE-MESSAGING-COMMAND (EE2061)
Request Length Type Description

EE2061 3 h Function Code

FM 1 h Function Modifier (FM=00)

SC 1 h Select Code
01 = Encrypt data only
02 = Calculate MAC only
04 = Calculate MAC and encrypt data

Session S-ENC Var K-spec Key specifier for Session S-ENC.


(Formats: 11, 12, 13, 14, 17, 18, 50, 51), (KMC: 0-3, 13, 17,
18)

Session S-MAC Var h Key specifier for Session S-MAC.


(Formats: 11, 12, 13, 14, 17, 18, 50, 51), (KMC: 0-3, 13, 17,
18)

Enc Method 1 h 00 = ECB


01 = CBC

MAC Method 1 h 00 = Single DES Plus Final Triple DES


01 = Full Triple DES

Text Var h Plaintext data. (multiple of 8 bytes)

RFU 2 h Reserved for future use.

ICV Flag 1 h 00 = Plaintext ICV


01 = Encrypted ICV

ICV 8 h Initial Chaining Vector

MAC Data Var h Data to be MAC'd


(multiple of 8 bytes)

Response Length Type Description

EE2061 3 h Function Code

rc 1 h Return Code

eSession S-ENC(Text) Var h Encrypted data

C-MAC Var h Message Authentication Code calculated using session S-


MAC key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 326
CHAPTER 4 Function Library

This function performs the cryptographic processing required for Secure Messaging of a command to be sent to the
card, i.e. message authentication and /or data encryption.
The function supports SCP01, SCP02 and SCP10. In these protocols, data encryption follows MAC calculation so
there is no requirement to place ciphertext into the MAC data.

Notes
– In support of command sequence integrity in SCP01 and SCP02, the ICV should be set to the C-MAC of the
previous command. The ICV Flag indicates whether ICV Encryption is being used.
– In support of command sequence integrity in SCP10, the ICV should be set to the value of the sequence
counter. As the value must be encrypted, the ICV Flag is set.

Processing Steps (explained in reference [36] )


1. If SC = 01 or 04, obtain S-ENC:

for formats 50, 51, derive card session S-ENC using KMC and data;
for formats 11 – 14, recover key (DPK) from key specifier.
2. If SC = 02 or 04, obtain S-MAC:

for formats 50, 51, derive card session S-MAC using KMC and data;
for formats 11 – 14, recover key (MPK) from key specifier.
3. If SC = 01 or 04, encrypt the Text using session S-ENC and the method specified in Enc Method as explained in
section D.3.4 of [36].
4. If SC = 02 or 04, calculate C-MAC using session S-MAC, ICV Flag, ICV, MAC Method and MAC Data as
explained in section D.1.3, D.1.5, and D.3.3 of [36].

Note: If flag = 00, set IV = ICV.


If flag = 01, set IV = 0 and prepend ICV to MAC Data.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 327
CHAPTER 4 Function Library

GP-SECURE-MESSAGING-COMMAND-SCP03 (EE2066)
Request Length Type Description

EE2066 3 h Function Code

FM 1 h Function Modifier (FM=00)

SC 1 h Select Code
01 = Encrypt data only
02 = Calculate MAC only
03 = Encrypt data and calculate MAC

Session S-ENC Var K-spec Key specifier for Session S-ENC.


(Formats: 52, 53)

Session S-MAC Var h Key specifier for Session S-MAC.


(Formats: 52, 53)

Counter 16 h Plaintext for encryption ICV

Text Var h Plaintext data. (multiple of 16 bytes)

Offset 2 h Position in MAC Data to insert encrypted text.

MCV 16 h MAC Chaining Value

MAC Data Var h Data to be MAC'd


(multiple of 16 bytes)

Response Length Type Description

EE2066 3 h Function Code

rc 1 h Return Code

eSession S-ENC(Text) Var h Encrypted data

C-MAC Var h Message Authentication Code calculated using session S-


MAC

This function performs the cryptographic processing required for Secure Messaging of a command to be sent to the
card. For example:
• Message authentication and / or data encryption, and
• Data encryption and / or generation of the C-MAC.
The function supports SCP03. In this protocol:
• Encryption is performed using AES in CBC mode and with an encrypted counter as the ICV;
• MACing is performed using CMAC, with S-MAC and a MAC Chaining Value;

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 328
CHAPTER 4 Function Library

• Data encryption precedes MAC calculation so there is a requirement to place ciphertext into the MAC data.

Processing Steps
1. If SC = 01 or 03, obtain S-ENC for formats 52, 53 and derive card session key S-ENC using KMC and data (as in
section 4.1.5 of [75]).
2. If SC = 02 or 03, obtain S-MAC for formats 52, 53 and derive card session key S-MAC using KMC and data (as in
section 4.1.5 of [75]).
3. If SC = 01 or 03, AES-CBC-encrypt the Text using session S-ENC. The plaintext value specified in counter will be
encrypted prior to use as the ICV in the encryption operation (as in section 6.2.6 of [75]).
4. If SC = 03, insert encrypted text into MAC Data at Offset.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 329
CHAPTER 4 Function Library

GP-SECURE-MESSAGING-RESPONSE (EE2062)
Request Length Type Description

EE2062 3 h Function Code

FM 1 h Function Modifier (FM=00)

SC 1 h Select Code
01 = Decrypt data only
02 = Verify MAC only
04 = Decrypt data and verify MAC

Session S-ENC Var K-spec Key specifier for Session S-ENC.


(Formats: 11, 12, 13, 14, 17, 18, 50, 51)

Session S-MAC Var h Key specifier for Session S-MAC.


(Formats: 11, 12, 13, 14, 17, 18, 50, 51)

Enc Method 1 h 00 = ECB


01 = CBC

MAC Method 1 h 00 = Single DES Plus Final Triple DES


01 = Full Triple DES

Encrypted Text Var h Ciphertext.

RFU 2 h Reserved for future use.

ICV Flag 1 h 00 = Plaintext ICV


01 = Encrypted ICV

ICV 8 h Initial Chaining Vector

MAC Data Var h Data to be MAC'd


(multiple of 8 bytes)

R-MAC Var h Message Authentication Code calculated using session S-


MAC key.

Response Length Type Description

EE2062 3 h Function Code

rc 1 h Return Code

Text Var h Decrypted data

This function performs the cryptographic processing required for secure messaging of a response message received
from the card.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 330
CHAPTER 4 Function Library

Processing Steps (explained in reference [37])


1. If SC = 01 or 04, obtain S-ENC:

for formats 50, 51, derive card session S-ENC using KMC and data;
for formats 11 – 14, recover key (DPK) from key specifier.
2. If SC = 02 or 04, obtain S-MAC:

for formats 50, 51, derive card session S-MAC using KMC and data;
for formats 11 – 14, recover key (MPK) from key specifier.
3. If SC = 01 or 04, decrypt the EncrypedText using session S-ENC and the method specified in Enc Method.
4. If SC = 02 or 04, calculate R-MAC using session S-MAC, ICV Flag, ICV, MAC Method and MAC Data.

Note: If flag = 00, set IV = ICV.


If flag = 01, set IV = 0 and prepend ICV to MAC Data.
5. If SC = 02 or 04, compare calculated R-MAC with R-MAC.
6. If SC = 04 and MAC verifies, return Text.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 331
CHAPTER 4 Function Library

HSM-STATUS (0001)
The HSM-STATUS request notifies the host of exception conditions at Luna EFT.

Request Length Type Description

0001 2 h Function Code

Msg ID 2 x Message Identifier

Response Length Type Description

0001 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 h Return Code

n 1 h Number of status bytes to follow

Data n x Returns ‘n’ number of ASCII digits that represent the


Software ID

The only two possible conditions are shown in the return code.
• A 00 code will denote successful completion and the data field will return with the software ID.
• A 08 code will denote a DES Cipher Processor Error. In this case, the software ID will not be returned.
This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 332
CHAPTER 4 Function Library

HSM-STATUS (01)
This function activates the self-tests and returns the results to the host.

Request Length Type Description

01 1 h Function Code

Response Length Type Description

01 1 h Function Code

rc 1 h Return Code

*RAM Status 1 h This is the result of performing a OS function to test the


RAM. A failure indicates faulty RAM.
0 = Passed
1 = Failed

ROM Status 1 h This is the result of performing a CRC check on the ROM. A
failure indicates ROM corruption or tampering.
0 = Passed
1 = Failed

*DES Status 1 h This is the result of performing numerous integrity checks


on the hardware cryptographic chip. A failure would indicate
faulty crypto hardware.
0 = Passed
1 = Failed

Host Port Status 1 h eth0 status


0 = Passed
1 = Failed
2 = Passed but not connected (for Ports)
Status check ensuring that the host port can be configured
and perform successful communication. Failure may
indicate either a software or hardware problem.
Note: The return value (02) is valid for Luna EFT platform
only.

Battery Status 1 h 0 = Passed


1 = Failed. Failure indicates a low or failed battery used to
maintain secure memory contents.

*Hard Disk Status 1 h Read IDE status port to ensure no IDE errors are reported.
0 = Passed
1 = Failed

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 333
CHAPTER 4 Function Library

Response Length Type Description

*RSA Accelerator 1 h Indicates that hardware is available to perform RSA


encryption and decryption and that it is functioning
correctly.
0 = Passed
1 = Failed
2 = Not Found.

Performance Level 1 h Configured Performance Level (PL).


If the Performance Level is either unknown or not
applicable, a value of 0 is returned.

Reset Count 2 h Number of time the HSM has been reset since
manufacture.
If the reset count is either unknown or not applicable, a
value of 0 is returned.

Calls in last minute 4 h Number of function calls to the host made in the last minute.
If the number of calls is either unknown or not applicable, a
value of 0 is returned.

Calls in last 10 mins. 4 h Number of function calls to the host made in the last 10
minutes.
If the number of calls is either unknown or not applicable, a
value of 0 is returned.

Software ID length 1 h The number of bytes (characters) making up the Software


ID. The maximum is 8.

Software ID n h Software ID.


The value has been set to M099999E.

* The values are as per the last selftest run on the HSM.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 334
CHAPTER 4 Function Library

HSM-STATUS-EXTN (0002)
This request notifies the host of exception conditions at Luna EFT.

Request Length Type Description

0002 2 h Function Code

Msg ID 2 x Message Identifier

Response Length Type Description

0002 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

dd 1 x Current Day

mm 1 x Current Month

yyyy 2 x Current Year

hh 1 x Current Hour

mm 1 x Current Minute

ss 1 x Current Second

PL 2 x Performance level

Flag 1 x RAM status


0 = passed
1 = failed

Flag 1 x ROM status

Flag 1 x DES status

Flag 1 x Host port status

Flag 1 x Battery status

Flag 1 x Hard Disk status

Flag 1 x RSA Accelerator


0 = passed
1 = failed
2 = not found

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 335
CHAPTER 4 Function Library

Response Length Type Description

Flag 1 bin Key Left = Key Right Flag


0 = Off
1 = On

Flag 1 bin Parity Check Flag


0 = Off
1 = On

Cnt 2 bin Reset count

CLM 4 bin Calls in last minute

CL10M 4 bin Calls in last 10 minute

CLRES 4 bin Calls since last reset mod 2**32

dd 1 x Day last used

mm 1 x Month last used

yyyy 2 x Year last used

hh 1 x Hour last used

mm 1 x Minutes last used

ss 1 x Seconds last used

dd 1 x Day last SCM reset

mm 1 x Month last SCM reset

yyyy 2 x Year last SCM reset

hh 1 x Hour last SCM reset

mm 1 x Minutes last SCM reset

ss 1 x Seconds last SCM reset

SWID_len 1 x Software ID. length

SWID n ASCII Software id.

Note:
This function supersedes function 0001.
All binary fields are little endian representation with least significant byte first.

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 336
CHAPTER 4 Function Library

HSM-STATUS-REV2 (EE0003)
This function activates the self-tests and return the results to the host. It also check and returns the status of AES
processor and Firmware Version.

Request Length Type Description

EE0003 3 h Function Code

FM 1 h Function Modifier (FM=00)

Response Length Type Description

EE0003 1 h Function Code

rc 1 h Return Code

*DES Status 1 h This is the result of performing numerous integrity checks


on the hardware cryptographic chip. A failure would indicate
faulty crypto hardware.
0 = Passed
1 = Failed

Host Port1 Status 1 h eth0 status


0 = Passed
1 = Failed
2 = Passed but not connected (for Ports)
Status check ensuring that the host port can be configured
and perform successful communication. Failure may
indicate either a software or hardware problem.
Note: The return value (02) is valid for Luna EFT platform
only.

Host Port2 Status 1 h eth1 status


0 = Passed
1 = Failed
2 = Passed but not connected (for Ports)
Status check ensuring that the host port can be configured
and perform successful communication. Failure may
indicate either a software or hardware problem.
Note: The return value (02) is valid for Luna EFT platform
only.

Battery Status 1 h 0 = Passed


1 = Failed. Failure indicates a low or failed battery used to
maintain secure memory contents.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 337
CHAPTER 4 Function Library

Response Length Type Description

AES Status 1 h 0 = Passed


1 = Failed
This is the result of performing numerous integrity checks
on the hardware cryptographic chip. A failure would indicate
faulty crypto hardware.

*RSA Accelerator 1 h Indicates that hardware is available to perform RSA


encryption and decryption and that it is functioning
correctly.
0 = Passed
1 = Failed
2 = Not Found.

Performance Level Var h Configured Performance Level (PL).


If the Performance Level is either unknown or not
applicable, a value of 0 is returned.

Reset Count 2 h Number of time the HSM has been reset since
manufacture.
If the reset count is either unknown or not applicable, a
value of 0 is returned.

Calls in last minute 4 h Number of function calls to the host made in the last minute.
If the number of calls is either unknown or not applicable, a
value of 0 is returned.

Calls in last 10 mins. 4 h Number of function calls to the host made in the last 10
minutes.
If the number of calls is either unknown or not applicable, a
value of 0 is returned.

Software ID Var h Software ID.


The value has been set to M099999E.

Firmware Version Var h Firmware version (x.x.x)

* The values are as per the last selftest run on the HSM.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 338
CHAPTER 4 Function Library

II-KEY-GEN (EE0402)
Request Length Type Description

EE0402 3 h Function Code

FM 1 h Function Modifier (FM = 00, 10, 20, 30. 40)

KIS/KI-Spec Var K-Spec Key specifier for KIS


(Formats: 0-3, 08, 10, 11, 12, 13, 14, 15, 17, 18)

Key Flags 2 h Key Type indicator / Encryption mode

Following fields must be present if 13th and 12th bit of Key Flags field is set to 10, i.e. response 1eKISn(KS) needed
in TR-31 format.
1Following fields must be repeated n times for each set of keys starting from the least bit (right most) of Key Flags
field.

Key Usage 2 h Valid values


DPK - ‘D0’
PPK - ‘P0’
MPK - ‘M0’, ‘M1’,’M2’,’M3’, ’M4’,’M5’, ’11’, ’12’, ’13’, ’14’,
’15’
KIS/KI - ‘K0’
Key Usage must be matched for Key Type in Key Flags.

Algorithms 1 h ‘D’, ‘T’, ‘2’.

Mode of use 1 h Any Valid values as described in the table Key Block
Header Fields for Key Block Format Keys

Key version number 2 h Key version number.

Exportability 1 h Any valid value as described in the table Defined Values for
Exportability Byte.

Key Block Version / 1 h xy, where


Padding Indicator x = Key block version
y = Padding indicator

x = 0 (TR-31 Key block Version A)


1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)
Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Number of optional fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Optional field 1 … n Var h


1KBS Var h Key Block structure. Optional.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 339
CHAPTER 4 Function Library

Response Length Type Description

EE0402 3 h Function Code

rc 1 h Return Code

N 1 h Number of following key sets.


1eKIS/KI vx(KS) Encrypted Session Key with KIS variant.
n
Or
1eKIS/KI (KB) Encrypted Session key in TR-31. Key Block format.
n
1KS-Spec Var Key-Spec Key specifier for Session key
(Formats: 10, 11, 12, 13, 14, 17, 18)
1KVC 3 h Key Verification Code

1 This set of fields will occur ‘n’ times in the response. Value of n can be at max 4.

Notes
– The key specifiers 10, 11, 13 under the Response, are generated when using the Legacy option.
– The key specifiers 10, 11, 13 under the Response, are generated based on the chosen operation on console
and FM. See section, Function Modifier Values.
*KBS field must be provided when key is needed in 17 or 18 formats. This field will repeat for each key to be generated.
When only host stored keys are needed in TR-31, KBS should be formed as:

KBS key block structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h Corresponding to key flags field in request.

Algorithms 1 h Any allowed value

Mode of use 1 h Any allowed mode of use for key usage

Key Version No. 2 h Any allowed value

Exportability 1 h Any allowed value

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 340
CHAPTER 4 Function Library

KBS key block structure

Field Length Type Description

Number of optional 0x00-0x03 (Decimal 00 to 03 Max)


fields

Optional field 0 … n Var h Number of optional field as defined in above filed. First byte of
optional field will be treated as Optional Block ID.

When both KTM encrypted key and key spec is need in TR-31 then KBS should be provided is mentioned below:

KBS key block structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h = 0000


Key usage will be determined from request TR-31 key block

Algorithms 1 h = 00
Algorithm will be determined from request TR-31 key block

Mode of use 1 h = 00
Mode of usage will be determined from request TR-31 key block

Key Version No. 2 h = 00 Key Version Number will be determined from TR31-key block

Exportability 1 h Any Valid value

Padding Indicator 1 h 00 = Do not pad


03 = Pad to triple length

Number of optional 1 h 00 = Same exportability as in request TR-31 key block


fields N = If request TR-31 has this field as ‘S’ or ‘E’, exportability will be
set to N in response key block.

Optional field 0 … n Var h Not allowed as Number of optional fields must be 0

This function generates a set of random DES or 3DES keys for an interchange. The key set may include any of the
session keys, PPK, MPK and DPK, and may also include a new key-encrypting key, KIS/KI.
If a key flag bit 3 or 7 or 11 is set then the following cases are possible:
• A bidirectional interchange key (KI) will be generated in the response if KIS/KI-Spec in request is in format 8.
• An interchange key send (KIS) will be generated in the response if the KIS/KI-Spec is any valid format other than
format 8.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 341
CHAPTER 4 Function Library

HMAC-SHA MPK can exist either inside the HSM or in the form of TR-31 key block protected under a transport key or
in key spec format 17 and 18 protected under KM for host storage. This function supports generation and distribution of
HMAC-SHA MPK.
For transmitting to the receiving institution, the generated keys are returned encrypted under the appropriate variant of
the Interchange Sending Key (KIS/KI) indicated by the 'KIS/KI-Spec' field in the function request. Exceptionally, if a
new KIS/KI is to be generated by the function, any session keys that are also generated are returned encrypted by that
new KIS/KI. For double-length keys, either ECB or CBC encryption modes may be selected.
The generated keys are also returned encrypted under the appropriate *KM variant for storage within the host. The
function also returns the KVCs of the generated keys.
The function response will contain one or more sets of encrypted key fields as shown: one set for each appropriate bit
set in the 'Key Flags' field. That field also indicates the encryption mode for any double-length keys that are generated.

FM = x0
The Host Key Protection using Function Modifier can be in the range of x0, where x = 0, 1, 2, 3, or
4.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 342
CHAPTER 4 Function Library

Key Flags Indicates the received encrypted keys and the encryption mode. The bit positions are allocated as
follows:

Bit Indicates

0 Single-length Data Key (DPK)

1 Single-length PIN encrypting key (PPK)

2 Single-length MAC key (MPK)

3 Single-length key-encrypting key (KIS/KI)

4 Triple-length Data Key (DPK)

5 Triple-length PIN encrypting key (PPK)

6 Triple-length MAC key (MPK)

7 Triple-length key-encrypting key (KIS/KI)

8 Double-length Data Key (DPK)

9 Double-length PIN encrypting key (PPK)

10 Double-length MAC key (MPK)

11 Double-length key encrypting key (KIS/KI)

12 - 13 Encryption mode for response eKIR/KInvx(KS):


00 = ECB
01 = CBC and
10 =TR-31, bit 12 is the least significant (right most) bit.

14 160 bit HMAC-SHA key (MPK)

15 Reserved. Must be zero.


Bit 0 is the least significant (right most) bit.

eKIR/KIvx(KS) Key encrypted by a variant of the Interchange Receive Key.

KS-Spec Key Specifier incorporating an encrypted key.

KVC Key Verification Code for the key

Example values of 'Key Flags' field


Value of 'Key Flags' field Encryption mode Keys to be generated

X’0004’ ECB Single-length MPK

X’0402’ ECB Single-length PPK; double-length MPK

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 343
CHAPTER 4 Function Library

Value of 'Key Flags' field Encryption mode Keys to be generated

X'1600' CBC Double-length PPK; double-length MPK

X'1A00' CBC Double-length KIS; double-length PPK

X’2204’ TR-31 Double-length PIN encrypting key; Single-length MAC key.

Details and Restrictions


1. The formats of the key specifiers in the response are dependent on the key type, and on the format of the KIS/KI-
Spec in the request.
2. If a HSM stored KIS/KI is provided in the request, the appropriate variant scheme will be used when encrypting a
generated key using that KIS/KI.
3. If a host stored KIS/KI is provided in the request in a key specifier format 8, 10, 11, 12, 13 or 14, the default KIS/KI
variants used to encrypt the outgoing session keys will be SafeNet variants. No variants will be used when the Use
'No Variants' with host stored KIS/KIR flag is set. Please refer to the Console Guide for further information on
setting or clearing this flag.
4. When the AS2805 variant scheme is used (HSM-stored KIS or host-stored KIS in a format 15 key specifier), a
double-length session key encrypted under KIS is encrypted using CBC. The encryption mode flag bit is ignored;
i.e. a value of 0 (ECB) will not cause an error.
5. When the Key Flags specify that a KIS/KI is to be generated:
a. If the KIS/KI keys are HSM stored (KIS/KI-Spec formats 0 – 3, 8), the key referenced must be set to "no
variants"
b. If the KIS/KI keys are host stored (KIS/KI-Spec formats 8, 10, 11 and 13) the keys are assumed to have no
variants. This will only affect the outgoing eKIS/KIvx(KIS/KI) field.
c. If the KIS-Spec is a Format 15, then only when the attributes are set to "no variant scheme" will this key spec
be accepted.

Failure caused due to any of the previous 3 occurrences will result in error 0x0C (Inconsistent request fields)
being returning as the return code
6. When the Key Flags specify that a KIS/KI is to be generated this new KIS is returned encrypted with the old
KIS/KI. The encryption mode depends upon the Key Flags mode bit.

Error Conditions
The following settings for the Key Flags field will result in a Return Code of 0C.
1. A request for a double-length key to be generated, though the KIS/KI indicated in the request is a single-length key
2. A request to generate a DPK, though this is disabled for the (HSM-stored) KIS/KI.
3. A request to generate a single-length KIS/KI, though the KIS indicated in the request is a double-length key
4. A reserved bit not set to zero.
5. A request to generate more than one of the same key type (regardless of key length, e.g. Single DPK/Double DPK).
Also see point 5 under "Details and Restrictions" above.

Notes
– The encryption mode for eKIS/KInvx(KS) and KS/KI-Spec is ECB unless otherwise specified.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 344
CHAPTER 4 Function Library

– This function will check the length of KIS/KIn and use the appropriate encryption method.
– When there is no variant scheme chosen for the KIS/KI, this function will automatically disable the ability to
generate a DPK. This part of the function can be manually enabled from the console by selecting “Enable
function for data key generation” under the KIS Options dialog.
– The AS2805 variant for KIS is chosen during key input at the HSM console.
– When the AS2805 variant scheme is used, the double length session key encrypted under KIS is output using
CBC. Please refer to the Console Guide for directions on how to set options for the KIS.
– This function supercedes function 51, 52, 53.
– Bits 13-15 of the key flags are reserved.
– Single length KIS/KI is not supported if generated Key is requested in TR-31 Key Block. i.e. Format 10 is not
supported for KIS-Spec. For format 0-3 HSM stored Single length KIS/KI Keys are also not supported.
– Allowed algorithms for Key Usage ‘M1’ will be ‘D’. Refer [45] of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 345
CHAPTER 4 Function Library

II-KEY-RCV (EE0403)
Request Length Type Description

EE0403 3 h Function Code

FM 1 h Function Modifier (FM = x0)

KIR/KI-Spec Var K-Spec Key specifier for KIR


(Formats: 0-3, 08, 10, 11, 12, 13, 14, 15, 17, 18)

Key Flags 2 h Key Type indicator / Encryption mode


1eKIR/KI vx(KS) Var h Encrypted Session Key
n
1eKIR/KI vx(KS) Encrypted Session Key by variants of KIR/KI.
n
Or Or
1eKIR/KI (KB) Encrypted Session Key in TR-31 Key Block formats.
n

*1KBS Var h Key Block structure. Optional and must be present if 1KS-
Spec required in TR-31 Key block format.

Response Length Type Description

EE0403 3 h Function Code

rc 1 h Return Code

N 1 h Number of following key sets.


1KS-Spec Var K-Spec Key specifier for Session Key
(Formats: 08, 10, 11, 12, 13, 14, 17, 18)
1KVC 3 h Key Verification Code.

1 This set of fields will occur ‘n’ times. Value of n can be at max 4.

Notes
– The key specifiers 10, 11 under the Response, are generated when using the Legacy option.
– The key specifiers 10, 11, 13 under the Response, are generated based on the chosen operation on console
and FM. See, Function Modifier Values.
*KBS field must be provided when key is needed in 17 or 18 formats. This field will repeat for each key received.
When incoming key is not in TR-31, KBS should be formed as:

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 346
CHAPTER 4 Function Library

KBS key block structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h Corresponding to key flags field in request.

Algorithms 1 h Any allowed value

Mode of use 1 h Any allowed mode of use for key usage

Key Version No. 2 h Any allowed value

Exportability 1 h Any allowed value

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Number of optional 1 h 0x00-0x03 (Decimal 00 to 03 Max)


fields

Optional field 0 … n Var h Number of optional field as defined in above filed. First byte of
optional field will be treated as Optional Block ID.

When incoming key is in TR-31 format KBS should be formed as:

KBS key block structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h == 0000


Key usage will be determined from request TR-31 key block

Algorithms 1 h = 00
Algorithm will be determined from request TR-31 key block

Mode of use 1 h = 00
Mode of usage will be determined from request TR-31 key block

Key Version No. 2 h = 00 Key Version Number will be determined from TR31-key block

Exportability 1 h = Any valid value


If this value clashes with exportability field of incoming key then
this value will be used to form response key block provided
incoming exportability is ‘E’ or ‘S’.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 347
CHAPTER 4 Function Library

KBS key block structure

Field Length Type Description

Padding Indicator 1 h 00 = Do not pad


03 = Pad to triple length

Number of optional 1 h = 00 Must be 0


fields

Optional field 0 … n Var h Not allowed as Number of optional fields must be 0

This function re-encrypts a received set of encrypted DES or 3DES keys for host storage. The key set may include any
of the session keys, PPK, MPK and DPK, and may also include a new key-encrypting key, KIR/KI.
If a key flag bit 3 or 7 or 11 is set then the following cases are possible:
• The new key-encrypting will be a bidirectional interchange key (KI), if the KIR/KI-Spec in request is in format 8.
• The new key-encrypting will be an interchange key receive (KIR),if the KIR/KI-Spec is any valid format other than
format 8.
As received from the sending interchange institution, the keys are encrypted under the appropriate variant of the
Interchange Receive Key (KIR/KI) indicated by the 'KIR/KI-Spec' field in the function request. Exceptionally, if a new
KIR/KI is included in the set, any session keys that are also included must be encrypted by that new KIR/KI. For
double-length keys, either ECB or CBC encryption modes are supported.
The received keys are returned encrypted under the appropriate *KM variant for storage within the host. The function
also returns the KVCs of the received keys.
The function request and response will contain one or more sets of encrypted key fields as shown: one set for each
appropriate bit set in the 'Key Flags' field. That field also indicates the encryption mode for any double-length keys that
are received.

FM = x0
The Host Key Protection using Function Modifier can be in the range of x0, where x = 0, 1, or 2.

KIR/KI-Spec A key specifier for an HSM-stored or host-stored, single-length or double-length or triple-length


KIR/KI. Accepts key spec formats 0 - 3, 08, 10, 11, 12, 13, 14, 15, 17 and 18.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 348
CHAPTER 4 Function Library

Key Flags Indicates the received encrypted keys and the encryption mode. The bit positions are allocated as
follows:

Bit Indicates

0 Single-length Data Key (DPK)

1 Single-length PIN encrypting key (PPK)

2 Single-length MAC key (MPK)

3 Single-length key-encrypting key (KIR/KI)

4 Triple-length Data Key (DPK)

5 Triple-length PIN encrypting key (PPK)

6 Triple-length MAC key (MPK)

7 Triple-length key-encrypting key (KIR/KI)

8 Double-length Data Key (DPK)

9 Double-length PIN encrypting key (PPK)

10 Double-length MAC key (MPK)

11 Double-length key encrypting key (KIR/KI)

12 - 13 Encryption mode for decipher of the inbound eKIRnvx(KS):


00 = ECB
01 = CBC
10 = TR-31, bit 12 is the least significant (right most) bit.

14 Indicates presence of 160 bit HMAC-SHA key (MPK)

15 Reserved. Must be zero.

eKIR/KIvx Key encrypted by a variant of the Interchange Receive Key.


(KS)

KS-Spec Key Specifier incorporating an encrypted key.

KVC Key Verification Code for the key. Depends upon the key flag and is calculated depending upon the
key flag.

Example values of 'Key Flags' field


Value of 'Key Flags' field Encryption mode Keys to be generated

X’0004’ ECB Single-length MPK

X’0402’ ECB Single-length PPK; double-length MPK

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 349
CHAPTER 4 Function Library

Value of 'Key Flags' field Encryption mode Keys to be generated

X'1600' CBC Double-length PPK; double-length MPK

X'1A00' CBC Double-length KIS; double-length PPK

X’2204’ TR-31 Double-length PIN encrypting key; Single-length MAC key.

Details and Restrictions


• The formats of the key specifiers in the response are dependent on the key type, and on the format of the KIR/KI-
Spec in the request.
• If an HSM-stored KIR/KI is provided in the request, its associated variant scheme will be used when decrypting an
encrypted key using that KIR.
• If a host stored KIR/KI is provided in the request in a format 8, 10, 11, 12 , 13, or 14 key specifier, the default KIR
variants used to decrypt the incoming session keys will be SafeNet variants. No variants will be used when the
Use 'No Variants' with host stored KIS/KIR flag is set. Please refer to the Console Guide for further information on
setting or clearing this flag.
• When the AS2805 variant scheme is used (HSM-stored KIR or host-stored KIR in a Format 15 key specifier), a
double-length session key encrypted under KIR is decrypted using CBC. The encryption mode flag bit is ignored;
i.e. a value of 0 (ECB) will not cause an error.
• When the Key Flags indicate that a new KIR/KI is included in the set:
– If the KIR/KI keys are HSM stored (KIR/KI-Spec formats 0 – 3, 8), the key referenced must be set to "no
variants"
– If the KIR/KI keys are host stored (KIR/KI-Spec formats 8, 10, 11, 12, 13 and 14) the keys are assumed to
have no variants. This will only affect the incoming eKIR/KIvx(KIR/KI) field.
– If the KIR-Spec is a Format 15, then only when the attributes are set to "no variant scheme" will this key spec
be accepted.
Failure caused due to any of the previous 3 occurrences will result in error 0x0C (Inconsistent request fields) being
returning as the return code.
• When the Key Flags specify that a new KIR/KI is included in the set this new KIR is encrypted with the old KIR/KI
(KIR/KI-Spec). The encryption mode depends upon the Key Flags mode bit.
• If eKIR/KIn(KB) is in TR-31 Key block format and Key expected for host storage is other than TR-31, key block will
only allow if it is enabled from Console.

Error conditions
The following settings for the 'Key Flags' field will result in a Return Code of 0C.
1. A request for a double-length key to be re-encrypted, though the KIR/KI indicated in the request is a single-length
key
2. A request to re-encrypt a DPK, though this is disabled for the (HSM-stored) KIR/KI.
3. A request to re-encrypt a single- and double-length key of same type.
4. A reserved bit not set to zero.

Notes
– The encryption mode for eKIR/KInvx(KS) and KS-Spec is ECB unless otherwise specified.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 350
CHAPTER 4 Function Library

– This function will check the length of KIR/KIn and use the appropriate encryption method.
When there is no variant scheme chosen for the KIR/KI, this function will automatically disable the ability to
generate a DPK. This part of the function can be manually enabled from the console by selecting “Enable
function for receiving of data keys” under the KIR/KI Options dialog.

The AS2805 variant for KIR is chosen during key input at the HSM console. When the AS2805 variant scheme
is used, the eKIRnvx(KS) must be encrypted using CBC. Please refer to the Console Guide for directions on
how to set options for the KIR.

This function supercedes functions 54, 55, 56. Bits 13-15 are reserved.
– Input Key 1eKIR/KIn(KS) may be in TR-31 Key Block. If input key is in TR-31 Key Block format Key Usage of
1eKIR/KI (KS)must be matched for Key Type for each set of keys starting from the least bit (right most) of Key
n
Flags field.
– Single length KIR/KI is not supported if incoming Key in TR-31 Key Block. i.e. Format 10 is not supported. For
format 0-3 HSM stored Single length KIR/KI Keys are also not supported.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 351
CHAPTER 4 Function Library

IMP-ENC-PUB-KEY (EE4008)
Request Length Type Description

EE4008 3 h Function Code

FM 1 h Function Modifier

Key Type 2 h Indicates the valid usage for the key


Bit Key Type
0 : Certificate
1 : Data Signature
Bit 0 is the least significant (rightmost) bit.

PK Var K-spec Key specifier for unauthenticated public key. (Format: 80)

User Data Var h Data to be stored in key specifier for PK. (May be zero-
length field)

Response Length Type Description

EF4008 3 h Function Code

rc 1 h Return Code

ePK Var K-spec Key specifier for encrypted authenticated public key.
(Format: 83)

This function accepts a RSA public key, encrypts it and places the result in a format-83 key specifier, thereby
producing an authenticated and confidentiality-protected public key. The function is used to import PCA-TM.

Note: The function is disabled, by default and to prevent unauthorized public keys from being
introduced, it is recommended to be kept in a disabled state.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 352
CHAPTER 4 Function Library

IMPORT-CSCK (AB)
Request Length Type Description

AB 1 h Function code

CSCK-Storage Indicator 1 h This field specifies whether the imported key is to be stored
in the host database or in HSM secure memory.
Currently only the value 0 is supported which means
storage on the host.

KIR/KI-Spec Var K-Spec Key specifier for KIR/KI (ZMK)


(Formats: 0–3, 08 (for KI only))

eKIR(CSCK) 16 Encrypted CSCK


or eKI(CSCK)

Response Length Type Description

AB 1 h Function code

rc 1 h Return code

CSCK-Spec Var K-Spec Key specifier for CSCK


(Format: 11, 13)

KVC 3 h Key verification code of CSCK

This function causes a key to be returned encrypted under the HSM’s KM variant 6 for storage on the host database.

Notes
– The key specifier 11 under the Response, are generated when using the Legacy option.
– The key specifiers 11, 13 under the Response, are generated based on the chosen operation on console and
FM.
– The KVC returned in the response is calculated as the leftmost 24 bits of the result of triple-DES encrypting a
64-bit Block of zeros with the double-length key.
– Bidirectional Interchange key “KI” will be allowed only in format 08 in the request. Also, within format 08 only
format 0-3 will be allowed for KI.
– The Encrypted CSCK in the request can be:
eKIR (CSCK) if KIR was received in the request field KIS/KI Spec.
eKI(CSCK) if KI was received in the request field KIS/KI Spec.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 353
CHAPTER 4 Function Library

IMPORT-EMV-CERTIFICATE (EE9011)
Request Length Type Description

EE9011 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PKCA Var K-Spec Authenticated public key of CA.


(Format: 81
Key Type: Certificate)

Hash Function 1 h 01 = SHA-1

Certificate Var h Public key Certificate

Public Key Remainder Var h Used to validate the recovered certificate data.

Public Exponent Var h = 3 or 65537 (216+1).

Key Type 2 h Indicates the valid usage for the private key

bit key type

0 Certificate

1 Data Signature

2 Key Transport

4 Data Protect

Bit 0 is the least significant (rightmost) bit.

User Data Var h Optional user data to be included in key specifier for the
public key.

Response Length Type Description

EE9011 3 h Function Code

rc 1 h Return Code

PK Var K-Spec Key specifier for authenticated public key. (Format: 81)

Certificate Data Var h The data recovered from Certificate, of length equal to the
length of the CA Public Key Modulus ( NCA)

This function verifies an EMV certificate. If successful, it returns the public key in a key specifier and also provides the
data recovered from the certificate.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 354
CHAPTER 4 Function Library

Processing Steps
1. Verify public key certificate
– Recover contents of certificate using PKCA
– Calculate hash of certificate using data in certificate, public key remainder and public key exponent under
SHA-1
– Verify certificate using hash calculated in step 1b and hash result recovered from certificate.
2. Retrieve public key from Certificate data.
3. Concatenate Public key remainder to the public key modulus (retrieved from certificate).
4. Calculate response PK (Key specifier for authenticated public key) using public modulus, public exponent, Key
type, and user data.

Note: Table 9 in reference [5] is used for format of the Data Recovered from the Issuer Public
Key Certificate.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 355
CHAPTER 4 Function Library

IMPORT-KEY-PACKAGE (EE3104)
Request Length Type Description

EE3104 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Control 1 h Representing segment type


= 01: First Segment
= 02: Other segments

File Length/Offset 4 h Dual Variable

Data Segment Var h A portion of the Key Package

Response Length Type Description

EE3104 3 h Function Code

rc 1 h Return Code

Cumulative Data Length 4 h Length of partial saved package

This function is used to load an Export Key Package to the HSM from the host. To load the files many calls may be
required. On success, the function returns a 4-byte value in cumulative length field to show the length of the file that has
been received so far, and this value must be included in the File Length / Offset field in the next function call.
Once the package is fully loaded the HSM will automatically begin the verification and key import operation. Depending
on the size of the package it may take some time in the verification and import process.

Control 01 – First segment of Key Package is being presented. If a Key Package (or part of key
Package) is already in the HSM then this function will cause the old package to be deleted.
02 – Add this segment to the end of the Key Package.

FileLength/Offset This field acts like a dual variable which holds the value of the total Key Package length
when function is being called for the first time (control=1) and the Offset for other function
calls (control=2).

DataSegment This field has a variable data length and contains the next data segment of the Key
Package.

Cumulative Data On success function return 4 bytes value to show the length of the Key Package that has
Length been received so far and this value must be included into the FileLength/Offset field of the
next function call.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 356
CHAPTER 4 Function Library

IMPORT-PUBLIC-KEY (EE9003)
Request Length Type Description

EE9003 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Key Type 2 h Indicates the valid usage for the private key

bit key type

0 Certificate

1 Data Signature

2 Key Transport

4 Data Protect

Bit 0 is the least significant (rightmost) bit.

PK Var K-Spec Key specifier for unauthenticated public key. (Format: 80)

User Data Var h Data to be stored in key specifier for PK. (May be zero-
length field.)

Response Length Type Description

EE9003 3 h Function Code

rc 1 h Return Code

PK Var K-Spec Key specifier for authenticated public key. (Format: 81)

This function produces a key specifier incorporating an authenticated public key.


To prevent unauthorized public keys from being introduced, the function should normally be disabled. The default
condition is disabled.

Function usage (in context of Remote ATM Initialization)


NCR

Import of NCR’s public key: PK-NCR.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 357
CHAPTER 4 Function Library

IMPORT-PUBLIC-KEY-CERTIFICATE (EE9004)
Request Length Type Description

EE9004 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PKCA Var K-Spec Authenticated public key of CA


(Format: 81
Key Type: Certificate)

Certificate Format 1 h 01 = EMV (not currently implemented)


02 = X.509
03 = NCR
04 = NCR2

Hash Function 1 h 00 = None


01 = SHA-1
Provide used hash function, if certificate format is of type
03.
03 = SHA224, 04=SHA256, 05=SHA384 and 06=SHA512
(for X.509 Certificate format only).

Certificate Var h Public key certificate

Key Type 2 h Indicates the valid usage for the private key

bit key type

0 Certificate

1 Data Signature

2 Key Transport

Bit 0 is the least significant (rightmost) bit.

User Data Var h Optional user data to be included in Public Key Specifier.

Response Length Type Description

EE9004 3 h Function Code

rc 1 h Return Code

PK Var K-Spec Key specifier for authenticated public key. (Format: 81)

This function verifies the signature on the public key certificate and returns the public key in an authenticated key
specifier. The key type of the key will be set in the key specifier as specified in the Key Type request field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 358
CHAPTER 4 Function Library

Function usage (in context of Remote ATM Initialization)


NCR

1. Import of Host’s public key, PK-HSM, from the signed public key: PK-HSM +
(PK-HSM)*SK-NCR. The signature is as generated by the RSASSA-PKCS-v1_5 scheme of [Reference [21] of
Mark II].

Note:
- The authenticated key specifier may not be required and may be discarded.
- The function may be used just to verify that the signed public key corresponds with the public
key sent to NCR. The Verify signed data function may be used instead.

(The Verify signed data function may be used instead.)


2. Import of EPP’s public key, PK-EPP, from the signed public key: PK-EPP +
(PK-EPP)*SK-NCR. The signature is as generated by the RSASSA-PKCS-v1_5 scheme of [Reference [21] of
Mark II].

Certificate If equal to 03 (NCR), the data in the Certificate field takes the format:
Format modulus (256 bytes) concatenated with signature (256 bytes).

If equal to 04 (NCR2), the data in the Certificate field is represented in


PKCS#1, ASN.1 type RSAPublicKey.

RSAPublicKey ::= SEQUENCE {


modulus INTEGER, -- n
publicExponent INTEGER, -- e
}

The fields of type RSAPublicKey have the following meanings:


- modulus is the modulus n.
- publicExponent is the public exponent e.

The following table illustrates a certificate in the PKCS#1, ASN.1 type RSAPublicKey (i.e. Certificate format = 04 -
NCR2 ).

Component Example

Sequence and length 3082010A

ASN.1 Integer type and length 02820101

ASN.1 Modulus (257 bytes – 256 byte modulus preceded by leading zero 009F9C7EAD…
byte

The ASN.1 integer type with length of 3 and then the exponent data 0203010001

Signature (256 bytes) 6E45FCE8D6…

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 359
CHAPTER 4 Function Library

Note:
- The certificate field is a Var field.
- The ASN.1 format described in the example above must be preceded by the variable length
prefix described in Function Construction.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 360
CHAPTER 4 Function Library

IMPORT-RSA-ENC-KEY (EE3060)
This function is used to translate a key from encryption under an asymmetric key to encryption under AES Domain
Master Key.

Request Length Type Description

EE3060 3 h Function Code

FM 1 h Function Modifier = 00

Private Key Var K-Spec Key specifier containing the private key encrypted by a KM
variant
Format: 82
Key Type: Key Transport

Mode 1 h 00: PKCS1-BLOCK


01: PKCS1-OAEP

ePK(Key) Var h Key encrypted under Public Key

Format 1 h Output format of the key


Allowed format for KTK: 1C

Key Details Var h Key Details.


Valid key type is KTK =35
Valid Algo is AES

KVC Method 1 h 01: Standard KVC method (Left Most 6 nibbles)

Response Length Type Description

EE3060 3 h Function Code

rc 1 h Return Code

eKMvx(Key) Var K-Spec KM encrypted key


Format: 1C

KVC Var h KVC of translated key

Key Details
Format 1C

Key detail field contains following details pertaining to 1C key format.

KM-index 1 h Index of KM

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 361
CHAPTER 4 Function Library

Key Type 1 d Variant id.

Algorithm 1 h Algorithm

Key length 1 h Key length

Padding 1 h Padding to be used in generated key

Mode of operation 1 h Mode of Operation

Processing Steps
1. Extract Private Key
2. Use extracted Private Key to decrypt key encrypted under Public Key and extract clear key.
3. Calculate extracted clear key’s KVC.
4. Using format and key details received in request, encrypt the extracted clear key (in step 2) under Domain Master
Key.
5. Return the KM encrypted key along with its KVC in response.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 362
CHAPTER 4 Function Library

IMPORT-RSA-PRIVATE-KEY (EE9013)
This function imports an encrypted RSA key private key.

Request Length Type Description

EE9013 3 h Function Code

FM 1 h Function Modifier (FM=00)

Private key structure Var Var Variable length private key structure

Output key format 1 h Format 82

Key Type 2 h Indicates the valid usage for the private key

bit key type

4 Data Protect (0x0010)

KM id 1 h Only 00 is supported

User Data Var h Data to be stored in key specifier for SK.


(May be zero-length field.)

Response Length Type Description

EE9013 3 h Function Code

rc 1 h Return Code

SK Var K-Spec Key specifier containing the private key (SK) encrypted by a
KM variant.
Format: 82

RSA private structure


Input private key 1 h 01 = PKCS12
format

Private Key Var K-Spec Private key


When input key format is 01, This field contains PKCS12
archive key store.
Only allowed values for modules are 1024 and 2048 bit.

Private key Var Var field PassPhrase


passphrase When input key format is 01, this field contains passphrase
used to encrypt key blob.
Maximum length of passphrase can be 128 bytes.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 363
CHAPTER 4 Function Library

This function imports RSA private key from PKCS#12 format to KM encrypted RSA keys. PKCS#12 format relies on
password for RSA key protection and comparatively less secure then HSM keys. Therefore, by default this function is
disabled.

Processing Steps
1. Extract Private Key from PKCS12 archive store. Use passphrase provided as password for decryption.
Note: The function will not check for validity of certificates stored inside the key store.
2. Validate RSA modulus size. Only 1024 bit and 2048 bit keys are supported.
3. Create format 82 key spec using private key extracted in step 1. Use input request parameters (KM id, key type,
user data).
4. Return private key in response.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 364
CHAPTER 4 Function Library

IMPORT-TRANSPORT-KEY (EE9203)
Request Length Type Description

EE9203 3 h Function Code

FM 1 h Function Modifier = x0

Private Key Var K-Spec Key specifier containing the private key (SK) encrypted by a
KM variant.
(Format: 82)

Key Type 1 d 05 = KTM

ePK(TransportKey) Var h Encrypted Transport Key using Public Key

Padding Scheme 1 h 01 = PKCS#11v1.5


02=OAEP

Response Length Type Description

EE9203 3 h Function Code

rc 1 h Return Code

eKMv5(KTM) Var h Retrieved KTM


(Format 11,12,13,14)

This function decrypts the padded KTM using RSA’s private key. Actual KTM will be retrieved depending on the correct
padding scheme. The retrieved KTM encrypted with KMv5 will be sent in response field. KTM is encrypted with KMv5,
so that it can be used directly in function EE040C.

FM The Host Key Protection using Function Modifier can be in the range of x0, where x= 0, 1, or 2.
00 : Global
10 : ECB
20: CBC

Private Key Format 82 (Key Type field will only support Key Transport)

ePK(TransportKey) Transport Key = Transport KeyType || KTM || KCV Data || KCV

Transport Key Structure


Field Name Size (In Bytes) Description

Transport Key Type 1 The transport key type. It shall have the following value:
0 – Double length triple DES key

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 365
CHAPTER 4 Function Library

Field Name Size (In Bytes) Description

KTM 16 The transport key value

KCV Data 8 The value used for the generating the KCV. This shall currently be all zeros.

KCV 3 or 4 The first 3 or 4 bytes of the KCV Data encrypted using the Transport Key

NOTE:
• Key Type (T) field will only support 0
• KTM can only be double length
• KCV Data can only be 8 zeros
• KCV is left most 3 or 4 bytes of eKTM(KCV Data)

Processing Steps
1. Validate the Private Key.
2. Validate the Padding Scheme. Only PKCS#11v1.5 and OAEP is supported. Any other value would result in error.
3. Decrypt the public key encrypted Transport key using given Private Key and Padding Scheme.
4. If Transport Key length is 28, KCV will be of 3 bytes and if Transport Key length is 29, KCV will be of 4 bytes. Any
other transport key length would result in error.
5. Validate the contents of Transport Key:
– First byte should be 00 to signify double length key. Any other value would result in error.
– Next 16 bytes is actual transport key (or KTM).
– Next 8 bytes of KCV Data would be all zeros. Any other value would result in error.
– Next 3 or 4 bytes is the retrieved KCV.
– Calculate the KCV using Transport Key (step 5b) and KCV Data (step 5c).
– Compare the calculated KCV with the retrieved KCV. Any mismatch would result in error.
6. Encrypt the retrieved KTM (step 5b) with KMv5 and return in response.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 366
CHAPTER 4 Function Library

INIT-KEY-EXCH (EE4005)
Request Length Type Description

E4005 3 h Function Code

FM 1 h Function Modifier

eSENC 40 x Terminal cryptogram


(EFTPOS cryptogram
data)

eKMv47(KE) Var K-spec Terminal random key (Formats: 11, 13)

eKMv47(KF) Var K-spec FEP random key (Formats: 11, 13)

STAN 6 h

Terminal ID 8 h

Issuer ID 4 h

TIK Var K-spec DUKPT Initial Key (Format: 20)

SMID 10 h DUKPT initial KSN

Response Length Type Description

EE4005 3 h Function Code

rc 1 h Return Code

eSENC 56 h FEP cryptogram with SMID and terminal initial key


(FEP cryptogram data)

This function performs the processing described in section 2.2 of [72], and as listed below.
• Verify terminal cryptogram according to appendix C.1 of [72].
• Create session keys according to chapter 4.4.3 of [72].
• Create cryptogram with terminal initial key according to appendix C.2 of [72].

Processing Steps
1. Recover KE and KF.
2. Calculate SENC and SMAC as specified in 4.4.3 of [73].
3. Decrypt the terminal cryptogram using SENC. (CBC with IV = 0. Include the (encrypted) MAC field in the decryption
process.)
4. Check the STAN and Terminal ID fields against those fields in the request message.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 367
CHAPTER 4 Function Library

5. Calculate a MAC using SMAC and the first 32 bytes of the plaintext, and check the result with the MAC field in the
plaintext.
6. Extract random number RNE.
7. Calculate DUKPT IK (TIK) using BDK and left 64 bits of SMID.
8. Create FEP Cryptogram, as specified in Appendix C2 of [73].
– Insert SMID, TIK, RNE and Pad Pattern.
– Calculate MAC using SMAC and insert result.
– Encrypt cryptogram data using SENC. (CBC with IV = 0. Include the MAC field in the encryption process.)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 368
CHAPTER 4 Function Library

INITIAL-KEY-REC (B580)
This function returns the initial key (KI), PIN Pad Identification Number, Date-Time-Stamp, Random Number and user
data from the Initialize Request Message.

Request Length Type Description

B580 2 h Function Code

Msg ID 2 x Message Identifier

eKMvA0(SKsp) Var K-Spec Sponsor’s Secret Key (Format: 42)

eKMvAC(PKtcu) Var K-Spec TCU’s Public key (Format: 42)

sSKtcu[cPKsp Var S-Block Signed initial key, PPID, Date and time stamp, Random
(KI,PPID,DTS,RN,data)] number and user data

RN 8 x Random Number

Response Length Type Description

B580 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKMv82(KI) Var K-Spec TCU Initialization Key (Format: 21)

PPID 8 d PIN Pad identification number

DTS 6 d Date-Time stamp

Data 16 x User Data

Note:
- The User Data field is left justified and right zero filled.
- The function verifies the Random Number. An error code of 40 - RANDOM NUMBER
VALIDATION ERROR - is returned if the validation fails.
- The TCU key pair has a length of 960 bits and the SP key pair has a length of 896 bits.
- The KI.PPID.DTS.RN.data clear text is formatted as DFormat 1 before encrypting with
PKSP. The output produced is then formatted again using DFormat 1 before signing by the
SKTCU.
- For RSA key encryption by a KM, the Format 42 is applied.
- 'data' may be variable length in the range 0 - 16. If less than 16 bytes, data will be left justified
and padded with zeros.

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 369
CHAPTER 4 Function Library

IPEK-DERIVE (EE040A)
Request Length Type Description

EE040A 3 h Function Code

FM 1 h Function Modifier (FM=00)

KTK Var K-spec A key specifier for the KTK


(Formats: 0-3)

IK Var K-spec Key specifier to derive Initial Key


(Format 20)

Enc. Mode 1 h Mode of operation for encryption of IK.

KBS Var h Key Block Structure (optional)

Response Length Type Description

EE040A 3 h Function Code

rc 1 h Return Code

eKTK(IK) Var h ECB- or CBC-encrypted DUKPT Initial Key


or
Encrypted Key in TR-31 Key Block Format (for Enc. Mode =
02)

KVC 3 h Key Verification Code of IK

This function derives the initial key for a DUKPT PIN Entry Device and returns it encrypted by a Key Transport Key
(KTK).

FM Must = 00

KTK Key specifier for HSM-stored Key Transport Key.

IK A format-20 key specifier that provides the BDK and KSN used to derive the initial key for PIN Entry
Device. The Encryption Counter part of the KSN (i.e. the least significant 21 bits) must be zeroes

Enc Mode Mode of operation for encryption of IK.


00 = ECB
01 = CBC
02 = TR-31 formatted result
This value will require KBS structure to be populated.

KBS Key Block structure. KBS must be present when encryption mode is 02.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 370
CHAPTER 4 Function Library

Note:
- The derived key will be a double length key – as only that key length is currently supported by
the format 20 key specifier. It is returned in a Var field to accommodate any future extensions.
- The KTK is the key type from the CI functionality. It can also be used to transport keys to an
EMV chip card. (It is not the ZKA KTK).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 371
CHAPTER 4 Function Library

IPEK-DERIVE-2 (EE040C)
Request Length Type Description

EE040C 3 h Function Code

FM 1 h Function Modifier (FM=00)

KTM Var K-spec A key specifier for the KTM


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18)

IK Var K-spec Key specifier to derive Initial Key


(Format 20), (BDK: 0-3, 13, 14, 17, 18)

Enc. Mode 1 h Mode of operation for encryption of IK.

KBS Var h Key Block Structure (optional)

Response Length Type Description

EE040C 3 h Function Code

rc 1 h Return Code

eKTM(IK) Var h ECB- or CBC-encrypted DUKPT Initial Key


or
Encrypted Key in TR-31 Key Block Format (for Enc. Mode =
02)

KVC 3 h Key Verification Code of IK

This function derives the initial key for a DUKPT PIN Entry Device and returns it encrypted by a Key Terminal Master
Key (KTM).

FM Must = 00

KTM Key specifier for HSM and host stored Terminal Master Key.

IK A format 20 key specifier that provides the BDK and KSN used to derive the initial key for PIN Entry
Device. The Encryption Counter part of the KSN (i.e. the least significant 21 bits) must be zeroes

Enc Mode Mode of operation for encryption of IK.


00 = ECB
01 = CBC
02 = TR-31 formatted result
This value will require KBS structure to be populated.

KBS Key Block structure. KBS must be present when encryption mode is 02.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 372
CHAPTER 4 Function Library

The following TR-31 field definition requires to be put in practice for use.

TR-31 Fields

Key Name Key usage Mode of use Algo

DUKPT Initial Key ' B1' X T


(IPEK)

Key Block Structure (KBS)


Response Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h B 0x42

Key Usage 2 h B1

Algorithms 1 h T

Mode of use 1 h X

Key Version No. 2 h Key version number

Exportability 2 h S

Padding Indicator 1 h 00 = Do not pad


03 = Pad to triple length

Number of optional fields 1 h 0x00 - 0x03 (Decimal 00 to 03 Max)

Optional field 0 … n Var h Number of optional field as defined in above field.


First byte of optional field will be treated as Optional Block ID.

Note:
- The derived key will be a double length key, as only that key length is currently supported by
the format 20 key specifier. It is returned in a Var field to accommodate any future extensions.
- The TR31 Key usage should be set to “B1” which is defined as DUKPT IPEK.
- The TR31 mode of use should be set to “X”, which is defined as key used to derive other keys.
- The TR31 exportability should be set to “S”, defined as a sensitive key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 373
CHAPTER 4 Function Library

IT-KEY-GEN (EE0400)
Request Length Type Description

EE0400 3 h Function Code

FM 1 h Function Modifier (FM = x0)

KTM-Spec Var K-Spec A key specifier for the KTM


(Formats: 0-3, 10, 11, 12, 13, 14, 16, 17, 18)

Key Flags 2 h Key Type generation specifier

Following fields must be present if 13th and 12th bit of Key Flags field is set to 10, .i.e. response 1eKTM(KS) is
needed in TR-31 format.

1Following fields must be repeated n times for each set of keys starting from the least bit (right most) of Key Flags
field.

Key Usage 2 h Valid values:


DPK - ‘D0’
PPK - ‘P0’
MPK - ‘M0’, ‘M1’,’M2’,’M3’,
’M4’,’M5’
KTM - ‘K0’, 'K1'
Key Usage must be matched for Key Type in Key Flags.

Algorithms 1 h ‘D’, ‘T’.

Mode of use 1 h Any Valid values as described in the table Key Block
Header Fields for Key Block Format Keys.

Key version number 2 h Key version number

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte.

Key Block Version / 1 h xy, where


Padding Indicator x = Key block version
y = Padding indicator

x = 0 (TR-31 Key block Version A)


1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)
Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 374
CHAPTER 4 Function Library

Request Length Type Description

Number of optional fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Optional field 1 … n Var h

*KBS Var h Key Block Structure. Optional.

Response Length Type Description

EE0400 3 h Function Code

rc 1 h Return Code

n 1 h Number of following key sets


1eKTM(KS) or Var h Encrypted Session Key
eKTM(KB) Encrypted Key in TR-31 Key Block format.
1KS-Spec Var K-Spec Key specifier incorporating encrypted Session Key
(Formats: 10, 11, 12, 13, 14, 16, 17, 18)
1KVC 3 h Key Verification Code

1 This set of fields will occur ‘n’ times in the response. Value of n can be at max 3.

This function generates a set of random session keys for an EFT terminal. For distribution to the terminal the session
keys are encrypted by the Terminal Master Key (KTM), and for host storage and subsequent use with other functions
they are encrypted by variants of the Domain Master Key. The function also returns the KVC of the session keys.
If a new KTM is to be generated by the function, any session keys that are also generated are returned encrypted by the
new KTM. For double-length DES session keys, either ECB or CBC modes may be selected.
When the request field KTM-Spec refers to a HSM or host stored SEED key (Format 16) the response field(s) KS-Spec
will be Format 16, the session key(s) will be encrypted according to the SEED algorithm and the KVC will be calculated
according to the SEED KVC method.
*KBS field must be provided when key is needed in 17 or 18 format. This field should repeat for each new key to be
generated.
When only host stored keys are needed in TR-31, KBS should be formed as :

KBS key block structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h Any allowed value for the key to be generated.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 375
CHAPTER 4 Function Library

KBS key block structure

Field Length Type Description

Algorithms 1 h Any allowed value

Mode of use 1 h Any allowed mode of use for key usage

Key Version No. 2 h Any allowed value

Exportability 1 h Any allowed value

Padding Indicator 1 h 03 = Pad to triple length

Number of optional fields 1 h 0x00-0x03 (Decimal 00 to 03 Max)

Optional field 0 … n Var h Number of optional field as defined in above filed. First byte of
optional field will be treated as Optional Block ID.

When both KTM encrypted key and key spec is need in TR-31 then KBS should be provided is mentioned below:

KBS (Key Block Structure)

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h =0000. will be determined by Key Usage field.

Algorithms 1 h = 00
Algorithm will be determined from request TR-31 key block

Mode of use 1 h = 00
Mode of usage will be determined from request TR-31 key block

Key Version No. 2 h =00 Key Version Number will be determined from TR31-key block

Exportability 1 h 00 = Same exportability as in request TR-31 key block


N = If request TR-31 has this field as ‘S’ or ‘E’, exportability will
be set to N in response key block.

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Number of optional fields 1 h = 00 Must be 0

Optional field 0 … n Var h Not allowed as Number of optional fields must be 0

Notes
– The key specifiers 10, 11, 13, 16 under the Response, are generated when using the Legacy option.
– The key specifiers 10, 11, 13 under the Response, are generated based on the chosen operation on console
and FM. See, section Function Modifier Values.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 376
CHAPTER 4 Function Library

FM = x0
The Host Key Protection using Function Modifier can be in the range of x0, where x= 0, 1, or 2.

KTM-Spec A key specifier, which incorporates an index to a HSM-stored or host-stored single length or double
length KTM. Formats 00 – 03, 10, 11, 12, 13, 14, 16, 17 and 18 accepted.

Key Flags Indicates the session keys to generate. The function response will contain one or more sets of
encrypted key fields as shown: one set for each bit set in the flags. The bit positions are allocated as
follows:

bit Session key type

0 Single-length Data Key (DPK)

1 Single-length PIN encrypting key (PPK)

2 Single-length MAC key (MPK)

3 Single-length terminal master key (KTM)

4 Triple-length Data Key (DPK)

5 Triple-length PIN encrypting key (PPK)

6 Triple-length MAC key (MPK)

7 Triple-length terminal master key (KTM)

8 Double-length Data Key (DPK)

9 Double-length PIN encrypting key (PPK)

10 Double-length MAC key (MPK)

11 Double-length terminal master key (KTM)

12 - 13 Encryption mode for response encrypting:


00 = ECB, 01 = CBC and 10 = TR-31, bit 12 is the least significant (right most) bit.

14 - 15 Reserved. Must be zero.


Bit 0 is the least significant (right most) bit.
Examples:
- To generate a single-length MAC key, this field must be set to X’0004’;
= To generate a double-length PIN encrypting key and a single-length MAC key, the
field must be set to X’0204’.

eKTM(KS) These fields form a key set. The response incorporates a key set for each bit (validly) set in the Key
KS-Spec Flags field. The order of the returned key sets is the same order that the keys are specified in the
KVC Key Flags field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 377
CHAPTER 4 Function Library

Return Error condition


code

0C An inconsistency is present in the setting of the Key Flags field. Seven conditional returns currently
exist:
- Double length session keys required with single length KTM.
- Single and double length session key of same type requested.
- Reserved bit not set to zero.
- Single length KTM required with double length KTM (Format 16 KTM-Spec).
- Single length MPK requested with SEED KTM (Format 16 KTM-Spec).
- Double length session keys requested with SEED KTM (Format 16 KTM-Spec).
- CBC mode requested with SEED KTM (Format 16 KTM-Spec).

Notes
– For key specifier formats, refer to Function Construction.
– This function supercedes functions 41, 42, 43, 4A
– Bit 7 and Bits 13-15 of the key flags are reserved.
– Error will be returned if request KTM-Spec refers to a HSM or host stored SEED key (Format 16) and response
eKTM(KS) requested into TR-31.i.e. Key Flag 12th and 13th bit has value 10.
– To generate a double-length PIN encrypting key and a single-length MAC key, and eKTM(KS) needed in TR-31
key block format the Key Flag field must be set to X’2204’.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 378
CHAPTER 4 Function Library

JAPPINTRAN (EF0601)
This function allows translation of PIN block format and PIN encryption key.

Request Length Type Description

EF0601 3 h Function Code

Pfi,Pfo 1 h PIN format (input/output)

e*PPKi(PIN) or PIN 8 h Encrypted or clear PIN depending on translation

e*KMV1(PPKi) 16 h Input PPK encrypted by KM variant

e*KMV1(PPKo) 16 h Output PPK encrypted by KM variant

ANB 6 h Account Number Block

Response Length Type Description

EF0601 3 h Function Code

rc 1 h Return Code

e*PPKo(PIN) or PIN 8 h Encrypted or clear PIN depending on translation

The host function supports


• encryption of a clear/encrypted PIN.
• translation of a PIN from encryption under a PPK to encryption under another PPK.
• decryption of a PIN from encryption under a PPK to yield a clear PIN.

PFi and PFo High and low nibble respectively of the PIN format input and output. These specify the format of the
supplied PIN block and of the required PIN block. If format translation is not required, the PFi and
PFo fields must be set to the same value.
The valid field values are:
0 = Clear PIN format
1 = AS/ANSI format
3 = IBM 3624 format
Examples: PFi = 3, PFo = 0
The above will take a PIN in IBM 3624 format and return the PIN in the clear.

e*PPKi(PIN) This value is dependent on the type of translation being performed as specified by PFi.
or PIN If PFi = 0, this value will be the PIN value in the clear.
If PFi = 1 or 3, this value must be the PIN encrypted by the PIN Protect Key.

ANB Is the 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 379
CHAPTER 4 Function Library

e*PPKo(PIN) This value is dependent on the type of translation being performed as specified by PFo.
or PIN If PFo = 0, this value will be the PIN value in the clear.
If PFo = 1 or 3, this value will be the PIN encrypted by the PIN Protect Key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 380
CHAPTER 4 Function Library

KB-MAC-GEN (73)
Request Length Type Description

73 1 h Function Code

Blocks 1 h No. of 8 byte Blocks

n 1 d KTM-Index

Data bks*8 h Must be multiple of 8 bytes

Response Length Type Description

73 1 h Function Code

rc 1 h Return Code

MAC 4 h Message Authentication Code

This function generates a 32-bit Message Authentication Code (MAC) for the supplied DATA using the Base Key (KBn)
indicated by the supplied KB-index, in accordance with AS2805.4. Note that only the first 99 KBs may be used with this
function.
The function may be used for both MAC generation and MAC verification.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 381
CHAPTER 4 Function Library

KB-PIN-VER (64)
Request Length Type Description

64 1 h Function Code

PVK-Index 1 d Index of PVK

KTM-Index 1 d Index of KTM

eKTMn(AS-PIN) 8 B64 PIN Block encrypted under KTM

PAN 8 h Primary Account Number

ANB 6 h Account Number Block

Offset 6 h Offset for the PIN

Response Length Type Description

64 1 h Function Code

rc 1 h Return Code

This function performs the verification of a PIN in an AS/ANSI formatted PIN Block using the IBM 3624 method. The
PIN Block is supplied encrypted by a SafeNet HSM stored Base Key.

PVK-index identifies the PVKn, DTn, and MINPINn appropriate to the PIN verification procedure.

KTM-Index identifies the Terminal Master Key (KTMn) with which the PIN Block is encrypted.

AS-PIN is the AS/ANSI formatted PIN Block containing the PIN to be verified.

PAN is the Primary Account Number (or other card data) used in the verification procedure. It must be
padded appropriately prior to input to this function.

ANB is the 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

Offset consists of up to 12 digits of offset data. The significant digits must be left-justified in the field. Unused
digits are ignored. If offsets are not used, the significant digits must be zeros.

The function returns no response data. An Error Code of 00 indicates successful verification, while 08 indicates a
verification failure.
The function will fail with Error Code 78 if an ISO-0 PIN block is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 382
CHAPTER 4 Function Library

KEY-EXPORT (EE0201)
Request Length Type Description

EE0201 3 h Function Code

FM 1 h Function Modifier (FM = 00)

KIS/KI Spec Var K-Spec Key specifier for the KIS/KI, (Formats: 0–3, 8, 10, 11, 12,
13, 14, 15, 17, 18)

Key Type 1 d Key type

Enc Mode 1 h Encryption Mode (for encipher of outbound eKIS/KIvx(K) or


eKIS/KI(K)).

Key Spec Var K-Spec Key specifier containing eKMx(K)


(Formats: 10, 11, 12, 13, 14, 15, 17, 18)

Following fields must be present if Enc Mode is 02, i.e. the Outgoing Key eKIS/KI(K) is in TR-31 format.

Key Usage 2 h Any Valid values as described in the table Key Block
Header Fields for Key Block Format Keys
Key usage must be matched correctly with the Key type
field.

Algorithms 1 h ‘D’ X’44, ‘T’ X’54.

Mode of use 1 h Any Valid values as described in the table Key Block
Header Fields for Key Block Format Keys

Key version number 2 h Key version number

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte.

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Key Block Version / 1 h xy, where


Padding Indicator x = Key block version
y = Padding indicator

x = 0 (TR-31 Key block Version A)


1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)

Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Number of optional fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 383
CHAPTER 4 Function Library

Request Length Type Description

Optional field 1….n Var h

Response Length Type Description

EE0201 3 h Function Code

rc 1 h Return Code

eKIS/KIvx(K) Var h Encrypted Key


or
eKIS/KI(KB) Encrypted Key in TR-31 Key Block format.

eKIS/KI(DT) 8 h Optional field.


Encrypted decimalization table. Only present if output key
is in TR-31 Key Block and Key Type is 07 KPV DT.

KVC 3 h Key Verification Code

This function re-encrypts a host-stored encrypted DES or 3DES key under a specified KIS/KI.
As stored on the host, the keys are encrypted under the appropriate variant of the Domain Master Key (KM). The keys
are returned encrypted under the appropriate KIS variant. The function also returns the KVC of the key.
Keys export from Key block form to variant form is allowed only if Enabled from console i.e. check box: Translation of
Keys Migration, import and export is enabled.
When Key Spec is provided in 17 & 18 ,key usage and mode of use must match with the key type.

FM = 00. Must be set to zero.

KIS/KI Spec A key specifier for a HSM-stored or host-stored, single length or double or triple length KIS/KI.
Accepts key spec formats 0 - 3, 8, 10, 11, 12, 13, 14 and 15.
Host stored or HSM stored KI will be in key spec format 08 only.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 384
CHAPTER 4 Function Library

Key Type Indicates the type of host-stored encrypted key as follows:

00: DPK 08: KPVV 31: IMKSMI 40: DK-DPK 52:


CMKCLUMD

01: PPK 09: KCVV 32:IMKSMC 41: DK-PPK 53:


CMKRPMD

02: MPK 10: KI 33: IMKDAC 42: DK-MPK 54:


CMKRPUMD

03: KIS 16: ZKA KGK 34: IMKDN 45: DK-KTM 55:
CMKCLIDN

04: KIR 17: ZKA KKBLZ 35: KTK 48: CCMK 56: MPPK

05: KTM 18:ZKA MK 36: PTK 49: IMKCL 57: MKDK

06: CSCK 24: BDK 37: KMC 50: IMKRP

07: KPV, DT 30: IMKAC 38: IMK-CVC 51: CMKCLMD

Enc Mode Indicates the mode of operation used for encrypting the outgoing key:
00 : ECB
01 : CBC
02 : Outgoing key is in TR-31 Key Block format.

eKIS/KIvx(K) Key encrypted by a variant of the Interchange Store Key.


If Enc Mode is 2, Key encrypted is in TR-31 format eKIS/KI(K). Optional fields must be present in
order to form key into TR-31 Key Block format.

Key Spec Key Specifier incorporating an encrypted key. (Formats 10, 11, 12, 13, 14, 17, and 18).

KVC Key Verification Code for the key

Details and Restrictions


• If a HSM-stored KIS/KI is provided in the request, its associated variant scheme will be used when encrypting the
outgoing key.
• If a host-stored KIS/KI is provided in the request in a format 08 (only for KI),10, 11, 12, 13 or 14 key specifier, no
variants will be used when encrypting the outgoing key.
• When Key Spec(in coming key) is in format 17 & 18, and outgoing key is required in TR-31 format then key block
attribute fields must be compatible with each other. The only fields that can have different values are ‘Exportability’
& ‘Key Block Version / Padding Indicator’.

Error conditions
If a double-length host-stored key is provided, but a single length KIS/KI is specified, this will result in an error condition
‘0C’ – Inconsistent Request Fields.

Notes
– This function will check the length of KIS/KI and use the appropriate encryption method (Single-DES or Triple-

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 385
CHAPTER 4 Function Library

DES).
– When the AS2805 variant scheme is used, the eKIS/KIvx(K) is always encrypted using CBC (it will ignore the
encryption mode specified in the ‘Enc Mode’ field). Please refer to Console Guide for directions on how to set
options for the KIS/KI.
– Single length BDKs and IMKs are not supported.
– PIN Verification Key, Decimalization Table (PVK, DT). (KMv7) support format 0- 3 and 13,14
– Function will return error code 19 for key-type not supported by “SafeNet Variant scheme” if “Use ‘No Variant’ “
is not-checked for Host-Stored KIS/KI.
– Function will return error code 19 for key-type not supported by “SafeNet Variant scheme” if variant scheme is
selected “SafeNet” for HSM stored KIS/KI.
– If outgoing key is in TR-31 Key Block format Key type must be matched correctly with the Key usage field.
– Single length KIS/KI is not supported if outgoing Key is in TR-31 Key Block. I.e. Format 10 is not supported for
KIS spec. For format 0-3 HSM stored Single length KIS/KI Keys are also not supported.
– AES keys are not supported in TR-31 format.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 386
CHAPTER 4 Function Library

KEY-EXPORT-AES (EE0206)
This function is used to export AES Keys.

Request Length Type Description

EE0206 3 h Function Code

FM 1 h Function Modifier (FM=00)

KI Var K-Spec Key specifier for the KI.


Formats: 8, 17, 18, 54

Key Type 1 d Key Type


48 = CCMK
57 = MKDK
10 = KI
30 = IMKAC
31 = IMKSMI
32 = IMKSMC
0 = DPK
2 = MPK

Wrapping Method 1 h Wrapping Mode (for decipher of incoming KIvx(K) or KI(K))


00 = ECB
01 = CBC
02 = CTR
0A = Schlüsselausgabe_AES_Schlüssel_v1.5 (Reference
A [92])
0B = NIST-SP800-38F – KW Method only (Reference A
[93])

Key Specifier 54 is only applicable for Wrapping Method =


0A

Encryption parameters Var h Encryption parameters depends on wrapping mode and


defined below. See "Encrypted key material with respect to
Wrapping Method"

Input Key Var K-Spec Key specifier containing key as eKMvx(K)


Formats: 17, 18

KVC method 1 h 0x00 = Standard


0x02 = SHA256
0x03 = ZL8

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 387
CHAPTER 4 Function Library

Response Length Type Description

EE0206 3 h Function Code

rc 1 h Return Code

eKIvx(K) Var h Encrypted Key and/or authenticated key

Key length 2 h Length of key.


Allowed values:
128 bits = 0080
192 bits = 00C0
256 bits = 0100

eKI(DT) 8 h Zero length field (RFU)

KVC Var h Key Verification Code

Encrypted key material with respect to Wrapping Method

Wrapping method = 00

data Var h zero length

Wrapping method = 01, 02

IV Var h IV must be 16 bytes for AES

Wrapping method = 0A

MAC Algorithm 1 h 00 = None


01 = CMAC

AD1 Var h Associated data 1

AD2 Var h Associated data 2

MAC Var h For MAC algo 01 = CMAC, otherwise 0 length field.


Range 4-16 bytes

ICV Var h Integrity check value (must be multiple of 8 bytes)


Range supported 8-32 both inclusive.
This ICV will be used for authentication of data after
decryption.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 388
CHAPTER 4 Function Library

Wrapping method = 0B

ICV Var h Integrity check value (must be multiple of 8 bytes)


Range supported 8-32 both inclusive.
This ICV will be used for authentication of data after
decryption.

ICV It has not been fixed to 8 bytes as NIST SP 80038F used as underlying layer for Schlüsselausgabe_AES_
Schlüssel_v1.5 doesn’t mentions it to be mandatorily 8 bytes.

Function Considerations
• This host function is similar to EE0201.
• Encryption and MAC key is derived using key spec 54.
• This function supports only Method 00 with key spec 54.
• KI spec 17 and 18 are RFU as of now, hence usage will return error.
• Wrapping Method 0A implies wrapping as defined in section 6.2 of NIST SP800-38F, Reference A [93].
• Padding Method for 192 bit keys is ISO 9797-1 pad 4.
• The output eKIvx(K) is always hex packed.

Processing Steps
1. KI and/or intermediary KI’s (KIENC and KIMAC) are derived using key spec. Only Method = 00 is applicable with
Key Spec 54.
2. KIvx/Input data is decrypted using algorithm, encryption mode and other data by KM as per required variant and
supplied Key spec.
3. KIvx is encrypted and/or authenticated using the KI and/or intermediate KI’s using wrapping method and encryption
parameters.
4. Output KVC as per KVC Method.

Wrapping Method
• For wrapping method = 00, use AES ECB mode to encrypt the key using KI.
• For wrapping method = 01, use AES CBC mode to encrypt the key using KI eKI(Key) with IV provided.
• For wrapping method = 02, use AES CTR mode to encrypt the key using KI eKI(Key) with IV provided.
• For wrapping Method = 0B
– ICV must always be multiple of 8 bytes.
– Encrypt key using NIST SP 800-38F 6.2 Algorithm 3 (Reference A [93]) and ICV.
• For wrapping Method = 0A
– When MAC algorithm is 00
– There must be no AD={AD1,AD2}.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 389
CHAPTER 4 Function Library

– MAC must be 0 length field.


– ICV must always be multiple of 8 bytes.
– Encrypt key using NIST SP 800-38F 6.2 Algorithm 3 (Reference A [93]) and ICV.
– When MAC algorithm is 01
– KI must be in format 54.
– ICV must always be multiple of 8 bytes.
– Encrypt key using NIST SP 800-38F 6.2 Algorithm 3 (Reference A [93]) and ICV.
– Use KIMAC to generate CMAC on S=AD1 || eKI(key) || AD2 using KIMAC.
Note that while calculating CMAC the eKI(key) is in ASCII packing, however, the output eKI(Key) is hex
packed.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 390
CHAPTER 4 Function Library

KEY-IMPORT (EE0200)
Request Length Type Description

EE0200 3 h Function Code

FM 1 h Function Modifier (FM = x0)

KIR/KI Spec Var K-Spec Key specifier for the KIR


(Formats: 0–3, 8, 10, 11, 12, 13, 14, 15, 17, 18)

Key Type 1 d Key Type

Enc Mode 1 h Encryption Mode (for decipher of incoming eKIR/KIvx(K) or


eKIR(K))

eKIR/KIvx(K) Var h Encrypted Key


or
eKIR/KI(KB) TR-31Key Block format.

eKIR/KI(DT) 8 h Optional field.


Encrypted decimalization table. Only present if input key is
in TR-31 Key Block and Key Type is 07 KPV DT.

KBS Var h Key Block structure. Optional and must be provided when
key in response is needed in key block format.

Response Length Type Description

EE0200 3 h Function Code

rc 1 h Return Code

Key Spec Var K-Spec Key specifier containing eKMx(K)


(Formats: 10, 11, 12, 13, 14, 17,18)

KVC 3 h Key Verification Code

This function re-encrypts a received encrypted DES or 3DES key for host storage.
As received, the keys are encrypted under the appropriate variant of the Interchange Receive Key (KIR/KI) indicated by
the 'KIR/KI-Spec' field in the function request.
The mode of encryption for the key sent in the function request (eKIR/KIvx(K)) may be ECB for single-length keys and
ECB or CBC for double-length keys.
The received key is returned CBC encrypted under the appropriate *KM variant for storage within the host. The function
also returns the KVC of the received key.

Notes
– The key specifiers 10, 11, 13, 14 under the Response, are generated when using the Legacy option.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 391
CHAPTER 4 Function Library

– The key specifiers 10, 11, 12, 13, 14 under the Response, are generated based on the chosen operation on
console and FM. See Function Modifier Values.

FM The Host Key Protection using Function Modifier can be in the range of x0, where x= 0 , 1, or 2.

KIR/KI A key specifier for a HSM-stored or host-stored, single-length or double-length or triple-length KIR/KI.
Spec Accepts key spec formats 0 - 3, 8, 10, 11, 12, 13, 14, 15, 17 and 18.

Key Type Indicates the type of received encrypted key as follows:

00: DPK 07: KPV, DT 24: BDK 36: PTK 48: CCMK 55:
01: PPK 08: KPVV 30: IMKAC 37: KMC 49: IMKCL CMKCLIDN
02: MPK 09: KCVV 31: IMKSMI 38: IMK-CVC 50: IMKRP 56: MPPK
03: KIS 10: KI 32:IMKSMC 40: DK-DPK 51: CMKCLMD 57: MKDK
04: KIR 16: ZKA KGK 33: IMKDAC 41: DK-PPK 52: CMKCLUMD
05: KTM 17: ZKA 34: IMKDN 42: DK-MPK 53: CMKRPMD
06: CSCK KKBLZ 35: KTK 45: DK-KTM 54: CMKRPUMD
18:ZKA MK

Enc Mode Indicates the mode of operation used for decrypting the incoming key:
0 : ECB
1 : CBC
2 : Incoming key is in TR-31 Key Block format.

eKIR/KIVx Key encrypted by a variant of the Interchange Receive Key.


(K) If Enc Mode is 2, Key encrypted in TR-31 format eKIR/KI(K).

Key Spec Key Specifier incorporating an encrypted key. Single length ECB and double length CBC encrypted
keys (Formats 10, 11, 12, 13, 14, 17, 18).

KVC Key Verification Code for the key

KBS Must be present if key in response needed in TR-31 K-Spec format is 17 and 18 for Host-storage.
Key Usage value into KBS must be matched to the correct Key Type field value.

Application Notes
When key in request is in variant form and resultant key is expected in TR-31, KBS fields will be used as below :

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h Corresponding to keytype field in request.

Algorithms 1 h Any allowed value

Mode of use 1 h Any allowed mode of use for key usage

Key Version No. 2 h Any allowed value

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 392
CHAPTER 4 Function Library

Field Length Type Description

Exportability 1 h Any allowed value

Padding Indicator 1 h 00 = Do not pad


03 = Pad to triple length

Number of optional 1 h 0x00-0x03 (Decimal 00 to 03 Max)


fields

Optional field 0 … n Var h Number of optional field as defined in above filed. First byte of
optional field will be treated as Optional Block ID.

When the key in request is in TR-31 form KBS must be provided as below:

KBS (key block structure)

Field Length Type Description

KBS identifier 1 h = 0x00


Format

Key Block Version 1 h Must be ‘B’


ID

Key Usage 2 h == 0000


Key usage will be determined from request TR-31 key block

Algorithms 1 h = 00
Algorithm will be determined from request TR-31 key block

Mode of use 1 h = 00
Mode of usage will be determined from request TR-31 key block

Key Version No. 2 h =00 Key Version Number will be determined from TR31-key block

Exportability 1 h 00 = Same exportability as in request TR-31 key block


N = If request TR-31 has this field as ‘S’ or ‘E’, exportability will be
set to N in response key block.

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Number of optional 1 h = 00 Must be 0


fields

Optional field 0 … n Var h Not allowed as Number of optional fields must be 0

Details and Restrictions


• If a HSM-stored KIR/KI is provided in the request, its associated variant scheme will be used when decrypting the
incoming key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 393
CHAPTER 4 Function Library

• If a host-stored KIR/KI is provided in the request in a format 8(only for KI), 10, 11, 12, 13, 14 key specifier, no
variants will be used when decrypting the incoming key.

Error conditions
When a double length received key is provided, but a single length KIR/KI is specified this will result in an error
condition ‘0C’ – Inconsistent Request Fields.

Notes
– This function will check the length of KIR/KI and use the appropriate encryption method (Single-DES).
– When the AS2805 variant scheme is used, the eKIRvx(K) is always received at the function encrypted using
CBC (the function will ignore the encryption mode specified in the ‘Enc Mode’ field).
– Single length BDKs and IMKs are not supported.
– PIN Verification Key, Decimalization Table (PVK, DT). (KMv7) support format 0-3 and 13, 14
– Function will return error code 19 for key-type not supported by “SafeNet Variant scheme” if “Use ‘No Variant’ “
is not-checked for Host-Stored KIR.
– Function will return error code 19 for key-type not supported by “SafeNet Variant scheme” if variant scheme is
selected “SafeNet” for HSM stored KIR .
– If input key is in TR-31 Key Block format Key type must be matched correctly with the Key usage of eKIR/KI
(KB).
– Single length KIR/KI is not supported if incoming Key in TR-31 Key Block. I.e. Format 10 is not supported. For
format 0-3 HSM stored Single length KIR Keys are also not supported.
– AES keys are not supported in TR-31 format.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 394
CHAPTER 4 Function Library

KEY-IMPORT-AES (EE0205)
This function is used to import AES Keys.

Request Length Type Description

EE0205 3 h Function Code

FM 1 h Function Modifier (FM=00)

KI Spec Var K-Spec Key specifier for the KI


Formats: 8, 17, 18, 54

Wrapping Method 1 h Wrapping Mode (for decipher of incoming KIvx(K) or KI(K))


00 = ECB
01 = CBC
02 = CTR
0A = Schlüsselausgabe_AES_Schlüssel_v1.5 (Reference
A [92])
0B = NIST-SP800-38F – KW Method only (Reference A
[93])

Key Specifier 54 is only applicable for Wrapping Method =


0A

Encrypted key material Var h Encrypted key material depends on wrapping mode. See
Encrypted key material table below.

KVC method 1 h 0x00 = Standard


0x02 = SHA256
0x03 = ZL8

eKI(DT) Var h Zero length field (RFU)

Output Key Spec Format 1 h Format 17, 18

Key details Var h Key details. For details, see below.

Response Length Type Description

EE0205 3 h Function Code

rc 1 h Return Code
08 = If authentication of key fails

Key Spec Var K-Spec Key specifier containing eKMx(K)


Formats: 17, 18

KVC Var h Key Verification Code

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 395
CHAPTER 4 Function Library

Key Details

Key Details Algorithm = AES


Supported Key Types:
48 = CCMK
57 = MKDK
10 = KI
30 = IMKAC
31 = IMKSMI
32 = IMKSMC
0 = DPK
2 = MPK

Key detail field contains following details pertaining to 17 and 18 key format.

KM-index 1 h Index of KM = 00

Key Type 1 d Variant id.

Key length 1 h Key length


02 = 128 bits
03 = 192 bits
04 = 256 bits

KBS Var h Key Block structure. Optional.


Must be provided when key in response is needed in key block format.

Where KBS is Key Block Structure, as mentioned below

Key Block Structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h Any allowed value for the key to be generated.

Algorithms 1 h Any allowed value

Mode of use 1 h Any allowed mode of use for key usage

Key Version No. 2 h Any allowed value

Exportability 1 h Any allowed value

Padding Indicator 1 h 00 = Do not pad


03 = Pad to triple length

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 396
CHAPTER 4 Function Library

Key Block Structure

Field Length Type Description

Number of optional 1 h 0x00-0x03 (Decimal 00 to 03 Max)


fields

Optional field 0 … n Var h If the Number of optional fields = 00, then no optional field
else, the Number of optional field as defined in above filed.
First byte of optional field will be treated as Optional Block ID.

Encrypted key material with respect to Wrapping Method

Wrapping method = 00

eKI(Key) Var h Encrypted key

Wrapping method = 01, 02

IV Var h IV must be 16 bytes for AES

eKI(Key) Var h Encrypted key

Wrapping method = 0A

MAC Algorithm 1 h 00 = None


01 = CMAC

ICV Var h Integrity check value (must be multiple of 8 bytes)


Range supported 8-32 both inclusive.
This ICV will be used for authentication of data after
decryption.

Associated Data (AD)1 + Var h AD1 + encrypted and/or authenticated key material + AD2
eKI(Key) + AD2

Encryption key material 2 h Offset for encrypted and/or authenticated key material
offset

eKI(Key) length 1 h Length of encrypted and/or authenticated key material

MAC Var h For MAC algo 01 = CMAC, otherwise 0 length field.


Maximum value = 16 bytes

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 397
CHAPTER 4 Function Library

Wrapping method = 0B

eKI(Key) Var h Encrypted and/or authenticated key material

ICV Var h Integrity check value (must be multiple of 8 bytes)


Range supported 8-32 both inclusive.
This ICV will be used for authentication of data after
decryption.

ICV It has not been fixed to 8 bytes as NIST SP 80038F used as underlying layer for Schlüsselausgabe_AES_
Schlüssel_v1.5 doesn’t mentions it to be mandatorily 8 bytes.

Function Considerations
• This host function is similar to EE0200.
• Encryption and MAC key is derived using key spec 54.
• This function supports only Method 00 with Key spec 54.
• KI spec 17 and 18 are RFU as of now, hence usage will return error.
• Wrapping Method 0A and 0B implies unwrapping as defined in section 6.2 of NIST SP800-38F, Reference A [93]
• Padding Method for 192 bit keys is ISO 9797-1 pad 4.
• eKI(Key) is always packed in hexadecimal for consistency across API’s.

Processing Steps
1. KI and/or intermediary KI’s (KIENC and KIMAC) are extracted/derived using key spec. Only Method = 00 is
applicable with Key Spec 54.
2. KIvx is decrypted and/or verified using the KI and/or intermediate KI’s using wrapping method and encrypted key
material.
3. KIvx is encrypted using key details per required variant identified by Key type.
4. Output KVC as per KVC Method.

Wrapping method

• For wrapping method = 00, use AES ECB mode to decrypt the encrypted key material eKI(Key) using KI.
• For wrapping method = 01, use AES CBC mode to decrypt the encrypted key material using KI eKI(Key) with IV
provided.
• For wrapping method = 02, use AES CTR mode to decrypt the encrypted key material using KI eKI(Key) with IV
provided.
• For wrapping Method = 0B,
– ICV must always be multiple of 8 bytes.
– Decrypt eKI(Key) using NIST SP 800-38F 6.2 Algorithm 4.
– Compare ICV. If fails, return error (08).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 398
CHAPTER 4 Function Library

– Remaining data is clear key.


• For wrapping Method = 0A
– When MAC algorithm is 00
– There must be no AD = AD1, AD2.
– MAC must be 0 length field.
– Encrypted key material offset must be 0.
– ICV must always be multiple of 8 bytes.
– Decrypt eKI(Key) using NIST SP 800-38F 6.2 Algorithm 4.
– Compare ICV. If fails, return error (08).
– Remaining data is clear key.
– When MAC algorithm is 01
– KI must be in format 54.
– Use KIMAC to validate CMAC on AD1 + eKI(key) + AD2. AD1 and AD2 are ASCII packed while eKI(Key)
is hex packed, thus prior to CMAC calculation, convert eKI(Key) from hex to ASCII; prepare data as
AD1+formatted eKI(Key)+ AD2 and then use KIMAC to calculate CMAC.
– After validation, retrieve eKI(key) using encryption key material offset and eKI(key) length.
– Decrypt eKI(Key) using NIST SP 800-38F 6.2 Algorithm 4.
– Compare ICV. If fails, return error (08).
– Resultant is clear key.

Note: In PCI mode, the strength of the KM with respect to imported key should be greater or
equivalent.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 399
CHAPTER 4 Function Library

KEY-MAILER (EE0E01)
Request Length Type Description

EE0E01 3 h Function Code

FM 1 h Function Modifier (FM = x0, 01, 02 or 03)

nA 1 h Number of text fields for env. ‘A’

Line No. 1 h

Column No. 1 h

Data Var h

nB 1 h Number of text fields for env. ‘B’

Line No. 1 h

Column No. 1 h

Data Var h

Key Type 1 h Indicates the KM-variant with which the key K is encrypted

KVC Type 1 h 00: Standard

KBS Var h Key Block structure. Optional.

Response Length Type Description

EE0E01 3 h Function Code

rc 1 h Return Code

eKMvX(key) Var Key-Spec Encrypted key (Formats: 10, 11, 12, 13, 14, 17,18)

KVC Var h KVC for the host stored key.

This function generates a random key for an EFT terminal. The available key types are - DPK, PPK, MPK, KIS, KIR,
KTM, KPVV, KCVV, KI. The key is supplied in the response, encrypted by a variant of the Domain Master Key (KM),
for host storage and subsequent use with other functions (e.g. Generate session keys). The key is also printed in split
form on two envelopes (A and B) for subsequent entry into the terminal.
KBS: Key Block structure, must be present if output Key is expected in Key Spec format 0x17 or 0x18 i.e. Key
Protection method chosen for output key is TR-31 ASCII Key Spec format 0x17 or Binary TR-31 Key Spec format 0x18
on console.
Key usage field value passed into KBS structure must match correctly with the Key Type field value.

Notes
– The key specifiers 10, 13 under the Response, are generated when using the Legacy option.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 400
CHAPTER 4 Function Library

– The key specifiers 10, 11, 12, 13, 14 under the Response, are generated based on the chosen operation on
console and FM. See, Function Modifier Values.
The function is controlled by an associated set of console operations that determine various options, including the key
type and whether the generated key is single or double or triple length.

FM Function Modifier = x0, x1, x2, x3


x0 - nB in position shown, no additional fields
x1 - nB moves below nA, no additional fields
x2 - nB in position shown, additional fields present
x3 - nB moves below nA, additional fields present
The Host Key Protection using Function Modifier can be in the range of x0, where x= 0, 1, or 2.

nA Number of text fields to print on the ‘A’ envelope (max.10).

Line No. This is the number of the line on which the ‘Data’ is to be printed. It must be in the range of 1 to 40.

Column No. This is the number of the column from which the ‘Data’ is to be printed. It must be in the range of 1 to
120.

Data This is a variable length field that contains the data to be printed.

nB Number of text fields to print on the ‘B’ envelope (max.10).

Key Type This field specifies the type of key that is to be printed and confirms the key type as input at the
console. It indicates the KM-variant with which the key is encrypted, as follows:

00: DPK 03: KIS 08: KPVV

01: PPK 04: KIR 09: KCVV

02: MPK 05: KTM 10: KI

In order to use the value input at the console, with no confirmation, this field must be set to X’FF’.
If key type specified in this field conflicts with that entered at the console, the function will fail with rc
= X’28’
This field is only present with FM value 02 and 03.

KVC Type Specifies the method used to calculate the KVC. Initially only a value of zero is supported, indicating
the use of the standard method. This field is only present with FM value 02 and 03.

eKMvX(key) “key” may be any of DPK, PPK, MPK, KIS, KIR, KTM, KPVV, KCVV, KI
The particular variant used “X” is dependent upon the key type. See the section Variants in Function
Construction for details.
Generated key formats are 10, 11, 12, 13, and 14.

ESMID Part of the PTK-EFT function call. The ESMID is a pointer to a NULL terminated string that identifies
the name of the SafeNet HSM (ESM) to which functions are directed. The SafeNet HSM name is set
using the wincommsconfig utility provided as part of the PTK-EFT product suite.

rc Returns value 28 if the Key Type field conflicts with the key type entered at the console

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 401
CHAPTER 4 Function Library

KVC Key Verification Code of the printed key calculated using the method specified in request field KVC
Type. This field is only present with FM value 02 and 03.

Note that each optional item to be printed is defined by appending a set of the fields ‘Line no.’, ‘Column no.’, and ‘Data’
to the host request. Each ‘Data’ character must be printed within the area defined by the size of the key mailer
envelope. Also, each ‘Data’ character must not overprint any other defined area (including other defined ‘Data’ areas).

Return code Error condition

02 Illegal Function Code (that is, the Key Mailer facility was not enabled when the Key Mailer request
was received).

04 Invalid data in message.


This condition occurs if:
- One of the fields ‘Line No.’ or ‘Column No.’ contains an invalid value.
- A ‘Data’ field character is to be printed outside the area defined by the size of the Key Mailer
envelope or is to overprint any character of the key, KVC or another ‘Data’ field.

0B Printer is not operable.

Note: The console operator must exit the key print parameters display in order for the function
to execute correctly. An error code of 0B may otherwise be returned.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 402
CHAPTER 4 Function Library

KEY-PACKAGE-STATUS (EE3102)
Request Length Type Description

EE3102 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Response Length Type Description

EE3102 3 h Function Code

rc 1 h Return Code

Status 1 h Representing Current Key Package Status


= 01: Package present
= 02: Loading from host
= 03: Package loaded
= 04: Not present

Length 4 h Total Length of the Package

Name Var h Key Package Name

checksum 4 x CRC32 checksum of the entire Key Package

This function returns the status of any Export Key Packages currently stored in the HSM.

rc return code of zero indicates function completed successfully

Status Key Package Status


01: Key Package is present and awaiting export.
02: Key Package is only partially present as a result of incomplete IMPORT_KEY_PACKAGE
sequence.
03: Key Package has been loaded.
04: No Key Package is present inside the HSM.

Length 32 bit Big Endian integer – total length of the Key Package

Name variable length field, holds printable ASCII characters

checksum CRC32 checksum of the entire Key Package – Algorithm TBA

If no Key Package is present in the HSM then the ‘rc’ will be zero and Status will be 4, Length=0, Name=empty and
Checksum=0

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 403
CHAPTER 4 Function Library

KEY-RETRIEVE-OPERATION (EE9012)
Request Length Type Description

EE9012 3 h Function Code

FM 1 h Function Modifier (FM = x0)

Mode of Operations 1 h Indicates the mode of operation


00 – Retrieve Key

SK Var K-Spec Key specifier to perform RSA operations


(Format: 82
Key Type: Key Transport)

Data Var h Data to be included in the RSA operation.

Key Format 1 h Format of the key that indicates the length of the key to be
retrieved from the provided data.
(Formats: 10, 11, 12, 13, 14)

Key Type 1 d Indicates the KM variant

Offset 1 h Offset at which key is to be read from data

Response Length Type Description

EE9012 3 h Function Code

rc 1 h Return Code

Output Data Var h Data as result of operation

Retrieved Key Var h Key specifier for the retrieved key


(Formats: 10, 11, 12, 13, 14)

This function retrieves the key from the provided data. By default, this function is disabled.

FM The Host Key Protection using function modifier can be in the range of x0, where x= 0, 1, or 2.

Mode of Operation Indicates the mode of operation


00 – Retrieve Key

SK Key specifier incorporating the Private Key for RSA operations. The key type of the private key
must be consistent with the operation.
The mode of operation is 00-Retrive Transport then the Key Transport flag must be set in Key
Type.
Bit 1 may be set alone or along with bits 0, 2 or 4, but bits 0, 2 and 4 are mutually exclusive.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 404
CHAPTER 4 Function Library

Data Data to be included in the RSA operation.

Key Format Format of the key that indicates the length of the key to be retrieved from the provided data.
(Formats: 10,11,12,13,and 14)

Key Type Key types supported are:


00 - DPK
03 - KIS
04 - KIR

Offset Position from where the key is to be retrieved as part of the decrypted data.

Output Data Data as result of operation.

Retrieved Key Key specifier for the retrieved key.

Processing Steps
1. Decrypt the ‘Data’ using the key, SK.
2. Retrieve the key at the offset position. The length of the retrieved key is determined by Key Format.
3. Encrypt the key again using the KM variant, as specified by Key Type.
4. Fill Key Bytes with 0x00.
5. Return decrypted ‘Data’ and Key Specifier.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 405
CHAPTER 4 Function Library

KIR-REC (EE3032)
Request Length Type Description

EE3032 3 h Function Code

FM 1 h Function Modifier (FM = x0),


where
x = 3 (TR31 format 0x17)
x = 4 (TR31 format 0x18)

SK-Spec Var K-Spec Key specifier for Index to SK HSM


(Formats: 0-3)

sSKs HSM(hash of key Var S-Block Signed hash of KIR


data)

ePKr HSM(KIR) Var S-Block Enciphered KIR

PKs-Spec Var K-Spec Key specifier for Sender’s Public Key


(Format: 80)

*KBS Var h Key Block structure. Optional and present only if KIR is
needed in TR-31 Key Block Form for host- storage.

Response Length Type Description

EE3032 3 h Function Code

rc 1 x Return Code

KIR-Spec Var K-Spec Key specifier for KIR


(Format: 15, 17, 18)

KVC(KIR) 3 x Verification Code of KIR

This function recovers an Interchange Key, which has been transferred from another HSM as part of the Interchange
Sending Key transfer procedure. The recovered key is used and denoted as an Interchange Key (KIR).
The KIR is transferred in a DEA 2 ciphertext Block as produced by the KIS-SEND function and deciphers this result.
The function returns KIR in a key specifier.

Notes
– The KIR spec Format 15 must contain the attributes specific to AS2805.6.3 2000.
– *KBS field must be provided when KIR is needed in TR-31 Key Block form (formats 17, 18) for host- storage.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 406
CHAPTER 4 Function Library

KIS-SEND (EE3031)
Request Length Type Description

EE3031 3 h Function Code

FM 1 h Function Modifier (FM = x0),


where
x = 3 (TR31 format 0x17)
x = 4 (TR31 format 0x18)

SK-Spec Var K-Spec Key specifier for Index to SK HSM(Formats: 0-3)

PKr Var K-Spec Receiver’s public Key


(Format: 80)

*KBS Var h Key Block structure. Optional and present only if KIS is
needed in TR-31 Key Block Form for host- storage.

Response Length Type Description

EE3031 3 h Function Code

rc 1 x Return Code

KIS-Spec Var K-Spec Key specifier for KIS


(Format: 15, 17, 18)

sSKs HSM(hash of key Var S-Block Signed hash of KIS


data)

ePKr(KIS) Var S-Block Enciphered KIS

KVC(KIS) 3 x Key Verification Code of KIS

This function generates a random interchange sending key (KIS) and prepares it for transfer to another HSM.
The function signs the generated KIS under a HSM private key (SK HSM s ) and enciphers it under the public key (PKr)
provided by the intended receiver of the KIS. The function also returns the KIS in a key specifier.

Note: The KIS spec Format 15 must contain the attributes specific to AS2805.6.3 2000.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 407
CHAPTER 4 Function Library

KM-MIGRATE (12)
Request Length Type Description

12 1 h Function Code

i 1 h KM Variant Used

n 1 h Number of Keys
1Key Spec Var K-Spec A key specifier for type of host-stored key used (Formats:
10, 11, 12, 13, 14, 18, 81, 82)
1KBS Var h Key Block structure. Optional.

Response Length Type Description

12 1 h Function Code

rc 1 h Return Code

n 1 h Number of Keys
1Key Spec Var K-Spec A key specifier for key encrypted under Current KM
(Formats: 10, 11, 12, 13, 14, 17, 18, 81, 82)

1 This field may be repeated.

This function translates keys from encryption under the old Domain Master Key to encryption under the current KM.
This function is enabled/disabled by a console operation.
KBS : Key Block structure. KBS must be present if input key Spec is other than 0x17 and 0x18 and output Key is
expected in Key Spec format 0x17 or 0x18, i.e. Key Protection method chosen for output key is TR-31 ASCII Key Spec
format 0x17, or Binary TR-31 Key Spec format 0x18 on console.

Notes
– The key specifiers 10, 11, 12, 18, 81, 82 under the Response, are generated when using the Legacy option.
– The key specifiers 10, 11, 12, 13, 14 under the Response, are generated based on the chosen operation on
console and FM. See, section Function Modifier Values.
– Keys migration from Variant form to Key block form is allowed only if Enabled from console.
– Variant field value will be matched against correct key usage passed.
– Use the value of KM variant as 00, when key is sent using format 18.

Definitions

Key Spec Single or double length key specifier

i Variant of the Domain Master Key

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 408
CHAPTER 4 Function Library

KM-STATUS (0006)
This request returns information on the usage of Master key versions.

Request Length Type Description

0006 2 h Function Code

Msg ID 2 x Message Identifier

kv 2 h KM Version.
Values = 00 - 0F

Response Length Type Description

0006 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

kv 2 x KM Version

dd 1 x Day (current)

mm 1 x Month (current)

yyyy 2 x Year (current)

hh 1 x Hours (current)

mm 1 x Minutes (current)

ss 1 x Seconds (current)

ks 1 x KM status
0 = valid
1 = invalid or not initialized

Function Code 2 x Function that last used this KM version

CLM 4 bin Calls in last minute

CL10M 4 bin calls in last 10 minutes

CLRES 4 bin calls since last reset mod 2**32

dd 1 x Day last used

mm 1 x Month last used

yyyy 2 x Year last used

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 409
CHAPTER 4 Function Library

Response Length Type Description

hh 1 x Hours last used

mm 1 x Minutes last used

ss 1 x Seconds last used

Note: This function is for use in KM migration.

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 410
CHAPTER 4 Function Library

KTK-KEY-EXPORT (EE2051)
Request Length Type Description

EE2051 3 h Function Code

FM 1 h Function Modifier (FM = 00)

KTK-Spec Var K-Spec Key Specifier for KTK


(Formats: 11, 12, 13, 14, 17, 18)

Key Type 1 h 02 = MPK

Enc Mode 1 h Encryption mode - for encryption of output key: eKTK(K).

KX-Spec Var K-Spec Key Specifier containing eKMx(KX)


(Formats: 11, 12, 13, 14, 17, 18)

Following fields must be present if Enc Mode is 02 i.e. the Outgoing Key eKIS(K) is in TR-31 format.

Key Usage 2 h Valid Value


MPK - ‘M0’, ‘M1’,’M2’,’M3’, ’M4’,’M5’

Algorithms 1 h D’ X’44, ‘T’ X’54.

Mode of use 1 h Valid value


‘C’,’G’,’N’,’V’

Key version number 2 h Key version number

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte.

Key Block Version / 1 h xy, where


Padding Indicator x = Key block version
y = Padding indicator
x = 0 (TR-31 Key block Version A)
1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)
Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Number of optional fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Optional field 1…n Var h

Response Length Type Description

EE2051 3 h Function Code

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 411
CHAPTER 4 Function Library

Response Length Type Description

rc 1 h Return Code

eKTK(KX) Var h Encrypted KX by KTK mode ECB, CBC


Or Or
eKTK(KB) TR-31 Key block format.

KVC 3 h Key Verification Code

This function re-encrypts a host stored encrypted 3DES key under a specified KTK. The function is similar to the
existing Key Export function, but uses a KTK rather than a KIS as the encryption key. The Enc. Mode is the mode of
operation for encrypting the outgoing key. The possible values are:
00 : ECB
01 : CBC
02 : Outgoing key is in TR-31 Key Block format
Keys export from Key block form to variant form is allowed only if enabled from console i.e. check box: Translation of
Keys Migration, import and export is enabled.

When Key Spec is provided in 17 & 18 ,key usage and mode of use must match with the key type.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 412
CHAPTER 4 Function Library

LOAD-CHARSET (EE0E07)
Request Length Type Description

EE0E07 3 h Function Code

FM 1 h Function Modifier (FM = 00)

‘0’ In Words Var h Numeric ‘0’

‘1’ In Words Var Numeric ‘1’

‘2’ In Words Var h Numeric ‘2’

‘3’ In Words Var h Numeric ‘3’

‘4’ In Words Var h Numeric ‘4’

‘5’ In Words Var h Numeric ‘5’

‘6’ In Words Var h Numeric ‘6’

‘7’ In Words Var h Numeric ‘7’

‘8’ In Words Var h Numeric ‘8’

‘9’ In Words Var h Numeric ‘9’

Response Length Type Description

EE0E07 3 h Function Code

rc 1 h Return Code

This function retrieves inputs from the user for language characters to support PIN printing in words. The ASCII
characters for the retrieved inputs are stored in a file created in the KMS.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 413
CHAPTER 4 Function Library

LOAD-PS (EE0E02)
Request Length Type Description

EE0E02 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Mode 1 h Mode of file.


Mode = 00 starting file
Mode = 01 Concatenating files.
Mode = 02 End of file or last chunk

Data Var h Data

Response Length Type Description

EE0E02 3 h Function Code

Error code 1 h Return Code

This function is used to copy the data to be printed to Luna EFT, in a postscript template file (20 MB maximum).

Processing Steps
1. Divide the post script template file into a chunk of N bytes.
2. Send the first file with mode 00 and thereafter send files with 01, and 02 modes. Indicate the end of file mode.
3. The function concatenates the data sent in files and creates a postscript template file for future use.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 414
CHAPTER 4 Function Library

LOAD-PUBLIC-KEY (C6A0)
This function encrypts a public key under the appropriate variant of KM for storage.

Request Length Type Description

C6A0 2 h Function Code

Msg ID 2 x Message Identifier

PVC(PKr) 8 x Verification code of PK

PKr Var K-Spec Public Key (Format 41)

Response Length Type Description

C6A0 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKMvAC(PKr) Var K-Spec Public Key encrypted under the appropriate variant of KM.
Format 42

Note:
- PKGP is used in interchange functions; refer NODEKEKSEND-EXPORT and
NODEKEKREC-EXPORT.
- This is a general-purpose function. Where this function is used to encrypt the manufacturer's
Public Key for TCU initialization purposes, this key would be represented as PKMAN.

CAUTION: Care needs to be taken with this function to prevent the introduction of
unauthenticated public keys.

Note: Please note that in all these functions we are denoted as the “Sender” (s) and our partner
as the “Receiver” (r). Our “Send” key becomes the partner’s “Receive” key and vice versa.
Therefore we generate “Send” keys and get the “Receive” key from our partners on the link.

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 415
CHAPTER 4 Function Library

LOAD-PUBLIC-KEY (NDC) (C6B0)


This function enciphers a public key under the appropriate variant of KM for storage.

Request Length Type Description

C6B0 2 h Function Code

Msg ID 2 x Message Identifier

PK-EPP Var K-Spec Public Key of EPP (format 41)

PK-NCR Var K-Spec Public Key of NCR (format 41)

(PK-EPP) * SK-NCR Var x Public key signature

Response Length Type Description

C6B0 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKMVAC(PK-EPP) Var K-Spec Public Key enciphered under the appropriate variant of KM.
Format 42

This host function is used for Australian Major Bank (AMB).


The function verifies that the signature of the PK-EPP is correct and enciphers the PK-EPP under the appropriate
variant of KM. The signature conforms to RSA Laboratories Cryptographic Token Interface Standard – PKCS #1, V2.0
using the RSASSA-PKCS1-v1_5 signature scheme.
The signature is unsigned by applying the RSAVP1 verification primitive, using public key PK-NCR.
The message to be verified by RSASSA-PKCS1-v1_5-VERIFY is the public key PK-EPP, DER-encoded with the
ASN.1 type RSAPublicKey:-
RSAPublicKey::= SEQUENCE
{
modulus INTEGER, --n
publicExponent INTEGER --e
}
The modulus in RSAPublicKey is one byte longer than the modulus supplied in PK-EPP, to which a byte with value of
binary zero is prepended. The exponent in RSAPublicKey is the modulus supplied in PK-EPP, with leading binary zero
bytes removed.
The RSAPublicKey is encoded with the EMSA-PKCS-v1_5 encoding operation, applying the SHA-1 hash function,
before comparison with the unsigned signature.
The following example is the hexadecimal representation of a 2048-bit PK-EPP. As supplied in the request, with 256-
byte modulus and exponent:

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 416
CHAPTER 4 Function Library

modulus D6047DC50D774CB00A8572AF2C165EB953FDEF43FE25D3A84E7D58288A0A3652
36D82EA8BEC135E7D89711D4FE357A396AD5C464B65339355696958498E4376D
D7BE489DBDA9DC74F0C7DC1DD5048357BFF1E6E7AFC67DB78C98C4F2A74EF170
E0714BFCC9894614581C697C0624E61493E2BC719FE3145392894F352665FD05
E800E411EC7AC6B00205030EF01BCB92E71F95F95492CF8C39AF6954E5C8B3A0
975BB8872751C94C39BAFAA921851855FA4EFDDCB51E0C05962E236FEB0165B6
84ED6D86FBCDC506E8CD6CEBAA8B53685D3F02B79331589F5C1FA32269DBFC88
C8169F3588E840AD758C1B91FC11A1A418D081F368722ACDB2A937ADE0DF5B61

exponent 0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000010001

As presented for hashing:

public key tag 3082010A

modulus tag 02820101

modulus 00D6047DC50D774CB00A8572AF2C165EB953FDEF43FE25D3A84E7D58288A0A36
5236D82EA8BEC135E7D89711D4FE357A396AD5C464B65339355696958498E437
6DD7BE489DBDA9DC74F0C7DC1DD5048357BFF1E6E7AFC67DB78C98C4F2A74EF1
70E0714BFCC9894614581C697C0624E61493E2BC719FE3145392894F352665FD
05E800E411EC7AC6B00205030EF01BCB92E71F95F95492CF8C39AF6954E5C8B3
A0975BB8872751C94C39BAFAA921851855FA4EFDDCB51E0C05962E236FEB0165
B684ED6D86FBCDC506E8CD6CEBAA8B53685D3F02B79331589F5C1FA32269DBFC
88C8169F3588E840AD758C1B91FC11A1A418D081F368722ACDB2A937ADE0DF5B
61

exponent tag 0203

exponent 010001

The SHA-1 hash of the above is 0622B140A0D61AD518388314115350D0A34D3958.


As presented for comparison with the unsigned signature:-

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 417
CHAPTER 4 Function Library

padding 0001FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00

Digestinfo 3021300906052B0E03021A05000414
tag

SHA-1 0622B140A0D61AD518388314115350D0A34D3958
hash

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 418
CHAPTER 4 Function Library

M-DPK-GEN (49)
Request Length Type Description

49 1 h Function Code

TKSI 1 d Terminal Key Set Index (1 - 2)

Response Length Type Description

49 1 h Function Code

rc 1 h Return Code

eKTM(DPK) 8 B64 Data Protect Key

eKM(DPK) 8 B64 Data Protect Key

This function generates a random communications key (DPK) for an IBM 3624 Consumer Transaction Facility.
For transmitting to the 3624, the key is returned encrypted under the Terminal Master Key (KTM) indicated by the
specified index (TKSI) which is stored in the HSM. It is also returned encrypted under KM, for storage within the host.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 419
CHAPTER 4 Function Library

MAC-GEN-FINAL (EE0701)
Request Length Type Description

EE0701 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Alg 1 h Algorithm Qualifier Specifies details of the MACing


algorithm. The left nibble specifies the padding and the right
nibble specifies the algorithm:
Left nibble:
= 0 : pad with zeroes.
= 1 : pad with a single one bit and subsequent zeroes

Right nibble:
For single length MPK – this nibble must be zero
For double length MPK:
= 0 : ISO 9807 method
= 1 : triple-DES CBC method

MAClength 1 h DES = 01 - 08 Bytes


HMAC-SHA-1 = 04 - 20 bytes
HMAC-SHA-224 = 04 – 28 bytes
HMAC-SHA-256 = 04 – 32 bytes
HMAC-SHA-384 = 04 – 48 bytes
HMAC-SHA-512 = 04 – 64 bytes

ICD 8 h Input Chaining Data

MPK-Spec Var K-Spec Key Specifier for MPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 20, 50, 51, 90, 93)

Data Var h Data to be MACed

Response Length Type Description

EE0701 3 h Function Code

rc 1 h Return Code

MAC Var h Message Authentication Code

This function is provided for MAC generation, using the supplied MAC Protect Key (MPK), in accordance with
AS2805.4 1985. The long message support is integrated whereby the OCD from MAC-UPDATE is passed as the ICD.
When the MPK is a HSM stored HMAC-SHA MPK, the HMAC-SHA MAC algorithm will be used for message
authentication depending on the attributes of the MPK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 420
CHAPTER 4 Function Library

For HMAC-SHA algorithm, valid range for requested MAC length will depend on the attributes of the HSM-stored MPK.
A format 17 and 18 key specifier (secure key block) containing a host stored HMAC-SHA MPK key may also be used
for HMAC-SHA message authentication. Note that Alg field is not applicable to the function processing if the MPK is an
HMAC-SHA MPK.
HMAC-SHA MPK key length can be 128, 160 or 192 bits.

FM = 00. Must be set to zero.

Alg Specifies the MACing algorithm to use.


Left nibble:
= 0 : pad with zeroes.
= 1 : pad with a single one bit and subsequent zeroes
Right nibble:
For single length MPK – this nibble must be zero
For double length MPK:
= 0 : ISO 9807 method
= 1 : triple-DES CBC method
e.g. Pad with zeroes and double-length MPK using triple-DES CBC method 0x01

NOTE:
• When single length key is used with algo 0 it is same as MAC algorithm 1 (ISO 9797).
• When double length key is used with algo 0 it is same as MAC algorithm 3 (ISO 9797).
• When double and triple length keys are used with algo 1 then it is TDES CBC MAC.

MAClength Specifies the length of the output MAC

ICD Input Chaining Data, used for long message feedback.

MPK-Spec A key specifier incorporating an encrypted MAC Protect Key.

Note: This function supercedes functions 70, 71, 72.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 421
CHAPTER 4 Function Library

MAC-GEN-FINAL-AES (EE0713)
Request Length Type Description

EE0713 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Alg 1 h Algorithm Qualifier Specifies details of the MACing


algorithm. The right nibble specifies the algorithm:
Left nibble:
= 0 : RFU

Right nibble:
= 0x02 : CMAC
= 0x03 : AES CBC Mac

MAClength 1 h 8-16 Bytes

ICD 16 h Input Chaining Data

MPK Var K-Spec Key Specifier for MPK


(Formats: 52, 53, 54, 1C)
Note: In case of format 54, only Algorithm 0A is applicable

Data Var h Data to be MAC'd

Response Length Type Description

EE0713 3 h Function Code

rc 1 h Return Code

MAC Var h Message Authentication Code

This function is provided for MAC generation, using the supplied MAC Protect Key (MPK), in accordance with
AS2805.4 1985. The long message support is integrated whereby the OCD from MAC-GEN-UPDATE-AES (EE0712)
is passed as the ICD. AES MPK key length can be 128, 192 or 256 bits.

FM = 00. Must be set to zero.

Alg Specifies the MACing algorithm to use.


Right nibble:
= 0x02 : CMAC
= 0x03 : AES CBC Mac
e.g. Pad with zeroes and double-length MPK using CMAC method 0x02.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 422
CHAPTER 4 Function Library

MAClength Specifies the length of the output MAC. Its value can be between 8-16 bytes

ICD Input Chaining Data, used for long message feedback.

MPK-Spec A key specifier incorporating an encrypted MAC Protect Key.

MAC Generated output Mac

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 423
CHAPTER 4 Function Library

MAC-GEN-UPDATE (EE0700)
Request Length Type Description

EE0700 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Alg 1 h Algorithm Qualifier Specifies details of the MACing


algorithm. The left nibble specifies the padding and the right
nibble specifies the algorithm:
Left nibble:
= 0 : pad with zeroes.
= 1 : pad with a single one bit and subsequent zeroes

Right nibble:
For single length MPK – this nibble must be zero
For double length MPK:
= 0 : ISO 9807 method
= 1 : triple-DES CBC method

ICD 8 h Input Chaining Data

MPK-Spec Var K-Spec Key Specifier for MPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 20, 50, 51, 90, 93)

Data Var h Data to be MACed

Response Length Type Description

EE0700 3 h Function Code

rc 1 h Return Code

OCD 8 h Output Chaining Data

This function is provided for long message MAC generation and verification, whereby a message authentication Block
(OCD) is generated for the supplied DATA, using the supplied MAC Protect Key (MPK), in accordance with AS2805.4
1985. The long message support is integrated whereby the OCD is passed back to the function as the ICD after each
cycle that the function performs. On the final Block of data the function MAC-GEN-FINAL (EE0701) should be called.
This function is also used during long message MAC verification, whereby the OCD is passed back as the ICD until the
last data Block. To finalize the MAC verification, the function MAC-VER-FINAL (EE0702) should be called.

FM = 00. Must be set to zero.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 424
CHAPTER 4 Function Library

Alg Specifies the MACing algorithm to use.


Left nibble:
= 0 : pad with zeroes.
= 1 : pad with a single one bit and subsequent zeroes
Right nibble:
For single length MPK – this nibble must be zero
For double length MPK:
= 0 : ISO 9807 method
= 1 : triple-DES CBC method
e.g. Pad with zeroes and double-length MPK using triple-DES CBC method 0x01

ICD Input Chaining Data, used for long message feedback.

MPK-Spec A key specifier incorporating an encrypted MAC Protect Key.

OCD Output Chaining Data, used for long message feedback.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 425
CHAPTER 4 Function Library

MAC-GEN-UPDATE-AES (EE0712)
Request Length Type Description

EE0712 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Alg 1 h Algorithm Qualifier Specifies details of the MACing


algorithm. The right nibble specifies the algorithm:
Left nibble:
= 0 : RFU
Right nibble:
= 0x02 : CMAC
= 0x03 : AES CBC Mac

ICD 16 h Input Chaining Data

MPK Var K-Spec Key Specifier for MPK


(Formats: 52, 53, 54,1C)
Note: In case of format 54, only Algorithm 0A is applicable

Data Var h Data to be MAC'd

Response Length Type Description

EE0712 3 h Function Code

rc 1 h Return Code

OCD 16 h Output Chaining Data

This function is provided for long message MAC generation and verification, whereby a message authentication Block
(OCD) is generated for the supplied DATA (whose length is multiple of 16 bytes), using the supplied MAC Protect Key
(MPK), in accordance with AS2805.4 1985. The long message support is integrated whereby the OCD is passed back
to the function as the ICD after each cycle that the function performs. On the final Block of data the function MAC-
GEN-FINAL-AES (EE0713) must be called.
This function is also used during long message MAC verification, whereby the OCD is passed back as the ICD until the
last data Block. To finalize the MAC verification, the function MAC-VER-FINAL-AES (EE0714) must be called.

FM = 00. Must be set to zero.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 426
CHAPTER 4 Function Library

Alg Specifies the MACing algorithm to use.


Right nibble:
= 0x02: CMAC
= 0x03: AES CBC Mac
e.g. Pad with zeroes and double-length MPK using CMAC method 0x02

ICD Input Chaining Data, used for long message feedback.

MPK-Spec A key specifier incorporating an encrypted MAC Protect Key.


Formats: 52, 53, 54,1C
Note: Algorithm 0A of Key Spec 54 is only applicable

Data Data to be mac’d. Length of Data must be multiple of 16 bytes.

OCD Output Chaining Data, used for long message feedback.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 427
CHAPTER 4 Function Library

MAC-VER-FINAL (EE0702)
Request Length Type Description

EE0702 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Alg 1 h Algorithm Qualifier. Specifies details of the MACing


algorithm.
Left nibble (Padding):
= 0 : pad with zeroes.
= 1 : pad with a single one bit and subsequent zeroes
Right nibble (Algorithm):
For single length MPK must be zero.
For double length MPK:
= 0 : ISO 9807 method
= 1 : triple-DES CBC method

ICD 8 h Input Chaining Data

MPK-Spec Var K-Spec Key Specifier for MPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 20, 50, 51, 90, 93)

MAC Var h Message Authentication Code

Data Var h Data to be MACed

Response Length Type Description

EE0702 3 h Function Code

rc 1 h Return Code

This function verifies that the MAC is valid for the supplied DATA using the supplied MAC Protect Key (MPK), in
accordance with AS2805.4 1985.
When the MPK is a HSM stored HMAC-SHA MPK, the HMAC-SHA MAC algorithm will be used for message
authentication depending on the attributes of the MPK.
For HMAC-SHA algorithm, valid length range for requested MAC verification will depend on the attributes of the HSM-
stored MPK and is given below:
• HMAC-SHA-1 = 04 - 20 bytes
• HMAC-SHA-224 = 04 – 28 bytes
• HMAC-SHA-256 = 04 – 32 bytes
• HMAC-SHA-384 = 04 – 48 bytes
• HMAC-SHA-512 = 04 – 64 bytes

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 428
CHAPTER 4 Function Library

A format 18 key specifier (embedded binary secure key Block) containing a host stored HMAC-SHA MPK key may also
be used for HMAC-SHA message authentication. Note that Alg field is not applicable to the function processing if the
MPK is an HMAC-SHA MPK.
HMAC-SHA MPK key length can be 128, 160 or 192 bits.

FM = 00. Must be set to zero.

Alg Specifies the MACing algorithm to use.


Left nibble:
= 0 : pad with zeroes.
= 1 : pad with a single one bit and subsequent zeroes
Right nibble:
For single length MPK – this nibble must be zero
For double length MPK:
= 0 : ISO 9807 method
=1 : triple-DES CBC method

ICD Input Chaining Data, used for long message feedback.

MPK-Spec A key specifier incorporating an encrypted MAC Protect Key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 429
CHAPTER 4 Function Library

MAC-VER-FINAL-AES (EE0714)
Request Length Type Description

EE0714 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Alg 1 h Algorithm Qualifier. Specifies details of the MACing


algorithm. The right nibble specifies the algorithm:
Left nibble:
= 0 : RFU
Right nibble:
= 0x02 : CMAC
= 0x03 : AES CBC Mac

ICD 16 h Input Chaining Data

MPK Var K-Spec Key Specifier for MPK


(Formats: 52, 53, 54, 1C)
Note: In case of format 54, only Algorithm 0A is applicable

MAC Var h Message Authentication Code

Data Var h Data to be MAC'd

Response Length Type Description

EE0714 3 h Function Code

rc 1 h Return Code

This function verifies that the MAC is valid for the supplied DATA using the supplied AES MAC Protect Key (MPK), in
accordance with AS2805.4 1985.
AES MPK key length can be 128, 192 or 256 bits. The MAC-VER-FINAL (EE0702) function returns no response data.
An Error Code of 00 indicates successful verification, while 08 indicates a verification failure.

FM 00. Must be set to zero.

Alg Specifies the MACing algorithm to use.


Right nibble:
= 0x02: CMAC
= 0x03: AES CBC Mac
e.g. Pad with zeroes and double-length MPK using CMAC method 0x02

ICD Input Chaining Data, used for long message feedback.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 430
CHAPTER 4 Function Library

MPK-Spec A key specifier incorporating an encrypted MAC Protect Key.

MAC Generated output Mac

Note: In EE0712, EE0713 and EE0714, only AES keys are allowed hence 52, 53 and 1C
formats must contain AES keys only.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 431
CHAPTER 4 Function Library

MAM-ACTIVATE (EE040D)
Request Length Type Description

EE040D 3 h Function Code

FM 1 h Function Modifier

K1, K2 Var K-spec Challenge encryption key


Format: 20

eK1(Challenge 1) 8 h Challenge 1 = RN || KSN2.

KSN2 Var h Rightmost two bytes of KSN,


or zero-length field.

Time 2 h Two bytes of time information.

Session ID 8 h Session ID

Response Length Type Description

EE040D 3 h Function Code

rc 1 h Return Code

eK2(Reply) 8 h Encrypted reply to challenge

eK2(Session ID) 8 h Encrypted Session ID

This function generates an encrypted reply to challenge using the following steps :
1. Derive keys K1 and K2 using the format-20 key specifier.

K1 is a variant of the current DUKPT PIN Encryption Key (Key XOR F0F0 F0F0 F0F0 F0F0 F0F0 F0F0 F0F0
F0F0). K2 is a variant of the current DUKPT PIN Encryption Key (Key XOR 3C3C 3C3C 3C3C 3C3C 3C3C 3C3C
3C3C 3C3C).
2. Decrypt eK1 (Challenge 1) using K1, thereby recovering the 6-byte random number and the rightmost 2 bytes of
KSN.

If KSN2 is not a zero-length field, compare it with the recovered two bytes of KSN. If they are not identical then
abort with error code (0x08 error). Create the reply to the challenge as the concatenation of the 6-byte random
number and the 2-byte Time.
3. Encrypt the reply using K2, to give eK2(Reply).
4. Encrypt the Session ID using K2, to give eK2(Session ID).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 432
CHAPTER 4 Function Library

MAM-DEACTIVATE (EE040E)
Request Length Type Description

EE040E 3 h Function Code

FM 1 h Function Modifier

K1, K2 Var K-spec Challenge encryption key


Format: 20

eK1(Challenge 2) 8 h Challenge encrypted by K1

Increment Flag 1 h Increment flag

Response Length Type Description

EE040E 3 h Function Code

rc 1 h Return Code

eK2(Reply) 8 h Encrypted reply to challenge

This function generates an encrypted reply to challenge using the following steps :
1. Derive keys K1 and K2 using the format-20 key specifier. (K1 is a variant of the current DUKPT PIN Encryption
Key (Key XOR F0F0 F0F0 F0F0 F0F0 F0F0 F0F0 F0F0 F0F0).) (K2 is a variant of the current DUKPT PIN
Encryption Key (Key XOR 3C3C 3C3C 3C3C 3C3C 3C3C 3C3C 3C3C 3C3C)).
2. Decrypt eK1(Challenge 2) using K1.
3. Create the reply to the challenge as the concatenation of the left seven bytes of Challenge 2 and the 1-byte
Increment Flag.
4. Encrypt the response using K2, to give eK2(Reply).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 433
CHAPTER 4 Function Library

MD5-GENERATOR (0020)
This function returns the MD5 hash value of the input data, to a maximum length as specified by the supplier. It can be
used to generate a PVC of a public key (see section Verification Codes - DEA 2 keys (PVC)).

Request Length Type Description

0020 2 h Function Code

Msg ID 2 x Message Identifier

Mode Flag 1 x 00 = only block


01 = initial block
02 = intermediate block
03= last block

Bit Count 8 bin Initially zeroes, then returned value from previous call

Chain Value 16 x Hash chaining Value, initially 0s then returned value

Data Var x Data

Response Length Type Description

0020 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

Bit Count 8 bin Cumulative bit count used for chaining

Hash Value 16 x Hash Value or chaining value if intermediate

This host function is used for Australian Major Bank (AMB).


This function allows input to be chained over multiple calls. The chain value and bit count must be set to zeros on the
initial call. Intermediate segments (mode flag = 01) must be a multiple of 64 bytes long. Maximum segment length is
the buffer size of Luna EFT.

Note: MD5 is defined for compatibility with heritage applications. For other applications the
use of SHA1 is preferred.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 434
CHAPTER 4 Function Library

MIGRATE-KM-ENC-PIN (EE0644)
Request Length Type Description

EE0644 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PIN-Spec Var K-Spec KM-encrypted PIN Block (old KM)


(Format: 1A)

ANB 6 h Account Number Block

Response Length Type Description

EE0644 3 h Function Code

rc 1 h Return Code

PIN-Spec Var K-Spec KM-encrypted PIN Block (current KM)


(Format: 1A)

This function re-encrypts a KM-encrypted PIN from the old KM to the current KM.
The function will fail with Error Code 78 if PIN block format ISO-3 is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 435
CHAPTER 4 Function Library

MIGRATEPIN (EE0601)
Request Length Type Description

EE0601 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PVK1-Spec Var K-Spec Key specifier for old PVK


(Formats: 0-3)

PAN 8 h Validation data

Offset1 6 h Existing offset for the PIN

PINLEN 1 h Number of digits in the PIN

PVK2-Spec Var K-Spec Key specifier for new PVK


(Formats: 0-3)

Response Length Type Description

EE0601 3 h Function Code

rc 1 h Return Code

Offset2 6 h Replacement offset for PIN

This function migrates a PIN from one 3624 PVK to another.


Note that this function will work only as permitted by the controlling console operation. Please refer to the Console
Guide for details on how to control this function via the console.

FM = 00. Must be set to zero.

PVK1-Spec Key specifiers that incorporate an index to an HSM-stored PVK and associated Decimalization
PVK2-Spec Table. The values specified must be as previously set in the controlling console operation,

PAN The ‘validation data’ that is used with the PVK and Decimalization table to produce the Offset.

Offset1 Existing and replacement PIN offset data. The significant digits are left-justified in the field.
Offset2

PINLEN Identifies the number of digits in the PIN, and hence the length of the Derived PIN

For additional details regarding the 3624 PIN verification method, please refer to IBM 3624 PIN Verification.
Note for users of CHKLEN during PIN verification:
If CHKLEN < PINLEN and only CHKLEN digits of the existing PIN offset are available, then these digits need to be
provided, positioned appropriately in the Offset1 field. The significant digits of the new PIN offset will be in the same
position in the Offset2 field.
Function Specific Return code.
02 - Signifies that PVK 1 or PVK 2 has not been initialized for PIN migration via the console.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 436
CHAPTER 4 Function Library

M-KEY-GEN (3B20)
This function generates a random ATM Master Key and returns it encrypted under KMv42, KMvAA and the ATM A-key.

Request Length Type Description

3B20 2 h Function Code

Msg ID 2 x Message Identifier

KL 1 x Key length:
1 = Single
2 = Double
3 = Triple

eKMvAA(A) Var K-Spec ATM A-key (Format 20, 21 or 22)

CM 1 x Cipher mode:
0 = ECB
1 = CBC

Response Length Type Description

3B20 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKMvAA(M) Var K-Spec ATM M-key (Format 20, 21 or 22)

eKMv42(M) Var K-Spec ATM M-key (Format 20, 21 or 22)

eA(M) Var B64/B128/ ECB or CBC encrypted ATM M-key


B192

Note: This function supersedes the host function 3620

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 437
CHAPTER 4 Function Library

MT-KPE-GEN (A0)
Request Length Type Description

A0 1 h Function Code

MT-Index 1 d Index of KEK

Response Length Type Description

A0 1 h Function Code

rc 1 h Return Code

eKEKn(KPE) 8 B64 PIN Encryption Key

eKMv1(KPE) 8 B64 PIN Encryption Key

KCV 2 h Key Check Value

This function generates a random PIN Encryption Key (KPE). For transmitting to the receiving institution, it is returned
encrypted under the Key Exchange Key (KEK) that is indicated by the specified index (MT-index). It is also returned
encrypted under the appropriate Domain Master Key (KM) variant for storage within the host. The Key Check Value
(KCV) for the generated key is also returned.

MT-Index This field has the range of 1 to 2 and indexes a KEK. The KEK is used to encrypt the KPE

eKEKn(KPE) The random PIN Encryption Key is returned encrypted under the Key Exchange Key indicated by
the specified index

eKMv1(KPE) The random PIN Encryption Key is returned encrypted under variant 1 of the Domain Master Key
for storage within the host

KCV The Key Check Value.

This function is not required by member institutions. For online key exchange, the PIN Encryption Keys (KPE) are
generated and distributed by the MasterCard Switch center. This function is included for testing purposes only.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 438
CHAPTER 4 Function Library

MT-KPE-RCV (A1)
Request Length Type Description

A1 1 h Function Code

MT-Index 1 d Index of KEK

eKEKn(KPE) 8 B64 PIN Encryption Key

Response Length Type Description

A1 1 h Function Code

rc 1 h Return Code

eKMv1(KPE) 8 B64 PIN Encryption Key

KCV 2 h Key Check Value

This function allows a received PIN Encryption Key (KPE) that has been encrypted under the Key Exchange Key
(KEKn) indicated by the supplied Index (MT-Index), to be further encrypted under Domain Master Key (KM) Variant1 for
storage within the host.
The Key Check Value (KCV) for the received key is also returned to allow verification of key synchronization.

MT-Index This field has the range of 1 to 2 and indexes a KEK. The KEK is used to encrypt the KPE.

eKEKn(KPE) The PIN Encryption Key is received encrypted under the Key Exchange Key indicated by the
supplied index.

eKMv1(KPE) The PIN Encryption Key is returned encrypted under variant 1 of the Domain Master Key for
storage within the host.

KCV The Key Check Value.

This function is provided for an acquirer / issuer member using the online key exchange procedure. As the received
KPE is re-encrypted by KM1, it may be used with the standard HSM PIN management functions. In this case, the KPE
is equivalent to the HSM notation of the PPK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 439
CHAPTER 4 Function Library

MT-PIN-TRAN (A2)
Request Length Type Description

A2 1 h Function Code

PF 1 h PIN Format

ePPK(PIN) 8 B64 PIN encrypted under PPK

eKMv1(PPK) 8 B64 PIN Protect Key

MT-Index 1 d Index of KEK

ANB 6 h Account Number Block

Response Length Type Description

A2 1 h Function Code

rc 1 h Return Code

eKPE(AS-PIN) 8 B64 AS/ANSI Formatted Pin Block

This function translates a PIN Block from encryption under a host stored PIN Protect Key (PPK) to encryption under a
HSM stored PIN Encryption Key (KPE). If appropriate, the PIN Block format is changed to AS/ANSI format.

PF This field specifies the format of the supplied PIN Block. The valid field values are:
1 = AS/ANSI format (no conversion required)
3 = IBM 3624 format (format conversion required)

ePPK(PIN) The PIN encrypted by a host stored PIN Protect Key.

eKMv1(PPK) The PIN Protect Key encrypted by a variant 1 of the Domain Master Key.

MT-Index This field has the range of 1 to 2 and indexes a KPE. The KPE is used to re-encrypt the PIN Block.

ANB The 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

eKPE(AS-PIN) The AS/ANSI formatted PIN Block containing the PIN to be verified is supplied encrypted by an
HSM stored PIN Encryption Key.

This function is provided for use by an acquirer employing manual key management.
The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled or conflicts with the
reformatting restrictions.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 440
CHAPTER 4 Function Library

MT-PIN-VER (A3)
Request Length Type Description

A3 1 h Function Code

PVK-Index 1 d Index of PVK

eKPE(AS-PIN) 8 B64 AS/ANSI Formatted Pin Block

MT-Index 1 d Index of KPE

PAN 8 h Primary Account Number

ANB 6 h Account Number Block

Offset 6 h PIN offset data

Response Length Type Description

A3 1 h Function Code

rc 1 h Return Code

This function performs the verification of a PIN in an AS/ANSI formatted PIN Block, using the IBM 3624 method.

PVK-Index This field has the range of 01 to 99 and indexes the PIN Verification Key (PVKn) and the
Decimalization Table (DTn) to be used in the PIN calculation process.

eKPE(AS-PIN) The AS/ANSI formatted PIN Block containing the PIN to be verified is supplied encrypted by an
HSM stored PIN Encryption Key.

MT-Index This field has the range of 1 to 2 and indexes a KPE.

PAN The Primary Account Number (or other card data) used in the verification procedure.

ANB The 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

Offset Up to 12 digits of offset data. The significant digits must be left-justified padded with zeros.

No response data is returned by this function, and it is only provided for use by an issuer employing manual key
management. An Error Code of 00 indicates successful verification, while 08 indicates a verification failure.
The function will fail with Error Code 78 if the ANSI PIN block format is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 441
CHAPTER 4 Function Library

MT-PIN-VER-PVV (A7)
Request Length Type Description

A7 1 h Function Code

PVVK-Index 1 d Index of PVVK

eKPE(AS-PIN) 8 B64 AS/ANSI Formatted Pin Block

MT-Index 1 d Index of KPE

ANB 6 h Account Number Block

TSP12 6 h Transformed Security Parameter

PVV 2 h PIN Verification Value

Response Length Type Description

A7 1 h Function Code

rc 1 h Return Code

This function performs the verification of a PIN in an AS/ANSI formatted PIN Block, using the PVV method.
The PVVK-index has a range of 1 to 36. The PVKI has a range of 1 to 6.

PVVK-Index Identifies the PVK-A/B pair that is to be used in the derivation of the PVV and must be in BCD
format.

eKPE(AS-PIN) The AS/ANSI formatted PIN Block containing the PIN to be verified is supplied encrypted by an
HSM stored PIN Encryption Key as specified by the MT-index.

MT-Index This field has the range of 1 to 2 and indexes a KPE.

ANB The 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

TSP12 The leftmost 12 digits of the TSP and consists of 11 PAN digits followed by the appropriate one
digit PVKI.

PVV The PIN Verification Value used to verify the calculated PVV.

The function returns no response data. A Return Code of 00 indicates that the PIN is verified. A 07 indicates that the
format of the PIN Block in the request is incorrect, and a 08 indicates PIN verification failure.
The function will fail with Error Code 78 if the ANSI PIN block format is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 442
CHAPTER 4 Function Library

NI-KEY-GEN (EE0404)
Request Length Type Description

EE0404 3 h Function Code

FM 1 h Function Modifier (FM = x0)

Key Flags 2 h Key Type indicator / Encryption mode


1KS Spec Var K-Spec Key Specifier for Session Key
n
(Formats: 10, 11, 12, 13, 14, 17, 18)

Following fields must be present if 13th and 12th bit of Key Flags field is set to 10 i.e. response 1eKSn(KSn+1) needed
in TR-31 format.

1Following fields must be repeated n times for each set of keys starting from the least bit (right most) of Key Flags
field.

Key Usage 2 h Valid values


DPK - ‘D0’
PPK - ‘P0’
MPK - ‘M0’, ‘M1’,’M2’,’M3’, ’M4’,’M5’
Key Usage must be matched for Key Type in Key Flags.

Algorithms 1 h ‘D’, ‘T’.

Mode of use 1 h Any Valid values as described in the table Key Block
Header Fields for Key Block Format Keys

Key version number 2 h Key version number.

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte

Key Block 1 h xy, where


Version/Padding Indicator x = Key block version
y = Padding indicator
x = 0 (TR-31 Key block Version A)
1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)

Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Number of optional fields 1 h 0x63 (Decimal 00 to 99 Max)

Optional field 1 … n Var h

*1KBS Var h Key Block structure. Optional and must be present if


1KSn+1-Spec required in TR-31 Key block format.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 443
CHAPTER 4 Function Library

Response Length Type Description

EE0404 3 h Function Code

rc 1 h Return Code

n 1 h Number of following key sets


1eKS (KSn+1) Var h Encrypted Session Key
n
Or Or
1eKS (KSn + 1) Encrypted Session Key in TR-31 Key Block formats.
n
1KS Spec Var K-Spec Key Specifier for Session Key (Formats: 10, 11, 12, 13, 14,
n+1
17, 18)
1KVC 3 h Key Verification Code

1This set of fields will occur ‘n’ times. Value of n can be at max 3.

Notes
– The key specifiers 10, 11 under the Response, are generated when using the Legacy option.
– The key specifiers 10, 11, 13 under the Response, are generated based on the chosen operation on console
and FM. See, section Function Modifier Values.
*KBS field must be provided when key is needed in 17 or 18 format. This field should repeat for each new key to be
generated.
When only host stored keys are needed in TR-31, KBS should be formed as:

KBS key block structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h Any allowed value for the key to be generated.

Algorithms 1 h Any allowed value

Mode of use 1 h Any allowed mode of use for key usage

Key Version No. 2 h Any allowed value

Exportability 1 h Any allowed value

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Number of optional fields 1 h 0x00-0x03 (Decimal 00 to 03 Max)

Optional field 0 … n Var h Number of optional field as defined in above filed. First byte
of optional field will be treated as Optional Block ID.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 444
CHAPTER 4 Function Library

When both Session key encrypted key and key spec is need in TR-31 then KBS should be provided is mentioned
below:

KBS key block structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h = 0000


Key usage will be determined from request TR-31 key block

Algorithms 1 h = 00
Algorithm will be determined from request TR-31 key block

Mode of use 1 h = 00
Mode of usage will be determined from request TR-31 key
block

Key Version No. 2 h = 00 Key Version Number will be determined from TR31-key
block

Exportability 1 h 00 = Same exportability as in request TR-31 key block


N = If request TR-31 has this field as ‘S’ or ‘E’, exportability
will be set to N in response key block.

Padding Indicator 1 h 00 = Do not pad


03 = Pad to triple length

Number of optional fields 1 h = 00 Must be 0

Optional field 0 … n Var h Not allowed as Number of optional fields must be 0

This function generates a set of new random DES or 3DES Session Keys (KSn+1-Spec) for an Interchange. For
transmitting to the receiving node, the generated keys are returned encrypted under the supplied previous Session Key
(KSn). For double-length keys, either ECB or CBC encryption modes may be selected.
The generated keys are also returned encrypted under the appropriate variant of the Domain Master Key (*KM), for
storage within the host system. This function also returns the KVCs of the session keys.
The function response will contain one or more sets of encrypted key fields as shown: one set for each appropriate bit
set in the 'Key Flags' field. That field also indicates the encryption mode for any double-length keys that are generated.

FM = x0
The Host Key Protection using Function Modifier can be in the range of x0, where x= 0, 1, or 2.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 445
CHAPTER 4 Function Library

Key Flags Indicates the keys to generate and the encryption mode. The bit positions are allocated as follows:

Bit Indicates

0 Single-length Data Key (DPK)

1 Single-length PIN encrypting key (PPK)

2 Single-length MAC key (MPK)

3 Reserved. Must be zero

4 Triple-length Data Key (DPK)

5 Triple-length PIN encrypting key (PPK)

6 Triple-length MAC key (MPK)

7 Reserved. Must be zero

8 Double-length Data Key (DPK)

9 Double-length PIN encrypting key (PPK)

10 Double-length MAC key (MPK)

11 Reserved. Must be zero

12 - 13 Encryption mode for the response encipher:


00 = ECB; 01 = CBC and 10 = TR-31, bit 12 is the least significant (right-most) bit.

14 - 15 Reserved. Must be zero.


Bit 0 is the least significant (right most) bit.

KSn-Spec A key specifier incorporating a session key encrypted by a variant of the Domain master key

eKSn(KSn+1) The new session key encrypted by the supplied session key

KSn+1-Spec A key specifier to the new session key

KVC Key Verification Code for the new session key

Notes
– The encryption mode for eKSn(KSn+1) and KSn spec is ECB unless otherwise specified.
– This function supercedes functions 57, 58, 59.
– Bit 3, Bit 7, Bit 11 and Bits 13-15 of the key flags are reserved.
– Single length KSn is not supported if generated Key requested in TR-31 Key Block. i.e.
Format 10 is not supported for 1KSn Spec.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 446
CHAPTER 4 Function Library

NI-KEY-RCV (EE0405)
Request Length Type Description

EE0405 3 h Function Code

FM 1 h Function Modifier (FM = x0)

Key Flags 2 h Key Type indicator / Encryption mode


1KS Spec Var K-Spec Key specifier for Session Key
n
(Formats: 10, 11, 12, 13, 14, 17, 18)
1eKS (KSn+1) Var h Encrypted Session Key in Key Spec format.
n
Or Or
1eKS (KSn+1) Encrypted Session Key in TR-31 Key Block formats.
n
1*KBS Var h Key Block structure. Optional and must be present if
1KS Spec required in TR-31 Key block format .
n+1

Response Length Type Description

EE0405 3 h Function Code

rc 1 h Return Code

n 1 h Number of following key sets


1KS Spec Var K-Spec Key Specifier for Session Key
n+1
(Formats: 10, 11, 12, 13, 14, 17, 18)
1KVC 3 h Key Verification Code

1These fields will occur ‘n’ times. Value of n can be at max 3.

Notes
– The key specifiers 10, 11 under the Response, are generated when using the Legacy option.
– The key specifiers 10, 11, 13 under the Response, are generated based on the chosen operation on console
and FM.
*KBS field must be provided when key is needed in 17 or 18 formats. This field will repeat for each key received.
When incoming key is not in TR-31, KBS should be formed as:

KBS key block structure

Field Length Type Description

KBS identifier 1 h = 0x00


Format

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 447
CHAPTER 4 Function Library

KBS key block structure

Field Length Type Description

Key Block Version 1 h Must be ‘B’


ID

Key Usage 2 h Corresponding to key flags field in request.

Algorithms 1 h Any allowed value

Mode of use 1 h Any allowed mode of use for key usage

Key Version No. 2 h Any allowed value

Exportability 1 h Any allowed value

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Number of optional 1 h 0x00-0x03 (Decimal 00 to 03 Max)


fields

Optional field 0 … n Var h Number of optional field as defined in above filed. First byte of
optional field will be treated as Optional Block ID.

When incoming key is in TR-31 format KBS should be formed as:

KBS key block structure

Field Length Type Description

KBS identifier 1 h = 0x00


Format

Key Block Version 1 h Must be ‘B’


ID

Key Usage 2 h == 0000


Key usage will be determined from request TR-31 key block

Algorithms 1 h = 00
Algorithm will be determined from request TR-31 key block

Mode of use 1 h = 00
Mode of usage will be determined from request TR-31 key block

Key Version No. 2 h =00 Key Version Number will be determined from TR31-key block

Exportability 1 h = Any valid value


If this value clashes with exportability field of incoming key then this
value will be used to form response key block provided incoming
exportability is ‘E’ or ‘S’.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 448
CHAPTER 4 Function Library

KBS key block structure

Field Length Type Description

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Number of optional 1 h = 00 Must be 0


fields

Optional field 0 … n Var h Not allowed as Number of optional fields must be 0

This function allows a Session Key rollover for the interchange. It re-encrypts a received set of encrypted DES or 3DES
keys for host storage. The key set may include any of the session keys, PPK, MPK and DPK.
The node receives a set of new Session Keys (KSn+1) encrypted under the current one (KSn) and sends them together
with the current Session Key encrypted under the appropriate *KM Variant to the HSM. For double-length keys, either
ECB or CBC encryption modes are supported.
The HSM returns the new Session Keys encrypted under the appropriate *KM Variant, for storage within the host. This
function also returns the KVCs of the session keys.

FM = x0
The Host Key Protection using Function Modifier can be in the range of x0, where x = 0, 1, or 2.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 449
CHAPTER 4 Function Library

Key Flags Indicates the keys to generate and the encryption mode. The bit positions are allocated as follows:

Bit Indicates

0 Single-length Data Key (DPK)

1 Single-length PIN encrypting key (PPK)

2 Single-length MAC key (MPK)

3 Reserved. Must be zero

4 Triple-length Data Key (DPK)

5 Triple-length PIN encrypting key (PPK)

6 Triple-length MAC key (MPK)

7 Reserved. Must be zero

8 Double-length Data Key (DPK)

9 Double-length PIN encrypting key (PPK)

10 Double-length MAC key (MPK)

11 Reserved. Must be zero

12 - 13 Encryption mode for decipher of the inbound


eKSn(KSn+1): 00 = ECB; 01 = CBC and 10 = TR-31
Bit 12 is the least significant (right most) bit.

14 - 15 Reserved. Must be zero.


Bit 0 is the least significant (right most) bit.

KS-Specn Key specifier incorporating an encrypted session key.

eKSn(KSn+1) A new session key encrypted by the old Session Key.

KVC Key Verification Code of the session key

Notes
– The encryption mode for eKSn(KSn+1) and KSn spec is ECB unless otherwise specified.
– This function supercedes functions 5A, 5B, 5C.
– Bit 3, Bit 7, Bit 11 and Bits 14-15 of the key flags are reserved.
– Single length KSn is not supported if incoming Key in TR-31 Key Block. I.e. Format 10 is not supported for
1KSn Spec.
– If input key is in TR-31 Key Block format Key Usage of 1eKIRn(KS) must be matched for Key Type for each
set of keys starting from the least bit (right most) of Key Flags field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 450
CHAPTER 4 Function Library

NODE-KEK-REC-EXPORT (C710)
This function recovers a Cross Domain Receive Key (KEKr) which has been transferred from another Luna EFT.

Request Length Type Description

C710 2 h Function Code

Msg ID 2 x Message Identifier

eKMvA0(SKsGP) Var K-Spec Encrypted receiver’s secret key (format 42) – our SK

eKMvAC(PKrGP) Var K-Spec Encrypted sender’s public key (format 42) – partner’s PK

sSKrGP(hash(key data)) Var S-Block Hash of key data signed with SKrGP – partner’s PK

cPKsGP(key data) Var S-Block Key data encrypted with PKSGP – our PK

Response Length Type Description

C710 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKMv84(KEKr) Var K-Spec Cross Domain Receive Key


Format 21

KVC(KEKr) 3 h Verification Code of KEKr

The recovered key is used and denoted as a Cross Domain Receive Key (KEKr). The function recovers KEKr by
decrypting the key data with the secret key (SKsGP), and authenticates the KEKr by verifying the hash data under the
public key (PKrGP) provided by the sender.
The function returns KEKr encrypted under the Domain Master Key and the KVC of the KEKr.
This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 451
CHAPTER 4 Function Library

NODEPROOF (EE3033)
Request Length Type Description

EE3033 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Output Len 1 h Output length required


01 = 64 bits
02 = 128 bits

KIS-Spec Var K-Spec Key specifier for KIS


(Formats 0-3, 15)

Response Length Type Description

EE3033 3 h Function Code

rc 1 x Return Code

eKISv82(RNs) Var h Encrypted Random Number

eKISv84(RNr) Var h Encrypted Inverted Random Number.

This function generates the random number to be forwarded to the remote node as part of the internodal proof-of-
endpoint processing.
The Random Number (RNs) is inverted to form RNr. RNs and RNr are returned to the host enciphered by the KIS.

Notes
– The Random Number is not adjusted for parity
– The length of the response random numbers can be determined from the Var field header.
– The encryption mode is CBC with an IV of zero.
– When Format 15 is used for the KIS-Spec, it must contain the attributes specific to AS2805.6.3 2000.
– When formats 00 – 03 are used for the KIS-Spec, the HSM stored KIS must be a double length key with the
variant scheme AS2805 1985 selected.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 452
CHAPTER 4 Function Library

NODERESP (EE3034)
Request Length Type Description

EE3034 3 h Function Code

FM 1 h Function Modifier (FM = 00)

KIR-Spec Var K-Spec Key specifier for KIR


(Formats 0-3, 15, 17, 18)

eKIRv82(RNs) Var h Encrypted Random Number

Response Length Type Description

EE3034 3 h Function Code

rc 1 x Return Code

eKIRv84(RNr) Var h Encrypted Random Number Inverted

This function performs the response part of the internodal proof-of endpoint processing.
The function deciphers a number (RNs) using the KIR in the request. RNr is formed by inverting RNs and is returned
enciphered under KIR.

Notes
– Encryption mode is CBC for B128 length.
– The length of the response random numbers can be determined from the Var field header.
– When Format 15 is used for the KIR-Spec, it must contain the attributes specific to AS2805.6.3 2000.
– When formats 00 – 03 are used for the KIR-Spec, the HSM stored KIR must be a double length key with the
variant scheme AS2805 selected.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 453
CHAPTER 4 Function Library

NT-KEY-GEN (EE0401)
Request Length Type Description

EE0401 3 h Function Code

FM 1 h Function Modifier (FM = x0)

Key Flags 2 h Key Type generation specifier


1KS Spec Var K-Spec Session Key Specifier
n
(Formats: 10, 11, 12, 13, 14, 17, 18)

Following fields must be present if 13th and 12th bit of Key Flags field is set to 10, i.e. response 1eKSn(KSn+1)is
needed in TR-31 format.
1Following fields must be repeated n times for each set of keys starting from the least bit (right most) of Key Flags
field.

Key Usage 2 h Valid values


DPK - ‘D0’
PPK - ‘P0’
MPK - ‘M0’, ‘M1’,’M2’,’M3’,
’M4’,’M5’
Key Usage must be matched for Key Type in Key Flags.

Algorithms 1 h ‘D’, ‘T’

Mode of use 1 h Any Valid values as described in the table Key Block
Header Fields for Key Block Format Keys.

Key version number 2 h Key version number.

Exportability 1 h Any valid value as described in the table Defined values for
exportability byte.

Key Block Version / 1 h xy, where


Padding Indicator x = Key block version
y = Padding indicator
x = 0 (TR-31 Key block Version A)
1 (TR-31 Key block Version B)
2 (TR-31 Key block Version C)

Y = 0 (Don’t pad)
Y = 3 (Pad to triple length)

Number of optional fields 1 h 0x00-0x63 (Decimal 00 to 99 Max)

Optional field 1 … n Var h

*KBS Var h

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 454
CHAPTER 4 Function Library

Response Length Type Description

EE0401 3 h Function Code

rc 1 h Return Code

N 1 h Number of following key sets


1eKS (KSn+1) Var h Encrypted Session Key
n
Or Or
1eKS (KSn + 1) Encrypted Session Key in TR-31 Key Block formats.
n
1KS Spec Var K-Spec Session Key specifier
n+1
(Formats: 10, 11, 12, 13, 14, 17, 18)
1KVC 3 h Key Verification Code

1This set of fields will occur ‘n’ times. Value of n can be at max 3.

This function generates a set of new random Session Keys (KSn+1) for an EFT Terminal.
For transmitting to the EFT Terminal, the keys are returned encrypted under the supplied previous Session Keys (KSn).
They are also returned encrypted under the appropriate KM variant, for storage within the host system. The function
also returns the KVCs of the Session Keys.
*KBS field must be provided when key is needed in 17 or 18 format. This field will repeat for each key to be generated.
When both KTM encrypted key and key spec is need in TR-31 then KBS should be provided is mentioned below:

KBS key block structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h =0000. Will be determined by Key Usage field.

Algorithms 1 h = 00
Algorithm will be determined from request TR-31 key block

Mode of use 1 h = 00
Mode of usage will be determined from request TR-31 key block

Key Version No. 2 h =00 Key Version Number will be determined from TR31-key
block

Exportability 1 h 00 = Same exportability as in request TR-31 key block


N = If request TR-31 has this field as ‘S’ or ‘E’, exportability will
be set to N in response key block.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 455
CHAPTER 4 Function Library

KBS key block structure

Field Length Type Description

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Number of optional 1 h = 00 Must be 0


fields

Optional field 0 … n Var h Not allowed as Number of optional fields must be 0

When only host stored keys are needed in TR-31, KBS should be formed as :

KBS key block structure

Field Length Type Description

KBS identifier Format 1 h = 0x00

Key Block Version ID 1 h Must be ‘B’

Key Usage 2 h Any allowed value for the key to be generated.

Algorithms 1 h Any allowed value

Mode of use 1 h Any allowed mode of use for key usage

Key Version No. 2 h Any allowed value

Exportability 1 h Any allowed value

Padding Indicator 1 h 00= Do not pad


03 = Pad to triple length

Number of optional 1 h 0x00-0x03 (Decimal 00 to 03 Max)


fields

Optional field 0 … n Var h Number of optional field as defined in above filed. First byte of
optional field will be treated as Optional Block ID.

Notes
– The key specifiers 10, 11 under the Response, are generated when using the Legacy option.
– The key specifiers 10, 11, 13 under the Response, are generated based on the chosen operation on console
and FM. See section, Function Modifier Values.

FM The Host Key Protection using Function Modifier can be in the range of x0, where x= 0, 1, or 2.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 456
CHAPTER 4 Function Library

Key Flags Indicates the session keys to generate. The function response will contain one or more sets of
encrypted key fields as shown: one set for each bit set in the flags. The bit positions are allocated
as follows:

bit session key type

0 Single-length Data Key (DPK)

1 Single-length PIN encrypting key (PPK)

2 Single-length MAC key (MPK)

3 Reserved. Must be zero

4 Triple-length Data Key (DPK)

5 Triple-length PIN encrypting key (PPK)

6 Triple-length MAC key (MPK)

7 Reserved. Must be zero

8 Double-length Data Key (DPK)

9 Double-length PIN encrypting key (PPK)

10 Double-length MAC key (MPK)

11 Reserved. Must be zero

12 - 13 Encryption mode for response eKSn(KSn+1)


00 = ECB, 01 – CBC and 10 =TR-31, bit 12 is the least significant (right most) bit

14-15 Reserved. Must be zero.


Bit 0 is the least significant (right most) bit.
Examples:
- To generate a single-length MAC key, this field must be set to X’0004’;
- To generate a single-length PIN encrypting key and a double-length MAC key, the
field must be set to X’0402’.
- To generate a double-length PIN encrypting key and a single-length MAC key, and
1eKS (KS ) needed in TR-31 key block format the field must be set to X’2204’.
n n+1

KS Spec A key specifier incorporating a session key, encrypted by a variant of the Domain master key

eKSn(KSn+1) The new session key encrypted by the supplied session key

KSn+1 Spec A key specifier to the new session key

KVC Key Verification Code for the new session key

Notes
– For key specifier formats, refer to the section "Key specifier formats for HSM-stored keys" earlier in this
chapter.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 457
CHAPTER 4 Function Library

– The encryption mode for eKSn(KSn+1) and KSn spec is ECB unless otherwise specified.
– This function supercedes functions 44, 45, 46
– Key flag bits 3, 7, 11 and 14-15 are reserved.
– Single length 1KSn is not supported if generated Key requested in TR-31 Key Block. I.e. Format 10 is not
supported for 1KSn Spec.
– Allowed algorithms for Key Usage ‘M1’ will be ‘D’.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 458
CHAPTER 4 Function Library

OAEP-ENCRYPT (EE9205)
Request Length Type Description

EE9205 3 h Function Code

FM 1 h Function Modifier

KTM-Spec Var K-Spec Key Specifier for Terminal Master Key (KTM)
(Formats: 11, 12, 13, 14, 17, 18)

Key Type 2 h Key Type

PK Var K-Spec Key Specifier for Public Key (Format 80, 81)
[Format: 81: Key Type – Data Protect]

Encryption Scheme 1 h 0x00 = RSAES_OAEP

P Var h PKCS#1 parameter string

Response Length Type Description

EE9205 3 h Function Code

rc 1 h Return Code

ePK(KTM) Var h Public Key Encrypted PIN Block

This function encrypts KTM using RSA-OAEP encryption detailed in PKCS#1v2.1, using the following steps:
1. Extract KTM from KTM-Spec.
2. Add 4 byte Miura key header to the KTM wherein, first 2 bytes is Key Type and second 2 bytes is Key length in bits.
3. New KTM = Key Type (2 bytes) + Key Length in bits (2 bytes) + KTM.
4. Fetch the Public Key’s modulus and exponent from PK.
5. Encrypt the New KTM with PK using specified encryption scheme (OAEP).
6. Return the encrypted KTM in response.
To enable PKCS#1 parameter string P, to specify the hash algorithm used in OAEP encoding, P can be in one of the
following formats:
– Variable length string without any formatting
– Variable length string in following format

Request Length Type Description

Header 2 h = X’5A5A’

Format 1 h =1

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 459
CHAPTER 4 Function Library

Request Length Type Description

OAEP Hash Algorithm 1 h = 2: SHA-1


= 4: SHA-
256
= 5: SHA-
384
= 6: SHA-
512

OAEP MGF 1 h = 12: MGF1


SHA-1
= 14: MGF1
SHA-256
= 15: MGF1
SHA-384
= 16: MGF1
SHA-512

OAEP P Var h PKCS#1


parameter
string /
Optional
Label to be
associated
with
encryption.

Trailer 2 h = X’A5A5’

If the Header and Trailer fields do not match then P is treated as an unstructured variable length string encoded using
SHA-1 and MGF1 SHA1. If they do match but any other fields are not as specified, then an appropriate error code is
returned.

Notes
• P can be either empty or a string of 32 hex digits (16 bytes)
• “Key Type” allowed values is 00
• The following error code is introduced:

Error Description
Code

0x84 OAEP Message Too Long (As in Reference [82]: If mLen > k – 2hLen – 2, output “message too long” and
stop). Where;
• mLen is "length of KTM to be encrypted",
• k is "length of PK modulus",
• and hLen is "length of OAEP Hash".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 460
CHAPTER 4 Function Library

OBM-CHANGE-PIN-3264 (EE3003)
Request Length Type Description

EE3003 3 h Function Code

FM 1 h Function Modifier (FM = 00)

EPB Struct PU Decrypt and decode RSA-encrypted PIN Block

PVK-Spec1 Var K-Spec Key specifier for PVK and Decimalization Table (Formats:
0–3, 11, 12, 13, 14, 17, 18)

Validation Data1 8 h Customer data – usually part of the PAN

Offset1 6 h PIN offset data

PVK-Spec2 Var K-Spec Key specifier for PVK and Decimalization Table (Formats:
0–3, 11, 12, 13, 14)

Validation Data2 8 h Customer Data – usually part of the PAN

Response Length Type Description

EE3003 3 h Function Code

rc 1 h Return Code

Offset2 6 h Returned PIN offset data

This function extracts the old PIN and new PIN from a RSA-encrypted PIN Block, verifies the old PIN and calculates a
PIN offset for the new PIN.

Notes
– This function only supports PINs in PIN Format 12
– This function only supports messages containing two PIN Block.

Processing Steps
1. Decrypt and decode the RSA-encrypted PIN Block using EPB PU to recover the PIN Block, M. If the resulting
Error Code is non-zero then end function processing and return appropriate value in Return Code.
2. Calculate the reference PIN, using the PVK and Decimalization Table indicated by PVK-Spec1, Validation Data1
and Offset1.
3. Compare the reference PIN with the transaction old PIN (from PB1 in the recovered PIN Block, M). Store the result
of the comparison in Return Code.
4. If the PIN verification succeeds, calculate the PIN offset for the transaction new PIN (from PB2 in the recovered
PIN Block, M) using PVK-Spec2 and Validation Data2.
5. Return the PIN offset in Offset2.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 461
CHAPTER 4 Function Library

OBM-CHANGE-PIN-HASH (EE3006)
Request Length Type Description

EE3006 3 h Function Code

FM 1 h Function Modifier (FM = 00)

EPB Struct PU RSA-encrypted password Block

CTPV 1 Struct PU Calculate TPV (Formats: 0–3, 10, 11, 13, 17, 18)

Reference TPV 1 Var h Transformed Password Value

CTPV 2 Struct PU Calculate TPV (Formats: 0–3, 10, 11, 13, 17, 18)

Response Length Type Description

EE3006 3 h Function Code

rc 1 h Return Code

Reference TPV 2 Var h Transformed Password Value.

This function extracts the old password and new password from a RSA-encrypted password Block, verifies the old
password and calculates a TPV for the new password.

Note: This function only supports PINs in PIN Format 12.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 462
CHAPTER 4 Function Library

OBM-DECRYPT-DATA-RSA (EE3022)
Request Length Type Description

EE3022 3 h Function Code

FM 1 h Function Modifier

SK Var K-spec Key specifier for RSA private key.

C Var h RSA-encrypted data block.

P Var h PKCS#1 parameter string

Response Length Type Description

EE3022 3 h Function Code

rc 1 h Return Code

Data Var x Decrypted user data

This function recovers the user data from the cipher text.

Processing Steps
1. Retrieve the index from the key specifier: SK. Read the RSA private key (SK) from the entry in the RSA Key Pair
table indicated by the index.
2. Decrypt the RSA-encrypted Data, C, using SK.
3. Decode the resulting decrypted Data, in accordance with PKCS #1 and using parameter string P, and thereby
recovering the message M.
4. Check that the first header byte of message M is equal to 3. If first header byte is not equal to 3, then send an error
OAEP_INVALID_HEADER_BYTE (Error code: 81) in response.
5. Extract the Data field from M and return it in response field Data.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 463
CHAPTER 4 Function Library

OBM-DECRYPT-DATA-SYMMETRIC (EE3023)
Request Length Type Description

EE3023 3 h Function Code

FM 1 h Function Modifier

SK Var K-spec Key specifier for RSA private key.

C Var h RSA-encrypted key block.

P Var h PKCS#1 parameter string

eK1(Data) Var h User data encrypted using symmetric cipher

Response Length Type Description

EE3023 3 h Function Code

rc 1 h Return Code

Data Var x Decrypted user data

Alg 1 h = 1: 3DES

Mode 1 h = 1: ECB
= 2: CBC

Key Length 1 h Key length.


If 3DES, value is 16 or 24.

IV Var h Initialisation Vector.


If ECB, length is 0.
If 3DES CBC length is 8.

eKM(K2) Var K-spec Key derived from K1.

This function processes an RSA-encrypted key block, recovering the parameters of the symmetric algorithm from the
ciphertext. It uses those parameters to decrypt the supplied encrypted data.
The parameters of the symmetric algorithm are returned in the response so that a check can be made that an
appropriate encryption method was used. (The key length is provided, not the key value.)
The symmetric key (K) will be used to derive K1 (which encrypted the data) and a second key K2.
This key (K2) is returned in a form that enables its use with an appropriate data encryption host function, so that
encrypted data can be sent back to the browser.

Processing Steps
1. Retrieve the index from the key specifier: SK. Read the RSA private key (SK) from the entry in the RSA Key Pair
table indicated by the index.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 464
CHAPTER 4 Function Library

2. Decrypt the RSA-encrypted Data, C, using SK.


3. Decode the resulting decrypted Data, in accordance with PKCS #1 and using parameter string P, and thereby
recovering the message M.
4. Check that the first header byte of message M is equal to 4. If first header byte is not equal to 4 then send an error
OAEP_INVALID_HEADER_BYTE in response.
5. Also, check whether the message M is in following format. In case M is not in the format as mentioned below, send
error INVALID_FIELD_CONTENT in response.

Field Length Type Description

Control 1 H =4

Alg 1 H = 1: 3DES

Mode 1 H = 1: ECB
= 2: CBC

K Var H Key of specified algorithm.


If 3DES, length is 16 or 24.

IV Var H Initialisation Vector.


If ECB, length is 0.
If 3DES CBC length is 8.

6. Extract the Key K from M and derive K1 and K2


7. Extract Alg, Mode, Key Length and IV to be returned in response.
8. Decrypt Data using K1 and return in response.
9. Encrypt K2 using KM and return in response.
The data keys, K1 and K2, will be derived from K using the method illustrated in Figure A-2 of [81] using the appropriate
variants constants as specified in Table A-1 of [81]. Derivation of K1 will use the ‘Data Encryption, request or both
ways’ variant constant and derivation of K2 will use the ‘Data Encryption, response’ variant constant.
X9-24.1 Derivation of double-length Data Encryption keys
Double-length transaction key K = K-L || K-R
Variant key-x = K-x xor Variant constant-x (x = L, R)
Encryption key-x = TDEA [Variant key-L+R](Variant key-x) (x = L, R)
Different variant constants L and R for request and response as in Table A-1:

Key used for Variant constant-L / -R

Data Encryption, request 0000000000FF0000

Data Encryption, response 000000FF00000000

SafeNet’s Derivation of triple-length Data Encryption keys – consistent with X9-24.1


Triple-length transaction key K = K-L || K-C ||K-R
Variant key-x = K-x xor Variant constant-x (x = L, C, R)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 465
CHAPTER 4 Function Library

Encryption key-x = TDEA [Variant key-L+C+R](Variant key-x) (x = L, C, R)


Different variant constants L, C and R for request and response as in Table A-1.

Key used for Variant constant-L / -C /


-R

Data Encryption, request 0000000000FF0000

Data Encryption, response 000000FF00000000

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 466
CHAPTER 4 Function Library

OBM-GENERATE-RANDOM-PIN (EE3017)
Request Length Type Description

EE3017 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PIN Type 1 h 0 = Numeric


1 = Alpha-numeric (upper & lower case alpha)
2 = Upper case Alpha and numeric
3 = Lower case Alpha and numeric

PIN Length 1 h In range 04 - 16

CTPV Struct CTPV Calculate TPV (Formats: 0–3, 10, 11, 13, 17, 18)
Processing
Unit

Print Token 8 h Print Token of the Remote HSM which will be printing out
this generated PIN

PPK-Spec Var K-Spec Key Specifier for PPK


(Formats: 0–3)

Response Length Type Description

EE3017 3 h Function Code

rc 1 h Return Code

ePPK(OBM Print PIN Var h Encrypted OBM Print PIN Block


Block)

Reference TPV Var h Transformed PIN Value

This function generates a random (numeric or alpha-numeric) PIN and returns:


– a reference TPV for storage and subsequent verification of the PIN
– an encrypted OBM Print PIN Block (PIN Block = Print Token + PIN Block) to be printed in a remote location
The Random PIN Generation adheres to the password restrictions as described in the section Online Banking Module
Password Restrictions.
The function returns error 0x07 (INVALID PIN BLOCK CONTENT), if the PIN Type is 1, 2 or 3 and the sum of
minimum numeric and alphabetic characters in the Password Restrictions Entry dialog on the Luna EFT console
exceeds the maximum PIN/Password length.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 467
CHAPTER 4 Function Library

OBM-GENERATE-RANDOM-PIN-2 (EE3021)
Request Length Type Description

EE3021 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PIN Type 1 h 0 = Numeric


1 = Alpha-numeric (upper & lower case alpha)
2 = Upper case Alpha and numeric
3 = Lower case Alpha and numeric

Restricted Characters Var h String of the characters that will be restricted in the PIN
to be generated.

PIN Length 1 h In range 04 - 16

CTPV Struct CTPV Calculate TPV


Processing
Unit

Print Token 8 h Print Token of the Remote HSM which will be printing out
this generated PIN

PPK-Spec Var K-Spec Key Specifier for PPK


(Formats: 0–3)

Response Length Type Description

EE3021 3 h Function Code

rc 1 h Return Code

ePPK(OBM Print PIN Var h Encrypted OBM Print PIN Block


Block)

Reference TPV Var h Transformed PIN Value

This function performs the following functionalities:


1. Generates a random (numeric or alpha-numeric) PIN and returns:
– A reference TPV for storage and subsequent verification of the PIN, and
– An encrypted OBM Print PIN Block (PIN Block = Print Token + PIN Block) to be printed in a remote location
2. While generating a random pin, it excludes the characters in the PIN, as supplied in the Restricted Characters
field. The Restricted characters that you specify can contain upper/lower-case letters, and numerics even if the
value of PIN Type limits the characters that are allowed.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 468
CHAPTER 4 Function Library

The Random PIN Generation adheres to the password restrictions as described in the section Online Banking Module
Password Restrictions.

Notes
– The function returns an error code 9F for any failure in PIN generation.
– The function returns error 0x07 (INVALID PIN BLOCK CONTENT), if the PIN Type is 1, 2 or 3 and the sum of
minimum numeric and alphabetic characters in the Password Restrictions Entry dialog on the Luna EFT
console exceeds the maximum PIN/Password length.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 469
CHAPTER 4 Function Library

OBM-GEN-RANDOM-NUMBER (EE3001)
Request Length Type Description

EE3001 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Random Number Length 1 h = 01 – FF (Range = 01– 255)

Response Length Type Description

EE3001 3 h Function Code

rc 1 h Return Code

RN Var h Random Number with length as specified in Length of


Random Number

This function generates and returns a random number of the specified length.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 470
CHAPTER 4 Function Library

OBM-GET-PRINT-TOKEN (EE3016)
Request Length Type Description

EE3016 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Response Length Type Description

EE3016 3 h Function Code

rc 1 h Return Code

Print Token 8 h Generated Print Token to be used for Print Verification

This function generates 8 bytes of random data, also known as a Print Token and
• stores the Print Token in Secure Memory, overwriting any prior Print Token
• returns the 8 byte Print Token in the clear to the host

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 471
CHAPTER 4 Function Library

OBM-GET-PUBLIC-KEY (EE3000)
Request Length Type Description

EE3000 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PK-Spec1 Var K-Spec Key specifier for RSA Public Key


(Formats: 0–3)
Provides the index into the key table in secure memory
where the key is stored.

Response Length Type Description

EE3000 3 h Function Code

rc 1 h Return Code

PK-Spec2 Var K-Spec Key specifier for RSA Public Key


(Format: 80)
Contains the key retrieved from secure memory.

PVC 8 h Public Verification Code for PK.

This function retrieves a Public Key from the HSM stored RSA Key Pair table in secure memory and returns it in a clear
form in a key specifier along with the PVC for the key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 472
CHAPTER 4 Function Library

OBM-MIGRATE-PIN-3624-TPV (EE3009)
Request Length Type Description

EE3009 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PVK-Spec Var K-Spec Key specifier for PVK and Decimalization Table. (Format 0–
3, 11, 12, 13, 14, 17, 18)

Validation Data 8 h Data (usually the PAN) used to derive the password.

Offset 6 h PIN offset data

Password Length 1 h Number of digits in the password

CTPV Struct PU Calculate TPV (Formats: 0–3, 10, 11, 13, 17, 18)

Response Length Type Description

EE3009 3 h Function Code

rc 1 h Return Code

Reference TPV Var h Transformed Password Value.

This function calculates the reference password from the keys and data of the 3624 Offset method, then calculates a
Reference TPV for storage and subsequent use in password verification.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 473
CHAPTER 4 Function Library

OBM-PRINT-ENCRYPTED-PIN (EE3018)
Request Length Type Description

EE3018 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PIN Length 1 h In range 04 – 16

PPK-Spec Var K-Spec Key Specifier for PPK


(Formats: 0–3)

ePPK(OBM Print PIN Var h Encrypted OBM Print PIN Block


Block)

Data Sets 1 h A data set contains a Line No field, Column No field and
Data field. The data sets field specifies the number of data
sets that follow.

Line No1 1 h The line number for the data to be printed at.

Column No1 1 h The column number for the data to be printed at.

Data1 Var h The data to be printed.

Response Length Type Description

EE3018 3 h Function Code

rc 1 h Return Code

1This set of fields repeats 0 or more times as specified by the Data Sets field.

This function decrypts an encrypted OBM Print PIN Block, verifies the Print Token and prints the PIN along with the
specified data on an attached serial printer. The function is normally disabled, and is controlled by the associated set of
console operations. Enabling PIN Printing enables this function.
Before using this function print parameters and a print control string must be entered from the main PIN mailer menu. If
print parameters or a print control string have not been entered a PIN mailing not enabled error (error code 02) will be
returned to the host.

Processing Steps
1. Check that the Print Token in Secure Memory is valid (i.e. not equal to 0x0000000000000000), otherwise return
error code Invalid Print Token (0x7F).
2. Decrypt the Encrypted OBM Print PIN block with the PPK specified.
3. Extract the Print Token (1st 8 bytes) from the OBM Print PIN Block.
4. Verify the extracted Print Token with the Print Token stored in Secured Memory. If both Print Tokens are not the
same, return error code Invalid Print Token (0x7F).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 474
CHAPTER 4 Function Library

5. Set the Print Token in Secure Memory to 0x0000000000000000.


6. Extract the PIN from the PIN block as specified by the PIN Length.
7. Print the PIN and supplied data on the attached serial printer.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 475
CHAPTER 4 Function Library

OBM-PRINT-PIN (EE3008)
Request Length Type Description

EE3008 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Password Type 1 h 0 = Numeric


1 = Alpha-numeric (upper & lower case alpha)
2 = Upper case alpha and numeric
3 = Lower case alpha and numeric

Password Length 1 h In range 04 – 16.

CTPV Struct CTPV Calculate TPV (Formats: 0–3, 10, 11, 13, 17, 18)
Processing
Unit

Data Sets 1 h Repeat count for the following data sets.

Line No 1 h This set of fields specifies data to be printed at

Column No 1 h a given line and column.

Data Var h The set of fields is optional and may be repeated multiple
times, as specified by the Data sets field, causing 0, 1 or
more data fields to be printed.

Response Length Type Description

EE3008 3 h Function Code

rc 1 h Return Code

Reference TPV Var h Transformed Password Value.

This function generates a random (numeric or alpha-numeric) password, prints the password along with specified data
on an attached serial printer, and returns a reference TPV for storage and subsequent verification of the password.
The function is normally disabled, and is controlled by the associated set of console operations.

Notes
– Before using this function print parameters and a print control string must be entered via the SafeNet HSM
console. If print parameters or a print control string have not been entered a PIN mailing not enabled error (error
code 02) will be returned to the host.
– The function returns error 0x07 (INVALID PIN BLOCK CONTENT), if the Password Type is 1, 2 or 3 and the
sum of minimum numeric and alphabetic characters in the Password Restrictions Entry dialog on the Luna
EFT console exceeds the maximum Password length.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 476
CHAPTER 4 Function Library

OBM-SET-PIN (EE3004)
Request Length Type Description

EE3004 3 h Function Code

FM 1 h Function Modifier (FM = 00)

EPB Struct PU RSA-encrypted password Block

CTPV Struct PU Calculate TPV (Formats: 0–3, 10, 11, 13, 17, 18)

Response Length Type Description

EE3004 3 h Function Code

rc 1 h Return Code

Reference Hash Var h Returned hash data

This function extracts the (numeric or alpha-numeric) password from a RSA-encrypted password Block and calculates
a Reference TPV for storage and subsequent use in password verification.

Note: This function only supports PINs in PIN Format 12.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 477
CHAPTER 4 Function Library

OBM-SET-PIN-TPV (EE3020)
Request Length Type Description

EE3020 2 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPK(PIN) 8 x PIN Block encrypted by PPK

PPKi-Spec Var K-Spec Input PIN Protect Key Specifier


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18, 90)

PFi 1 h Input PIN Block Format


(Formats: 01, 03, 08, 09, 10, 11, 12, 13)

ANB 6 h Account Number Block

CTPV Struct PU Calculate TPV (Formats: 0–3, 10, 11, 13, 17, 18)

Response Length Type Description

EE3020 2 h Function Code

rc 1 h Return Code

Reference TPV Var h Transformed PIN Value

This function extracts the numeric PIN from a PPK-encrypted PIN Block and calculates a reference TPV for storage
and subsequent use in PIN verification.

Notes
– This function only works for numeric PINs which are of length 04 to 12.
– This function has a potential for a brute force attack on a known reference TPV, so it has to be configurable at
the HSM console's function control menu whether this function is enabled or disabled.
– The function will fail with Error Code 78 if PFo indicates a PIN block format that is disabled or conflicts with the
reformatting restrictions.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 478
CHAPTER 4 Function Library

OBM-TRANSLATE-PIN (EE3019)
Request Length Type Description

EE3019 2 h Function Code

FM 1 h Function Modifier (FM = 00)

EPB Struct PU Decrypt and decode RSA-encrypted PIN Block

PPK-Spec Var K-Spec Key Specifier for PPK


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18, 90)

PFo 1 h PIN Block format


(Formats: 01, 10, 11, 12, 13)

ANB 6 h Account Number Block

Response Length Type Description

EE3019 2 h Function Code

rc 1 h Return Code

ePPKo 8 x Encrypted PIN Block

This function decrypts an OBM RSA-encrypted, format 12 PIN Block, changes the PIN Block format to that specified
by the output PIN Block format and returns it encrypted by the specified PPK.

Notes
– This function only works for numeric PINs which are of length 04 to 12.
– This function has a potential to export a user PIN, so it has to be configurable at the HSM console's function
control menu whether this function is enabled or disabled.
– The function will fail with Error Code 78 if PFo indicates a PIN block format that is disabled or conflicts with the
reformatting restrictions.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 479
CHAPTER 4 Function Library

OBM-VERIFY-PIN-3624 (EE3002)
Request Length Type Description

EE3002 3 h Function Code

FM 1 h Function Modifier (FM = 00)

EPB Struct PU Decrypt and decode RSA-encrypted PIN Block

PVK-Spec Var K-Spec Key specifier for PVK and Decimalization Table (Formats:
0–3, 11, 12, 13, 14, 17, 18)

Validation Data 8 h Customer data – usually part of the PAN

Offset 6 h PIN offset Data

Response Length Type Description

EE3002 3 h Function Code

rc 1 h Return Code

This function extracts the PIN from a RSA-encrypted PIN Block and verifies the PIN using the 3624 Offset method.

Notes
– This function only supports PINs in PIN Format 12
– This function only supports messages containing one PIN Block.

Processing Steps
1. Decrypt and decode the RSA-encrypted PIN Block using EPB PU to recover the PIN Block, M. If the resulting
Error Code is non-zero then end function processing and return appropriate value in Return Code.
2. Calculate the reference PIN, using the PVK and Decimalization Table indicated by PVK-Spec, Validation Data and
Offset.
3. Compare the reference PIN with the transaction PIN (from recovered PIN Block, M). Return the result of the
comparison in Return Code.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 480
CHAPTER 4 Function Library

OBM-VERIFY-PIN-HASH (EE3005)
Request Length Type Description

EE3005 3 h Function Code

FM 1 h Function Modifier (FM = 00)

EPB Struct PU RSA-encrypted password Block

CTPV Struct PU Calculate TPV (Formats: 0–3, 10, 11, 13, 17, 18)

Reference TPV Var h Transformed Password Value.

Response Length Type Description

EE3005 3 h Function Code

rc 1 h Return Code

This function extracts the (numeric or alpha-numeric) password from a RSA-encrypted password Block, and verifies
the password by using the extracted password to calculate a transaction TPV and comparing the result with the
Reference TPV.

Note: This function only supports PINs in PIN Format 12.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 481
CHAPTER 4 Function Library

PAN-KEY-EXCH (EE4006)
Request Length Type Description

EE4006 3 h Function Code

FM 1 h Function Modifier

eSENC(EFTPOS cryptogram 40 x Terminal cryptogram


data)

eKMv 47(KE) Var K-spec Terminal random key


(Formats: 11, 13)

eKMv 47(KF) Var K-spec FEP random key


(Formats: 11, 13)

STAN 6 h

Terminal ID 8 h

Issuer ID 4 h

Response Length Type Description

EE4006 3 h Function Code

rc 1 h Return Code

eSENC(FEP cryptogram data) 40 h FEP cryptogram with static PAN key

eKM(DPK) Var K-spec Static PAN key


(Formats: 11, 13)

This function performs the processing described in section 2.2 of [72], and as listed below.
– Verify terminal cryptogram according to appendix C.1 of [72].
– Create session keys according to chapter 4.4.3 of [72].
– Create cryptogram with terminal initial key according to appendix C.2 of [72].

Processing Steps
1. Recover KE and KF.
2. Calculate SENC and SMAC as specified in 4.4.3 of [73].
3. Decrypt the terminal cryptogram using SENC. (CBC with IV = 0. Include the (encrypted) MAC field in the decryption
process.)
4. Check the STAN and Terminal ID fields against those fields in the request message.
5. Calculate a MAC using SMAC and the first 32 bytes of the plaintext, and check the result with the MAC field in the
plaintext.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 482
CHAPTER 4 Function Library

6. Extract random number RNE.


7. Generate 128-bit random static PAN key (DPK in Mark II parlance).
8. Encrypt DPK with a variant of the current KM.
9. Create FEP Cryptogram, as specified in Appendix C3 of [73].
– Insert Static PAN Key, RNE and Pad Pattern.
– Calculate MAC using SMAC and insert result.
– Encrypt cryptogram data using SENC. (CBC with IV = 0. Include the MAC field in the encryption process.)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 483
CHAPTER 4 Function Library

PIN-FROM-OFF (EE0609)
Request Length Type Description

EE0609 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PVK Var K-Spec Key specifier for PVK/DT used in the regeneration of the
reference PIN.
(Formats: 0–3, 11, 12, 13, 14, 17, 18)

Validation Data 8 h Validation Data

Offset 6 h Offset Data

PIN Len 1 h Length of PIN ( 04 - 12)

PPK Var K-Spec Key specifier for PPK


(Formats: 0–3, 11, 12, 13, 14, 17, 18)

PFo 1 h PIN Block Format


(Formats: 01, 10, 11, 13)

ANB 6 d Account Number Block -12 digits of the Primary Account


Number (PAN), excluding the check digit

Response Length Type Description

EE0609 3 h Function Code

rc 1 h Return Code

ePPK(PIN) 8 x Encrypted PIN Block

This function calculates a PIN from a supplied IBM 3624 Offset and returns the PIN encrypted using the supplied PPK
from the request. The PIN is returned in encrypted form, using the PIN format specified in the request (PFo). The PIN
Block format for output is represented in the request using PFo and can be any of the PIN Block formats indicated
below.

PVK PVK-Spec may be key specifier formats: HSM-stored (0-3) and Host-stored 11, 12, 13, 14, 17 and
18. When the key specifier format is Host-stored 11, 12, 13, 14, 17 and 18, then PVK is encrypted
with KMv7. PVK key specifier represents the PVK and associated Decimalization Table and is
used with the IBM offset supplied in the request to regenerate the PIN.

Validation data Validation Data, which is usually a part of the Primary Account Number (PAN), and is used in the
calculation of the reference PIN.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 484
CHAPTER 4 Function Library

Offset Offset, consists of up to 12 nibbles of offset data. The significant nibbles must be left-justified in
the field. For example, if the offset to be used is 0x1234, this should be formatted as
0x123400000000 in this field. Unused nibbles are ignored.

PIN Length PIN Length, identifies the number of digits in the PIN, and hence the length of the PIN.

PPK PPK-Spec may be key specifier formats: HSM-stored (0-3) and Host-stored 11, 12 , 13, 14, 17 and
18. When the key specifier format is Host-stored 11, 12, 13, 14, 17 or 18, then PPK is encrypted
with KMv1.The function supports HSM-stored single-length, double-length and triple length
DES/TDES keys, host-stored double-length and triple-length DES/TDES keys

PFo PFo Supports PIN formats: 01, 10, 11 and 13.

ANB Account Number Block, which is the right-most 12 digits of the Primary Account Number (PAN),
excluding the check digit.

The function will fail with Error Code 78 if PFo indicates a PIN block format that is disabled.

Notes
– Calculation of an IBM offset is unrelated to PIN Block formats.
– A Derived PIN may also be generated by this method if an Offset of all zeros is used.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 485
CHAPTER 4 Function Library

PIN-GENERATE (EE0E04)
Request Length Type Description

EE0E04 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PIN Len 1 h PIN Length – in the range 04 - 12

PFo 1 h Output PIN Block Format


(Formats: 01, 10, 13)

ANB 6 h Account Number Block

PPK-Spec Var K-Spec Key specifier for PPK


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18)

Response Length Type Description

EE0E04 3 h Function Code

rc 1 h Return Code

ePPK(PIN) 8 h Encrypted PIN Block.

This function generates a random PIN, formats and encrypts it for host storage.

Processing Steps
1. Generate a random PIN of the specified length.
2. Format the PIN into an ISO Format 0 or 3 PIN Block.
3. Encrypt the PIN Block using the PPK.
The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 486
CHAPTER 4 Function Library

PIN-GENERATION (EF0616)
Request Length Type Description

EF0616 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ABI 5 d ABI code, Issuer Domestic Code - ASCII

PAN 12 d PAN Number - ASCII

Check Digit 1 d Check Digit PAN - ASCII

eKMv7(PVK) Var K-Spec Encrypted PVK


(Formats: 0–3, 10, 17, 18)

DT 8 d Decimalization Table

PF 1 h PIN Block Format


(Formats: 00, 01, 10)

PPK-Spec Var K-Spec Key specifier for PPK (Formats: 0–3, 10, 11, 12, 13, 14, 17,
18)

Response Length Type Description

EF0616 3 h Function Code

rc 1 h Return Code

ePPK(PIN) 8 h Encrypted PIN Block


(ISO-0 or IBM-3624 format)

This function generates Italian 5 digit PIN according to IBM 3624 method (for derived PINs).
The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled except for format 00 which is
always enabled for this function.

Note: For PVK in format 17, or 18 – the key in the key block is single length PVK followed by 8
bytes of DT and the external DT field is all 0s.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 487
CHAPTER 4 Function Library

PIN-MAIL (E2)
Request Length Type Description

E2 1 h Function Code

PVK-Index 1 d Index of PVK

PAN 8 h Primary Account Number

PIN Len 1 h PIN Length

PIN Type 1 h PIN Type = 0 or Non zero

Line No* 1 h Line Number

Column No* 1 h Column Number

Data Len* 1 h Data Length

Data* DATALEN h Data

Response Length Type Description

E2 1 h Function Code

rc 1 h Return Code

Offset 6 h PIN offset Data

* = optional set of fields.


The optional data fields may be repeated as many times as is necessary, or until the buffer is full.

This function generates a PIN that has a length equal to PIN Len. If a random PIN is generated an Offset associated
with this PIN is returned with the HSM response.

PVK-Index This field identifies the PVKn and DTn to be used in the PIN calculation process. This index should
equal the institution index used in the access of the PIN Mailer console operations.

PAN This is the Primary Account Number used in the generation of the PIN. It must be padded
appropriately prior to input to this function.

PIN Len This field specifies the number of PIN digits to be printed. It must be in the range 4 to 12 and be less
than or equal to the number of PIN digits entered on the PIN Mailer Print Parameters screen.

PIN Type This field is an indicator for the type of PIN that is to be printed. The valid values are:
0: Use the derived PIN as the customer PIN and do not return an Offset in the response data; or
non-0: Use a randomly generated number as the PIN and return an Offset which equals the randomly
generated PIN minus the derived PIN.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 488
CHAPTER 4 Function Library

Line No This is the number of the line on which Data is to be printed. It must be in the range 1 to 40.

Column No This is the number of the column from which Data is to be printed. It must be in the range 1 to 120.

Data Len This refers to the length of the Data. The maximum length of the data depends on the Ignore Optional
data length check check box on the print parameter screen. If the check box is not selected, the
length is greater than zero and must not extend beyond the end of an envelope line. If the check box is
selected, then the data length check is ignored.

Data This field contains the data to be printed.

Offset This field consists of 12 digits of offset data. The significant digits are left-justified in the field.

ESMID Part of the PTK-EFT function call. The ESMID is a pointer to a NULL terminated string that identifies
the name of the SafeNet HSM (ESM) to which functions are directed. The SafeNet HSM name is set
using the wincommsconfig utility provided as part of the PTK-EFT product suite.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 489
CHAPTER 4 Function Library

PIN-MAIL-2 (EE0E06)
Request Length Type Description

EE0E06 1 h Function Code

FM 1 h Function Modifier (FM = 00, 01)

PVK Var K-Spec PVK (Formats: 0–3, 11, 12, 13, 14)

PAN 8 h Primary Account Number

PIN Len 1 h PIN Length (4 to 12)

PIN Type 1 h PIN Type = 0 or Non zero

PIN Line No* 1 h Line Number for PIN

PIN Column No* 1 h Column Number for PIN

PAN Line No* 1 h Line Number for PAN

PAN Column No* 1 h Column Number for PAN

Data Sets 1 h Repeat count for the following data sets.

Line No 1 h Line Number

Column No 1 h Column Number

Data Var h Data

Response Length Type Description

EE0E06 1 h Function Code

rc 1 h Return Code

Offset 6 h PIN offset Data

This function is enhanced version of host-function E2. Functionality of function will be same as host function E2 with
FM value 00.

Notes
– *=Fields only present if FM=01.
– If FM =00, PIN and PAN line number and column number must be set to 0. PIN and PAN line number and
column number values will be taken from console.
– If FM =01, PIN line number and column number must be present.
– PAN line number and column number values must be present if Print 16-digit PAN setting is enabled on
console. If Print 16-digit PAN setting is disabled PAN line number and column number field value must be 0.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 490
CHAPTER 4 Function Library

– The function will use PIN and PAN line number and column number values provided with the host function and
values entered on console will be ignored.

PVK This field identifies the PVK and DT to be used in the PIN calculation process. If HSM-stored PVK key
is used, PVK index should equal the institution index used in the access of the PIN Mailer console
operations. Supported K-Spec formats are: 0-3, 11,12,13,14.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 491
CHAPTER 4 Function Library

PIN-OFF (EE0604)
Request Length Type Description

EE0604 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPK(PIN) 8 x PIN Block encrypted under PPK

PPK-Spec Var K-Spec Key specifier for PPK


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18, 20, 90)

PF 1 h PIN Block Format

ANB 6 d Account Number Block

PVK-Spec Var K-Spec Key specifier for PVK


(Formats: 0–3, 11, 12, 13, 14, 17, 18)

Validation Data 8 h Validation Data

Response Length Type Description

EE0604 3 h Function Code

rc 1 h Return Code

Offset 6 h Offset for the PIN

PINLEN 1 h Length of returned PIN

This function calculates an IBM 3624 Offset for a PIN and also provides the length of the PIN. The PIN is supplied in
encrypted form, using any of the PIN Block formats specified under IBM 3624 PIN Verification Methods. See, IBM
3624 PIN Verification.

PPK-Spec May be any valid key specifier for a PPK. Consequently, the function supports an encrypted PIN
Block encrypted using a single-length or double-length or triple –length HSM-stored or host-stored
key.

PF Supports PIN Formats: 01, 03, 08, 09, 10, 11, and 13.

ANB Account Number Block, which is the right most 12 digits of the Primary Account Number (PAN),
excluding the check digit.

Validation Data Data, which is usually a part of the PAN, and is used in the calculation of the reference PIN.

The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.
The function performs a check that the ANB field and the Validation field contain a number of consecutive digits in
common. The number of digits to check is in the range 0 to 12, as may be specified using a console operation, and
defaults to 8. If the number of digits to check has been set to 0 the check is disabled, and in this case the function will

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 492
CHAPTER 4 Function Library

accept any supported PIN block format that is enabled. If the number of digits to check is greater than 0, then only ISO-
0 and ISO-3 PIN blocks are allowed, if enabled. If the check fails, the function will fail with Return Code 79.

Note: This function includes all the capabilities of the following existing functions, and
therefore supercedes the following:
PIN-OFF-AS (6A), PIN-OFF-PP (6B)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 493
CHAPTER 4 Function Library

PIN-PRINT (EE0E05)
Request Length Type Description

EE0E05 3 h Function Code

FM 1 h Function Modifier (FM = 00, 01)

ePPK(PIN) 8 h Encrypted PIN Block

PPK-Spec Var K-Spec Key specifier for


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18)

PFi 1 h Input PIN Block Format


(Formats: 01, 10, 13)

ANB 6 h Account Number Block

PAN 8 h Primary Account Number


Content is significant only if PAN print is selected in PIN
Mail control screen

PIN Line No* 1 h Line Number for PIN

PIN Column No* 1 h Column Number for PIN

PAN Line No* 1 h Line Number for PAN

PAN Column No* 1 h Column Number for PAN

Data Sets 1 h Repeat count for the following data sets

Line No 1 h This set of fields specifies data to be printed at a given line


Column No 1 h and column.
Data Var h
The set of fields is optional and may be repeated multiple
times, as specified by the Data sets field, causing 0, 1 or
more data fields to be printed.

Response Length Type Description

EE0E05 1 h Function Code

rc 1 h Return Code

This function prints a previously generated PIN. It is normally disabled and is controlled by the PIN Mailer console
operations.

Notes
– *= Fields only present if FM=01.
– If FM=01, PIN line number and column number must be present.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 494
CHAPTER 4 Function Library

– PAN line number and column number values must be present if Print 16-digit PAN setting is enabled on
console.
– If Print 16-digit PAN setting is disabled PAN line number and column number field value must be 0.
– The function will use PIN and PAN line number and column number values provided with the host function and
values entered on console will be ignored.

ESMID Part of the PTK-EFT function call. The ESMID is a pointer to a NULL terminated string that identifies
the name of the SafeNet HSM (ESM) to which functions are directed. The SafeNet HSM name is set
using the wincommsconfig utility provided as part of the PTK-EFT product suite.

Processing Steps
1. Decrypt the supplied encrypted PIN Block using PPK.
2. Extract the PIN from the ISO PIN Block.
3. Build a print image using the PIN, PAN and optional data.
The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 495
CHAPTER 4 Function Library

PIN-TRAN-2 (EE0602)
This function performs translation of both the PIN Block format and the PIN encryption key.

FM =00
Request Length Type Description

EE0602 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPKi(PIN) 8 x Encrypted PIN Block.

PPKi-Spec Var K-Spec Key specifier for PPK


(Formats: 0-7, 10, 11, 12, 13, 14, 17, 18, 20, 90, 93)

PFi 1 h Input PIN Block format

ANB 6 h Account Number Block

PFo 1 h Output PIN Block format

PPKo-Spec Var K-Spec Key specifier for PPK


(Formats: 0-7, 10, 11, 12, 13, 14, 17, 18, 20, 90)

Response Length Type Description

EE0602 3 h Function Code

rc 1 h Return Code

ePPKo(PIN) 8 h Encrypted PIN Block

FM If FM = 00 the function remains as per EE0602.

PFi Specifies the format of the input PIN Block format and supports PIN formats, 01, 02, 03, 08,
09, 10, 11, and 13 specified under PIN Block Formats.

ANB Account Number Block, which is the rightmost 12 digits of the Primary Account Number
(PAN), excluding the check digit.

PFo Specifies the output PIN Block format and supports PIN formats: 01, 02, 03, 08, 09, 10, 11,
12, and 13 specified under PIN Block Formats. The following restriction applies:
formats 02, 08 (Docutel) and 11 (ISO Format 1) are valid only in the case that PFo = PFi – i.e.
that the clear text PIN Block format is not changed. If PIN format translation is not required,
PFo must be set to the same value as PFi.
Specific restrictions on reformatting are specified under Function Construction.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 496
CHAPTER 4 Function Library

PPKo and PPKi The key specifiers, PPKi-Spec and PPKo-Spec, may be any valid key specifier for a PPK.
Consequently, the function supports all combinations of single-length , double-length and
triple length, HSM-stored and host-stored keys. For example, the input key could be a single-
length, host-stored key and the output key could be a double-length, HSM stored key.

ePPKo (PIN+PIN Variable length field of either 8 or 16 bytes dependent upon length of PIN Data supplied.
Data)

PIN Data Data to incorporate with PIN in encrypted result. The data Block would typically incorporate
the PIN Try Counter and PIN Try Limit, as specified in reference of Mark II, but no checks
are applied to the data content. The field can contain 0 or 8 bytes. If the length is 0, this
function performs identically to the PIN_TRANSLATE function. If the length is 8, the data
Block is concatenated to the right of the (re-)formatted, plaintext PIN Block and the resulting
16-byte character sequence is CBC-encrypted using the PPKo.

The function will fail with Error Code 78 if PFi or PFo indicates a PIN block format that is disabled or conflicts with the
reformatting restrictions.

Note: This function includes all the capabilities of the following existing functions, and
therefore supercedes the following:
PIN- TRAN (60), D51-PIN-TRAN (65), PIN-TRAN-1 (94), PIN-TRAN-2 (95).

FM = 01
Provides support for Visa Data Secure Platform (VDSP) P2PE.

Request Length Type Description

EE0602 3 h Function Code

FM 1 h Function Modifier (FM = 01)

ePPKi(PIN) 8 x Encrypted PIN Block.

PPKi-Spec Var K-Spec Key specifier for PPK


(Formats: 0-7, 10, 11, 12, 13, 14, 17, 18, 20, 90, 93)

PFi 1 h Input PIN Block format

ANB Var h Encrypted PAN/Account Number Block

PFo 1 h Output PIN Block format

PPKo-Spec Var K-Spec Key specifier for PPK


(Formats: 0-7, 10, 11, 12, 13, 14, 17, 18, 20, 90)

Algorithm 1 h 01=TDES(Generic)

Encryption Method 1 h 00 = ECB


01 = CBC
02= VDSP Standard (hex packing)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 497
CHAPTER 4 Function Library

Request Length Type Description

ICV Var h Input Chaining Value. Can be zero length.

DPK-Spec Var K-Spec Key specifier for DPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 20)

Check Digit 1 h 00=Check Digit not present in PAN


01=Check digit present in PAN

Following field to be present only if Encryption Method ={00,01}

Padding Method 1 h XY
X = 0 : pad with all zeroes to make last block multiple of
block size of cipher algorithm
X = 1: data to be encrypted not multiple of block size add
0x80 and then as many zeroes as required.
X = 2 Add with random number to make last block multiple
of block size of cipher algorithm
Y = 0 left padded
Y= 1 right padded

No of nibbles padded 1 h No of nibbles used for padding

Response Length Type Description

EE0602 3 h Function Code

rc 1 h Return Code

ePPKo(PIN) 8 h Encrypted PIN Block

Processing Steps
1. Decrypt ePPKi(PIN) using PPKi to retrieve PIN block.
2. Decrypt ANB using Algorithm, Encryption Method, ICV and DPK.
– Encryption Method = CBC/ECB implies data with no special formatting except padding (as defined in Padding
Method). In this scenario, after the data is decrypted and padding removed, the retrieved data is a PAN. The
format of the PAN depends on the number of bytes used for extracted PAN.
– If the number of bytes are less than 11, it implies PAN is in BCD format.
– If number of bytes are greater than 11, it implies the PAN is in ASCII format.
A secondary check should be applied for each digit in the extracted data, i.e., all the elements should be a digit
between 0-9.
– Encryption Method = VDSP implies with PAN formatted as defined in section 6 of reference [90] of Mark II.
The PAN needs to be extracted as is from the formatted data as per rules.
3. The check digit which is the last digit of the PAN is removed based on the values of Check Digit field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 498
CHAPTER 4 Function Library

4. Extract ANB.
ANB content is the 12 rightmost digits of the primary account number (PAN) excluding the check digit. If the PAN
excluding the check digit is less than 12 digits, the digits are right justified and padded to the left with zeroes.
Permissible values are 0000 (zero) to 1001 (9). Use Check digit field to discard or include last digit while deriving
PAN.
5. Extract the PIN using the PFi and decrypted PIN and ANB.
6. Prepare the output PIN block as specified by PFo using decrypted PIN and ANB.
7. Encrypt the PIN block using PPKo.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 499
CHAPTER 4 Function Library

PIN-TRAN-8 (EE0608)
Request Length Type Description

EE0608 3 h Function Code

FM 1 h Function Modifier (FM = 00, 01)

ePPKi(PIN) 8 x Encrypted PIN block

PPKi-Spec Var K-Spec Key specifier


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18)

PFi 1 h Input PIN Block format

ANB 6 h Account Number Block

Pfo 1 h Output PIN block format

PPKo-Spec Var K-Spec PPK Key specifier


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18, 50, 51)

Encryption Method 1 h 00 = ECB


01 = CBC
11 = Pad+CBC

PIN Data Var h Data to incorporate with PIN in encrypted result. The length
must be 0 or 8.

Response Length Type Description

EE0608 3 h Function Code

rc 1 h Return Code

ePPKo(PIN + PIN Data) Var h Encrypted PIN and associated data

This function is similar to PIN-TRANSLATE (EE0602) but also:


• allows the PPKo to be specified in key specifier formats 50 and 51. Translates a PIN block, producing an encrypted
PIN block that incorporates the PIN Try Counter and PIN Try Limit.
• allows an additional data block, specified in PIN Data, to be appended to the plaintext PIN block prior to re-
encryption.

FM When FM=01, an additional Field (Session Method, see below for details) is incorporated into the
function. If FM = 00 the function remains as per EE0602.

PFi specifies the format of the input PIN block format.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 500
CHAPTER 4 Function Library

ANB Account Number Block, which is the rightmost 12 digits of the Primary Account Number (PAN),
excluding the check digit.

PFo specifies the output PIN block format and supports PIN formats: 01, 03, 08, 09, 10, 11, 12, and 13.
The following restriction applies: formats 08 (Docutel) and 11 (ISO Format 1) are valid only in the
case that PFo = PFi – i.e. that the clear text PIN block format is not changed. If PIN format
translation is not required, PFo must be set to the same value as PFi.

PPKo and The key specifiers, PPKi-Spec and PPKo-Spec, may be any valid key specifier for a PPK.
PPKi Consequently, the function supports all combinations of single-length, double-length or triple-length,
HSM-stored and host-stored keys. For example, the input key could be a single-length, host-stored
key and the output key could be a double-length, HSM stored key.

Encryption Used when FM = 01. Encryption Method encrypts ePPKo(PIN + PIN Data) as per selected
Method method. 00 = ECB, 01 = CBC,11=Pad+CBC.

ePPKo Variable length field of either 8 or 16 bytes dependent upon length of PIN Data supplied.
(PIN+PIN
Data)

PIN Data Data to incorporate with PIN in encrypted result. The data block would typically incorporate the PIN
Try Counter and PIN Try Limit, as specified in reference [29] of CI, but no checks are applied to the
data content. The field can contain 0 or 8 bytes. If the length is 0, this function performs identically
to the PIN-TRAN-2 (EE0602). If the length is 8, the data block is concatenated to the right of the
(re-)formatted, plaintext PIN block and the resulting 16-byte character sequence is CBC-encrypted
using the PPKo.

The function will fail with Error Code 78 if PFi or PFo indicates a PIN block format that is disabled.

Note: The Session Method field has been renamed as Encryption Method.

For Encryption Method = 11, the PIN block will be padded as shown in following table. The 16- or 24-byte plaintext
padded block will be encrypted using the CBC mode of operation. This will produce a 16- or 24-byte encrypted PIN
block, which will be returned in the Var field in the response.

Length (bytes) 1 8/16 1 6

Content 0x08 or 0x10 PIN + PIN Data 0x80 00 00 00 00 00 00

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 501
CHAPTER 4 Function Library

PIN-TRAN-3624 (63)
Request Length Type Description

63 1 h Function Code

ePVK(PP-PIN) 8 B64 PIN Block encrypted under PVK

PVK-Index 1 d Index of PVK

eKMv1(PPK) 8 B64 PPK encrypted under KM

ANB 6 h Account Number Block

Response Length Type Description

63 1 h Function Code

rc 1 h Return Code

ePPK(AS-PIN) 8 B64 PIN Block encrypted under PPK

This function translates both the format and the encryption key of a PIN Block which is supplied encrypted by a HSM
stored PIN Verification Key (PVK).

PP-PIN is the IBM 3624 formatted PIN Block. It must be supplied encrypted by a HSM stored PIN Verification
KEY (PVK).

PVK-index identifies the PVKn with which the supplied PIN Block is encrypted.

eKMv1 is the host stored encrypted session key with which the resultant AS/ANSI PIN Block is returned
(PPK) encrypted.

ANB is the 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

The function will fail with Error Code 78 if IBM 3624 or ISO-0 PIN block is disabled or reformatting of IBM 3624 to ISO-0
PIN block is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 502
CHAPTER 4 Function Library

PIN-TRANS-SEED-DES (EE0615)
Request Length Type Description

EE0615 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPKi(PIN) Var x Encrypted PIN Block

PPKi-Spec Var K-Spec PIN Protection Key specifier


(Formats: 0–3, 16, 17, 18)

PFi 1 h Input PIN Block Format


(Formats: 01, 03, 08, 10, 11, 13)

ANB Var h Account Number Block

PFo 1 h Output PIN Block Format


(Formats: 01, 03, 08, 10, 11, 13)

PPKo-Spec Var K-Spec Key specifier for PPK


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18)

Response Length Type Description

EE0615 3 h Function Code

rc 1 h Return Code

ePPKo(PIN) Var h Encrypted PIN Block

This function performs a translation from SEED to DES of the PIN Block format.
The incoming PIN Block format is verified. Please note that only the first 8 bytes of the PIN Block are verified. For
example, if the PFi field indicates an ANSI PIN Block the first 8 bytes of the PIN Block are verified according to the
ANSI format while the last 8 bytes are ignored.
The function will fail with Error Code 78 if PFi or PFo indicates a PIN block format that is disabled or conflicts with the
reformatting restrictions.

FM = 00. Must be set to zero.

PFi and PFo Specify the format of the supplied PIN Block and of the required PIN Block. If PIN format translation
is not required, PFo must be set to the same value as PFi. Supports PIN Formats 01, 03, 08, 10, 11
and 13.

ANB Account Number Block

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 503
CHAPTER 4 Function Library

PPKi The key specifier PPKi-Spec. Format 00 – 03, 16, 17 and 18 accepted. Where a HSM stored PPK
is indicated (formats 00 – 03) the key must have been stored as a SEED key.

PPKo The key specifier PPKo-Spec. Formats 00 – 03, 10, 11, 12 , 13, 14, 17 and 18 are accepted.

ePPKi(PIN) PIN Block encrypted using the SEED algorithm1 by PPKi. This Var field must be 16 bytes in length.

Note: For key specifier formats, refer to Function Construction.

1A 128-bit block cipher that has been widely used in Korea for confidential services such as ecommerce, email,
financial services, data storage, electronic toll collection, VPN and digital rights management.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 504
CHAPTER 4 Function Library

PIN-VER-IBM-MULTI (EE0603)
Request Length Type Description

EE0603 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPK(PIN) 8 x Encrypted PIN Block

PPK-Spec Var K-Spec Key specifier for PPK


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18, 20, 90)

PF 1 h PIN Block Format

ANB 6 h Account Number Block

PVK-Spec Var K-Spec Key specifier for PVK


(Formats: 0–3, 11, 12, 13, 14)

Validation Data 8 h Validation Data

Offset 6 h Existing offset for the PIN

Check-Len 1 h PIN Check Length (04 - 12)

Response Length Type Description

EE0603 3 h Function Code

rc 1 h Return Code

This function performs the verification of a PIN using the IBM 3624 Offset method. The PIN is supplied in encrypted
form, using any of the PIN Block formats.

PPK-Spec May be any valid key specifier for a PPK. Consequently, the function supports an encrypted PIN
Block encrypted using a single-length or double-length or triple-length HSM-stored or host-stored
key.

PF Supports PIN Formats: 01, 02, 03, 08, 09, 10, 11, 13

ANB Account Number Block, which are the right most 12 digits of the Primary Account Number (PAN),
excluding the check digit.

Validation Data Data (usually a part of the PAN) used in the calculation of the reference PIN.

Offset Up to 12 digits of offset data. The significant digits must be left justified in the field. Unused digits
are ignored. If offsets are not used, the significant digits must be zeros.

Check-Len The number of PIN digits to be checked. This may be less than or equal to the actual length of the
PIN. The significant Offset digits must be supplied left aligned and right padded in the Offset field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 505
CHAPTER 4 Function Library

The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.

Note: This function includes all the capabilities of the following existing functions, and
therefore supercedes the following:
PIN-VER (61), PIN-VER-PP (62), D51-PIN-VER (66), VAR-PIN-VER (67), VAR-PIN-VER-PP
(68).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 506
CHAPTER 4 Function Library

PPID-ENCRYPT (E550)
This function is the reverse of the function E540 – VERIFY PPID.

Request Length Type Description

E550 2 h Function Code

Msg ID 2 x Message Identifier

eKMv84(KIA) Var K-Spec Acquirer Initialization Key (formats 21 or 23)

PPID 8 d PIN Pad Identification Number

Response Length Type Description

E550 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKIA(PPID) 4 x Left hand 32 bits of the PPID encrypted under the Acquirer
Initialization Key

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 507
CHAPTER 4 Function Library

PRINT-KM-ENC-PIN (EE0641)
Request Length Type Description

EE0641 3 h Function Code

FM 1 h Function Modifier (FM = 00, 01)

PIN-Spec Var K-Spec KM-encrypted PIN Block


(Format: 1A)

ANB 6 h Account Number Block

PAN 8 h Primary Account Number.


Content is significant only if PAN print is selected in PIN
Mail control screen.

PIN Line No* 1 h Line Number for PIN

PIN Column No* 1 h Column Number for PIN

PAN Line No* 1 h Line Number for PAN

PAN Column No* 1 h Column Number for PAN

Data Sets 1 h Repeat count for the following data sets.

Line No 1 h This set of fields specifies data to be printed at a given line


and column.
Column No 1 h The set of fields is optional and may be repeated multiple
times, as specified by the Data sets field, causing 0, 1 or
Data Var h more data fields to be printed.

Response Length Type Description

EE0641 3 h Function Code

rc 1 h Return Code

This function prints a KM-encrypted PIN.

Notes
– *=Fields only present if FM=01.
– If FM=01, PIN line number and column number must be present.
– PAN line number and column number values must be present if Print 16-digit PAN setting is
enabled on console.
– If Print 16-digit PAN setting is disabled PAN line number and column number field value must be 0.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 508
CHAPTER 4 Function Library

– The function will use PIN and PAN line number and column number values provided with the host function and
values entered on console will be ignored.
– The function will fail with Error Code 78 if PIN block format ISO-3 is disabled.
The function performs the same process as PIN-PRINT (EE0E05). The only difference is the form of the encrypted PIN
input to the function.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 509
CHAPTER 4 Function Library

PRINT-PS (EE0E03)
Request Length Type Description

EE0E03 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PIN Format 1 d Indicates the PIN Format for PIN Block

ePPK(PIN) 8 x Encrypted PIN block under PPK

PPK Spec Var Key-Spec Key specifier for PPK (Formats: 0–3, 10, 11, 12, 13, 14)

ANB 6 h Account number block

Address 1 Var H Address1

Address 2 Var H Address 2

Address 3 Var H Address 3

Address Salutation Var H Address Salutation

Date Var H Date Field

Response Length Type Description

EE0E03 3 h Function Code

rc 1 h Return Code

Once the USB printer is configured, and the Postscript PIN Mailer option is enabled through the console interface, this
function is used to read the postscript template file copied on to Luna EFT by host function EE0E02. The function
replaces the place holder with actual PIN, and other sensitive information and generates the final format before printing
it using a postscript printer connected on a USB port.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 510
CHAPTER 4 Function Library

PRIVATE-KEY-OPERATIONS (EE9010)
Request Length Type Description

EE9010 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Mode of Operations 1 h Indicates the mode of operation


00 - Decrypt
01 - Sign

SK Var K-Spec Key specifier to perform RSA operations (Format 82, Key
Type: Data Protect, Data Signature)

Data Var h Data to be included in the operation

Response Length Type Description

EE9010 3 h Function Code

rc 1 h Return Code

Output Data Var h Data as result of operation

This function performs RSA Private key Operations as decrypt/sign as specified in the mode of operation.

FM The function modifier =00

Mode of Operation Indicates the mode of operation


00 - Decrypt
01 – Sign

SK Key specifier incorporating the Private Key for RSA operations.


The key type of the private key must be consistent with the operation.
When mode of operation is 00-Decrypt then the Data Protect flag must be set in Key Type.
When mode of operation is 01-Sign then the Data Signature flag must be set in Key Type
Bit 1 may be set alone or along with bits 0, 2 or 4, but bits 0, 2 and 4 are mutually exclusive.

Data Data to be included in the RSA operation.


Note: The numerical value of Data must be less than the numerical value of the modulus.
If the length of data is greater than the length of Modulus, then the function will return error 0C.

Output Data Data as result of operation

Processing Steps
1. Check the field ‘Mode of Operation’ field to retrieve the type of operation to be performed.
2. In case of Decrypt Operation.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 511
CHAPTER 4 Function Library

– Data will be decrypted using the key SK


– The resultant will be returned in response
3. In case of Sign Operation.
– Sign the ‘Data’ using the key SK
– Return ‘Signed – data’ in response

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 512
CHAPTER 4 Function Library

PROTECT-CLEAR-MOBILE-PIN (EE3056)
This function is used to encrypt the clear Mobile PIN.

Request Length Type Description

EE3056 3 h Function Code

FM 1 h Function Modifier = 00

MobilePIN Var h Mobile PIN (Length 4-8 digits)

ANB 6 h Account Number Block

MPPK Spec Var K-Spec Key to encrypt mobile PIN


Formats: 0-3, 11, 13, 17, 18, 1C

Pfo 1 h = 00. PIN block format (ISO-3)

Padding Mode 1 h 0 = Conditional


1 = Always
(See Padding Mode described in reference [83], [84], [85] of
Mark II.

Encryption Mode 1 h 00 = ECB


01 = CBC

IV Var h Use IV if decryption method is CBC


In case of ECB, this must be a zero length field.

Response Length Type Description

EE3056 3 h Function Code

rc 1 h Return Code

eMPPK(MobilePIN) Var h The Mobile PIN encrypted under MPPK

Processing Steps
1. Check Mobile PIN value for length >=4 and <=8. Any length outside the range is error condition.
2. Prepare PIN Block as specified by Pfo using:
a. ANB
b. Clear PIN
3. Apply padding to PIN Block data with respect to Padding Mode
4. Extract MPPK for PIN Encryption using MPPK spec
5. Encrypt padded/unpadded PIN Block by MPPK using encryption mode and IV.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 513
CHAPTER 4 Function Library

Note: For preparing PIN Block format 3, refer to EE0602.

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 514
CHAPTER 4 Function Library

PROTECT-DC-FILE (EE305C)
This function is used to prepare the file containing keys used for AC generation in cloud based payments.

Request Length Type Description

EE305C 3 h Function Code

FM 1 h Function Modifier = 00

CCMK-Spec key Spec h Key spec for key details for CCMK
Formats: 0-3, 1C

Encryption Mode 1 h 01 = CBC

IV Var h Initialization Vector.


In case of ECB, this must be a zero length field.

Padding Mode 1 h 0 = Conditional


1 = Always
(See Padding Mode described in reference [83], [84], [85] of
Mark II)

Binding Method 1 h Indicates the method for binding the data to the SUK_Info
and the ATC.
00 = SHA256 (Refer SHA256 method defined in
MCBPv1.0)
01 = Data supplied in DC_CP data will be used as is.

DC_CP Data Var h Data over which binding method to be applied.


Must not be zero length

ATC 2 h The ATC associated with the SKs and SUKs

Key Information 1 h 0x01 = SK CLMD present


0x02 = SUK CLUMD present
0x04 = SK RPMD present
0x08 = SUK RPUMD present
Bitwise OR the values for specifying the category of keys in
input.
If any of these values are not required placeholder must be
passed instead of key.

N_S(U)K 2 d No of sets of SKs and SUKs


Must not exceed 8.

Array of IDN Var h Array of 16 byte IDNs

Array of SK/Placeholder Var h Array of SKs for CLMD/random placeholder data


data

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 515
CHAPTER 4 Function Library

Decryption Key Details Var h Decryption details for SK for CLMD


Must be zero length if random placeholder data is used in
place of SK for CLMD

Array of SUK/Placeholder Var h Array of SUKs for CLUMD/random placeholder data


data

Decryption Key Details Var h Decryption details for SUK for CLUMD.
Must be zero length if random placeholder data is used in
place of SUK for CLMD

Array of SK/Placeholder Var h Array of SKs for RPMD/random placeholder data


data

Decryption Key Details Var h Decryption details for SK for RPMD.


Must be zero length if random placeholder data is used in
place of SK for RPMD

Array of SUK/Placeholder Var h Array of SUKs for RPMD/random placeholder data


data

Decryption Key Details Var h Decryption details for SKs for RPMD.
Must be zero length if random placeholder data is used in
place of SUK for RPMD

DC File format Type 1 h 00 = MCBP format

DC File format Var h DC file format

Response Length Type Description

EE305C 3 h Function Code

rc 1 h Return Code

eCCMK(DC_File) Var h The DC_File encrypted under CCMK


Formats: 0-3, 1C

Structure for Decryption Key details

Field Length Type Description

KTK Spec Var K-Spec Transport Key used for key decryption.
Key Spec for Key Transport Key
Formats: 0-3, 11, 12, 13, 14, 17, 18

Decryption Mode 1 h 00 = ECB


01 = CBC

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 516
CHAPTER 4 Function Library

Field Length Type Description

IV Var h Initialization Vector


In case of ECB, this must be a zero length field.

Structure of DC file for format 00

Field Length Type Description

Input data Var h Input data

Offset ATC 2 h Offset of ATC

Offset SUK_CL_ 2 h Offset of SUK_CL_UMD


UMD

Offset SK_CL_MD 2 h Offset of SK_CL_MD

Offset SUK_RP_ 2 h Offset of SUK_RP_UMD


UMD

Offset SK_RP_MD 2 h Offset of SK_RP_MD

Offset IDN 2 h Offset of IDN

Offset ATC 2 h Offset of ATC

Offset hash of 2 h Offset hash of binding data


binding data

Processing Steps
1. Calculate Hash for DC_CP as SHA256 over DC_CP data.
2. Key information field will be used for identifying whether the DC file will contain specific key or random data.
Based on Key information values, which explains whether the encrypted key is present or a random data is there,
check and perform as given:

Key Information Values Action

Key information values&0x01=0x01 Decrypt all the keys from Array for SK for CLMD
using decryption key details.
Store them in ArrayCLMDSK

Key information values&0x01=0x00 Parse array of random place holder data and store
them in ArrayCLMDSK

Key information values&0x02=0x02 Decrypt all the keys from Array for SUK for CLUMD
using decryption key details.
Store them in ArrayCLUMDSUK

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 517
CHAPTER 4 Function Library

Key Information Values Action

Key information values&0x02=0x00 Parse array of random place holder data and store
them in ArrayCLUMDSUK

Key information values&0x04=0x04 Decrypt all the keys from Array for SK for RPMD
using decryption key details.
Store them in ArrayRPMDSK

Key information values&0x04=0x00 Parse array of random place holder data and store
them in ArrayRPMDSK

Key information values&0x08=0x08 Decrypt all the keys from Array for SUK for RPUMD
using decryption key details.
Store them in ArrayRPUMDSUK

Key information values&0x08=0x00 Parse array of random place holder data and store
them in ArrayRPUMDSUK

3. If Array of IDN length =16*N_SUK then parse IDNs in an array.


4. Loop for n times starting from supplied ATC and incrementing it by 1 on each iteration. For each iteration, repeat
steps 4-11.
5. Use DC Format data to populate ATC, IDNs and other keys. The DC data will have placeholder values, so the data
will be replaced by calculated values.
6. Prepare DC_SUK_ID = DC_ID || ATC || Expiry
7. Format the data as given below:
With DC_SUK_ID as calculated, SUKInfo from other data, RFU from other data.

SUK_CL_MD from ArrayCLUMDSUK as per iteration counter


SK_CL_MD from Array CLMDSK as per iteration counter
SUK_RP_UMD from ArrayRPUMDSUK as per iteration counter
SK_RP_MD from Array RPMDSK as per iteration counter
IDN from Array of IDN
ATC from current ATC as per iteration counter
Hash from Hash for DC_CP
Here is a sample of a DC file format:
“DC_SUK_ID”: “5413339000001513FFFF011411271118000312141227”,
“DC_SUK_CONTENT”:
{
“SUKInfo”: “38”,
“RFU”: “00”,
“SUK_CL_UMD”: “CAC54E4AB4BA8B89749567E9E496FC7D”,
“SK_CL_MD”: “0D602C3316DD080051DA5F78BCAAD831,
“SUK_RP_UMD”: “74BCDBBC3EDD114C92DB87B4C8923B21”,
“SK_RP_MD”: “8F72332324B907B888450BA4FD382ADD”,
“IDN”: “E394E95A5031DC5623C4011861CB37A8”,
“ATC”: “0312”,
“Hash”: “4A98D08AE555DF3AB1E1802ADBDBE7C8137B1D9D3AAFB3CABEC3F94495BFEDB5”

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 518
CHAPTER 4 Function Library

}
8. Increment ATC and loop iteration counter by 1.
9. Encrypt the buffer with KM48 for CCMK in specified key details.

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 519
CHAPTER 4 Function Library

PROTECT-ENCRYPTED-MOBILE-PIN (EE3057)
This function is used to translate the encrypted mobile PIN from one set of protection key to another.

Request Length Type Description

EE3057 3 h Function Code

FM 1 h Function Modifier = 00

Encrypted Mobile PIN Var h Structure for Encrypted Mobile PIN Details
Details

MPPKo Var K-Spec Key spec for key to translate mobile PIN
Formats: 0-3, 11, 13, 17, 18, 1C

Pfo 1 h = 00. PIN block format (ISO-3)

Padding Mode 1 h 0 = Conditional


1 = Always
(See Padding Mode described in reference [83], [84], [85] of
Mark II.

Encryption Mode 1 h 00 = ECB


01 = CBC

IVo Var h Use IV if encryption mode is CBC.


In case of ECB, this must be a zero length field.

Response Length Type Description

EE3057 3 h Function Code

rc 1 h Return Code

eMPPKo(MobilePIN) Var h The Mobile PIN encrypted under MPPKo

Encrypted Mobile PIN Details


Encrypted Mobile PIN Details

Field Length Type Description

MPPK –spec Var K-spec Key specifier to denote the MPPK to be used to
decrypt Mobile PIN
Formats: 0-3, 11, 13, 17, 18, 1C

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 520
CHAPTER 4 Function Library

Encrypted Mobile PIN Details

Field Length Type Description

eMPPK(Mobile Var h Encrypted Mobile PIN


PIN)

Decryption Mode 1 h 00 = ECB


01 = CBC

IV Var h If the encryption method is CBC, use IV.


In case of ECB, this must be a zero length field.

Padding Mode 1 h 0 = Conditional


1 = Always
(See Padding Mode described in reference [83], [84],
[85] of Mark II.

PF 1 h = 00. PIN block format (ISO-3)

ANB 6 h Account number

Processing Steps
1. Decrypt the Mobile PIN using parameters from Encrypted Mobile PIN details. Padding Method is used to extract
the PIN Block.
2. Prepare PIN Block as specified by Pfo using:
a. ANB
b. Clear PIN
3. Apply padding to PIN Block data with respect to Padding Mode.
4. Extract MPPKo for PIN Encryption using MPPK spec.
5. Encrypt padded/unpadded PIN Block by MPPK using encryption mode and IV.

Note: For preparing PIN Block format 3, refer to EE0602.

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 521
CHAPTER 4 Function Library

PRV-GENERATION (EF0E02)
This function generates a PIN Reference Value (PRV).

Request Length Type Description

EF0E02 3 h Function Code

FM 1 h Function Modifier = 00

PIN Block Format 1 h Input PIN Block format

Minimum Length of the 1 h PIN Length, in the range of 04 - 12


incoming PIN

Maximum Length of the 1 h PIN Length, in the range of 04 - 12


incoming PIN

PIN Encryption key spec Var Key Spec Key specifier for the incoming PIN encryption key which will
be PPK.
Formats: 11, 13

ePPK(PIN-Block) 8 h Encrypted PIN Block

PIN Block Data 6 h The incoming PIN-Block-Data. The PIN Block Data for the
ISO-0 PIN-Block.

PRV PAC key spec Var K-Spec Key specifier for PPK which will be used in calculation of
the PRV
Formats: 11, 13

PIN Identification Data 16 h The PID is a concatenated value. This field is a 32-digit (16-
(PID) Byte) hexadecimal value and is the data that is a part of the
PRV calculation.

Algorithm Type 1 h The hashing algorithm used in PRV calculation.

Response Length Type Description

EF0E02 3 h Function Code

rc 1 h Return Code

PRV Var h PIN Reference Value

FM =00. Must be set to zero.

PIN-Block-Format Specifies the format of the supplied PIN Block.


Formats: 01, 02, 03, 08, 09, 10, 11, and 13, if enabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 522
CHAPTER 4 Function Library

Minimum Length of Minimum PIN Length


the incoming PIN

Maximum Length Maximum PIN Length


of the incoming
PIN

PIN Encryption key Key specifier for the incoming PIN encryption Key.
spec Formats: 11, 13

ePPK(PIN-Block) Is the input formatted PIN Block containing the PIN. It must be supplied encrypted by a KPE.

PIN Block Data Refers to the incoming PIN-Block-Data. It is a 12 digit BCD value whose permissible digits
range in between 0-9, or the rightmost PAN digits. This field is used for the following:
• To calculate the clear PIN-Block in case of input PIN-Block-Format is ISO-0.
• Creation of the intermediate ISO-0 PIN block as part of the PRV calculation.
• To verify the 12 digit PAN incorporated in the PID field.

PRV PAC key Key specifier for the PPK to encrypt /decrypt the ISO-0-PIN-Block as part of the PRV
spec calculation.
Formats: 11, 13

PIN Identification PID (PIN-Identification-Data) is a concatenation of the following values:


Data (PID) • 3 Byte-BCD PAN, place 1-6 ('nn nn nn')
• 5 Byte-BCD PAN, place 7 - 16 (‘nn nn nn nn nn’)
• 2 Byte BCD PAN, place 17 - 20 ('00 00')
• 2 Byte-BCD Filler ('00 00')
• 2 Byte-BCD Filler ('00 00')
• 2 Byte-binary PIN-Change-Counter ('bb bb')
Note: Labeling the PIN Identification data digits starts at zero.

Algorithm Type The hashing algorithm used in PRV calculation.


• 1 if Algorithm to be used is SHA 256
• 2 if Algorithm to be used is SHA 512

PIN Reference PRV is:


Value (PRV) • A 32-Byte hexadecimal number, if the Algorithm is SHA-256.
• A 64 Byte hexadecimal number, if the Algorithm is SHA-512.

The return codes returned by the function are:

Return Code Error condition

0x06 (FN_INVALID_PF) An invalid PIN format specifier is supplied.

0x07 (FN_INVALID_PIN_ The length of the incoming PIN is out of the range, as specified between the
BLOCK_CONTENT) Minimum and Maximum length.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 523
CHAPTER 4 Function Library

Return Code Error condition

0x0C (FN_INCONSISTANT_ The PIN_Block_Data sent in the request does not match the 12 digits from digit 3 to
REQ_FIELDS) 14 of the PIN Identification Data (PID) field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 524
CHAPTER 4 Function Library

PRV-VERIFICATION (EF0E03)
This function verifies a PIN Reference Value (PRV).

Request Length Type Description

EF0E03 3 h Function Code

FM 1 h Function Modifier = 00

PIN-Block-Format 1 h Input PIN Block format

Minimum Length of the 1 h PIN Length, in the range of 04 – 12


incoming PIN

Maximum Length of the 1 h PIN Length, in the range of 04 - 12


incoming PIN

PIN Encryption key spec Var Key Spec Key specifier for the incoming PIN encryption Key which
will be PPK.
Formats: 11, 13

ePPK(PIN-Block) 8 h Encrypted PIN Block.

PIN Block Data 6 h The incoming PIN-Block-Data. The PIN Block Data for the
ISO-0- PIN-Block.

PRV PAC key spec Var K-Spec Key specifier for PPK which will be used in calculation of
the PRV
Formats: 11, 13

PIN Identification Data 16 h The PID is a concatenated value. This field is a 32-digit (16-
(PID) Byte) hexadecimal value and is the data that is a part of the
PRV calculation.

Algorithm Type 1 h The hashing algorithm used in PRV calculation.

PRV Var h PIN Reference Value.

Response Length Type Description

EF0E03 3 h Function Code

rc 1 h Return Code

PRV Var h PIN Reference Value, calculated


using the data supplied in the request.

This function picks up an encrypted PIN Block and a PRV as input besides other inputs and calculates a PRV and
matches this calculated value against the supplied PRV. It returns a Validation Error (0x08) if the calculated PRV does
not match the supplied PRV.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 525
CHAPTER 4 Function Library

FM =00. Must be set to zero.

PIN Block Format Specifies the format of the supplied PIN Block.
Formats: 01, 02, 03, 08, 09, 10, 11, and 13, if enabled.

Minimum Length of the Minimum PIN Length


incoming PIN

Maximum Length of the Maximum PIN Length


incoming PIN

PIN Encryption key spec Key specifier for the incoming PIN encryption Key. (Formats: 11, 13)

eKPE(PIN-Block) Refers to the input formatted PIN Block containing the PIN. It must be supplied
encrypted by a KPE.

PIN Block Data Refers to the incoming PIN-Block-Data. It is a 12 digit BCD value whose permissible
digits range in between 0-9, or the rightmost PAN digits. This field is used for the
following:
• To calculate the clear PIN-Block in case of input PIN-Block-Format is ISO-0.
• Creation of the intermediate ISO-0 PIN block as part of the PRV calculation.
• To verify the 12 digit PAN incorporated in the PID field.

PRV PAC key spec Key specifier for the PPK to encrypt /decrypt the ISO-0-PIN-Block as part of the PRV
calculation.
Formats: 11, 13

PIN Identification Data PID (PIN-Identification-Data) is a concatenation of the following values:


(PID) • 3 Byte-BCD PAN, place 1-6 ('nn nn nn')
• 5 Byte-BCD PAN, place 7 - 16 (‘nn nn nn nn nn’)
• 2 Byte BCD PAN, place 17 - 20 ('00 00')
• 2 Byte-BCD Filler ('00 00')
• 2 Byte-BCD Filler ('00 00')
• 2 Byte-binary PIN-Change-Counter ('bb bb')
Note: Labeling the PIN Identification data digits starts at zero.

Algorithm Type The hashing algorithm used in PRV calculation.


• 1 if Algorithm to be used is SHA 256
• 2 if Algorithm to be used is SHA 512

PIN Reference Value PRV is:


(PRV) • A 32-Byte hexadecimal number, if the Algorithm is SHA-256
• A 64 Byte hexadecimal number, if the Algorithm is SHA-512

The return codes returned by the function are:

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 526
CHAPTER 4 Function Library

Return Code Error condition

0x06 (FN_INVALID_PF) An invalid PIN format specifier is supplied.

0x07 (FN_INVALID_PIN_ The length of the incoming PIN is out of the range, as specified between the
BLOCK_CONTENT) Minimum and Maximum length.

0x08 (FN_VALIDATION_ The PRV supplied in the request does not match the calculated PRV.
ERROR)

0x0C (FN_INCONSISTANT_ The PIN_Block_Data sent in the request does not match the 12 digits from digit 3 to
REQ_FIELDS) 14 of the PIN- Identification-Data (PID) field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 527
CHAPTER 4 Function Library

PUBLIC-KEY-OPERATIONS (EE9009)
Request Length Type Description

EE9009 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Mode of Operations 1 h Indicates the mode of operation


00 - encrypt
01 - recover
02 – Key Transport

PK Var K-Spec Key specifier to perform RSA operations (Format: 81)


(Key Type: Data Protect, Key Transport, Data Signature)

Data Var h Data to be included in the operation.

Symmetric key Var K-Spec Key specifier for key to be included in operation, this can be
a zero-length field (as below).
(Formats: 10, 11, 12, 13, 14, 20)

Key Type 1 d Indicates the KM variant use in Symmetric key

Offset 1 h Offset at which key to be Overwrite into data

Response Length Type Description

EE9009 3 h Function Code

rc 1 h Return Code

Output Data Var h Data as result of operation

This function performs RSA operation using public key as encrypt/recover/key transport specified by the mode of
operation.

FM Function Modifier = 00

Mode of Indicates the mode of operation.


Operation 00 – Encrypt
01 – Recover
02 – Key Transport

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 528
CHAPTER 4 Function Library

PK Key specifier incorporating the Public Key.


The key type of the public key must be consistent with the operation.
When mode of operation is 00-Encrypt then the Data Protect flag must be set in Key Type.
When mode of operation is 01-Recover then the Data Signature flag must be set in Key Type.
When mode of operation is 02-key Transport then the Key Transport flag must be set in Key Type.
Bit 1 may be set alone or along with bits 0, 2 or 4, but bits 0, 2 and 4 are mutually exclusive.

Data Data to be included in the RSA operation.


Note: The numerical value of Data must be less than the numerical value of PK modulus.
If length of data is greater than the length of Modulus, then the function will return error 0C.

Symmetric Key The key specifier for key to be included in the operation at the supplied offset. When Symmetric
key is in format-20, only initial key can be derived, not transaction key. So, 21-bits of transaction
counter in KSN must be zero.
Note: If Mode of operation is not Key Transport then only this field can be zero length. This filed
will be ignored.

Key Type Indicates the KM-variant that will be used to retrieve the key from ‘Symmetric key’.

00: DPK 03: KIS 40: DK-DPK

01: PPK 04: KIR 41: DK-PPK

02: MPK 05:KTM 42: DK-MPK

Note: When Symmetric key is in format-20 then Key Type will be ignored. A terminal initial key
will be derived from the BDK and KSN present in key spec 20 in this case and placed in the data.

Offset Supplies the offset position at which key will be Overwrite the data. A value of 0 – 255 is sufficient
for a modulus length of up to 2048 bits.

Output Data This field will specify the result of the operation.

Processing Steps
1. Check the field ‘Mode of Operation’ field to retrieve the type of operation to be performed.
• In case of Encrypt Operation
– Data will be encrypted by the key PK.
– The resultant will be returned in ‘Output Data’ in response.
• In case of Recover Operation
– Return recovered data response
• In case of Key Transport Operation
– Include the Symmetric key into Data at Offset position.
– Resultant data will be encrypted by the key PK.
– The encrypted will be returned in ‘Output Data’ in response.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 529
CHAPTER 4 Function Library

PVV-CALC (EE0607)
Request Length Type Description

EE0607 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPK(PIN) 8 x Encrypted PIN Block

PPK-Spec Var K-Spec PIN Protection Key specifier


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18, 20, 90)

PF 1 h PIN Block Format


(Formats: 01, 03, 08, 09, 10, 11. 13)

ANB 6 d Account Number Block

PVVK-Spec Var K-Spec Visa PIN Verification Key specifier


(Formats: 0–3, 11, 13, 17, 18)

TSP12 6 h Transformed Security Parameter

Response Length Type Description

EE0607 3 h Function Code

rc 1 h Return Code

PVV 2 x PIN Validation Value

This function calculates a Visa PVV for a PIN and also provides the length of the PIN. The PIN is supplied in encrypted
form, using any of the PIN Block formats specified in Function Construction.

PPK-Spec This may be any valid key specifier for a PPK. Consequently, the function supports an encrypted
PIN Block encrypted using a single-length or double-length or triple-length HSM-stored or host-
stored key.

ANB Account Number Block, which are the 12 right most digits of the Primary Account Number (PAN),
excluding the check digit.

PVVK-Spec A specifier to a HSM-stored or host-stored PVVK (PVK-A and PVK-B).

TSP12 The left most 12 digits of the Transformed Security Parameter.

The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.
The function performs a check that the ANB field and the TSP12 field contain a number of consecutive digits in
common. The number of digits to check is in the range 0 to 12, as may be specified using a console operation, and
defaults to 8. If the number of digits to check has been set to 0 the check is disabled, and in this case the function will

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 530
CHAPTER 4 Function Library

accept any supported PIN block format that is enabled. If the number of digits to check is greater than 0, then only ISO-
0 and ISO-3 PIN blocks are allowed, if enabled. If the check fails, the function will fail with Return Code 79.

Note: This function includes all the capabilities of the following existing functions, and thereby
supercedes the following:
PVV-CHANGE (9A)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 531
CHAPTER 4 Function Library

PVV-CALC-3624 (EE0606)
Request Length Type Description

EE0606 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PVK-Spec Var K-Spec Key specifier for PVK


(Formats: 0–3)

Validation Data 8 h Validation Data

Offset4 2 d PIN offset data

PVVK-Spec Var K-Spec Key specifier for PVVK


(Formats: 0–3, 11,13, 17, 18)

TSP12 6 h Transformed Security Parameter

Response Length Type Description

EE0606 3 h Function Code

rc 1 h Return Code

PVV 2 x PIN Validation Value

This function calculates a Visa PVV from a PIN’s IBM Offset data. The four leftmost digits of the derived or random PIN
are appended to the TSP12 to form the TSP.

PVK-Spec A specifier to the HSM stored PVK

Validation Data Data which is usually part of the PAN and used in the calculation of the reference PIN.

Offset4 Leftmost 4 digits of the PIN offset. If an offset is not used, the digits must contain zeros.

PVVK-Spec A specifier to a HSM-stored or host-stored PVVK (PVK-A and PVK-B)

TSP12 The leftmost 12 digits of the Transformed Security Parameter.

Note: This function includes all the capabilities of the following existing functions, and thereby
supercedes the following:
PVV-GEN-1 (90), PIN-GEN-2 (96).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 532
CHAPTER 4 Function Library

PVV-VER (EE0605)
Request Length Type Description

EE0605 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPK(PIN) 8 x Encrypted PIN Block

PPK-Spec Var K-Spec Key specifier for PPK


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18, 20, 90)

PF 1 h PIN Block Format

ANB 6 h Account Number Block

PVVK-Spec Var K-Spec Key specifier for PVVK


(Formats: 0–3, 11, 13, 17, 18)

TSP12 6 h Transformed Security Parameter

PVV 2 x PIN Validation Value

Response Length Type Description

EE0605 3 h Function Code

rc 1 h Return Code

This function performs the verification of a PIN using the Visa PVV method. The PIN is supplied in encrypted form,
using any of the PIN Block format specified in Function Construction.

PPK-Spec May be any valid key specifier for a PPK. Consequently, the function supports an encrypted PIN
Block encrypted using a single-length or double-length or triple-length HSM-stored or host-stored
key.

PF specifies the format of the input PIN Block format.

ANB Account Number Block, which are the 12 right most digits of the Primary Account Number (PAN),
excluding the check digit.

PVVK-Spec A specifier to a HSM-stored or host-stored PVVK (PVK-A and PVK-B)

TSP12 The left most 12 digits of the Transformed Security Parameter.

The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 533
CHAPTER 4 Function Library

Note: This function includes all the capabilities of the following existing functions and hence
supercedes PVV-VER-1 (91), PVV-VER-2 (92), PVV-VER-3 (93), PVV-VER-4 (97), PVV-VER-
5 (98), PVV-VER-6 (99)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 534
CHAPTER 4 Function Library

RAND-GEN (B570)
This function generates a 64 bit random number and returns it in the clear.

Request Length Type Description

B570 2 h Function Code

Msg ID 2 x Message Identifier

Response Length Type Description

B570 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

rn 8 x Random Number

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 535
CHAPTER 4 Function Library

RANDOM-KEY-GENERATION (EF0618)
Request Length Type Description

EF0618 3 h Function Code

FM 1 h Function Modifier (FM = 00)

KF 1 h Key Format
(Formats: 10, 11, 12, 13, 14, 17, 18)

KMVar 1 h KM Variant Index

Response Length Type Description

EF0618 3 h Function Code

rc 1 h Return Code

eKMvX(Key) Var K-Spec Key specifier encrypted under current KM (Formats: 10, 11,
12, 13, 14, 17, 18)

This is a generic function allowing the random generation of any key type and encryption under the respective KM
variant. This is required by the function PIN-GENERATION (EF0616). To create an eKMv7 PVK, the following
parameters are to be passed in, KF = 10, KMVar= 7.

Note: This function now creates host-stored DK-KTM.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 536
CHAPTER 4 Function Library

READ-USER-STORE-DATA (EE4103)
Request Length Type Description

EE4103 3 h Function Code

FM 1 h Function Modifier

i Var K-spec Index of location in User Store.


(Formats: 4–7)

Response Length Type Description

EE4103 3 h Function Code

rc 1 h Return Code

Data Var h User data

This function reads the variable-length data from the specified location. If the entry contains a key item, it will be read
and returned.

Note: The read operation is not destructive.

See Also

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 537
CHAPTER 4 Function Library

READ-USER-STORE-KEY (EE4101)
Request Length Type Description

EE4101 3 h Function Code

FM 1 h Function Modifier

Key Type 1 d Type of stored key

i Var K-spec Index of location in User Store.


(Formats: 4–7)

Response Length Type Description

EE4101 3 h Function Code

rc 1 h Return Code

K Var K-spec Key read from store.


(Formats: 11, 12, 13, 14)

KVC 3 h Key Verification Code

This function stores a KM-encrypted key at the specified location. Although, the key specifier is returned as read
initially, the encrypted key is decrypted and the KVC of the key is calculated and returned.
The function fails if the entry contains a data item and not a key specifier.

Note: The read operation is not destructive.

See Also

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 538
CHAPTER 4 Function Library

RETRIEVE-KEY (21)
Request Length Type Description

21 1 h Function Code

FM 1 h Function Modifier (FM = x0)

KXT Spec Var K-Spec Key specifier for Key Transfer Table (Formats: 0–3)

Response Length Type Description

21 1 h Function Code

rc 1 h Return Code

Key Type 1 h Representing returned Key Type:


01 = KIS
02 = KIR
03 = ZCMK
04 = KI

Key Spec Var K-Spec Key specifier for retrieved key


(Formats: 10, 11, 12, 13, 14, 15, 17, 18)

KVC 3 h Key Verification Code

This function is used to retrieve a key from the key transfer table. The key is deleted from the table if the retrieval is
successful.
The KVC/KCV of the key is also returned. 4-digit KVC/KCVs are returned with two trailing zeroes. KVC is returned for
KIS or KIR or KI key types, and KCV is returned for ZCMK key.

KXT Spec Transfer Table Key (1-20)

Notes
– The key specifiers 10, 11,15 under the Response, are generated when using the Legacy option.
– The key specifiers 10, 11, 13 under the Response, are generated based on the chosen operation on console
and FM. See, Function Modifier Values.
– The key specifier returned will depend on the key type stored in the transfer table. Single length keys will result
in key specifier Format 10, double length keys will result in key specifier Format 11 and 13, and triple length in
12 & 14. Keys that have been stored as Format 15 through the STORE-KEY function will result in Format 15
being returned as the key specifier response field.
– Keys that have been stored as Format 15, 17, 18 through the STORE-KEY (22) function will result
correspondingly in Format 15, 17 and 18 only.
– The chosen Key Protection method Legacy on console will not affect keys stored in 0x17 and 0x18 format by
STORE-KEY function.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 539
CHAPTER 4 Function Library

– When the Key Spec is returned as a Format 10, 11, 12, 13, 14 the specific KM variants are used. KM variant 4
is used for ZCMK's and KIR. KM variant 3 is used for KIS and the KM variant 10 is used for KI.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 540
CHAPTER 4 Function Library

RNS-MESSAGE (EE305F)
This function is used to prepare Remote Notification Service Message and provide DPK encrypted Session Id to be
used in CBP as derivation n/verification data.

Request Length Type Description

EE305F 3 h Function Code

FM 1 h Function Modifier = 00

DPK-Spec Var K-Spec Key to encrypt SessionID under DPK


Formats: 0-3, 11, 12, 13, 14, 17, 18, 1C
(In case of format 17, 18, valid values for DPK are:
Key Length - Double length, Triple length
Algorithm - T)

Encryption Mode for 1 h 00 = ECB


SessionID 01 = CBC

IV Var h Initialization Vector for encryption of SessionID


In case of ECB, this must be a zero length field.

Padding Mode 1 h 00 = Conditional


01 = Always
(Refer Padding Mode described in reference [83], [84], [85]
of Mark II)

SessionID Var h Must be zero length if session ID has to be generated inside


the HSM

SessionID length 1 h Length of session id when it is generated by HSM. i.e when


SessionID field is zero length field. Otherwise, value of this
field will be ignored.

D1 Var h Data D1 to be put before Session ID

D2 Var h Data D2 to be put after Session ID

MKDK-1 Spec Var K-Spec MKDK1


Format: 1C

MKDK-2 Spec Var K-Spec MKDK2


Format: 1C

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 541
CHAPTER 4 Function Library

Encryption and 1 h 0xXY


Authentication Method for X = Encryption method
Session Data Y = Authentication method
X:
0 = ECB
1 = CBC
Y:
0 = MAC Algorithm 1 in ISO/IEC 9797-1 with padding
method 2

IV ENC Var h Initialization Vector for Encryption of Session Data


In case of ECB, this must be a zero length field.

Padding Mode for 1 h 00 = Conditional


Encryption 01 = Always

IV MAC Var h Initialization Vector for MACing of Session Data


In case of ECB, this must be a zero length field.

MAC Length 1 h Length of MAC to be calculated over encrypted Session


data

D3 Var h Additional data to be used with Session ID before


encryption

D4 Var h Plain Diversifier data to be concatenated before encrypted


and authenticated session data

Response Length Type Description

EE305F 3 h Function Code

rc 1 h Return Code

eDPK(Session_ID) Var h Session_ID encrypted under DPK

RNSMsg Var h The RNS_Msg to be pushed to Mobile Payment Application

D1 Data D1 to be put before the Session ID.


MCBP v1.0 set it to B1 or B2

D2 Data D2 to be put after the Session ID.


MCBP v1.0 set it to B27-B29 (expiry date in this field as YYMMDD)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 542
CHAPTER 4 Function Library

D3 Additional data to be used with Session ID before encryption.


MCBP v1.0 pass 3-byte RemMgt_Info as first part of the diversifier (200000), however, there is no
restriction on this value.

D4 Plain diversifier data to be concatenated before encrypted and authenticated session data.
NOTE: Concatenation has to be done after the Session Data has been encrypted and authenticated.
MCBP v1.0 set it to RNSMsgID.

Processing Steps
1. Check for the value of Session ID (=SID). If Session ID is zero length, generate an N byte random number
(=RND=SID) where N= Session id length
2. Calculate Session ID as SID = D1 || SID || D2
3. Concatenate SessionID || RemMgmtInfo to form Session Data (=S)
4. Process Protecting Session ID using S, IV ENC, IV MAC, MKDK1, MKDK2, MAC Length, Padding Info, as
described in reference [83], [84], [85] of Mark II).
5. Compute RNMsg = D4 || ASD from step 6.
6. Protect SID by DPK using IV and Encryption Mode for Session ID and Padding Method. Padding will be done to
make the data left justified.

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 543
CHAPTER 4 Function Library

RSA-ENCIPHER-PIN (EE204E)
Request Length Type Description

EE204E 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PVK-Spec Var K-Spec Key Specifier for PVK and Dec. Table
(Formats: 0–3, 11, 12, 13, 14, 17, 18)

Validation Data 8 h Data (usually a part of the PAN) used in the calculation of
the reference PIN

PIN Length 1 h Number of digits in the reference PIN

Offset 6 h PIN offset data

ICC Unpredictable 8 h
Number

PPE-Spec Var K-Spec Key Specifier for ICC Public Key.


or PIC-Spec Key Type = PIN Encryption
(Formats: 0–3, 81)

Response Length Type Description

EE204E 3 h Function Code

rc 1 h Return Code

ePxx (PIN) Var h Enciphered PIN – using PPE or PIC

This function calculates a card's random PIN, formats it in accordance with section 7.2 of [5] and encrypts it using the
card's ICC PIN Encipherment Public Key, PPE, or DDA key, PIC.

Function Modifier Reserved for possible future use; must be set to zero.

PVK-Spec Key specifier for PIN Verification Key (PVK) (Formats 0 - 3, 11, 12, 13, 14, 17, 18). HSM
stored and encrypted with KMv7

Validation Data 8 bytes of PAN data used to recreate the reference PIN.

PIN Length Valid ISO PIN length.

Offset 6 byte offset that is used to recreate the reference PIN. The offset is in bcd format – big
endian. With the validation data and PIN length, the PIN can be recalculated.

ICC Unpredictable 8 byte number used to form the PIN Block.


Number

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 544
CHAPTER 4 Function Library

PPE-Spec or PIC-Spec Key specifier for PIN encryption key (Formats 0 - 3, 81).

Return Code Contains zero for success.

ePxx(PIN) The return Pxx encrypted PIN.

The function will fail with Error Code 78 if the ISO-2 PIN block format is disabled.

Function usage
• Encipherment of a cardholder-entered PIN is generally performed by the terminal. This function may be used by a
card issuer wishing to test a card prior to issue.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 545
CHAPTER 4 Function Library

SELF-CERT-ISSUER-PUBLIC-KEY (EE2041)
Request Length Type Description

EE2041 3 h Function Code

FM 1 h Function Modifier (FM = 00)

SI-Spec Var K-Spec Key Specifier for the issuer private key used in the signing
operation.
Key Type = Certificate, Data Signature
(Formats: 0-3, 82)

PI-Spec Var K-Spec Key Specifier for the issuer public key to be signed.
Key Type = Certificate, Data Signature
(Formats: 0-3, 81)

ID of Certificate Subject 4 h Value = 11.

Certificate Expiry Date 2 h MMYY format for when the Certificate expires.

Certificate Serial Number 3 h 3 bytes chosen by the Issuer.

Hash Algorithm Indicator 1 h EMV currently specify the Hash Algorithm as SHA-1 value
01.

Issuer Public Key Index 3 h Uniquely identifies the IPK.

Response Length Type Description

EE2041 3 h Function Code

rc 1 h Return Code

Issuer Public Key Length 1 h Length of the issuer public key modulus (NI).

Issuer Public Key 1 h len(e) = 1 or 3.


Exponent Length

Leftmost Digits of Issuer Var h Most significant bytes of modulus.


Public Key

Issuer Public Key 36 h Least significant bytes of modulus.


Remainder

Issuer Public Key Var h = 3 or 216 + 1.


Exponent

Issuer Public Key Var h The 'Self-certified Issuer Public Key', of length equal to the
Certificate length of the Issuer Public Key Modulus (NI)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 546
CHAPTER 4 Function Library

Response Length Type Description

Issuer Public Key Check 20 h Check Sum Value


Sum

This function creates the 'Self-certified Issuer Public Key', as described in reference [17] of Card Issuance. It confirms
that the provided public and private keys form a valid key pair, by verifying the self-certified public key.
The function returns the certificate and other public key data, in the format required for providing to the CA. It also
returns the calculated hash-code, for sending separately to the CA.

SI-Spec Key specifier for the Issuer Private Key SK (formats 0-3, 82). The Key specifier in
formats 0 - 3 describes the location of the key to be loaded from the ESM. The Key
specifier in format 82 describes the complete Issuer SK.

PI-Spec Key specifier for the Issuer Public Key (formats 0-3, 81). The Key specifier in formats 0
- 3 describes the location of the key to be loaded from the ESM. The Key specifier in
format 81 describes the complete Issuer PK.

ID of Certificate Subject Specified in Tables 3-1 and 3-2 of [17]

Certificate Expiry Date Specified in Tables 3-1 and 3-2 of [17]

Certificate Serial Number Specified in Tables 3-1 and 3-2 of [17]

Hash Algorithm Indicator Specified in Tables 3-1 and 3-2 of [17]

Issuer Public Key Index Specified in Tables 7-2 of [17]

Return Code Contains zero for success.

Issuer Public Key Length Variable length Issuer PK modulus length.

Issuer Public Key Exponent 1 byte, valid length values are 1 and 3.
Length

Leftmost Digits of Issuer Variable length field to represent Issuer PK modulus length. As in Tables 3-1 and 3-2 of
Public Key Ref [17]

Issuer Public Key IPK remainder. As in Tables 3-1 and 3-2 of Ref [17]
Remainder

Issuer Public Key Exponent Variable length field. Valid values are value=3 (length=1) and value=216+1 (length=3).

Issuer Public Key As in Tables 3-1 and 3-2 of Ref [17]


Certificate

Issuer Public Key As in Tables 3-1 and 3-2 of Ref [17]


Checksum

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 547
CHAPTER 4 Function Library

Processing Steps
1. Build the data block to be included in the hash calculation, as specified in Tables 3-1 and 3-2 of [17], using the
appropriate fields provided in the request and the public key specified by PK-Spec.
The following fixed values fields will also be incorporated into the data block: Certificate Format = 11 (hex); Issuer
Public Key Algorithm Indicator = 01 (hex).
2. Calculate the hash result. [Currently, SHA-1 is the only approved hash algorithm, and is indicated in Hash
Algorithm Indicator by a value of hex '01'.]
3. Truncate the data block, append the hash result, and add the data header and trailer to form the block to be signed.
4. Calculate Issuer Public Key Certificate by signing the block to be signed, using the private key specified in SK-
Spec.
5. Confirm that SK and PK constitute a key pair, by using PK to recover the data block from Certificate and
comparing the recovered data block with the original. Return an error if they do not.
6. Calculate the Issuer Public Key Check Sum, using ID of Certificate Subject, Issuer Public Key Index and the
public key specified by PK-Spec, in accordance with Chapter 7 of [17]

Function usage
• The function is used to create the Self-certified Issuer Public Key and associated Issuer Public Key Check Sum
that is required to be sent to the Europay-MasterCard CA in order to obtain an Issuer Certificate.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 548
CHAPTER 4 Function Library

SELF-SIGN-ISSUER-PK-VISA (EE2044)
Request Length Type Description

EE2044 3 h Function Code

FM 1 h Function Modifier (FM = 00, 01)

SI-Spec Var K-Spec Key Specifier for the issuer private key used in the
signing operation.
Key Type = Certificate, Data Signature
(Formats: 0-3, 82)

PI-Spec Var K-Spec Key Specifier for the issuer public key to be signed.
Key Type = Certificate, Data Signature
(Formats: 0-3, 81)

General Public Key Data 15 h Data included in the self-signed public key data.
The first six fields from Table 3.3 of [18] currently 18
bytes in total.

Hash Algorithm Indicator 1 h = 01: SHA-1

Issuer's Public Key Algorithm 1 h = 01: RSA


Indicator

Response Length Type Description

EE2044 3 h Function Code

rc 1 h Return Code

Signature Var h The 'Self-Signed Issuer Public Key Data', of length


equal to the length of the Issuer Public Key Modulus
(NI)

Hash Result 20 h SHA-1 Hash Result

This function creates the 'Self-Signed Issuer Public Key Data', as described in 3.2.3.2 of [18]. It confirms that the
provided public and private keys form a valid key pair, by verifying the self-signed public key.

Function Reserved for possible future use; must be set to zero.


Modifier

SI-Spec Key specifier for the Issuer Private Key SK (formats 0 - 3, 82). The Key specifier in formats 0 - 3
describes the location of the key to be loaded from the ESM. The Key specifier in format 82
describes the complete Issuer SK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 549
CHAPTER 4 Function Library

PI-Spec Key specifier for the Issuer Public Key (Formats 0 - 3, 81). The Key specifier in formats 0 - 3
describes the location of the key to be loaded from the ESM. The Key specifier in format 81
describes the complete Issuer PK.

General Public As in Table 3.3 of Ref [18]


Key Data

Hash Algorithm Currently specified as SHA-1 value 01.


Indicator

Issuer's Public Currently specified as RSA value 01.


Key Algorithm
Indicator

Return Code Contains zero for success.

Signature The returned variable length signature as in 3.2.3.2 of Ref [18]

Processing Steps
1. Build the data block to be included in the hash calculation using: General Public Key Data, the algorithm
indicators and the public key specified by PK-Spec. Calculate the hash result.
2. Truncate the data block and append the hash result, to form the block to be signed.
3. Calculate Signature by signing the block to be signed, using the private key specified in SK-Spec.
4. Confirm that SK and PK constitute a key pair, by using PK to recover the data block from Signature and comparing
the recovered data block with the original. Return an error if they do not.

Function usage
• The function is used to obtain the 'Self-Signed Issuer Public Key Data' that is required to be sent to the Visa CA in
order to obtain an Issuer Certificate.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 550
CHAPTER 4 Function Library

SET-CLOCK (0015)
This function sets the date and time in Luna EFT.

Request Length Type Description

0015 2 h Function Code

Msg ID 2 x Message Identifier

CCYYMMDD 15 d Date and time to be set for Luna EFT.


Thhmmss

Response Length Type Description

0015 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

This host function is used for Australian Major Bank (AMB).


The date and time is provided in the CCYYMMDDThhmmss format. This is the basic format for a complete
representation of calendar date and local time as specified in paragraph 5.4.1 of AS/NZS 3802:1997 Data elements and
interchange format—Information interchange—Representation of dates and times.

Note: This function should be disabled unless specifically required.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 551
CHAPTER 4 Function Library

SHA1-GENERATOR (0021)
This function returns the SHA1 hash value of the input data, to a maximum length as specified by the supplier.

Request Length Type Description

0021 2 h Function Code

Msg ID 2 x Message Identifier

Length Flag/ Algorithm 1 x hash length 00 = 160


Flag

Mode Flag 1 x 00 = only block


01 = initial block
02 = intermediate block
03 = last block

Bit Count 8 bin Initially zeroes, then returned value from previous call

Hash Value Var x Hash chaining Value, initially 0s then returned value

Data Var x Data

Response Length Type Description

0021 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 h Return Code

Bit Count 8 bin Cumulative bit count used for chaining

Hash Value Var x Hash Value or chaining value if intermediate

This host function is used for Australian Major Bank (AMB).


This function allows input to be chained over multiple calls. The chain value and bit count must be set to zeros on the
initial call. Intermediate segments (mode flag=01) must be a multiple of 64 bytes long.

Note: The length of the Input Hash Chaining value determines the length of the hash value in
the response. The length must be one of the valid values defined for the SHA-1 algorithm. At
present only the 160-bit (20 byte) hash value has been defined in Australian Standard AS2805
Part 13:2000. Algorithms for SHA-256, SHA-384 and SHA-512 have been defined by NIST.
The initial implementation need only have the 160-bit algorithm implemented.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 552
CHAPTER 4 Function Library

SIGN-DATA (EE9005)
Request Length Type Description

EE9005 3 h Function Code

FM 1 h Function Modifier (FM = 00)

SK Var K-Spec Key specifier for Private Key.


(Format: 82, Key Type: Data Signature)

Signature Algorithm 1 h 01 = RSASSA-PKCS1-v1.5

Hash Function 1 h 00 = None.


01 = SHA-1
02 = MD5
03 = SHA-224
04 = SHA-256
05 = SHA-384
06 = SHA-512

Data Var h Data to be signed

Response Length Type Description

EE9005 3 h Function Code

rc 1 h Return Code

Signature Var h Signed data: sSK(Data) or sSK(h(Data))

This function signs the data using the private key and signature algorithm indicated, and returns the digital signature.
If 0 is given as hash function, data must be already hashed and formatted into a valid ASN.1 DER-Encoded DigestInfo
structure.

Function usage (in context of Remote ATM Initialization)


None.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 553
CHAPTER 4 Function Library

SIGN-FEP-PUB-KEY (EE4007)
Request Length Type Description

EE4007 3 h Function Code

FM 1 h Function Modifier

SCA Var K-spec CA private key used to create the digital signature for the
public key certificate.
(Formats: 82)
Key Type = Certificate

PI Var K-spec Public key to be signed.


(Formats: 81)
Key Type = Key Transport.

Issuer Identifier 4 h Identification of the certificate issuer

Certificate Expiration Date 2 h MMYY, expiration of the certificate

Certificate Serial Number 3 h Serial number of the certificate

Hash Algorithm Indicator 1 01 = SHA-1

Issuer Public Key 1 h 01 = RSA


Algorithm Indicator

Response Length Type Description

EE4007 3 h Function Code

rc 1 h Return Code

Issuer Public Key Certificate Var h Digital signature for the public key certificate. The field
length is equal to the length NCA of the modulus of SCA

Issuer Public Key Var h


Remainder

Issuer Public Key Exponent Var h

This function creates the certificate for the FEP public key (PI) using the private key of the CA (SCA). The EMV format
02 certificate is formulated as specified in section 5.1 of [74], and will have the format (when recovered) described in
Appendix A of [73].
The function inserts the data fields supplied in the request message into the certificate, along with the following fields:
Public Key Length, Public Key Exponent Length, Leftmost Digits of the Public Key, Hash Result.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 554
CHAPTER 4 Function Library

SIGN-ICC-STATIC-DATA (EE204B)
Request Length Type Description

EE204B 3 h Function Code

FM 1 h Function Modifier (FM = 00)

SI-Spec Var K-Spec Key Specifier for Issuer Private Key


Key Type = Data Signature
(Formats: 0-3, 82)

Signed Data Format 1 h = 03

Hash Algorithm Indicator 1 h = 01


As specified in Annex B of [5]

Data Authentication Code 2 h Issuer-assigned code

Static Data to be Var h Static Data to be authenticated


Authenticated

Response Length Type Description

EE204B 3 h Function Code

rc 1 h Return Code

Signed Static Application Data Var h Digital signature for the Static Application Data. The
field length will be equal to the length NI of the modulus
of SI

This function calculates a digital signature for the ICC Static Application Data using an Issuer Private Key.
The function request fields provide all the variable data fields that form the Static Application Data to be signed, as
specified in Table 2 in [5].

Function Modifier Reserved for possible future use; must be set to zero.

SI-Spec Key specifier for the Issuer Private Key (Formats 0 - 3, 82).

Signed Data Format EMV currently specify the signed data format value 03.

Hash Algorithm EMV currently specify the Hash Algorithm as SHA-1 value 01.
Indicator

Data Authentication Issuer assigned 2 byte code.


Code

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 555
CHAPTER 4 Function Library

Static Data to be Variable length static data to be authenticated.


Authenticated

Return Code Contains zero for success.

Signed Static The variable length return signed static application data.
Application Data

Processing Steps
1. Build the Static Application Data using the request fields and the appropriate Pad Pattern.
2. Calculate the hash result for the Static Application Data using the hash algorithm indicated by Hash Algorithm
Indicator. [Currently, SHA-1 is the only approved hash algorithm, and is indicated by a value of hex '01'.]
3. Build the signature block using the calculated hash result and the leftmost bytes of the Static Application Data, as
defined in A2.1.2 in [5].
4. Sign the signature block using SI and its associated asymmetric algorithm. [Currently, RSA is the only approved
asymmetric algorithm.]
5. Return the signature in Signed Static Application Data.

Function usage
• The function is for use during ICC initialization: the Static Application Data and corresponding digital signature
would be passed subsequently to the card personalization system.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 556
CHAPTER 4 Function Library

SIGN-PUBLIC-KEY (NDC) (C6C0)


This function self-signs a public key with the corresponding secret key, for use in a signature request to be sent to an
ATM manufacturer.

Request Length Type Description

C6C0 2 h Function Code

Msg ID 2 x Message Identifier

PK-HSM Var K-spec Public Key of sender (format 41)

eKMVA0 Var K-spec Secret Key of sender (format 42)


(SK-HSM)

Response Length Type Description

C6C0 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

RSAPublicKey Var x ASN.1 public key

(PK-HSM) * Var x Public key signature


SK-HSM

This host function is used for Australian Major Bank (AMB).


This function signs the public key PK-HSM with the secret key SK-HSM. It checks that PK-HSM and SK-HSM have
the same modulus. The signature conforms to RSA Laboratories Cryptographic Token Interface Standard – PKCS #1,
V2.0, using the RSASSA-PKCS1-v1_5 signature scheme.
The message to be signed by RSASSA-PKCS1-v1_5-SIGN is the public key PK-HSM, DER-encoded with the ASN.1
type RSAPublicKey:-
RSAPublicKey::= SEQUENCE
{
modulusINTEGER, --n
publicExponentINTEGER --e
}

The modulus in RSAPublicKey is one-byte longer than the modulus supplied in PK-HSM, to which a byte with value of
binary zero is prepended. The exponent in RSAPublicKey is the exponent supplied in PK-HSM, with leading binary zero
bytes removed. The DER-encoded RSAPublicKey is returned in the response.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 557
CHAPTER 4 Function Library

The public key is encoded with the EMSA-PKCS-v1_5 encoding operation, applying the SHA-1 hash function, before it
is signed with the RSASP1 signature primitive.

Note:
- Only a modulus length (PK-HSM field) of 256 bytes is accepted.
- Only a public key exponent value of 0x10001 (65537) is accepted.

Example:
The following example is the hexadecimal representation of a 2048-bit PK-HSM.
Table 1: As supplied in the request, with 256-byte modulus and exponent

modulus 960356F5B591C57183FA0DA622D84CC5C6D13A0680DB4575EE6A6F150359301
BB41F0AD9E21DEF216B888F3653D08C887BD4C93769CDE86734BBCB977235E
9C3778FE209467E404BBE563D805C29D67178D238F12A9B3BB31A48AEA5562D
8494DC88EAD0DA34E55C33A910F367DBB6D5D7450AC3187624478F6BC84D92
3F66A156EF7F79081E5B2B8B4BFA2C11D89978D383F2719215E7CA21D7FED2A
D85FC4B7C4E21234931171C8304F250219B4523A66D81FADADDC7C3CD3A3AE
4AE407C0B88B0EF97B00F5A2D90B78EF0E3148C5E9BF1D7C7E550E0C5CFB97
87308F8DA71C3717180972029BDE8290162529FF7C61BD46A89C1DFF853713A1C
466BED18F3

exponent 00000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000
000000000010001

Table 2: As presented for hashing

public key tag 3082010A

modulus tag 02820101

modulus 00960356F5B591C57183FA0DA622D84CC5C6D13A0680DB4575EE6A6F150359
301BB41F0AD9E21DEF216B888F3653D08C887BD4C93769CDE86734BBCB977
235E9C3778FE209467E404BBE563D805C29D67178D238F12A9B3BB31A48AEA
5562D8494DC88EAD0DA34E55C33A910F367DBB6D5D7450AC3187624478F6B
C84D923F66A156EF7F79081E5B2B8B4BFA2C11D89978D383F2719215E7CA21
D7FED2AD85FC4B7C4E21234931171C8304F250219B4523A66D81FADADDC7
C3CD3A3AE4AE407C0B88B0EF97B00F5A2D90B78EF0E3148C5E9BF1D7C7E
550E0C5CFB9787308F8DA71C3717180972029BDE8290162529FF7C61BD46A8
9C1DFF853713A1C466BED18F3

exponent tag 0203

exponent 010001

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 558
CHAPTER 4 Function Library

Note: The SHA-1 hash of the above is 946E316E93FD9F8136BEC60F48EAE1457997DB54.

Table 3: As presented for signature

padding 0001FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFF00

Digestinfo 3021300906052B0E03021A05000414
tag

SHA-1 hash 946E316E93FD9F8136BEC60F48EAE1457997DB54

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 559
CHAPTER 4 Function Library

SIGN-PUBLIC-PKCS10 (C810)
This function self-signs a public key with the corresponding secret key, for use in a certification request to be sent to a
certification authority.

Request Length Type Description

C810 2 h Function Code

Msg ID 2 x Message Identifier

Name Var x ASN.1 subject name

VHOST Var K-spec Public Key of host (format 41)

eKMVA0(SHOST) Var K-spec Secret Key of host (format 42)

Response Length Type Description

C810 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

Certification Request Var x ASN.1 PKCS #10 Certification Request

This host function is used for Australian Major Bank (AMB).


This function signs a certification request containing the public key VHOST with the secret key SHOST. It checks that
VHOST and SHOST have the same modulus. The signature conforms to RSA Laboratories Cryptographic Token
Interface Standard – PKCS #1, V2.0 using the RSASSA-PKCS1-v1_5 signature scheme.
The function constructs a Certification Request which conforms to RSA Laboratories Certification Request Syntax
Standard - PKCS #10 v1.7. The DER-encoded Certification Request is returned in the response.
CertificationRequest ::= SEQUENCE {
certificationRequestInfo CertificationRequestInfo,
signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }},
signature BIT STRING
}
CertificationRequestInfo ::= SEQUENCE {
version INTEGER { v1(0) } (v1,...),
subject Name,
subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }},
attributes [0] Attributes{{ CRIAttributes }}}
In the CertifcationRequestInfo, subject is the distinguished name of the certificate subject, as provided as a DER-
encoded ASN.1 Name in the request. The name contains the common name, organization name, and country name of
the subject. The SubjectPublicKeyInfo contains an RSAPublicKey with the public key modulus and exponent supplied
in the request. There are no attributes.
RSAPublicKey::= SEQUENCE

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 560
CHAPTER 4 Function Library

{
modulusINTEGER, --n
publicExponentINTEGER --e
}
The modulus in RSAPublicKey is one byte longer than the modulus supplied in VHOST, to which a byte with value of
binary zero is prepended. The exponent in RSAPublicKey is the exponent supplied in VHOST, with leading binary zero
bytes removed.
The message to be signed by RSASSA-PKCS1-v1_5-SIGN is the DER-encoded CertificationRequestInfo. The
CertificationRequestInfo is encoded with the EMSA-PKCS-v1_5 encoding operation, applying the SHA-1 hash
function, before it is signed with the RSASP1 signature primitive. The signature is placed in the Certification Request
which is returned in the response.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 561
CHAPTER 4 Function Library

SPONSOR-KEY-GEN (B510)
This function generates a random Cross Acquirer Key (KCA) and a housekeeping key (KMACH) and returns them
encrypted under the appropriate variant of KM.

Request Length Type Description

B510 2 h Function Code

Msg ID 2 x Message Identifier

Response Length Type Description

B510 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKMv44(KCA) Var K-Spec Cross Acquirer Key (format 21)

eKMv24(KMACH) Var K-Spec Housekeeping MAC key (format 21)

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 562
CHAPTER 4 Function Library

STORE-KEY (22)
Request Length Type Description

22 1 h Function Code

FM 2 h Function Modifier (FM = 00)

KXT Spec Var K-Spec Key specifier for Key Transfer Table, (Formats: 0-3)

Key Type 1 h Key Type representing key to store


01 = KIS
02 = KIR
03 = ZCMK
04 = KI

Key Spec Var K-Spec Key specifier for stored key, (Formats: 10, 11, 12, 13, 14,
15, 17, 18) (See notes))

KVC 3 h Key Verification Code

Response Length Type Description

22 1 h Function Code

rc 1 h Return Code

This function is used to store a key in the key transfer table. The KVC/KCV of the key is also returned. 4-digit
KVC/KCVs needs to be entered with two trailing zeroes. KVC is returned for KIS or KIR or KI key types, and KCV is
returned for ZCMK key.

Notes
– Format 15 is only accepted when the key sub type sent is 1 or 2. When the Key Spec field is a Format 15, the
key stored in the transfer table will have its attributes set.
– Format 15 will not be supported for key KI.
– Formats 10, 11, 12, 13, 14 for the Key Spec use the specific KM variant for the key type. KM variant 4 is used
for ZCMK's and KIR. KM variant 3 is used for KIS and KM variant 10 is used for KI.
– For format 17 and 18 the following restrictions will be implemented for KI:
- Allowed mode of use for KI can only be “B”.
- Key Usage should be K0.
- Algorithm should be D or T.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 563
CHAPTER 4 Function Library

TERM-AUTH-1 (EE4003)
Request Length Type Description

EE4003 3 h Function Code

FM 1 h Function Modifier

PCA-TM Var K-spec Public key of CA of terminal manufacturer


(Formats: 81, 83)

CTM Var h Certificate of terminal manufacturer (EMV)

Public Key Remainder for Var h


PTM

Public Key Exponent for Var h


PTM

CEFT Var h Terminal EMV certificate

Public Key Remainder for Var h


PEFT

Public Key Exponent for Var h


PEFT

Issuer Identifier 4 h

Terminal ID 8 h

Issuer ID 4 h

Hash Algorithm Indicator 1 h 01: SHA-1


02: SHA-256

Response Length Type Description

EE4003 3 h Function Code

rc 1 h Return Code

PEFT Var K-Spec Terminal public key


(Format: 81
Key Type: Key Transport)

ePEFT(FEP Cryptogram 1 Var h FEP cryptogram – as specified in Appendix B1 of [72] and


data) encrypted using PEFT.

RNF 16 h FEP random number

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 564
CHAPTER 4 Function Library

eKMv47(KF) Var K-Spec FEP random key – 128-bit, parity-adjusted value encrypted
by suitable variant of KM.
(Formats: 11, 13)

This function performs the processing described in section 2.2 of [72], and as listed below.
• Verify terminal EMV certificate according to Appendix A of [72].
• Recover terminal public key.
• Generate authentication cryptogram according to Appendix B.1 of [72].

Note: In Appendix B.1, Hash Result will be - Hash of fields Random, Key, Terminal ID, Issuer
ID, Hash Algorithm Indicator and Pad Pattern.

Processing Steps
1. Verify CTM using PCA-TM and recover PTM. Check Issuer Identifier is the same as value in the certificate.
2. Verify CEFT using PTM and recover PEFT. Check Issuer ID is the same as value in the certificate.
3. Generate RNF – 16 byte random number.
4. Generate KF – a 128-bit, parity-adjusted 3DES key.
5. Encrypt KF with a variant of the current KM.
6. Create FEP Cryptogram 1, as specified in Appendix B1 of [73] with length equal to length of modulus of PEFT.
Insert RNF, KF, Terminal ID, Issuer ID and Hash Algorithm Indicator.
7. Calculate the Hash Result using algorithm specified in Hash Algorithm Indicator and insert into the appropriate
cryptogram field.
8. Encrypt the completed cryptogram data using PEFT.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 565
CHAPTER 4 Function Library

TERM-AUTH-2 (EE4004)
Request Length Type Description

EE4004 3 h Function Code

FM 1 h Function Modifier

SFEP Var K-spec FEP private key


(Format: 82
Key Type: Key Transport)

ePFEP(EFTPOS Cryptogram Var h Terminal cryptogram – as specified in Appendix B2 of


data) [73] and encrypted using PFEP.

RNF 16 h FEP random number

Terminal ID 8 h

Issuer ID 4 h

PEFT Var K-spec Terminal public key


(Format: 81
Key Type: Key Transport)

Response Length Type Description

EE4004 3 h Function Code

rc 1 h Return Code

ePEFT(FEP Cryptogram 2 Var h FEP cryptogram –encrypted using PEFT.


data)

eKMv47(KE) Var K-spec Terminal random key.


(Formats: 11, 13)

This function performs the processing described in section 2.2 of [72], and as listed below.
• Verify terminal cryptogram and FEP random number according to appendix B.2 of [72].
• Generate authentication cryptogram according to appendix B.3 of [72].

Processing Steps
1. Check that length of terminal cryptogram is equal to length of modulus of SFEP
2. Decrypt terminal cryptogram using SFEP.
3. Check the values of the Data Header and Data Trailer are correct.
4. Calculate the hash result using the Hash Algorithm Indicator field and check against the Hash Result field.
5. Check the values of the Terminal Id, Issuer Id and FEP Random fields against those in the request message.
6. Extract the random number, RNE, and the key, KE.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 566
CHAPTER 4 Function Library

7. Encrypt KE with a variant of the current KM.


8. Create FEP Cryptogram 2, as specified in Appendix B3 of [73], with length equal to length of modulus of PEFT.
9. Insert RNE, Terminal ID, Issuer ID and Hash Algorithm Indicator (from the terminal cryptogram).
10. Calculate the Hash Result using algorithm specified in the Hash Algorithm Indicator field (from the terminal
cryptogram) and insert into the appropriate cryptogram field.
11. Encrypt the completed cryptogram data using PEFT.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 567
CHAPTER 4 Function Library

TERM-VER-2 (EE0406)
Request Length Type Description

EE0406 3 h Function Code

FM 1 h Function Modifier (FM = 00)

KTM-Spec Var K-Spec Key specifier for KTM


(Formats: 0–3, 10, 11, 12, 13, 14, 17, 18)

SEC-No 8 h Security Number

Logon-Data 8 h Logon Data

Response Length Type Description

EE0406 3 h Function Code

rc 1 h Return Code

This function verifies the validity of an EFT terminal by checking that the LOGON-DATA is equal to the result of
encrypting its Security Number (SEC-NO) under its KTM.
The function returns no response data. An Error Code of 00 indicates successful verification, while 08 indicates a
verification failure.

KTM-Spec A key specifier which incorporates an index to an HSM-stored or host-stored single length or double
length KTM.

SEC-No Security Number for the terminal.

Logon-Data The logon data is equivalent to the security number encrypted under the terminal master key.

Notes
– For key specifier formats, refer to Function Construction.
– This function supercedes function 4C.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 568
CHAPTER 4 Function Library

TLS-ENCRYPTION-AND-MAC-KEY-DERIVATION (EE6004)
Request Length Type Description

EE6004 3 h Function Code

FM 1 h Function Modifier

eKMv39(MS) Var K-spec KM-encrypted master secret

R1 28 x Client random

R2 28 x Server random

MAC Algorithm 1 h 03 = HMAC-SHA-1

MPK Length 2 h Number of bits in MAC keys.


= 128, 160 or 192 (decimal)

Enc Algorithm 1 h 01 = 3DES

DPK Length 2 h Number of bits in data keys.


= 128 or 192 (decimal)

IV Length 2 h Number of bits IVs.


= 0 or 64 (decimal)

Response Length Type Description

EE6004 3 h Function Code

rc 1 h Return Code

eKMv(MPK1) Var K-spec Client MAC key

eKMv(MPK2) Var K-spec Server MAC key

eKMv(DPK1) Var K-spec Client data key

eKMv(DPK2) Var K-spec Server data key

IV1 Var x Client IV

IV2 Var x Server IV

This function supports a call to PKCS #11 function C_DeriveKey with the mechanism CKM_TLS_KEY_AND_MAC_
DERIVE.

Notes
– The 160 bit MPK will be padded with 4 bytes of 0s to the right in order to expand it to triple length before
encryption with KM.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 569
CHAPTER 4 Function Library

– Host key rationalization restrictions will apply to this function.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 570
CHAPTER 4 Function Library

TLS-MASTER-KEY-DERIVATION (EE6003)
Request Length Type Description

EE6003 3 h Function Code

FM 1 h Function Modifier

eKMv39(PMS) Var K-spec KM-encrypted premaster secret

R1 28 x Client random

R2 28 x Server random

Response Length Type Description

EE6003 3 h Function Code

rc 1 h Return Code

Version 2 h TLS protocol version

eKMv39(MS) Var K-spec KM-encrypted master secret

This function supports a call to PKCS #11 function C_DeriveKey with the mechanism CKM_TLS_MASTER_KEY_
DERIVE. It derives the master secret from the premaster secret and the random numbers of the client and server.
For more explanation, refer section 8.1 of [49].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 571
CHAPTER 4 Function Library

TLS-PRE-MASTER-KEY-GENERATION (EE6000)
Request Length Type Description

EE6000 3 h Function Code

FM 1 h Function Modifier

Version 2 h Provides the TLS protocol version number, where MSB and
LSB is used for major and minor version respectively.
For example, for version 2.10, major =02 and minor =10.

Response Length Type Description

EE6000 3 h Function Code

rc 1 h Return Code

eKMv39(PMS) Var K-spec KM-encrypted premaster secret

This function supports a call to PKCS #11 function C_GenerateKey with the mechanism CKM_TLS_PRE_MASTER_
KEY_GEN.
The function concatenates Version (specified as CK_VERSION in reference [54] of Mark II) and 46 bytes of randomly
generated data to form the premaster secret and encrypts the secret for local storage.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 572
CHAPTER 4 Function Library

TLS-PRE-MASTER-KEY-RECEIVE (EE6002)
Request Length Type Description

EE6002 3 h Function Code

FM 1 h Function Modifier

ePK(PMS) Var x RSA-encrypted premaster secret

SK Var K-spec Key specifier for Private Key.


(Format: 82
Key Type: Key Transport)

Pad mechanism 1 h 0x00 = RSA_PKCS1_v1_5

Response Length Type Description

EE6002 3 h Function Code

rc 1 h Return Code

eKMv39(PMS) Var K-spec KM-encrypted premaster secret

Version 2 h TLS protocol version

This function supports a call to PKCS #11 function C_UnwrapKey to RSA-decrypt the previously generated premaster
secret.
The function re-encrypts the received encrypted premaster secret for local storage and also extracts the TLS protocol
version number from it while providing that in a clear form.
For more explanation on C_UnwrapKey function, refer to section 11.14 in reference [54] of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 573
CHAPTER 4 Function Library

TLS-PRE-MASTER-KEY-SEND (EE6001)
Request Length Type Description

EE6001 3 h Function Code

FM 1 h Function Modifier

eKMv39(PMS) Var K-spec KM-encrypted premaster secret

PK Var K-spec Key specifier for Public Key.


(Format: 81
Key Type: Key Transport)

Pad mechanism 1 h 0x00 = RSA_PKCS1_v1_5

Response Length Type Description

EE6001 3 h Function Code

rc 1 h Return Code

ePK(PMS) Var x RSA-encrypted premaster secret

This function supports a call to PKCS #11 function C_WrapKey to RSA-encrypt the previously generated premaster
secret for sending it to the server.
For more explanation on C_WrapKey function, refer to section 11.14 in reference [54] of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 574
CHAPTER 4 Function Library

TRANS-KM-ENC-PIN (EE0643)
Request Length Type Description

EE0643 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPK(PIN) 8 x Encrypted PIN Block

PPK-Spec Var K-Spec Key specifier for PPK


(Formats: 0 - 3, 10, 11, 13, 12, 14, 17, 18, 20, 90)

PF 1 h PIN Block Format


(Formats: 01, 03, 08, 09, 10, 11, 13)

ANB 6 h Account Number Block

Response Length Type Description

EE0643 3 h Function Code

rc 1 h Return Code

PIN-Spec Var K-Spec KM-encrypted PIN Block


(Format: 1A)

This function translates a PIN from encryption using PPK to encryption using KM.

Notes
– The ANB field is used (if required) in recovering the input PIN. It is also used to build the KM-encrypted PIN.
– The function will fail with Error Code 78 if PIN block format ISO-3 or PIN block format indicated by PF is
disabled or conflicts with the reformatting restrictions.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 575
CHAPTER 4 Function Library

TRANSLATE-DATA-P2PE (EE080C)
This function is used to translate data for P2PE.

Request Length Type Description

EE080C 3 h Function Code

FM 1 h Function Modifier = 00

Data Field 1 h = 00 (Generic data)


= 01 (PAN with Valid Check Digit)
= 02 (PAN without Valid Check Digit)
= 03 (Cardholder Name)
= 04 (Track1 Discretionary Data Only)
= 05 (Track2 Discretionary Data Only/Chip MSI)

Algorithm 1 h 01 = TDES

Source Mode and Format 1 h 01 = VDSP VFPE


02 = VDSP Standard

Data Format 1 h = 00 (Reserved for future use)

Data Element Type 1 h 00 = Only applicable for VDSP VFPE


01 = Not applicable for VDSP VFPE

eDPK(Data) Var h Data to be translated


For Source Mode and Format = VDSP VFPE, this data will
be treated as alphabet numbers.
For Source Mode and Format= VDSP Standard, this data
will be treated as encrypted data.

Counter Var h Counter value


For Source Mode and Format =01, this field is treated as
counter.
8 byte for TDES; leftmost 7 bits must be zero
For Source Mode and Format =02, this field is treated as
Initialization Vector.

DPK-Spec Var K-Spec Key specifier for DPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 20)

Encryption Formatting 1 h 01 = No Formatting


Method 02 = VDSP Standard

Encryption IV Var h Initialization Vector

Target DPK-Spec Var K-Spec Key specifier for encryption key


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 20)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 576
CHAPTER 4 Function Library

Request Length Type Description

Following Field to be present only if Source Mode and Format = 01

Counter Block length 1 h Counter Block length in digits

Alphabet table Index 1 h 00 = Default


01, 02, 03, 04, 05 = Internally reserved for VISA.
09 = Alphabet table as host function parameter
This translation is dependent on Data Element Type

Target Format 1 h = 01 (ASCII text)


= 03 (hexadecimal digits)
= 04 (EBCDIC)

Following Field to be present only if Source Mode and Format = 01 and Alphabet table Index=09

Base Number 2 h Base of the number system

Alphabet Table Var h Alphabet table as defined in alphabet parameter.

Following Field to be present only if Encryption Formatting Method = 01

Padding Method 1 h XY
X = 0 : pad with all zeroes to make last block multiple of
block size of cipher algorithm
X = 1: data to be encrypted not multiple of block size add
0x80 and then as many zeroes as required.
X = 2 Add with random number to make last block multiple
of block size of cipher algorithm
Y = 0 left padded
Y= 1 right padded

Response Length Type Description

EE080C 3 h Function Code

rc 1 h Return Code

eDPK(Data) Var h Cipher-text under target DPK

Following field to be present only if Encryption Formatting Method = 01

Number of nibbles for 2 h No of nibbles used for padding


padding

Processing Steps
1. Extract the supplied DPK

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 577
CHAPTER 4 Function Library

2. For Data Element Type=00, convert each byte of Data as unsigned integer (as a byte).
3. Check for input alphabet numbers with base number (deduced from alphabet table). The alphabet number should be
in the range of 0 to 2^n-1.
4. In case of Source Mode and Format =01; for Data Field type other than {01,02}, decrypt processed data with VFPE
Algorithm (as described in reference [89]) using the calculated transaction specific data encryption key, counter,
counter block length, base number, alphabet table index and alphabet table.
5. In case of Source Mode and Format =01; for Data Field type =01; decrypt processed data with VFPE Algorithm (as
described in reference [89]) using the calculated transaction specific data encryption key, counter, counter block
length, base number, alphabet table index and alphabet table. Adjust 5th digit from right to maintain the Luhn check
integrity.
6. In case of Source Mode and Format =01; for Data Field type =02; decrypt processed data with VFPE Algorithm (as
described in reference [89]) using the calculated transaction specific data encryption key, counter, counter block
length, base number, alphabet table index and alphabet table.
7. Follow the translation rules as given in table below:

Source Mode Formatting requirements on Target Encryption Formatting Requirement for


and Format source data Method target

VDSP VFPE Input data is binary representation of CBC (No Formatting) Formatting requirement is given
number. by Target Format. Data after
VFPE Decryption

VDSP Standard Input data is hex representation of CBC (No Formatting) Remove the formatting as given
encrypted data. in VDSP standard method. Only
package the data and return the
number of nibbles used for
padding. Padding Method field
will be applicable here.

VDSP VFPE Input data is binary representation of VDSP Standard Convert the data as defined in
number. target format. Thereafter
package it as defined in section
6 of reference [90].

VDSP Standard Input data is hex representation of VDSP Standard No formatting


encrypted data.

8. Encrypt the converted/target content in the specified cipher mode using IV and the DPK extract from Target DPK
Spec.

Note: For VDSP standard formatting of generic data, refer section 6.3 of reference [90].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 578
CHAPTER 4 Function Library

Alphabet Table Processing


Data Element Type Alphabet Table Use Additional Condition

Generic Alphabet table needs to be defined


else for default value Track-1
alphabet table will be used.

PAN with Valid Check BASE-10 First 6 and last 4 not to be encrypted.
Digit The extracted data is VFPE enciphered. In the
resulting data the first digit from last 5 digits is
recomputed for check digit and replaced.

PAN without Valid BASE-10 First 6 and last 4 not to be encrypted.


Check Digit

Cardholder Name FPE Track 1 FPE Name Alphabet

Track1 Discretionary TRACK-1


Data Only

Track2 Discretionary Base-15


Data Only/Chip MSI

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 579
CHAPTER 4 Function Library

TRANSLATE-DATA-RSA-TO-RSA (EE9014)
This function is used to translate sensitive data encrypted under one RSA key to another RSA key.

Request Length Type Description

EE9014 3 h Function Code

FM 1 h Function Modifier (FM=00)

RSA private key Var K-Spec RSA private key format 82.
Key Type must be “Data Protect”

Encrypted data encoding 1 h 0x01 = Base 64 encoding


method

Encrypted data Var Var Encrypted data

Input data encryption 1 h 0x00 = OAEP


scheme

Input data formatting 1 h 0x00 = NPCI formatting (described below)

Output data encoding 1 h 0x01 = Base 64 encoding


scheme

RSA public key Var K-Spec Format 81 RSA public key


Key type must be “Data Protect”

Output Encryption 1 h 0x00 = RSAES_OAEP


Scheme

P Var h PKCS#1 parameter string

Response Length Type Description

EE9014 3 h Function Code

rc 1 h Return Code

Encrypted data Var Var Data encrypted under public key

Clear data Var Var Clear text data after stripping sensitive information.

Non sensitive data after decryption is returned in clear.


To enable PKCS#1 parameter string P, to specify the hash algorithm used in OAEP encoding, P can be in one of the
following formats:
a. Variable length string without any formatting. The valid string length is 0-16
b. Variable length string in following format.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 580
CHAPTER 4 Function Library

PKCS#1 Parameter String

Header 2h h = X’5A5A

Format 1 h 1

OAEP Hash Algorithm 1 h = 2: SHA-1


= 4: SHA-256
= 5: SHA-384
= 6: SHA-512

OAEP MGF 1 h = 12: MGF1 SHA-1


= 14: MGF1 SHA-256
= 15: MGF1 SHA-384
= 16: MGF1 SHA-512

OAEP P Var h PKCS#1 parameter string / Optional Label to be


associated with encryption.
Valid string length: 0-16

Trailer 2h h = X’5A5A

If the Header and Trailer fields do not match then P is treated as an unstructured variable length string encoded using
SHA-1 and MGF1 SHA1. If they do match but any other fields are not as specified, then an appropriate error code is
returned.
When input encryption scheme is 0x00 (OAEP), parameter string is assumed to be empty string and Hash algorithm
and OAEP MGF are SHA-1 and MGF1 SHA-1 respectively.
Note: Only 1024 and 2048 bit RSA modulus size is supported.

Processing Steps
1. Extract RSA private key.
2. Decode base 64 encoded encrypted data.
3. Decrypt data using RSA private key. Decrypted data will be base 64 encoded.
4. Decode decrypted data to get cleartext.
5. Clear text data must be in below format for NPCI formatting.
<Transaction Id><delimiter><Common library version><delimiter><Captured credential><delimiter><Transaction
amount><delimiter><Random number>
If it is not in above format, return error. Delimiter character used is ‘|’.
Below data can be used as example,
172652@u712373|33.22|978678|4000|402384
6. Extract captured credential from clear data. For example, 978678.
7. Encrypt data using public key.
8. Base 64 encode encrypted data according to output data encoding scheme.
9. Return encoded string in response.
10. Return clear data after removing user credential. For example, 172652@u712373|33.22|4000|402384

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 581
CHAPTER 4 Function Library

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 582
CHAPTER 4 Function Library

TRANSLATE-SENSITIVE-DATA (EE0645)
Request Length Type Description

EE0645 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Key Type 1 d Key type that encrypts data to be translated.


00 = DPK
01 = PPK
35 = KTK
KTK derived from KMC if KTK-spec is of format 50 or 51.

Key data Var x Sensitive data encrypted under decryption key as indicated
or PIN data by Key Type
(multiple of 8 bytes)

KTK-spec Var K-spec Key specifier for decryption key


or PPK-spec (Formats: 0–3, 10, 11, 12, 13, 14, 17, 18, 50, 51)
or DPK - spec (KMC: 0–3, 13, 17, 18)

Decryption Method 1 h 00 = ECB


01 = CBC

Decryption IV 8 x Initialization Vector (used for CBC only)

Header Var x (May be a zero length field)

Trailer Var x (May be a zero length field)

TK-spec (DPK2/KMC) Var K-spec Key specifier for encryption key


(Formats: 0–3, 11, 12, 13, 14, 17, 18, 50, 51)
(for format 50 and 51, key is derived from KMC;
for format 11 and 13, key refers to a host-stored KMC;
for formats 0-3, 11, 12, 13, 14, 17, 18, 50, 51, key refers to
DPK if Key Type is DPK)

Encryption Method 1 h 00 = ECB


01 = CBC

Encryption IV 8 x Initialization Vector (used for CBC only)

Response Length Type Description

EE0645 3 h Function Code

rc 1 h Return Code

eTK(key or PIN data) Var x Sensitive data encrypted under transport key

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 583
CHAPTER 4 Function Library

This function translates encrypted sensitive data (key or PIN data) for sending to an IC card. The function supports the
crypto processing defined in the Global Platform [Reference [75] of Mark II] and EMV [Reference [79] of Mark II] CPS
specifications.

KTK/PPK/DPK-spec For formats 0-3, 10, 11, 12, 13, 14, 17, 18 references an HSM- or host-stored key of the type
indicated by Key Type.
For formats 50 or 51, the decryption key is derived from a stored KMC.
Format 10 is supported for key type PPK/DPK.

TK-spec For formats 11 or 13 references a host stored KMC.


For formats 50 or 51, the decryption key is derived from a stored KMC.
If Key Type is DPK then the formats 0-3, 11, 12, 13, 14, 17, 18, 50, 51 references HSM- or
host-stored DPK.

Processing Steps
1. Check that the Header and Trailer fields have a combined length that is a multiple of 8 bytes. If not, abort with an
error.
2. Decrypt the sensitive data using the specified key of the type as indicated, decryption mode and (if applicable)
decryption IV.
3. Concatenate the Header, decrypted data from step 1, and the Trailer ( in that order). The result will necessarily be a
multiple of 8 bytes.
Encrypt the result of step 3 using the specified KEK, encryption mode and, if applicable, encryption IV.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 584
CHAPTER 4 Function Library

TRANSLATE-VFPE-ALPHABET-TO-DATA (EE080E)
This function is used to translate data from a VFPE alphabet binary string to target formatted binary string.

Request Length Type Description

EE080E 3 h Function Code

FM 1 h Function Modifier = 00

Alphabet table Index 1 h Alphabet index table value

Target Format 1 h 00 = ISO Modified 5 bit ASCII


01 = ISO Modified 7 bit ASCII
02 = 4 bit BCD
03 = 7 bit ASCII
04 = 8 bit EBCDIC

Data Packaging 1 h 0x00 = bit stream left padded


0x01 = bit stream right padded
0x10 = byte stream

Data Var h Data as VFPE alphabet number


The input will be treated as integer and will be formatted as
binary data packaged as defined in Data packaging.

Response Length Type Description

EE080E 3 h Function Code

rc 1 h Return Code

Data Var h Binary data in target format and packaging

Following field to be present only if Data packaging = {00,01}

No of bits padded 1 h No of bits padded to complete a byte for receive packet.

Processing Steps
1. Identify the alphabet table to be used and verify if the target format is applicable for that alphabet table. Refer
Alphabet Table as described in reference [89] of Mark II.
2. Read the input data byte by byte convert it into corresponding binary data set from the alphabet table.
3. Package the bit/byte stream as defined by data packaging after conversion in the same order as alphabet numbers
were sent.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 585
CHAPTER 4 Function Library

TRANSLATE-VFPE-DATA-TO-ALPHABET (EE080D)
This function is used to translate data from a source formatted data to VFPE alphabet binary string.

Request Length Type Description

EE080D 3 h Function Code

FM 1 h Function Modifier = 00

Alphabet table Index 1 h Alphabet index table value

Source Format 1 h 00 = ISO Modified 5 bit ASCII


01 = ISO Modified 7 bit ASCII
02 = 4 bit BCD
03 = 7 bit ASCII
04 = 8 bit EBCDIC

Data Packaging 1 h 0x00= bit stream left padded


0x01= bit stream right padded
0x10=byte stream

Data Var h Data in source format


The input will be treated as specified in data packaging and
parsed from left to right.

Following field to be present only if Data packaging={00,01}

No of bits padded 1 h No of bits padded to complete a byte for receive packet.

Response Length Type Description

EE080D 3 h Function Code

rc 1 h Return Code

Data Var h Binary data

Processing Steps
1. Identify the alphabet table to be used and verify if the source format is applicable for that alphabet table. Refer
Alphabet Table as described in reference [89] of Mark II.
2. Read the input data with respect to data packaging as defined in source format and convert it into corresponding
alphabet number from the alphabet table.
3. In each byte of output convert this alphabet number into integer and represent it in binary form.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 586
CHAPTER 4 Function Library

VALIDATE-CBP-CVC3 (EE3054)
This function is used to verify the CVC3 generated for magnetic stripe cards used in cloud based payments.

Request Length Type Description

EE3054 3 h Function Code

FM 1 h Function Modifier = 00

Card Key Type 1 h 00 = CMKCLMD


01 = CMKCLUMD
02 = CMKRPMD
03= CMKRPUMD
Determine IMKxx type

IMKxx-Spec Var K-Spec IMKxx key spec


Formats: 0-3, 11, 13, 17, 18
xx = {CL, RP}

CMK Derivation Method 1 h 00 = MCBP

CMK Derivation Method Var h For derivation method = 00, PAN || PAN Sequence No. ||
Data Mod PAN Sequence No.

Session Key Derivation 1 h 00 = MCBP


Method

Session Derivation Data Var h For derivation method = 00, 8-byte value for SK derivation

IV Data Var h Static part of Track 1 or 2 data used to calculate IVCVC3

XOR String 2 h A value to XOR the calculated IV.


MCBP v1.0 set it to 9559

UN 4 x Unpredictable Number

CVC generation method 1 h 00 = MCBP v1.0 (use CVC3 Generation method described
in reference [83], [84], [85] of Mark II.

nCVC 1 h Number of relevant MCBP CVC3 digits.


The routine will only check the n rightmost digits of the
supplied MCBP CVC3 value(s)

CVC3 2 h Dynamic MCBP CVC3

Response Length Type Description

EE3054 3 h Function Code

rc 1 h Return Code

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 587
CHAPTER 4 Function Library

Processing Steps
1. Extract IMKCLor IMKRP depending upon the card key type
a. If Card Key Type = {00,01}, extract IMKCL
b. If Card Key Type = {02,03}, extract IMKRP
2. Derive Card Master Keys as specified in Card Key Type using
a. corresponding IMKxx extracted in step1
b. CMK derivation data
c. CMK derivation method as defined in reference [83], [84], [85] of Mark II.
3. Derive Session Key from CMKxx from step 2 using
a. Session Key Derivation Data
b. Session Key Method as defined in reference [83], [84], [85] of Mark II.
4. Generate CVC as required using IV Data, XOR String, ATC, UN.
Supply these values to CVC3 Generation for MCBP, as described in reference [83], [84], [85] of Mark II, if CVC
generation method = 00.
5. Compare the generated CVC3 in step 4 with CVC3 value for n rightmost digits as specified by nCVC3.

Note:
- xx in CMKxx refers to Card Key Type - CLMD, CLUMD, RPMD, RPUMD
- xx in IMKxx refers to CL, RP

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 588
CHAPTER 4 Function Library

VALIDATE-CLOUD-AC-GENERATE-ARPC (EE3053)
This function is used to verify the Application Cryptogram and generate ARPC for Cloud Based Payments and generate
ARPC if required using same key.

Request Length Type Description

EE3053 3 h Function Code

FM 1 h Function Modifier = 00

Action Type 1 h 01 = Verify AC only


02 = Generate ARPC only
03 = Verify AC and generate ARPC

Card Key Type 1 h 00 = CMKCLMD


01 = CMKCLUMD
02 = CMKRPMD
03= CMKRPUMD

IMKxx-Spec Var K-Spec IMKxx key spec


Formats: 0–3, 11, 13, 17, 18

CMK Derivation Method 1 h 00 = MCBP CMK derivation method


01 = VISA CMK Derivation Method

CMK Derivation Data Var h For CMK derivation method = 00 and 01, data contains PAN
data concatenated with PAN sequence number or mod
PAN sequence number

Session Key Method 1 h 00 = CSK (Common Session Key Derivation)


01 = LUK (VISA Limited Use Key)

Derivation Data R Var h For Method = 0, 8-byte value R for SK derivation


e.g., 2-byte ATC || 00 00 00 00 00 00 for CSK
For Method=1, YHHHHCC (left justified) 4 bytes in length.

Received AC Var h The received AC

AC/ARPC Generation 1 h 00 = MCBP


method 01 = VISA qVSDC cryptogram verification
02 = VISA MSD cryptogram verification

AC Data Var h Data to generate AC

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 589
CHAPTER 4 Function Library

Request Length Type Description

maskAC 8 h An 8 byte mask value.


The received and calculated AC are both masked with this
value before they are compared.
Expected bytes/masks for UMD are:
- No mask for face to face payment (equivalent to FFFF
FFFF FFFF FFFF)
- 0000 0000 FFFF FFFF for a remote payment
Expected bytes/masks for MD are:
- FFFF FFFF FF00 0000 for a face to face transaction
- FFFF FFFF 0000 0000 for a remote payment

ARPC Key Method 1 h 00 = same key as derived for AC

ARPC Method 1 h 01 = Method 1


02 = Method 2

ARPC Data Var h Data on which the ARPC has to be calculated. This field
can be zero length if no ARPC calculation required.

Response Length Type Description

EE3053 3 h Function Code

rc 1 h Return Code

ARPC Var h ARPC can be zero length

Processing Steps
1. Extract IMKCLor IMKRP depending upon the card key type
a. If Card Key Type = {00,01}, extract IMKCL, or,
b. If Card Key Type = {02, 03}, extract IMKRP
2. Derive Card Master Keys as specified in Card Key Type using
a. corresponding IMKxx extracted in step 1
b. CMK derivation data
c. CMK derivation method
If CMK derivation method = 00 (MCBP), the card master key is derived using the method specified in reference
[83], [84], [85] of Mark II.
If CMK derivation method = 01 (VCBP), the card master key is derived using the method specified in reference
[86]. [87], [88] of Mark II.
3. Derive Session Key from CMKxx from step 2, using
a. Derivation Data R

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 590
CHAPTER 4 Function Library

b. Session Key Method


For Session Key Method = 00 (MCBP), see reference [83], [84], [85] of Mark II.
For Session Key Method = 01 (VCBP), see reference [86]. [87], [88] of Mark II.
4. Action Type field defines what operation has to be done - AC verification or ARPC generation or both.
5. Generate ACs and/or ARPC over data as required by AC Generation (depending on Action Type).
For AC generation method = 00, refer AC Generation
For AC generation method = {01, 02}, refer AC Generation for VCBP
For AC generation method = 02, the final cryptogram before masking and verification will be decimalized
For ARPC generation, no decimalization and/or will be done on generated cryptogram
While calculating ARPC using the key derived in step 3 over ARPC data, if present, follow the method in
EE2018 for ARPC method {01, 02} with LUK.
6. Mask received AC with maskAC for derived CMxx.
7. Mask calculated AC with maskAC for derived CMxx.
8. Compare the masked ACs from step 5 and 6 above. If it matches, return success, else standard AC failure errors
to be published.

Note: xx in CMKxx refers to Card Key Type - CLMD, CLUMD, RPMD, RPUMD

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 591
CHAPTER 4 Function Library

VAR-KB-PIN-VER (69)
Request Length Type Description

69 1 h Function Code

PVK-Index 1 d Index of PVK

KTM-Index 1 d Index of KTM

eKTM(AS-PIN) 8 B64 PIN Block encrypted under KTM

PAN 8 h Primary Account Number

ANB 6 h Account Number Block

CHKLEN 1 h PIN Check Length (04 - 12)

Offset 6 h Offset for the PIN

Response Length Type Description

69 1 h Function Code

rc 1 h Return Code

This function verifies an AS/ANSI formatted PIN. The PIN Block must be supplied encrypted under an HSM stored
Terminal Master Key (KTM).
Note that only the first 99 KTMs may be used with this function.

PK-Index identifies the PVKn, DTn, and MINPINn appropriate to the PIN verification procedure.

AS-PIN is the AS/ANSI formatted PIN Block containing the PIN to be verified. It must be supplied encrypted
by a PIN Protect session key (PPK).

PAN the Primary Account Number used in the verification procedure. It must be padded appropriately prior
to input to this function.

ANB is the 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

CHKLEN The CHKLEN field contains the number of PIN digits to be checked and may be less than, or equal to,
the actual length of the PIN. The significant Offset digits must be supplied left aligned and right
padded in the Offset field.

Offset consists of up to 12 digits of offset data. The significant digits must be left- justified in the field.
Unused digits are ignored. If offsets are not used, the significant digits must be zeros.

The function will fail with Error Code 78 if an ISO-0 PIN block is disabled.
See IBM 3624 PIN Verification, for a more detailed overview of the PIN verification procedure.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 592
CHAPTER 4 Function Library

VCEPS-GEN-HASH-CEP (EF0F01)
Request Length Type Description

EF0F01 3 h Function Code

FM 1 h Function Modifier (FM = 00)

KMx-Spec Var K-Spec Key specifier for Master Derivation Key (KML)
(Formats: 0-3)

IDCEP 6 h Serial number of the CEP card

Hash Data Var h Data used in the calculation of HCEP

Response Length Type Description

EF0F01 3 h Function Code

rc 1 h Return Code

HCEP 10 h Leftmost 80 bits of hash result.

This function calculates RCEP , appends it to the hash data, then calculates and returns the hash result, HCEP .

Processing Steps
1. Derive the card's diversified key (KDL) using the Master Derivation Key and IDCEP , according to the method
specified in 3.5.1 of reference [12] of Mark II.
2. Calculate RCEP using KDL, according to the method specified in 3.6.1 of reference [12] of Mark II.

Note: The NETS document indicates that a OWF2(KDLcep. NTcep) is used to calculate RCEP. This differs from
the above.
3. Append RCEP to Hash Data, and use the resulting string to calculate HCEP according to the method specified in
3.6.1 of reference [12] of Mark II.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 593
CHAPTER 4 Function Library

VCEPS-GEN-SN (EF0703)
Request Length Type Description

EF0703 3 h Function Code

FM 1 h Function Modifier (FM = 00)

KMx-Spec Var K-Spec Key specifier for Master Derivation Key (KMx)
(Formats: 0-3)

Derivation Data Var h Data used in the calculation of the derived key. (0 or 2 - 6
bytes)

Session Key Data Var h Data used in the calculation of the session key. (0 or 2 - 6
bytes)

Sn Data Var h Data used in the calculation of Sn.


Must be a multiple of 8 bytes

Response Length Type Description

EF0703 3 h Function Code

rc 1 h Return Code

Sn 8 h MAC to send to CEP card

This function generates a MAC to send to the CEP card.

Processing Steps
1. Derive the diversified key using the Master Derivation Key and Derivation Data, according to the method specified
above in Verify Sn, step 1.
2. Derive the card Session Key (SK) using the diversified key and Session Key Data according to the method
specified above in Verify Sn, step 2.
3. Calculate the Sn MA, reference [12] of Mark II. Return the result in Sn.

Function usage
• The function could be used generate any Sn MAC, e.g. for testing purposes.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 594
CHAPTER 4 Function Library

VCEPS-MAC-VER-LSAM (EF0704)
Request Length Type Description

EF0704 3 h Function Code

FM 1 h Function Modifier (FM = 00)

LSAMK-Spec Var K-Spec Key specifier for LSAM (Format: 11, 13, 17,18)

eLSAMK(R1) 16 h ECB encrypted MAC key.

MAClsam 4 h MAC created by LSAM.

Data Var h Data included in MAC calculation.


Must be a multiple of 8 bytes

Response Length Type Description

EF0704 3 h Function Code

rc 1 h Return Code

This function verifies the MAC calculated by the LSAM.


The LSAM key that encrypts R1 (the MAC key) is provided in an encrypted form, encrypted by Variant 5 of KM.

Processing Steps
1. Recover the MAC key, R1.
2. Calculate a MAC for Data, according to the method specified in 5.1.3 of reference [12] of Mark II.
3. Compare the calculated MAC with MACLSAM and return the result.

Function usage
• The function can be used when function Generate LSAM Key is used to generate the LSAM key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 595
CHAPTER 4 Function Library

VCEPS-VER-S1-GEN-S2 (EF0701)
Request Length Type Description

EF0701 3 h Function Code

FM 1 h Function Modifier (FM = 00)

KMx-Spec Var K-Spec Key specifier for Master Derivation Key (KML or KMX).
(Formats: 0-3)

IDcep 6 h Serial number of the CEP card

NTcep 2 h Transaction number from the CEP card

S1 8 h MAC calculated by CEP card

S1 Data Var h Data used in the calculation of S1


Must be a multiple of 8 bytes

S2 Data Var h Data used in the calculation of S2


Must be a multiple of 8 bytes

Response Length Type Description

EF0701 3 h Function Code

rc 1 h Return Code

S2 8 h MAC to send to CEP card

This function verifies the S1 MAC produced by the CEP card and generates the S2 MAC for sending to the CEP card.

Processing Steps
1. Derive the card's diversified key (KDL or KDX) using the Master Derivation Key and IDcep, according to the method
specified in 3.5.1 of reference [12] of Mark II.
2. Derive the card Session Key (SK) using the card's diversified key and NTcep, according to the method specified in
5.1.2 of reference [12] of Mark II.
3. Calculate the S1 MAC using SK and the data provided in S1 Data, according to the method specified in 5.1.3 of
reference [12] of Mark II.
4. Compare the values of the calculated S1 and that supplied in S1. If the values are not identical, fail with the
appropriate error code.
5. Calculate the S2 MAC using SK and the data provided in S2 Data, according to the method specified in 5.1.3 of
reference [12] of Mark II. Return the result in S2.

Function usage
• The function is used for Load / Unload and Currency Exchange authorization transactions.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 596
CHAPTER 4 Function Library

VCEPS-VER-SN (EF0702)
Request Length Type Description

EF0702 3 h Function Code

FM 1 h Function Modifier (FM = 00)

KMx-Spec Var K-Spec Key specifier for Master Derivation Key (KM3L, KM3X or
KMP). (Formats: 0-3)

Derivation Data Var h Data used in the calculation of the derived key. (0 or 2 - 6
bytes)

Session Key Data Var h Data used in the calculation of the session key. (0 or 2 - 6
bytes)

Sn 8 h MAC calculated by CEP card.

Sn Data Var h Data used in the calculation of Sn


Must be a multiple of 8 bytes

Response Length Type Description

EF0702 3 h Function Code

rc 1 h Return Code

This function verifies a MAC produced by the CEP card or PSAM.

Processing Steps
1. Derive the diversified key (KD3L, KD3X, KDP, etc) using the Master Derivation Key and Derivation Data.
– To derive the left half of the diversified key, Derivation Data is left-justified in an 8-byte data Block and padded
to the right with 'F0' and sufficient '00' bytes to fill the Block. The data Block is then encrypted with the Master
Derivation Key; the result is the left half of the diversified key.
– To derive the right half of the diversified key, Derivation Data is left-justified in an 8-byte data Block and padded
to the right with '0F' and sufficient '00' bytes to fill the Block. The data Block is then encrypted with the Master
Derivation Key; the result is the right half of the diversified key.
2. If Session Key Data has a length of zero, use the diversified key directly as the Session Key (SK) otherwise derive
the SK using the diversified key and Session Key Data.
– To derive the left half of the session key, Session key Data is left-justified in an 8-byte data Block and padded
to the right with 'F0' and sufficient '00' bytes to fill the Block. The data Block is then encrypted with the
diversified key; the result is the left half of the session key.
– To derive the right half of the session key, Session Key Data is left-justified in an 8-byte data Block and padded
to the right with '0F' and sufficient '00' bytes to fill the Block. The data Block is then encrypted with the
diversified key; the result is the right half of the session key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 597
CHAPTER 4 Function Library

3. Calculate the Sn MAC using SK and the data provided in Sn Data, according to the method specified in 5.1.3 of
reference [12] of Mark II.
4. Compare the values of the calculated Sn and that supplied in Sn.

Function usage
The function may be used to verify:

S3 S4 S5 S6 S6' S6''

Note: S6'' is named Sib in the VCEPS document [14].

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 598
CHAPTER 4 Function Library

VER-KM-ENC-PIN (EE0642)
Request Length Type Description

EE0642 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPK(PIN) 8 x Encrypted PIN Block

PPK-Spec Var K-Spec Key specifier for PPK


(Formats: 0 - 3, 10, 11, 12, 13, 14, 17, 18, 20, 90)

PF 1 h PIN Block Format


(Formats: 01, 03, 08, 09, 10, 11, 13)

ANB 6 h Account Number Block

PIN-Spec Var K-Spec KM-encrypted PIN Block


(Format: 1A)

Response Length Type Description

EE0642 3 h Function Code

rc 1 h Return Code

This function verifies a transaction PIN by comparing it with a KM-encrypted reference PIN.

Notes
– The ANB field is used (if required) in recovering the transaction PIN. It is also used to recover the reference
PIN.
– The function will fail with Error Code 78 if either PIN block format ISO-3 or PIN block format indicated by PF is
disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 599
CHAPTER 4 Function Library

VERIFY-ATM-RESPONSE-DIEBOLD (EE9102)
Request Length Type Description

EE9102 3 h Function Code

FM 1 h Function Modifier (FM = 00)

KTA2 Var h PKCS#7 message

IHOST Var h Identifier of Host

rATM Var h ATM random nonce

rHOST Var h Host random nonce

PATM Var K-Spec Key specifier for ATM Public Key.


(Format: 81
Key Type: Data Signature)

Response Length Type Description

EE9102 3 h Function Code

rc 1 h Return Code

This function processes the ATM’s response (KTA2) to the download of the initial key (KTB1). It verifies the signature on
the PKCS#7 messages and compares random nonce’s and identifier provided in the function request.

Note: 2048 length public keys only.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 600
CHAPTER 4 Function Library

VERIFY-CA-PK-VISA (EE2045)
Request Length Type Description

EE2045 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Visa CA Public Key 1 h = 01: RSA


Algorithm Indicator

RID 5 h Registered Application Provider Identifier

Visa CA Public Key Index 1 h PK Index

Visa CA Public Key Var h PK Modulus


Modulus (NCA)

Visa CA Public Key Var h = 3 or 216 + 1


Exponent

Hash Result 20 h SHA-1 hash of previous four fields.

Certificate Var h The 'Self-Signed Visa CA Public Key Certificate', of length


equal to the length of the CA Public Key Modulus (NCA).

User Data Var h Data to be stored in key specifier for PK


(May be a zero length field)

Response Length Type Description

EE2045 3 h Function Code

rc 1 h Return Code

PCA-Spec Var K-Spec Key Specifier for the CA public key.


Key Type = Certificate
(Format: 81)

Certificate Data Var h The data recovered from Certificate, of length equal to the
length of the CA Public Key Modulus (NCA).

This function validates the 'Self-Signed Visa CA Public Key Certificate, as described in 3.4 of [18]. It provides the
public key for host storage, and the recovered certificate data for further processing by the host.

Function Modifier Reserved for possible future use; must be set to zero.

Visa CA Public Key Algorithm Currently specified as RSA value 01.


Indicator

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 601
CHAPTER 4 Function Library

Registered Application As in Tables 3-1 and 3-2 of Ref [17].


Provider Identifier (RID)

Visa CA Public Key Index As in Tables 3-1 and 3-2 of Ref [17].

Visa CA Public Key Modulus As in Tables 3-1 and 3-2 of Ref [17].

Visa CA Public Key Exponent As in Tables 3-1 and 3-2 of Ref [17].

Hash Result As in Tables 3-1 and 3-2 of Ref [17].

Certificate As in Tables 3-1 and 3-2 of Ref [17].

User Data Variable length user data for input to the PK/SK generation process. User data is
inserted into the clear PK and clear component of the SK. When no User data is
being supplied, this field is 1 byte in length with value of zero to represent a zero
length variable field.

Return Code Contains zero for success.

PCA-Spec Key specifier for the CA Public Key (format 81). The Key specifier describes the
complete CA PK.

Certificate Data As in table 3-10 of Ref [18].

Processing Steps
1. Validate the Visa CA Public Key, as specified in steps 1 – 4 of 3.4.4 of [18]
2. Build PCA-Spec, using Visa CA Public Key Modulus and Visa CA Public Key Exponent.
3. Provide the data block recovered from Certificate in Certificate data.

Function usage
• The function is used to validate and store a CA public key received from Visa.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 602
CHAPTER 4 Function Library

VERIFY-CA-PUBLIC-KEY-MC (EE2042)
Request Length Type Description

EE2042 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ID of Certificate Subject 5 h Certificate ID

CA Public Key Index 1 h PK Index

CA Public Key Algorithm 1 h = 01: RSA


Indicator

Leftmost Digits of CA Var h CA Public Key (PCA)


Public Key (NCA – 37)

CA Public Key Remainder 37 h PK Remainder

CA Public Key Exponent Var h = 3 or 216 + 1

CA Public Key Certificate Var h The 'Self-certified Europay-MasterCard Public Key'


(NCA)

CA Public Key Checksum Var D-Spec PK Checksum

Hash Algorithm Indicator 1 h = 01: SHA-1

User Data Var h Data to be stored in key specifier for PK


(May be a zero length field)

Response Length Type Description

EE2042 3 h Function Code

rc 1 h Return Code

Verify Flag 1 h Indicates the result

Certificate Data Var h The data recovered from CA Public Key Certificate, of
length equal to the length of the CA Public Key Modulus
(NCA).

PCA-Spec Var K-Spec Key specifier for the CA public key.


Key Type = Certificate
(Format: 81)

This function verifies the Self-certified Europay-MasterCard Public Key, as described in chapter 4 of [17]. It provides
the public key for host storage, and the recovered certificate data for further processing by the host.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 603
CHAPTER 4 Function Library

Function Modifier Reserved for possible future use; must be set to zero.

ID of Certificate Subject Specified in Tables 3-1 and 3-2 of [17].

CA Public Key Index Specified in Tables 4.1 and 7-1 of[17].

CA Public Key Algorithm As in Tables 3-1 and 3-2 of Ref [17]. Currently specified as RSA value 01.
Indicator

Leftmost Digits of CA Public Key Left-most digits of CA PK modulus. Variable length equal to (C_modLen - 32 -
CERT_ID_LEN) or modulus length.

CA Public Key Remainder Only present if CA PK (modulus length > (C_modLen - 32 - CERT_ID_LEN).
Variable length field, length is (C_modLen - 32 - CERT_ID_LEN) otherwise is
length 1 with value 0. As in Tables 3-1 and 3-2 of Ref [17].

CA Public Key Exponent As in Tables 3-1 and 3-2 of Ref [17].

CA Public Key Certificate As in Tables 3-1 and 3-2 of Ref [17].

CA Public Key Checksum As in Tables 3-1 and 3-2 of Ref [17].

Hash Algorithm Indicator EMV currently specify the Hash Algorithm as SHA-1 value 01.

User Data Variable length user data for input to the PK/SK generation process. User data is
inserted into the clear PK and clear component of the SK. When no User data is
being supplied, this field is 1 byte in length with value of zero to represent a zero
length variable field.

Certificate Data The recovered CA PK data as in Tables3.1/3.2 of Ref [17].

Processing Steps
1. Verify the 'Self-certified Europay-MasterCard Public Key', as described in chapter 4 of [17].
2. Build PCA-Spec, using CA Public Key Modulus and CA Public Key Exponent.
3. Provide the data block recovered from Certificate in Certificate Data.

Function usage
• The function is used to verify and store a CA public key received from Europay or MasterCard.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 604
CHAPTER 4 Function Library

VERIFY-CERTIFICATE (C800)
This function can be used to verify the certificates received from an ATM (for example, Diebold) and extract the public
keys from them. This function is required to support Diebold ATMs.

Request Length Type Description

C800 2 h Function Code

Msg ID 2 x Message Identifier

CertEPPv or CertEPPe Var x ATM verification or encipherment certificate

CERTICA Var x Initial Certificate Authority certificate

Response Length Type Description

C800 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

KMVAC(VATM) or Var K-Spec ATM public verification or encipherment key


KMVAC(EATM) Format 42

Each of the certificates CertEPPv , CertEPPe, and CERTICA is an X.509 certificate embedded in a PKCS #7 message.
The certificates are encoded using the Distinguished Encoding Rules (DER). CERTICA is not necessarily a root CA
certificate, and need not be self-signed. The calling application is assumed to have established a trust path from this
path to a trusted root CA certificate prior to calling function C800.
This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 605
CHAPTER 4 Function Library

VERIFY-CSC (EE0502)
Request Length Type Description

EE0502 3 h Function code

FM 1 h Function Modifier (FM = 00)

CSC Algo 1 h 00 = CSC v1.0


01 = CSC v2.0

CSCK-Spec Var K-Spec Key specifier for CSCK


(Formats: 0–3, 11, 13, 17, 18)

Expiry date/Unpredictable 2 d Any random number


Number

PAN 8 d The account block

ServiceCode 2 d Service code


Must be 0000 for CSC Algo = 00

CSC 1 h 00 = verify 3 CSC value


01 = verify 4 CSC value
02 = verify 5 CSC value

CSC Value 3 d Relevant CSC value should be sent right justified padded
with zeros on left.
5 CSC value = 0XXXXX
4 CSC value = 00XXXX
3 CSC value = 000XXX
Where, X represents digits.

Response Length Type Description

EE0502 3 h Function code

rc 1 h Return code
00 = CSC verification passed
08 = verification failure

This host function verifies the given CSC value. It derives the CSC values from Expiry date, PAN and Service Code
and verifies it with the given CSC Value. The CSC field identifies which CSC value of CSC string needs to be verified.

FM Function Modifier = 00

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 606
CHAPTER 4 Function Library

CSC Algo CSC Algorithm used to calculate CSC values


00 = CSC v1.0
01 = CSC v2.0

CSCK Spec Key Specifier for CSC Key.


Formats: 0-3, 11, 13, 17, 18

Expiry Any Random Number, as specified in Table 37 of Page 69, in American Express Hardware
Date/Unpredictable Security Module (HSM) Function Requirements.pdf , October 2010.
Number

PAN 15 digit Permanent account number. Leading nibble must be 0.

Service Code Service code to derive CSC string. Left most nibble must be 0.
The possible range is 000-999 as given in section 4.6.4 of Reference [47] and Page 3-20 of
Reference [46].
Must be 0000 in case of CSC v1.0

CSC Identify which CSC value (3 or 4 or 5) of CSC string to be verified.

CSC Value Relevant Packed CSC value (to be verified) should be sent right justified padded with zeros on
left.

Processing Steps
1. Form a 12-nibble CSC string as detailed in processing steps of function EE0501.
2. Using the CSC, find out which CSC value needs to be verified.

If CSC = 00, then verify 3 CSC of CSC string with given CSC value.

If CSC = 01, then verify 4 CSC of CSC string with given CSC value.

If CSC = 02, then verify 5 CSC of CSC string with given CSC value.
3. Return error 0x00 if verification succeeds, else return an appropriate error code.

Note: It is the application’s responsibility to provide correct Service code and there is no check
for correctness in host function.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 607
CHAPTER 4 Function Library

VERIFY-CSC-1 (0010)
This host function verifies the given CSC value.

Request Length Type Description

0010 3 h Function code

Msg Id 2 x Message Identifier

CSC Algo 1 h 00 = CSC v1.0


01 = CSC v2.0

CSCK-Spec Var K-Spec Key specifier for CSCK


(Formats: 21, 23)

Expiry date/Unpredictable 2 d Any random number


Number

PAN 8 d The account block

Service Code 2 d Service code


Must be 0000 for CSC Algo = 00

CSC 1 h 00 = verify 3 CSC value


01 = verify 4 CSC value
02 = verify 5 CSC value

CSC Value 3 d Relevant CSC value should be sent right justified padded
with zeros on left.
5 CSC value = 0XXXXX
4 CSC value = 00XXXX
3 CSC value = 000XXX
Where, X represents digits.

Response Length Type Description

0010 2 h Function code

Msg Id 2 x Message Identifier

rc 1 h Return code
00 = CSC verification passed
09 = verification failure

This host function is used for Australian Major Bank (AMB).


This host function derives the CSC values from Expiry date, PAN and Service Code and verifies it with the given CSC
Value. The CSC field identifies which CSC value of CSC string needs to be verified.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 608
CHAPTER 4 Function Library

CSC Algo CSC Algorithm used to calculate CSC values


00 = CSC v1.0
01 = CSC v2.0

CSCK Spec Key Specifier for CSC Key. Formats: 21, 23

Expiry Date / Any Random Number, as specified in Table 37 of Page 69, in American Express Hardware
Unpredictable Security Module (HSM) Function Requirements.pdf , October 2010.
Number

PAN 15 digit Permanent account number.


Leading nibble must be 0.

Service Code Service code to derive CSC string.


Left most nibble must be 0.
The possible range is 000-999 as given in section 4.6.4 of Reference [17], and Page 3-20 of
Reference [16].
Must be 0000 in case of CSC v1.0

CSC Identify which CSC value (3 or 4 or 5) of CSC string to be verified.

CSC Value Relevant Packed CSC value (to be verified) should be sent right justified padded with zeros
on left.

Processing Steps
1. Form a 12-nibble CSC string as detailed in processing steps of function EE0501.
2. Using the CSC, find out which CSC value needs to be verified.
– If CSC = 00, then verify 3 CSC of CSC string with given CSC value
– If CSC = 01, then verify 4 CSC of CSC string with given CSC value
– If CSC = 02, then verify 5 CSC of CSC string with given CSC value
3. Return error 0x00 if verification succeeds; else return an appropriate error code.

Note: It is the application’s responsibility to provide correct Service code and there is no check
for correctness in host function.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 609
CHAPTER 4 Function Library

VERIFY-DETACHED-CERT-VISA (EE2047)
Request Length Type Description

EE2047 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PCA-Spec Var K-Spec Key Specifier for the CA public key.


Key Type = Certificate
(Format: 81)

Detached Signature Var h Detached signature for Issuer Public Key, of length NCA.

Hash Data Var h Data that is hashed for inclusion in the detached signature –
concatenation of the Output Extension and the resolved IPK
Certificate.

Response Length Type Description

EE2047 3 h Function Code

rc 1 h Return Code

This function validates the Issuer Public Key Detached Signature, as described in 3.3.3.3 of [18].

Processing Steps
1. Validate the Detached Signature according to 3.3.3.3 of [18].

Function Modifier Reserved for possible future use; must be set to zero.

PCA-Spec Key specifier for the CA Public Key (Format 81). The Key specifier describes the complete
CA PK.

Detached Signature Variable length detached signature to be verified.

Hash Data Variable length hash data (SHA-1) used to verify the detached signature.

Return Code Returns the result of validation tests for the Visa Detached Signature. Contains value zero to
represent validation was successful.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 610
CHAPTER 4 Function Library

VERIFY-EPP (NDC) (C6D0)


This function verifies the signature of the Encrypting PIN pad serial number.

Request Length Type Description

C6D0 2 h Function Code

Msg ID 2 x Message Identifier

SN-EPP Var x EPP serial number

PK-NCR Var K-spec Public Key of NCR (format 41)

(SN-EPP) * SK-NCR Var x Signature of EPP serial number

Response Length Type Description

C6D0 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

This host function is used for Australian Major Bank (AMB).


This function verifies that the signature of the SN-EPP is correct. The signature conforms to RSA Laboratories
Cryptographic Token Interface Standard – PKCS #1, V2.0, using the RSASSA-PKCS1-v1_5 signature scheme.
The signature is unsigned by applying the RSAVP1 verification primitive, using public key PK-NCR.
The message to be verified by RSASSA-PKCS1-v1_5-VERIFY is the EPP serial number SN-EPP, as supplied in the
request.
The EPP serial number is encoded with the EMSA-PKCS-v1_5 encoding operation, applying the SHA-1 hash function,
before comparison with the unsigned signature.
Example:
The following example is the hexadecimal representation of an 8-byte SN-EPP, 00001026:
Table 1: As supplied in the request

SN-EPP 3030303031303236

Table 2: As presented for hashing

SN-EPP 3030303031303236

Note: The SHA-1 hash of the above is


D2D7E5AA22FE05F6C84DD32F6C9A0AE171AD4B9E.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 611
CHAPTER 4 Function Library

Table 3: As presented for comparison with the unsigned signature

padding 0001FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00

Digest info tag 3021300906052B0E03021A05000414

SHA-1 hash D2D7E5AA22FE05F6C84DD32F6C9A0AE171AD4B9E

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 612
CHAPTER 4 Function Library

VERIFY-ICC-CERTIFICATE (EE2049)
Request Length Type Description

EE2049 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PI-Spec Var K-Spec Key Specifier for Issuer Public Key.


Key Type = Certificate, Data Signature
(Formats: 0-3, 81)

ICC Public Key Certificate Var h Digital signature for the public key certificate. The field
length is equal to the length NI of the modulus of PI

ICC Public Key Var h As specified in Table 7 in [5].


Remainder

ICC Public Key Exponent Var h = 3 or 216 + 1. As specified in Table 7 in [5].

Static Data to be Var h As specified in Table 7 in [5].


Authenticated

Response Length Type Description

EE2049 3 h Function Code

rc 1 h Return Code

Pxx -Spec Var K-Spec Key Specifier for PIC or PPE.


Key Type = Data Signature, PIN Encryption
(Format: 81)

This function verifies an ICC Certificate for PIC or PPE. It also returns the public key for subsequent use in verifying a
DDA signature or encrypting a PIN.

Function Modifier Reserved for possible future use; must be set to zero.

PI-Spec Key specifier for the Issuer Public Key (Formats 0-3, 81).

ICC Public Key Signature for the ICC PK certificate.


Certificate

ICC Public Key Variable length right-most digits of the ICC PK. Only present when (ICC_modLen >
Remainder (ISS_modLen - 42)). Length equals (ICC_modLen - (ISS_ModLen + 42)) or 1 (value=0,
when no remainder present).

ICC Public Key Exponent Variable length ICC PK exponent Valid values are value = 3 (length = 1) and value =
216+1 (length = 3).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 613
CHAPTER 4 Function Library

Static Data to be Variable length static data to be authenticated.


Authenticated

User Data Variable length user data for input to the PK/SK generation process. User data is inserted
into the clear PK and clear component of the SK. When no User data is being supplied,
this field is 1 byte in length with value of zero to represent a zero length variable field.

Return Code Contains zero for success.

Pxx-Spec Key specifier for the return Public Key (Format 81). The Key specifier describes the
complete PK.

Processing Steps
1. Validate the ICC Public Key Certificate according to Table 7 in [5].
2. Build the Pxx -Spec

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 614
CHAPTER 4 Function Library

VERIFY-ICC-DYNAMIC-DATA (EE204D)
Request Length Type Description

EE204D 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PIC-Spec Var K-Spec Key Specifier for ICC Public Key.


Key Type = Data Signature
(Format: 81)

Terminal Dynamic Data Var h As specified in Table 11 in [5].

Signed Dynamic Var h Digital signature for the Dynamic Application Data. The field
Application Data length must be equal to the length NIC of the modulus of
PIC.

Response Length Type Description

EE204D 3 h Function Code

rc 1 h Return Code

Verify Flag 1 h = 00: Signature verification passed;


= 01: Length of Signed Static Application Data ≠ NI.
= 02: Invalid Recovered Data Header or Recovered Data
Trailer.
= 03: Invalid Signed Data Format.
= 04: Invalid Hash Algorithm Indicator.
= 05: Calculated hash result ≠ recovered Hash Result.
= 06: Modulus Match ≠ recovered Modulus Result.
= 07: Certificate ID Error
= 08: PK Algorithm ID Error
= 09: Hash Not Verified Error

Signed Data Format 1 h Data fields recovered from Signed Dynamic Application
Data - as specified in Table 13 in [5].
Hash Algorithm Indicator 1 h

ICC Dynamic Data Length 1 h

ICC Dynamic Data LDD h

This function verifies an ICC's Dynamic Application Data and the associated digital signature, using an ICC Public
Key. Data recovered from the signature block is returned in the response.

Function Modifier Reserved for possible future use; must be set to zero.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 615
CHAPTER 4 Function Library

PIC-Spec Key specifier for the ICC Public Key (Format 81). The Key specifier describes the
complete ICC PK.

Terminal Dynamic Data Variable length terminal dynamic data as described in Table 11 in [5].

Signed Dynamic Variable length signed dynamic application data.


Application Data

Return Code Contains zero for success.

Verify Flag 1 byte length to represent result of validation test on the recovered signed application
data.

Signed Data Format Recovered from the signed data and PK values. EMV currently specify the signed data
format value 05.

Hash Algorithm Indicator Recovered from the signed data and PK values. EMV currently specify the Hash
Algorithm as SHA-1 value 01.

ICC Dynamic Data Length of the built return ICC dynamic data.
Length

ICC Dynamic Data The return built dynamic data.

Processing Steps
1. Obtain the Recovered Data, using the Signed Dynamic Application Data with PIC and its associated
asymmetric algorithm. [Currently, RSA is the only approved asymmetric algorithm.]
2. Check the values of the Recovered Data Header, Recovered Data Trailer, Signed Data Format and Hash
Algorithm Indicator.
3. Build the Dynamic Application Data using the Terminal Dynamic Data request field and fields extracted from the
Recovered Data.
4. Calculate the hash result for the Dynamic Application Data using the hash algorithm indicated by Hash Algorithm
Indicator in the Recovered Data. [Currently, SHA-1 is the only approved hash algorithm, and is indicated by a
value of hex '01'.]
5. Compare the calculated hash result with the Hash Result field in the Recovered Data. If the two hash results are
identical, then the signature is verified.

Function usage
• Verification of the signature (i.e. data authentication) is generally performed by the terminal. This function may be
used by a card issuer wishing to test a card prior to issue.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 616
CHAPTER 4 Function Library

VERIFY-ICC-STATIC-DATA (EE204C)
Request Length Type Description

EE204C 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PI-Spec Var K-Spec Key Specifier for Issuer Public Key.


Key Type = Data Signature
(Formats: 0-3, 81)

Static Data to be Var h As specified in Table 2 in [5].


Authenticated

Signed Static Application Var h Digital signature for the Static Application Data. The field
Data length must be equal to the length NI of the modulus of PI

Response Length Type Description

EE204C 3 h Function Code

rc 1 h Return Code

Verify Flag 1 h = 00: Signature verification successful.


= 01: Length of Signed Static Application Data ≠ NI.
= 02: Invalid Recovered Data Header or Recovered Data
Trailer.
= 03: Invalid Signed Data Format.
= 04: Invalid Hash Algorithm Indicator.
= 05: Calculated hash result ≠ recovered Hash Result.
= 06: Modulus Match ≠ recovered Modulus Result.
= 07: Certificate ID Error
= 08: PK Algorithm ID Error
= 09: Hash Not Verified Error

Signed Data Format 1 h Data fields recovered from Signed Static Application Data -
as specified in Table 5 in [5]. If there is a verification failure
Hash Algorithm Indicator 1 h these 3 fields are returned zero filled.
Data Authentication Code 2 h

This function verifies an ICC's Static Data and the associated digital signature, using an Issuer Public Key. Data
recovered from the signature block is returned in the response.

Function Modifier Reserved for possible future use; must be set to zero.

PI-Spec Key specifier for the Issuer Public Key (Formats 0-3, 81).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 617
CHAPTER 4 Function Library

Static Data to be Variable length static data to be authenticated. Used to build the static application
Authenticated data.

Signed Static Application Variable length signed static application data. Used to validate the recovered
Data signature from the Issuer PK.

Return Code Contains zero for success.

Verify Flag 1 byte length to represent result of validation test on the recovered signed application
data.

Signed Data Format Recovered from the signed data and PK values. EMV currently specify the signed
data format value 03.

Hash Algorithm Indicator Recovered from the signed data and PK values. EMV currently specify the Hash
Algorithm as SHA-1 value 01.

Data Authentication Code Recovered from the signed data and PK values.

Processing Steps
1. Obtain the Recovered Data, using the Signed Static Application Data with PI and its associated asymmetric
algorithm. [Currently, RSA is the only approved asymmetric algorithm.]
2. Check the values of the Recovered Data Header, Recovered Data Trailer, Signed Data Format and Hash
Algorithm Indicator.
3. Build the Static Application Data using the Static Data to be Authenticated request field and fields extracted from
the Recovered Data.
4. Calculate the hash result for the Static Application Data using the hash algorithm indicated by Hash Algorithm
Indicator in the Recovered Data. [Currently, SHA-1 is the only approved hash algorithm, and is indicated by a value
of hex '01'.]
5. Compare the calculated hash result with the Hash Result field in the Recovered Data. If the two hash results are
identical, then the signature is verified.

Function usage
• Verification of the signature (i.e. data authentication) is generally performed by the terminal. This function may be
used by a card issuer wishing to test a card prior to issue.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 618
CHAPTER 4 Function Library

VERIFY-MAC-NDC-ATM (5630)
This function compares a reference MAC contained in the request message with the MAC calculated on the data
contained in the request message. The result of the comparison is reflected in the return code in the response message.
The MAC shall be computed in accordance with the NDC+ PRM (PRM 5.1-9).

Request Length Type Description

5630 2 h Function Code

Msg ID 2 x Message Identifier

eKMv48(KMACr) Var K-Spec MAC Receive Key (format 21)

MACdata Var x MAC received from remote location.


Max. value = 8

Data Var x Data

Response Length Type Description

5630 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 619
CHAPTER 4 Function Library

VERIFY-ISSUER-PK-CERT-MC (EE2043)
Request Length Type Description

EE2043 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PCA-Spec Var K-Spec Key Specifier for the CA public key.


Key Type = Certificate
(Format: 81)

PI-Spec Var K-Spec Key Specifier for the Issuer public key.
Key Type = Certificate, Data Signature
(Formats: 0-3, 81)

Issuer Public Key Var h Concatenation of leftmost digits and remainder.


Remainder

Issuer Public Key Var h = 3 or 216 + 1


Exponent

Issuer Public Key Var h The 'Self-certified Europay-MasterCard Public Key', of


Certificate length equal to the length of the CA Public Key (NCA).

Response Length Type Description

EE2043 3 h Function Code

rc 1 h Return Code

Verify Flag 1 h 00 = Verified


01 = Verification Failure

Certificate Data Var h The data recovered from Certificate, of length equal to the
length of the CA Public Key Modulus (NCA).

This function verifies the signature, form, and content of an Issuer Public Key Certificate.

Function Modifier Reserved for possible future use; must be set to zero.

PCA-Spec Key specifier for the CA Public Key (Format 81). The Key specifier describes the complete CA
PK.

PI-Spec Key specifier for the Issuer Public Key (Formats 0-3, 81). The Key specifier in formats 0 - 3
describes the location of the key to be loaded from the ESM. The Key specifier in format 81
describes the complete Issuer PK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 620
CHAPTER 4 Function Library

Issuer Public Key Used to validate the recovered certificate data from the CA PK.
Remainder

Issuer Public Key Used to validate the recovered certificate data from the CA PK.
Exponent

Issuer Public Key As in tables Table 3.1/3.2 of Ref [17].


Certificate

Return Code Contains zero for success.

Verify Flag 1 byte representing the result of validation tests on the certificate. Value 1 when validation
failed, otherwise value 0.

Certificate Data Variable length certificate data recovered from the CA PK.

Processing Steps
1. Validate the certificate and recover the Issuer Public Key.
2. Provide the recovered certificate data block.

Function usage
• The Issuer Public Key Certificate is stored for subsequent transfer to an ICC.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 621
CHAPTER 4 Function Library

VERIFY-ISSUER-PK-CERT-VISA (EE2046)
Request Length Type Description

EE2046 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PCA-Spec Var K-Spec Key Specifier for CA Public Key


Key Type = Certificate
(Format: 81).

PI-Spec Var K-Spec Key Specifier for Issuer Public Key


Key Type = Certificate, Data Signature
(Formats 0–3, 81).

IPK Modulus Remainder Var h Length = max (0, NI-NCA+36)

IPK Exponent Var h Issuer PK Exponent

CERI Var h Issuer Public Key Certificate, of length NCA.

Response Length Type Description

EE2046 3 h Function Code

rc 1 h Return Code

Verify Flag 1 h 00 = Verified


01 = Verification Failure

Certificate Data Var h Recovered certificate data, of length NCA.

This function verifies the signature, form, and content of an Issuer Public Key Certificate (CERI). It provides the
recovered certificate data for any further host checking.

Function Modifier Reserved for possible future use; must be set to zero.

PCA-Spec Key specifier for the CA Public Key (Format 81). The Key specifier describes the complete CA
PK.

PI-Spec Key specifier for the Issuer Public Key (Formats 0-3, 81). The Key specifier in formats 0 - 3
describes the location of the key to be loaded from the ESM. The Key specifier in format 81
describes the complete Issuer PK.

IPK Modulus 36 least significant bytes of the Issuer PK modulus.


Remainder

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 622
CHAPTER 4 Function Library

IPK Exponent Variable length field. Valid values are value = 3 (length = 1) and value
= 216+1 (length = 3).

CERI Variable length field Issuer PK certificate.

Return Code Contains zero for success.

Verify Flag 1 byte representing the result of validation tests on the certificate. Value 1 when validation
failed, otherwise value 0.

Certificate Data Variable length certificate data recovered from the CA PK.

Processing Steps
1. Validate the certificate and recover the Issuer Public Key, as specified in 5.3 of [5], and provide the result in Verify
Flag.
2. Provide the recovered certificate data block in Certificate Data.

Function usage
• The Issuer Public Key Certificate is stored for subsequent transfer to an ICC.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 623
CHAPTER 4 Function Library

VERIFY-SIGNED-DATA (EE9006)
Request Length Type Description

EE9006 3 h Function Code

FM 1 h Function Modifier (FM = 00)

PK Var K-Spec Key specifier for Public Key.


(Format: 81
Key Type: Data Signature)

Signature Algorithm 1 h 01 = RSASSA-PKCS1-v1.5

Hash Function 1 h 00 = None.


01 = SHA-1
02 = MD5
03 = SHA-224
04 = SHA-256
05 = SHA-384
06 = SHA-512

Data Var h Data used for signature

sSK(Data) or sSK(h Var h Signature


(Data))

Response Length Type Description

EE9006 3 h Function Code

rc 1 h Return Code

This function verifies the signature on a signed message.


If 0 is given as hash function, data must be already hashed and formatted into a valid ASN.1 DER-Encoded DigestInfo
structure.

Function usage (in context of Remote ATM Initialization)


NCR

• The function may be used to verify that the received signed public key PK-HSM + (PK-HSM)*SK-NCR
corresponds with the public key sent to NCR.
• The function may be used to verify the signed serial number of an EPP: SN-EPP + (SN-EPP)*SK-NCR.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 624
CHAPTER 4 Function Library

VERIFY-TOKEN-A2 (C860)
This function verifies the key token A2 by verifying the signature with the ATM’s public verification key and checking
the contents of the token. This function is required to support Remote Key transport on Diebold ATMs.

Request Length Type Description

C860 2 h Function Code

Msg ID 2 x Message Identifier

KTA2 Var x Key token A2 received from ATM

IHOST Var x Host Identifier

rATM Var x Random number sent by ATM in token A1

rHOST Var x Random number put in token B1

KMVAC(VATM) Var K-spec ATM public verification key (format 42)

Response Length Type Description

C860 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

DEA2 keys must have a 256 byte modulus length and a public key exponent value of 0x10001.
This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 625
CHAPTER 4 Function Library

VFPE-DECRYPT (EE080B)
This function is used to decrypt data in a format preserving way. This is meant to support P2P program.

Request Length Type Description

EE080B 3 h Function Code

FM 1 h Function Modifier = 00

Data Element Type 1 h = 00 (binary data)

eDPK(Data) Var h Data to be deciphered

Base Number 2 h Base of the number system {2-256}

Algorithm 1 h 01 = TDES

Cipher Mode 1 h 02 = VFPE

Counter Var h Counter value


8 byte for TDES; leftmost 7 bits must be zero

Counter Block length 1 h Counter Block length in digits

DPK-Spec Var K-Spec Key specifier for DPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 20)

Response Length Type Description

EE080B 3 h Function Code

rc 1 h Return Code

Data Var h Plain Text data in the format specified by Data Element
Type

Processing Steps
1. Extract the supplied DPK
2. For Data Element Type = 00, convert each byte of Data as unsigned integer (as a byte).
3. Check for input alphabet numbers with base number. The alphabet number should be in the range of 0 to 2^n-1.
4. Decrypt processed data with VFPE Algorithm, as described in reference [89] of Mark II, using the calculated
transaction specific data encryption key, counter, counter block length and base number.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 626
CHAPTER 4 Function Library

VFPE-ENCRYPT (EE080A)
This function is used to encrypt data in a format preserving way. This is meant to support P2P program

Request Length Type Description

EE080A 3 h Function Code

FM 1 h Function Modifier = 00

Data Element Type 1 h = 00 (binary data)

Clear Data Var h Data to be enciphered

Base Number 2 h Base of the number system for clear data.


Range = {2,256}

Algorithm 1 h 01 = TDES

Cipher Mode 1 h 02 = VFPE

Counter Var h Counter value


8 byte for TDES; leftmost 7 bits must be zero

Counter Block length 1 h Counter Block length in digits

DPK-Spec Var K-Spec Key specifier for DPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 20)

Response Length Type Description

EE080A 3 h Function Code

rc 1 h Return Code

eDPK(Data) Var h Cipher-text

Processing Steps
1. Extract the supplied DPK
2. For Data Element Type = 00, convert each byte of Data as unsigned integer (as a byte).
3. Check for input alphabet numbers with base number. The alphabet number should be in the range of 0 to 2^n-1.
4. Encrypt processed data with VFPE Algorithm, as described in reference [89] of Mark II, using the extracted data
encryption key, counter, counter block length and base number.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 627
CHAPTER 4 Function Library

VISA-RECEIVE (4501)
This function deciphers a set of double length session keys received, from a Visa Interchange, enciphered under a
KEK, and re-enciphers them under the current Domain Master Key.

Request Length Type Description

4501 2 h Function Code

Msg ID 2 x Message Identifier

eKMV84(KEKr) Var K-spec Cross Domain Receive Key (format 21)

eKEKr(IWK) 128 B128 Received Session Keys, ECB enciphered by KEKr

eKEKr(AWK) 128 B128 Received Session Keys, ECB enciphered by KEKr

Response Length Type Description

4501 2 h Function Code

2 x Message Identifier

rc 1 x Return Code

eKMV42(KPEr) Var K-spec Enciphered IWK (format 21)

eKMV28(KPEs) Var K-spec Enciphered AWK (format 21)

Note:
- This function supports the Visa Dynamic Key Exchange protocol.
- Enciphered session keys input to the function are ECB enciphered by the KEKr.
- The translated keys are returned CBC enciphered under the Domain Master Key for
subsequent use with PINBLOCKTRANS-6.3 to 6.3 (AWK) and PINVERIFY-VISA (IWK).

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 628
CHAPTER 4 Function Library

VISA-RECEIVE-AWK (4504)
This function deciphers a double-length Acquirer Working Key received from a Visa Interchange, enciphered under an
Acquirer Dynamic Key Exchange Key, and re-enciphers it under the current Domain Master Key.

Request Length Type Description

4504 2 h Function Code

Msg ID 2 x Message Identifier

eKMv82(AKEK) Var K-Spec Acquirer Dynamic Key Exchange Key (Format: 21)

eAKEK(AWK) 16 B128 Received Acquirer Working Key, ECB enciphered by AKEK

Response Length Type Description

4504 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKMv28(AWK) Var K-Spec Enciphered Acquirer Working Key


(Format: 21)

Note:
- This function supports the Visa Dynamic Key Exchange protocol.
- The enciphered session key input to the function is ECB-enciphered by the AKEK, with no
variant.
- The translated key is returned CBC-enciphered under the KPEs variant of the Domain Master
Key, for subsequent use with PINBLOCKTRANS-6.3 TO 6.3.
- This function is provided as an alternative to VISA-REC (4501), for use when it is desired to
enforce key separation between the IWK and the AWK.
- The AKEK has previously been entered at the SCM console by combining the three
components of a Visa ZCMK (Zone Control Master Key) with the variant value
X’08000000000000000800000000000000’, and saving it encrypted under the KEKs variant of
the Domain Master Key.
- For key separation, the AKEK must have a different value from the IKEK used with VISA-
REC-IWK (4503). Institutions which are Visa acquirers and also Visa issuers will need to
establish separate ZCMKs with Visa.

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 629
CHAPTER 4 Function Library

VISA-RECEIVE-IWK (4503)
This function deciphers a double-length Issuer Working Key received from a Visa Interchange, enciphered under an
Issuer Dynamic Key Exchange Key, and re-enciphers it under the current Domain Master Key.

Request Length Type Description

4503 2 h Function Code

Msg ID 2 x Message Identifier

eKMv84(IKEK) Var K-Spec Issuer Dynamic Exchange Key (Format: 21)

eIKEK(IWK) 16 B128 Received Issuer Working Key, ECB enciphered by IKEK

Response Length Type Description

4503 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 x Return Code

eKMv42(IWK) Var K-Spec Enciphered Issuer Working Key


(Format: 21)

Note:
- This function supports the Visa Dynamic Key Exchange protocol.
- The enciphered session key input to the function is ECB-enciphered by the IKEK, with no
variant.
- The translated key is returned CBC-enciphered under the KPEr variant of the Domain Master
Key, for subsequent use with PINBLOCKTRANS-6.3 to 6.3 or PINVERIFY-VISA.
- This function is provided as an alternative to VISA-REC (4501), for use when it is desired to
enforce key separation between the IWK and the AWK.
- The IKEK has previously been entered at the SCM console by combining the three
components of a Visa ZCMK (Zone Control Master Key) with the variant value
X’08000000000000000800000000000000’, and saving it encrypted under the KEKr variant of
the Domain Master Key.
- For key separation, the IKEK must have a different value from the AKEK used with VISA-
REC-AWK (4504). Institutions that are Visa acquirers and also Visa issuers will need to
establish separate ZCMKs with Visa.

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 630
CHAPTER 4 Function Library

WEB-SERVICE-MESSAGE (EE305B)
This function is used for both encryption and authentication for sending message as well as verification and decryption
of received message.

Request Length Type Description

EE305B 3 h Function Code

FM 1 h Function Modifier = 00

Key Category 1 h 00 = MKDK (Mobile Master Keys)


01 = DPK/MPK (Mobile Session Keys)

eKMv0(DPK) or Var K-Spec Encrypted DPK


eKM57(MKDK1) Format 1C (only AES)

eKMv2(MPK) or Var K-Spec Encrypted MPK


eKM57(MKDK2) Format 1C (only AES)

Padding Mode 1 h 02 = None

SV 16 h Starting value for CTR mode encryption

Method 1 h 0xXY
X = Encryption method
Y = Authentication method
X:
0 = Counter
Y:
0: MAC Algorithm 1 in ISO/IEC 9797-1 with padding method
2
00 = Refer Algorithm for MCBP v1.0

MAC Length 1 h 4-16 bytes

Operation Type 1 h 00 = Send Message


01 = Receive Message

Following fields to be present if Operation Type = 00

ClrMessage Var h First part of message in clear text. Can be zero length field.

EncMessage Var h Second part of the message, encrypted under the KTK or
DPK.
Can be zero length field.

Key Type 1 h 00 = DPK


35 = KTK
48 = CCMK (to support DC File)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 631
CHAPTER 4 Function Library

Request Length Type Description

Key Details Var h Key details to decrypt encrypted data. See Key Details.

Following Fields to be present if Operation Type = 01

WS Message Var h Encrypted and authenticated received message

Response Length Type Description

EE305B 3 h Function Code

rc 1 h Return Code

Message Var h If Operation type = 00, this is encrypted and authenticated


Web Service message (under the Mobile Session Keys
(DPK and MPK))
If Operation Type = 01, this is a decrypted message.

Encrypted message key details value for defined values of key type

Key Type Value = 00

Field Length Type Description

DPK-Spec Var K-Spec Key Spec for DPK


Formats: 0-3, 11, 12, 13, 14, 17, 18, 1C
(In case of format 17, 18, valid values for DPK are:
Key Length - Double length, Triple length
Algorithm - T)

Decryption Mode 1 h Mode used to decrypt the data


0 = ECB
1 = CBC
2 = CTR

IV/SV Decryption Var h In case of ECB, this must be zero length field.
In CBC, this is IV
In CTR, this is SV

Padding Mode Dec 1 h 0 = RFU


1 = Always
(Refer Padding Mode described in reference [83],
[84], [85] of Mark II)
2 = None

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 632
CHAPTER 4 Function Library

Key Type Value = 35*

Field Length Type Description

KTK-Spec Var K-Spec Key Spec for KTK


Formats: 0-3, 11, 12, 13, 14, 17, 18,

Decryption Mode 1 h Mode used to decrypt the data


0 = ECB
1 = CBC

IV Var h In case of ECB, this must be zero length field.


In CBC this is IV

Padding Mode 1 h 0 = RFU


1 = Always
(Refer Padding Mode described in reference [83],
[84], [85] of Mark II)
2 = None

*In case of KTK decrypted key length must be {8,16,24} bytes

Key Type Value = 48*

Field Length Type Description

CCMK-Spec Var K-Spec Key Spec for CCMK


Formats: 0-3, 1C

Decryption Mode 1 h Mode used to decrypt the data


0 = ECB
1 = CBC
2 = CTR

IV/SV Decryption Var h In case of ECB, this must be zero length field.
In CBC this is IV
In CTR this is SV
IV/SV must be 16 bytes in length

Padding Mode 1 h 0 = RFU


1 = Always
(Refer Padding Mode described in reference [83],
[84], [85] of Mark II)
2 = None
(For AES CTR Mode, Padding Mode must be 2)

*In case of CCMK, there is no restriction on decrypted data length.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 633
CHAPTER 4 Function Library

Processing Steps
1. Read Key Category to identify if MKDK1/MKDK2 or MPK/DPK to be extracted.
2. Decrypt the identified key.
3. Check for Operation Type.
4. If Operation Type = 1, go to step 5, else step 7
5. Pass SV, Method, Keys and WSMessage for receiving data from the Mobile Payment Application, as described in
reference [83], [84], [85] of Mark II.
6. Publish the decrypted message and exit.
7. Decrypt encrypted message using Key type and Key details.
8. Concatenate clear message || decrypted message.
9. Process algorithm for protecting data sent to mobile payment, as defined in reference [83], [84], [85] of Mark II.
10. Return encrypted Message.

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 634
CHAPTER 4 Function Library

WRITE-USER-STORE-DATA (EE4102)
Request Length Type Description

EE4102 3 h Function Code

FM 1 h Function Modifier

Key Type 1 d Type of stored key

i Var K-spec Index of location in User Store.


(Formats: 4–7)

Data Var h User data

Response Length Type Description

EE4102 3 h Function Code

rc 1 h Return Code

This function stores the variable-length data at the specified location. Writing of a zero-length byte-string can be used to
delete an entry.

Note: The write operation is destructive and overwrites any previous contents of an entry
without any warning or notification.

See also

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 635
CHAPTER 4 Function Library

WRITE-USER-STORE-KEY (EE4100)
Request Length Type Description

EE4100 3 h Function Code

FM 1 h Function Modifier

Key Type 1 d Type of key to be stored.

K Var K-spec Key to be stored.


(Formats: 11, 12, 13, 14)

i Var K-spec Index of location in User Store.


(Formats: 4–7)

KVC 3 h Key Verification Code

Response Length Type Description

EE4100 3 h Function Code

rc 1 h Return Code

This function stores a KM-encrypted key at the specified location. Although, the key specifier is stored as provided
initially, the encrypted key is decrypted and the KVC of the key is checked. If the check fails, then an error is displayed
and the key is not stored.

Note: The write operation is destructive and overwrites any previous contents of an entry
without any warning or notification.

See also

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 636
CHAPTER 4 Function Library

ZKA-CALC-PVN (EE0612)
Request Length Type Description

EE0612 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPK(PIN) 8 X Encrypted PIN Block

PPK-Spec Var K-Spec Key specifier for PPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 90)

PF 1 h PIN Block Format


(Formats: 01, 03, 08, 09, 10, 11, 13)

ANB 6 D Account Number Block

*KKBLZ-Spec Var K-Spec Key specifier for ZKA BLZ


(Formats: 0-3, 11, 13, 17, 18, 91)

Account Number 5 D 10-digit Account Number

CSN 1 D Card Sequence Number 00-09

Expiration Year 1 D Last digit only (00 - 09)

PVN Type 1 h PIN Verification Number Type = 00 or 04

Response Length Type Description

EE0612 3 h Function Code

rc 1 h Return Code

PVN Var h PIN Verification Number

PINLEN 1 h PIN Length

This function calculates the two PVNs for a PIN and also provides the length of the PIN. The PIN is supplied in an
encrypted form, using any of the standard PIN Block formats.

FM = 00. Must be set to zero.

ePPK(PIN Is the input formatted PIN Block containing the PIN to be verified. It must be supplied encrypted by
a PIN Protect session key (PPK).

PPK-spec Can be any valid key specifier for a PPK. Consequently, the function supports an encrypted PIN
Block encrypted using a single-length or double-length or triple-length, HSM Mark II-stored or host-
stored key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 637
CHAPTER 4 Function Library

PF Specifies the format of the supplied PIN Block, as defined for the standard PIN Translate function.
(includes formats: 1, 3, 8, 9, 10, 11 and 13).

ANB Account Number Block, which is the rightmost 12 digits of the Primary Account Number (PAN),
excluding the check digit.

*KKBLZ-spec Can be any valid key specifier for a *KKBLZ. Consequently, the function supports an encrypted
PIN Block encrypted using a single-length HSM Mark II-stored or double-length, HSM Mark II-
stored or double length host-stored key.

Account No. Is a 10 digit Account Number.

CSN Is the Card Sequence Number.

Expiration Year Is the last digit of the expiry year of the card.

PVN Type 0 = Complete value of X (undecimalized) in PVN.


4 = leftmost 4 digits of decimalize(X) packed in 2 bytes in PVN.

PVN Is the returned PIN Verification Number, used to verify the user’s PIN.

PINLEN Is the returned length of the encrypted PIN.

The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 638
CHAPTER 4 Function Library

ZKA-IMPORT-MK (EE0210)
Request Length Type Description

EE0210 3 h Function Code

FM 1 h Function Modifier (FM = x0 or x1)

e*KTK(K) 16 h Encrypted Key


or Or Or
e*KTK(KB) Var Encrypted Key in TR-31 Key Block format

*KTK-Spec Var K-Spec Key specifier for KTK


(Formats: 0-3)

Encryption Mode 1 h 00 = ECB


(of e*KTK(K)) 1 h 01 = CBC
Key Type 10 = *KGK
11 = *KKBLZ
12 = MK

ICM 1 h 00 = No check
01 = Standard KVC
02 = MDC-2

ICV Var h Leftmost 6 digits of eMK(0)


16-byte MDC-2 hash

Response Length Type Description

EE0210 3 h Function Code

rc 1 h Return Code

K-Spec Var K-Spec Key specifier containing eKMx(K)


Formats: (11, 13, 17 ,18)

This function translates an ECB- or CBC-encrypted MK to encryption by variant 18 of the Domain Master Key for host
storage. It optionally performs an integrity check on the clear MK using the specified method. If the integrity check fails,
a return code of 08 results (and the key is not re-encrypted).

NOTES
– The key specifier 13 under the Response, are generated when using the Legacy option.
– The key specifiers 11, 13 under the Response, are generated based on the chosen operation on console and
FM. See, section Function Modifier Values.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 639
CHAPTER 4 Function Library

FM = x0
The Host Key Protection using Function Modifier can be in the range of x0, where x= 0 , 1, or 2.

e*KTK(K) Is the supplied key encrypted by a Key Transport Key (*KTK).

*KTK-spec Supports only double-length HSM Mark II-stored keys. (Formats: 0-3)

Encryption Mode Indicates the encryption setting used for the *KTK
00 = ECB Encryption Mode, and
01 = CBC Encryption Mode.

Key Type Indicates the Key Type and KM variant used to encrypt for Host storage.

ICM The Integrity Check Method - additional integrity check methods will be added later.

ICV The Integrity Check Value - This value is set to ‘00’ if the ICM is zero.

• FM = x1 input Key in TR-31 Key block format.


• If FM=x1 Encryption Mode field will be ignored and should be set to 00.
• Key Type field must be matched to correct Key Usage in TR-31 key block key. Following Table described Key
Type and valid Key usage and algorithms.

Key Type Key Usage Algorithms

10 ‘B0’ ‘T’

11 ‘V0’

12 ‘K0’

Note: There is no appropriate key usage in TR-31 draft that matches KGK. KGK is used for key
derivation therefore key usage B0 will be used for KGK.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 640
CHAPTER 4 Function Library

ZKA-MAC-GEN (EE0710)
Request Length Type Description

EE0710 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Alg 1 h Algorithm Qualifier:


00 = Retail MAC (ISO 9807) method
01 = Triple-DES CBC method

MAClen 1 h MAC Length 1 – 8 Bytes

ICD 8 h Input Chaining Data

MK-Spec Var K-Spec Key Specifier for ZKA Master Key


(Format: 11, 13, 17, 18, 93*)

Data Var h Data to be MACed


Must be a multiple of 8 bytes.

c 2 h Position in DATA where RND is inserted

Response Length Type Description

EE0710 3 h Function Code

rc 1 h Return Code

MAC Var h Message Authentication Code

RND 16 h Random Number (encrypted session key)

*When using MK-Spec format 93, ignore the RND field.

This function generates a random encrypted MAC key, RND, and uses the clear MAC key to generate a MAC for the
provided data. The value of RND may be inserted in the data prior to calculating the MAC.

FM = 00. Must be set to zero

ALG Specifies the MACing algorithm to use


For single-length MPK – this field must be zero
For double-length MPK
00 - ISO 9807 method
01 - triple-DES CBC method

MAClength Specifies the length of the output MAC.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 641
CHAPTER 4 Function Library

ICD Input Chaining Data, used for long message feedback.

MK-spec A key Specifier incorporating a ZKA Master Key.

Data The data to be MACed. Must be a multiple of 8 bytes.

C Offset used to insert RND into Data. If zero, do not insert RND, else insert RND at specified offset,
(1 indicates insert at leftmost byte of Data).

Note: ICD will normally be set equal to zero.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 642
CHAPTER 4 Function Library

ZKA-MAC-GEN-1 (EE0711)
Request Length Type Description

EE0711 3 h Function Code

FM 1 h Function Modifier (FM = 00)

Alg 1 h Algorithm Qualifier

MAClen 1 h MAC Length 1 – 8 Bytes

ICD 8 h Input Chaining Data

MK2-Spec-1 Var K-Spec Key Specifier for ZKA MK2


(Format: 90, 93)*
VerNo / GenNo / ExpDate = FFFF9999

Data Var h Data to be MAC’d

Offset1 2 h Position in Data where RND replaces Data.

Offset2 2 h Position in Data where VerNo replaces Data.

Offset3 2 h Position in Data where GenNo replaces Data.

Response Length Type Description

EE0711 3 h Function Code

rc 1 h Return Code

MAC Var h Message Authentication Code

RND 16 h Random No. (encrypted session key)

MK2-Spec-2 Var K-Spec Key Specifier for ZKA MK2


(Format: 92)

* When using MK2-spec-1 format 90/format93, ignore the RND field.

This function generates a random encrypted MAC key, RND, and uses the clear MAC key to generate a MAC for the
provided data. The values of RND, Version Number and Generation Number may be inserted in the data prior to
calculating the MAC.

FM = 00. Must be set to zero.

Alg Specifies the MACing algorithm to use.


00 - Retail MAC (ISO 9807) method
01 - triple-DES CBC method

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 643
CHAPTER 4 Function Library

MAClength Specifies the length of the output MAC

MK2-Spec A key specifier for the Master Key.

Data The data to be MAC’d. Must be a multiple of 8 bytes.

Offset1 If zero, do not insert RND in Data, else insert RND at specified Offset1 (01 indicates insert at
leftmost byte of Data.)

Offset2 If zero, do not insert Version Number in Data, else insert Version Number at specified Offset2 (01
indicates insert at leftmost byte of Data.)

Offset3 If zero, do not insert Generation Number in Data, else insert Generation Number at specified Offset3
(1 indicates insert at leftmost byte of Data.)

Note: ICD will normally be set equal to zero.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 644
CHAPTER 4 Function Library

ZKA-PIN-TRANS (EE0610)
Request Length Type Description

EE0610 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPKi(PIN) 8 X Encrypted PIN Block.

PPKi-Spec Var K-Spec Key specifier for PPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 90, 93)

PFi 1 h Input PIN Block Format


(Formats: 01, 03, 08, 09, 10, 11, 13)

ANB 6 h Account Number Block

PFo 1 h Output PIN Block Format


(Formats: 01, 03, 08, 10, 11, 13)

MK-Spec Var K-Spec Key Specifier for ZKA MK


(Format: 11, 13, 17, 18)

Response Length Type Description

EE0610 3 h Function Code

rc 1 h Return Code

ePPKo(PIN) 8 h Encrypted PIN Block

RNDo 16 h Random Number (encrypted session key)

This function performs translation of both the PIN Block format and the PIN encryption key. The input PIN Block is
encrypted by a PPKi, which might be a host- or HSM Mark II-stored session key or might be a ZKA-encrypted PAC key
(RND). The output PIN Block is encrypted by a session key generated within the function. The session key is also
returned in encrypted form (RNDo).

FM = 00. Must be set to zero.

ePPKi(PIN) Is the input formatted PIN Block containing the PIN to be verified. It must be supplied encrypted by
a PIN Protect session key (PPK).

PPKi-spec Can be any valid key specifier for a PPK. Consequently, the function supports an encrypted PIN
Block encrypted using a single-length or double-length or triple-length, HSM Mark II-stored or host-
stored key – or a ZKA terminal random number

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 645
CHAPTER 4 Function Library

PFi and PFo These respectively specify the format of the supplied PIN Block and of the required PIN Block, as
defined for the standard PIN Translate function (includes formats 1, 3, 8, 9, 10, 11 and 13).
NOTE: Restriction is placed on output format 8, PFi 8 – PFo8 only.

ANB Account Number Block, which is the rightmost 12 digits of the Primary Account Number (PAN),
excluding the check digit.

MK-spec A Host stored (format 13) CBC key specifier incorporating an encrypted ZKA Master Key.

ePPKo(PIN) Is the output formatted PIN Block containing the PIN to be verified. It must be supplied encrypted
by a PIN Protect session key (PPK).

RNDo Is the encrypted Session Key (Refer Session Key Derivation for details).

The function will fail with Error Code 78 if Pfi or PFo indicates a PIN block format that is disabled or conflicts with the
reformatting restrictions.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 646
CHAPTER 4 Function Library

ZKA-PIN-TRANS-1 (EE0613)
Request Length Type Description

EE0613 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPKi(PIN) 8 X Encrypted PIN Block

PPKi-Spec Var K-Spec Key specifier for PPK


Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 90)

PFi 1 h Input PIN Block Format


(Formats: 01, 03, 08, 09, 10, 11, 13)

ANB 6 h Account Number Block

PFo 1 h Output PIN Block Format


(Formats: 01, 03, 08, 09, 10, 11, 13)

MK2-Spec-1 Var K-Spec Key Specifier for ZKA MK2


(Format: 90)*
VerNo / GenNo / ExpDate = FFFF9999

Response Length Type Description

EE0613 3 h Function Code

rc 1 h Return Code

ePPKo(PIN) 8 h Encrypted PIN Block

RNDo 16 h Random Number (encrypted session key)

MK2-Spec-2 Var K-Spec Key Specifier for ZKA MK2


(Format: 92)

* When using MK2-spec-1 format 90, ignore the RND field.

This function performs translation of both the PIN Block format and the PIN encryption key. It is similar to function
ZKA-PIN-TRANS (EE0610), but derives the output PPK using an MK from the MK2 table.
The input PIN Block is encrypted by a PPKi, which might be a host- or HSM Mark II -stored session key or might be a
ZKA-encrypted PAC key (RND). The output PIN Block is encrypted by a session key generated within the function.
The session key is also returned in encrypted form (RNDo).
The function uses MK2-spec-1 to search the MK2 table for the record for Sub-type Number that has the latest Expiry
Date. The MK in this record is used to derive the PPKo. The MK2-spec-2 in the response has all fields completed from
the MK record used.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 647
CHAPTER 4 Function Library

Pfi and Pfo respectively specify the format of the supplied PIN Block and of the required PIN Block, as defined for
the standard PIN Translate function (including ISO formats 0 and 1).
NOTE: Restriction is placed on output format 8, PFi 8 – PFo8 only.

ANB Account Number Block, which is the rightmost 12 digits of the Primary Account Number (PAN),
excluding the check digit.

The function will fail with Error Code 78 if Pfi or PFo indicates a PIN block format that is disabled or conflicts with the
reformatting restrictions.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 648
CHAPTER 4 Function Library

ZKA-PIN-VER (EE0611)
Request Length Type Description

EE0611 3 h Function Code

FM 1 h Function Modifier (FM = 00)

ePPK(PIN) 8 X Encrypted PIN Block

PPK-Spec Var K-Spec Key specifier for PPK


(Formats: 0-3, 10, 11, 12, 13, 14, 17, 18, 90, 93)

PF 1 h PIN Block Format


(Formats: 01, 03, 08, 09, 10, 11, 13)

ANB 6 h Account Number Block

*KKBLZ-Spec Var K-Spec Key specifier for ZKA BLZ


(Formats: 0-3, 11, 13, 17, 18, 91)

Account Number 5 D 10-digit Account Number

CSN 1 D Card Sequence Number 00 - 09

Expiration Year 1 D Last digit only (00 – 09)

PVN Type 1 h PIN Verification Number Type = 00 or 04

PVN 2 D PIN Verification Number

Response Length Type Description

EE0611 3 h Function Code

rc 1 h Return Code

This function performs the verification of a PIN using the ecPVN method. The PIN is supplied in encrypted form, using
any of the PIN Block formats supported by the standard product (including ISO formats 0 and 1).

FM = 00. Must be set to zero.

ePPK(PIN) Is the input formatted PIN Block containing the PIN to be verified. It must be supplied encrypted by
a PIN Protect session key (PPK).

PPK-spec Can be any valid key specifier for a PPK. Consequently, the function supports an encrypted PIN
Block encrypted using a single-length or double-length or triple length, HSM Mark II-stored or host-
stored key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 649
CHAPTER 4 Function Library

PF Specifies the format of the supplied PIN Block, as defined for the standard PIN Translate function
(included formats: 1, 3, 8, 9, 10, 11, and 13).

ANB Account Number Block, which is the rightmost 12 digits of the Primary Account Number (PAN),
excluding the check digit.

*KKBLZ-spec Can be any valid key specifier for a *KKBLZ. Consequently, the function supports an encrypted
PIN Block encrypted using a single-length HSM Mark II-stored or double-length, HSM Mark II-
stored or double length host-stored key.

Account No. Is the 10 digit Account Number.

CSN Is the Card Sequence Number.

Expiration Year Is the last digit of the expiry year of the card.

PVN Type 0 = Complete value of X (undecimalized) in PVN.


4 = leftmost 4 digits of decimalize(X) packed in 2 bytes in PVN.

PVN Is the PIN Verification Number, used to verify the user’s PIN.

The function will fail with Error Code 78 if PF indicates a PIN block format that is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 650
APPENDIX A
Legacy Functions

This section contains a list of functions that have been superceded by another function that contains additional
functionality apart from original.

Function Group Function Code Function Name Description

PIN 60 PIN-TRAN Allows translation of both the PIN block format and the
PIN encryption key.

61 PIN-VER-AS Performs the verification of a PIN in an AS/ANSI


formatted PIN block, using the IBM 3624 method.

62 PIN-VER-PP Verifies a PIN in a IBM 3624 formatted PIN Block


using the IBM 3624 method.

65 D51-PIN-TRAN Performs translation of both the PIN block format and


the PIN block encryption key of an encrypted PIN
block received from a Docutel 5100 ATM.

66 D51-PIN-VER Performs the verification of a PIN in a Docutel 5100


formatted PIN block, using the IBM 3624 method.

67 VAR-PIN-VER Verifies an AS/ANSI formatted PIN.

68 VAR-PIN-VER-PP Verifies a IBM 3624 formatted PIN.

6A PIN-OFF-AS Generates an Offset for an AS/ANSI formatted PIN.

6B PIN-OFF-PP Generates an Offset for a IBM 3624 formatted PIN.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 651
APPENDIX A Legacy Functions

Function Group Function Code Function Name Description

EFT 41 IT-PPK-GEN Generates a random initial session key (KS) for an


EFT terminal.

42 IT-MPK-GEN Generates a random initial session key (KS) for an


EFT terminal.

43 IT-DPK-GEN Generates a random initial session key (KS) for an


EFT terminal.

44 NT-PPK-GEN Generates a new random session key for an EFT


Terminal.

45 NT-MPK-GEN Generates a new random session key for an EFT


Terminal.

46 NT-DPK-GEN Generates a new random session key for an EFT


Terminal.

4A GEN-SESS-KEYS Generates a set of random session keys for an EFT


terminal.

4C TERM-VER Verifies the validity of an EFT terminal by checking


that the LOGON-DATA is equal to the result of
encrypting its Security Number (SEC-NO) under its
Base Key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 652
APPENDIX A Legacy Functions

Function Group Function Code Function Name Description

Interchange 51 II-PPK-GEN Generates a random initial interchange session key


(KS).

52 II-MPK-GEN Generates a random initial interchange session key


(KS).

53 II-DPK-GEN Generates a random initial interchange session key


(KS).

54 II-PPK-RCV Allows a received Interchange Session Key (KS) to be


re-encrypted from encryption under the Receive
Interchange Key (KIRn) indicated by the supplied
index (KI-index), to encryption under the appropriate
*KM variant for storage within the host.

55 II-MPK-RCV Aallows a received Interchange Session Key (KS) to


be re-encrypted from encryption under the Receive
Interchange Key (KIRn) indicated by the supplied
index (KI-index), to encryption under the appropriate
*KM variant for storage within the host.

56 II-DPK-RCV Allows a received Interchange Session Key (KS) to be


re-encrypted from encryption under the Receive
Interchange Key (KIRn) indicated by the supplied
index (KI-index), to encryption under the appropriate
*KM variant for storage within the host.

57 NI-PPK-GEN Generates a new random session key (KSn+1) for an


Interchange.

58 NI-MPK-GEN Generates a new random session key (KSn+1) for an


Interchange.

59 NI-DPK-GEN Generates a new random session key (KSn+1) for an


Interchange.

5A NI-PPK-RCV Allows a Session Key roll-over for the remote


Interchange.

5B NI-MPK-RCV Allows a Session Key roll-over for the remote


Interchange.

5C NI-DPK-RCV Allows a Session Key roll-over for the remote


Interchange.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 653
APPENDIX A Legacy Functions

Function Group Function Code Function Name Description

MAC 70 MAC-GEN Generates a 32-bit Message Authentication Code


(MAC) for the supplied DATA using the supplied MAC
Processing Key (MPK), in accordance with AS2805.4.

71 MAC-TRAN Verifies that MACi is a valid MAC for DATA using


MPKi, and generates a new MAC (MACo) using
MPKo. If MACi fails to verify no Response Data is
returned, and the failure is indicated by an Error Code
of 08.

72 MAC-VER Verifies that the MAC is a valid MAC for the supplied
DATA using the supplied MAC Processing Key
(MPK), in accordance with AS2805.4.

Data 80 ENCIPHER Encrypts the supplied DATA under the supplied Data
Management Protect Key (DPK), using the DES Cipher Block Chain
method and a fixed non-zero Initialisation Vector.

81 DECIPHER Decrypts the supplied encrypted DATA using the


supplied Data Protect Key (DPK), the DES Cipher
Block Chain method and a fixed non-zero Initialisation
Vector.

82 ENCIPHER-ECB Encrypts the supplied DATA under the supplied Data


Protect Key (DPK), using the DES Electronic Code
Book mode.

83 DECIPHER-ECB Decrypts the supplied encrypted DATA using the


supplied Data Protect Key (DPK) and the DES
Electronic Code Book mode.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 654
APPENDIX A Legacy Functions

Function Group Function Code Function Name Description

VISA 90 PVV-GEN-1 Calculates the PVV by using the IBM 3624 method to
produce the PIN.

91 PVV-VER-1 Verifies an Issuer AS 2805.3 formatted PIN by using


the VISA PVV method.

92 PVV-VER-2 Performs a local PIN verification of a PIN in an AS


2805.3 formatted PIN block using the VISA PVV
method.

93 PVV-VER-3 Performs a local PIN verification of a IBM 3624


formatted PIN by using the VISA PVV method

94 PIN-TRAN-1 Performs a PIN Translation from the local Key (PPK)


to the VISA Acquirer Key (AWK).

95 PIN-TRAN-2-VISA Performs a PIN Translation from a VISA Issuer Key


(IWK) to the local Key (PPK).

96 PVV-GEN-2 This function is similar to the VISA function PVV-


GEN-1 (Function Code 90), except that the request
includes an index to select the PVK-A/B pair which is
to be used in the verification process.

97 PVV-VER-4 This function is similar to the VISA function PVV-


VER-1 (Function Code 91), except that the request
includes an index to select the PVK-A/B pair which is
to be used in the verification process.

98 PVV-VER-5 This function is similar to the VISA function PVV-


VER-2 (Function Code 92), except that the request
includes an index to select the PVK-A/B pair which is
to be used in the verification process.

99 PVV-VER-6 This function is similar to the VISA function PVV-


VER-3 (Function Code 93), except that the request
includes an index to select the PVK-A/B pair which is
to be used in the verification process.

9A PVV-CHANGE Generates a PVV for the encrypted PIN in the request.

9B CVV-GEN Generates a Card Verification Value (CVV) by the


VISA method for card data (CVV-data).

9C CVV-VER Verifies card data (CVV-data) deriving a CVV for that


data and validating it against the CVV in the request.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 655
APPENDIX A Legacy Functions

AUTHENTICATION-PARAMETER-GEN (E100)
This function generates an Authentication Parameter according to Australian Standard AS2805.6.2 1988.

Request Length Type Description

E100 2 h Function Code

Msg ID 2 x Message Identifier

CV3 8 B64 Card Value 3


(Refer AS2805.6.2 1988)

CV4 8 B64 Card Value 4


(Refer AS2805.6.2 1988)

CV5 8 B64 Card Value 5


(Refer AS2805.6.2 1988)

STAN 3 d Systems Trace Audit Number

CATID 8 x Card Acceptor Terminal Identification

Amount 6 d Transaction Amount

Response Length Type Description

E100 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 h Return Code

AP 8 B64 Authentication Parameter

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 656
APPENDIX A Legacy Functions

CVV-GEN (9B)
Request Length Type Description

9B 1 h Function Code

CVK-Index 1 d Index of CVK

CVV-Data 16 h Card Verification Value Data

Response Length Type Description

9B 1 h Function Code

rc 1 h Return Code

CVV 2 h Card Verification Value

This function generates a Card Verification Value (CVV) by the Visa method for card data (CVV-data).

CVK-Index A one byte BCD field that indicates which HSM stored CVK-A/B pair to use in the CVV generation
process.

CVV-Data The data from which the CVV is generated. It is up to the host to format the field correctly and to do
any required range checking on the data.

CVV The three digit Card Verification Value. The three digits are left aligned and right padded with the
hexadecimal digit "F".

Note: This function is superceded by function EE0802.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 657
APPENDIX A Legacy Functions

CVV-VER (9C)
Request Length Type Description

9C 1 h Function Code

CVK-Index 1 d Index of CVK

CVV-Data 16 h Card Verification Value Data

CVV 2 h Card Verification Value

Response Length Type Description

9C 1 h Function Code

rc 1 h Return Code

This function verifies card data (CVV-data) deriving a CVV for that data and validating it against the CVV in the request.

CVK-Index is a one byte BCD field which indicates which HSM stored CVK-A/B pair to use in the CVV generation
process.

CVV-Data is the data from which the CVV is generated. It is up to the host to format the field correctly and to do
any required range checking on the data.

CVV is the digit byte Card Verification Value. The three digits are left aligned and right padded with the
hexadecimal digit "F".

Note: This function is superceded by function EE0803.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 658
APPENDIX A Legacy Functions

D51-PIN-TRAN (65)
Request Length Type Description

65 1 h Function Code

ePPKi, PPKo(51-PIN) 8 B64 Encrypted PIN Block

eKMv1(PPKi) 8 B64 Encrypted Input PPK

eKMv1(PPKo) 8 B64 Encrypted Output PPK

ANB 6 h Account Number Block

Response Length Type Description

65 1 h Function Code

rc 1 h Return Code

ePPKo(AS-PIN) 8 B64 Encrypted PIN Block

This function performs translation of both the PIN Block format and the PIN Block encryption key of an encrypted PIN
Block received from a Docutel 5100 ATM.

51-PIN is the Docutel formatted PIN Block. It must contain from four to six numeric PIN digits, left
justified and terminated to the right with a single hex 'F' digit. All other digits in the PIN Block
(Julian Date and Serial Number) are ignored.

PPKi respectively specify the PIN Protect Key of the supplied PIN Block and of the required PIN
Block. If key translation is not required, PPKo must equal PPKi.

ANB is the 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

AS-PIN is the resultant AS/ANSI formatted PIN Block.

The function will fail with Error Code 78 if the Docutel or ANSI/ISO 0 PIN block format is disabled.

Note: This function is superceded by function EE0602.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 659
APPENDIX A Legacy Functions

D51-PIN-VER (66)
Request Length Type Description

66 1 h Function Code

PVK-Index 1 d Index of PVK

ePPK(D51-PIN) 8 B64 Encrypted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

PAN 8 h Primary Account Number

Offset 6 h PIN Offset Data

Response Length Type Description

66 1 h Function Code

rc 1 h Return Code

This function performs the verification of a PIN in a DOCUTEL 5100 formatted PIN Block, using the IBM 3624 method.

PVK- identifies the PVKn, DTn, and MINPINn appropriate to the PIN verification procedure.
Index

D51-PIN is the DOCUTEL 5100 formatted PIN Block containing the PIN to be verified. It must be
supplied encrypted by a PIN Protect Key (PPK).

PAN is the Primary Account Number (or other card data) used in the verification procedure. It
must be padded appropriately prior to input to this function.

Offset consists of up to 12 digits of Offset data. The significant digits must be left-justified in the
field. Unused digits are ignored. If Offsets are not used, the significant digits must be zeros.

The function will fail with Error Code 78 if the Docutel PIN block format is disabled.

Note: This function is superceded by function EE0603.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 660
APPENDIX A Legacy Functions

DECIPHER (81)
Request Length Type Description

81 1 h Function Code

Blocks 1 h No of 8 byte Blocks

eKM(DPK) 8 B64 Data Protect Key

eDPK(Data) bks*8 B64 Must be multiple of 8 bytes

Response Length Type Description

81 1 h Function Code

rc 1 h Return Code

Data bks*8 h Clear Data

This function DES decrypts the supplied encrypted DATA using the supplied Data Protect Key (DPK), the Cipher Block
Chaining mode of operation and a fixed Initialization Vector having a value of X’555555555555555555.

Note: This function is superceded by function EE0801.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 661
APPENDIX A Legacy Functions

DECIPHER-ECB (83)
Request Length Type Description

83 1 h Function Code

Blocks 1 h No of 8 byte Blocks

eKM(DPK) 8 B64 Data Protect Key

eDPK(Data) bks*8 B64 Must be multiple of 8 bytes

Response Length Type Description

83 1 h Function Code

rc 1 h Return Code

Data bks*8 h Clear Data

This function decrypts the supplied encrypted DATA using the supplied Data Protect Key (DPK) and the DES in
Electronic Code Book mode.

Note: This function is superceded by function EE0801.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 662
APPENDIX A Legacy Functions

ENCIPHER (80)
Request Length Type Description

80 1 h Function Code

Blocks 1 h No of 8 byte Blocks

eKM(DPK) 8 B64 Encrypted DPK

Data bks*8 h Must be multiple of 8 bytes

Response Length Type Description

80 1 h Function Code

rc 1 h Return Code

eDPK(Data) bks*8 B64 Data encrypted under DPK

This function DES encrypts the supplied DATA using the supplied Data Protect Key (DPK), the Cipher Block Chaining
mode of operation and a fixed Initialization Vector having a value of X’555555555555555555.

Note: This function is superceded by function EE0800.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 663
APPENDIX A Legacy Functions

ENCIPHER-ECB (82)
Request Length Type Description

82 1 h Function Code

Blocks 1 h No of 8 byte Blocks

eKM(DPK) 8 B64 Data Protect Key

Data bks*8 h Must be multiple of 8 bytes

Response Length Type Description

82 1 h Function Code

rc 1 h Return Code

eDPK(Data) bks*8 B64 Data encrypted under DPK

This function encrypts the supplied DATA under the supplied Data Protect Key (DPK), using the DES in Electronic
Code Book mode.

Note: This function is superceded by function EE0800.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 664
APPENDIX A Legacy Functions

GEN-SESS-KEYS (4A)
Request Length Type Description

4A 1 h Function Code

KTM-Spec Var K-Spec Key specifier for KTM


(Formats: 0-3)

Key Flags 2 h Key Type generation specifier.

Response Length Type Description

4A 1 h Function Code

rc 1 h Return Code
1eKTM(KS) 8 B64 Encrypted Session Key
1eKMx(KS) 8 B64 Session Key

1 This pair of fields will occur one or more times in the response

This function generates a set of random session keys for an EFT terminal. For distribution to the terminal the session
keys are encrypted by the Terminal Master Key (KTM), and for host storage and subsequent use with other functions
they are encrypted by variants of the Domain Master Key.

KTM-Spec A key specifier which incorporates an index to an HSM-stored KTM.

Key Flags Indicates the session keys to generate. The function response will contain one or more sets of
encrypted key fields as shown: one set for each bit set in the flags. The bit positions are allocated as
follows:

bit session key type

0 Single-length Data Key (DPK)

1 Single-length PIN encrypting key (PPK)

2 Single-length MAC key (MPK)

3-15 Reserved. Must be zero

Bit 0 is the least significant (rightmost) bit. Examples:


- To generate a single-length MAC key, this field must be set to X’0004’;
- To generate a single-length PIN encrypting key and a MAC key, the field must be set to X’0006’.

eKTM(KS) These fields form a key set. The response incorporates a key set for each bit (validly) set in the Key
eKMx(KS) flag field. The order of the returned key sets is the same order that the keys are specified in the Key
flag field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 665
APPENDIX A Legacy Functions

Note: This function is superceded by function EE0400.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 666
APPENDIX A Legacy Functions

II-DPK-GEN (53)
Request Length Type Description

53 1 h Function Code

n 1 d KIS Index

Response Length Type Description

53 1 h Function Code

rc 1 h Return Code

eKISn(DPK) 8 B64 Data Protect Key

eKM(DPK) 8 B64 Data Protect Key

This function generates a random initial interchange Data Protect Key (DPK).
For transmitting to the receiving institution, the key is returned encrypted under the Interchange Sending Key (KISn)
indicated by the specified index (KIS Index). It is also returned encrypted under the KM, for storage within the host.

eKISn(DPK) is the session key encrypted under KISn.

eKM(DPK) is the host stored session key encrypted under the KM.

Notes
– This function will check the length of KISn and use the appropriate encryption method.
– When there is no variant scheme chosen for the KIS, this function will be automatically disabled. In such a
case the function can be manually enabled from the console by selecting “Enable function for data key
generation” under the KIS Options dialog.
– Please refer to the Console Guide for directions on how to set options for the KIS.
– This function is superceded by function EE0402.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 667
APPENDIX A Legacy Functions

II-DPK-RCV (56)
Request Length Type Description

56 1 h Function Code

n 1 d KIR Index

eKIRn(DPK) 8 B64 Data Protect Key

Response Length Type Description

56 1 h Function Code

rc 1 h Return Code

eKM(DPK) 8 B64 Data Protect Key

This function takes an Interchange Data Protect Key (DPK) that has already been encrypted under the Interchange
Receive Key (KIRn) indicated by the supplied index (KIR Index), and re-encrypts it under the KM, for storage within the
host.

eKIRn(DPK) is the session key encrypted under KIRn.

eKM(DPK) is the host stored session key encrypted under the KM.

Notes
– This function will check the length of KIRn and use the appropriate encryption method.
– When there is no variant scheme chosen for the KIR, this function will be automatically disabled. In such a
case, this function can be manually enabled from the console by selecting “Enable function for receiving of data
keys” under the KIR Options dialog.
– This function is superceded by function EE0403.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 668
APPENDIX A Legacy Functions

II-MPK-GEN (52)
Request Length Type Description

52 1 h Function Code

n 1 d KIS Index

Response Length Type Description

52 1 h Function Code

rc 1 h Return Code

eKISnv2(MPK) 8 B64 MAC Protect Key

eKMv2(MPK) 8 B64 MAC Protect Key

This function generates a random initial interchange MAC Protect Key (MPK).
For transmitting to the receiving institution, the key is returned encrypted under variant 2 of the Interchange Sending
Key (KISn) indicated by the specified index (KIS Index). It is also returned encrypted under KM variant 2, for storage
within the host.

eKISnv2(MPK) is the session key encrypted under variant 1 of KISn. The variant is determined by the variant
scheme associated with KISn.

eKMv2(MPK) is the host stored session key encrypted under variant 1 of the KM.

Notes
– This function will check the length of KISn and use the appropriate encryption method.
– This function is superceded by function EE0402.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 669
APPENDIX A Legacy Functions

II-MPK-RCV (55)
Request Length Type Description

55 1 h Function Code

n 1 d KIR Index

eKIRnv2(MPK) 8 B64 MAC Protect Key

Response Length Type Description

55 1 h Function Code

rc 1 h Return Code

eKMv2(MPK) 8 B64 MAC Protect Key

This function takes an Interchange MAC Protect Key (MPK) that has already been encrypted under the Interchange
Receive Key (KIRn) indicated by the supplied index (KIR Index), and re-encrypts it under KM variant 2, for storage
within the host.

eKIRnv2 is the session key encrypted under variant 2 of KIRn. The variant is determined by the variant scheme
(MPK) associated with KIRn.

eKMv2 is the host stored session key encrypted under variant 2 of the KM.
(MPK)

Notes
– This function will check the length of KIRn and use the appropriate encryption method.
– This function is superceded by function EE0403.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 670
APPENDIX A Legacy Functions

II-PPK-GEN (51)
Request Length Type Description

51 1 h Function Code

n 1 d KIS Index

Response Length Type Description

51 1 h Function Code

rc 1 h Return Code

eKISnv1(PPK) 8 B64 PIN Protect Key

eKMv1(PPK) 8 B64 PIN Protect Key

This function generates a random initial interchange PIN Protect Key (PPK).
For transmitting to the receiving institution, the key is returned encrypted under variant 1 of the Interchange Sending
Key (KISn) indicated by the specified index (KIS Index). It is also returned encrypted under KM variant 1, for storage
within the host.

eKISnv1(PPK) is the session key encrypted under variant 1 of KISn. The variant is determined by the variant
scheme associated with KISn.
KIS range = 01 - 99.

eKMv1(PPK) is the host stored session key encrypted under variant 1 of the KM.

Notes
– This function will check the length of KISn and use the appropriate encryption method.
– This function is superceded by function EE0402.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 671
APPENDIX A Legacy Functions

II-PPK-RCV (54)
Request Length Type Description

54 1 h Function Code

n 1 d KIR Index

eKIRnv1(PPK) 8 B64 PIN Protect Key

Response Length Type Description

54 1 h Function Code

rc 1 h Return Code

eKMv1(PPK) 8 B64 PIN Protect Key

This function takes an Interchange PIN Protect Key (PPK) that has already been encrypted under variant 1 of the
Interchange Receive Key (KIRn) indicated by the supplied index (KIR Index), and re-encrypts it under KM variant 1, for
storage within the host.

eKIRnv1 is the session key encrypted under variant 1 of KIRn. The variant is determined by the variant
(PPK) scheme associated with KIRn.

eKMv1(PPK) is the host stored session key encrypted under variant 1 of the KM.

Notes
– This function will check the length of KIRn and use the appropriate encryption method.
– This function is superceded by function EE0403.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 672
APPENDIX A Legacy Functions

IT-DPK-GEN (43)
Request Length Type Description

43 1 h Function Code

n 1 D KTM Index

Response Length Type Description

43 1 h Function Code

rc 1 h Return Code

eKTMn(DPK) 8 B64 Data Protect Key

eKM(DPK) 8 B64 Data Protect Key

This function generates a random initial Data Protect Key (DPK) for an EFT terminal.
For transmitting to the EFT terminal, the key is returned encrypted under the Terminal Master Key (KTMn) indicated by
the specified index (KTM index). It is also returned encrypted under the KM, for storage within the host.

Note: This function is superceded by function EE0400.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 673
APPENDIX A Legacy Functions

IT-MPK-GEN (42)
Request Length Type Description

42 1 h Function Code

n 1 D KTM Index

Response Length Type Description

42 1 h Function Code

rc 1 h Return Code

eKTMn(MPK) 8 B64 MAC Protect Key

eKMv2(MPK) 8 B64 MAC Protect Key

This function generates a random initial MAC Protect Key (MPK) for an EFT terminal.
For transmitting to the EFT terminal, the key is returned encrypted under the Terminal Master Key (KTMn) indicated by
the specified index (KTM index). It is also returned encrypted under KM Variant 2, for storage within the host.

Note: This function is superceded by function EE0400.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 674
APPENDIX A Legacy Functions

IT-PPK-GEN (41)
Request Length Type Description

41 1 h Function Code

n 1 D KTM Index

Response Length Type Description

41 1 h Function Code

rc 1 h Return Code

eKTMn(PPK) 8 B64 PIN Protect Key

eKMv1(PPK) 8 B64 PIN Protect Key

This function generates a random initial PIN Protect Key (PPK) for an EFT terminal.
For transmitting to the EFT terminal, the key is returned encrypted under the Terminal Master Key (KTMn) indicated by
the specified index (KTM Index). It is also returned encrypted under the Master Key Variant 1(KMv1) for storage within
the host.

Notes
– This function is superceded by function EE0400.
– This function only supports use of the first 99 KTMs.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 675
APPENDIX A Legacy Functions

MAC-GEN (70)
Request Length Type Description

70 1 h Function Code

Blocks 1 h No of 8 byte Blocks

eKMv2(MPK) 8 B64 Encrypted MPK

Data Bks*8 h Must be a multiple of 8 Bytes

Response Length Type Description

70 1 h Function Code

rc 1 h Return Code

MAC 4 h Message Authentication Code

This function generates a 32-bit Message Authentication Code (MAC) for the supplied DATA using the supplied MAC
Protect Key (MPK), in accordance with AS2805.4 1985.

Note: This function is superceded by function EE0701.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 676
APPENDIX A Legacy Functions

MAC-TRAN (71)
Request Length Type Description

71 1 h Function Code

Blocks 1 h No of 8 byte Blocks

eKMv2(MPKi) 8 B64 Encrypted Input MPK

eKMv2(MPKo) 8 B64 Encrypted Output MPK

Data bks*8 h Must be multiple of 8 bytes

MACi 4 h Input Message Authentication Code

Response Length Type Description

71 1 h Function Code

rc 1 h Return Code

MACo 4 h Output Message Authentication Code

This function verifies that MACi is a valid MAC for Data using MPKi, and generates a new MAC (MACo) using MPKo.

Note: This function is superceded by function EE0701.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 677
APPENDIX A Legacy Functions

MAC-VER (72)
Request Length Type Description

72 1 h Function Code

Blocks 1 h No of 8 byte Blocks

eKMv2(MPKi) 8 B64 Encrypted Input MPK

Data bks*8 h Must be multiple of 8 Bytes

MAC 4 h Message Authentication Code

Response Length Type Description

72 1 h Function Code

rc 1 h Return Code

This function verifies that the MAC is a valid MAC for the supplied DATA using the supplied MAC Protect Key (MPK),
in accordance with AS2805.4 1985.

Note: This function is superceded by function EE0701.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 678
APPENDIX A Legacy Functions

NI-DPK-GEN (59)
Request Length Type Description

59 1 h Function Code

eKM(DPKn) 8 B64 Data Protect Key

Response Length Type Description

59 1 h Function Code

rc 1 h Return Code

eDPKn(DPKn+1) 8 B64 Data Protect Key

eKM(DPKn+1) 8 B64 Data Protect Key

This function generates a new random Data Protect Key (DPKn+1) for an Interchange.
For transmitting to the receiving node, the key is returned encrypted under the supplied previous Data Protect Key
(DPKn). It is also returned encrypted under the KM, for storage within the host system.

Note: This function is superceded by function EE0404.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 679
APPENDIX A Legacy Functions

NI-DPK-RCV (5C)
Request Length Type Description

5C 1 h Function Code

eKM(DPKn) 8 B64 Data Protect Key

eDPKn(DPKn+1) 8 B64 Data Protect Key

Response Length Type Description

5C 1 h Function Code

rc 1 h Return Code

eKM(DPKn+1) 8 B64 Data Protect Key

This function allows a Data Protect Key roll-over for the remote Interchange.
The remote Interchange receives a new Data Protect Key (DPKn+1) encrypted under the current one (DPKn) and sends
it together with the current Data Protect Key encrypted under the KM to the HSM.

Note: This function is superceded by function EE0405.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 680
APPENDIX A Legacy Functions

NI-MPK-GEN (58)
Request Length Type Description

58 1 h Function Code

eKMv2(MPKn) 8 B64 MAC Protect Key

Response Length Type Description

58 1 h Function Code

rc 1 h Return Code

eMPKn(MPKn+1) 8 B64 MAC Protect Key

eKMv2(MPKn+1) 8 B64 MAC Protect Key

This function generates a new random MAC Protect Key (MPKn+1) for an Interchange.
For transmitting to the receiving node, the key is returned encrypted under the supplied previous MAC Protect Key
(MPKn). It is also returned encrypted under KM Variant 2, for storage within the host system.

Note: This function is superceded by function EE0404.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 681
APPENDIX A Legacy Functions

NI-MPK-RCV (5B)
Request Length Type Description

5B 1 h Function Code

eKMv2(MPKn) 8 B64 MAC Protect Key

eMPKn(MPKn+1) 8 B64 MAC Protect Key

Response Length Type Description

5B 1 h Function Code

rc 1 h Return Code

eKMv2(MPKn+1) 8 B64 MAC Protect Key

This function allows a MAC Protect Key roll-over for the interchange.
The node receives a new MAC Protect Key (MPKn+1) encrypted under the current one (MPKn) and sends it together
with the current MAC Protect Key encrypted under KM Variant 2 to the HSM. The HSM returns the new MAC Protect
Key encrypted under KM Variant 2, for storage within the host.

Note: This function is superceded by function EE0405.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 682
APPENDIX A Legacy Functions

NI-PPK-GEN (57)
Request Length Type Description

57 1 h Function Code

eKMv1(PPKn) 8 B64 PIN Protect Key

Response Length Type Description

57 1 h Function Code

rc 1 h Return Code

ePPKn(PPKn+1) 8 B64 PIN Protect Key

eKMv1(PPKn+1) 8 B64 PIN Protect Key

This function generates a new random PIN Protect Key (PPKn+1) for an Interchange.
For transmitting to the receiving node, the key is returned encrypted under the supplied previous PIN Protect Key
(PPKn). It is also returned encrypted under KM Variant1, for storage within the host system.

Note: This function is superceded by function EE0404.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 683
APPENDIX A Legacy Functions

NI-PPK-RCV (5A)
Request Length Type Description

5A 1 h Function Code

eKMv1(PPKn) 8 B64 PIN Protect Key

ePPKn(PPKn+1) 8 B64 PIN Protect Key

Response Length Type Description

5A 1 h Function Code

rc 1 h Return Code

eKMv1(PPKn+1) 8 B64 PIN Protect Key

This function allows a PIN Protect Key roll-over for the interchange.
The node receives a new PIN Protect Key (PPKn+1) encrypted under the current one (PPKn) and sends it together with
the current PIN Protect Key encrypted under KM Variant 1 to the HSM. The HSM returns the new PIN Protect Key
encrypted under KM Variant 1, for storage within the host.

Note: This function is superceded by function EE0405.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 684
APPENDIX A Legacy Functions

NT-DPK-GEN (46)
Request Length Type Description

46 1 h Function Code

eKM(DPKn) 8 B64 Data Protect Key

Response Length Type Description

46 1 h Function Code

rc 1 h Return Code

eDPKn(DPKn+1) 8 B64 Data Protect Key

eKM(DPKn+1) 8 B64 Data Protect Key

This function generates a new random Data Protect Key (DPKn+1) for an EFT Terminal.
For transmitting to the EFT Terminal, the key is returned encrypted under the supplied previous Data Protect Key
(DPKn). It is also returned encrypted under the KM, for storage within the host system.

Note: This function is superceded by function EE0401.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 685
APPENDIX A Legacy Functions

NT-MPK-GEN (45)
Request Length Type Description

45 1 h Function Code

eKMv2(MPKn) 8 B64 MAC Protect Key

Response Length Type Description

45 1 h Function Code

rc 1 h Return Code

eMPKn(MPKn+1) 8 B64 MAC Protect Key

eKMv2(MPKn+1) 8 B64 MAC Protect Key

This function generates a new random MAC Protect Key (PPKn+1) for an EFT Terminal.
For transmitting to the EFT Terminal, the key is returned encrypted under the supplied previous MAC Protect Key
(MPKn). It is also returned encrypted under KM Variant 2, for storage within the host system.

Note: This function is superceded by function EE0401

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 686
APPENDIX A Legacy Functions

NT-PPK-GEN (44)
Request Length Type Description

44 1 h Function Code

eKMv1(PPKn) 8 B64 PIN Protect Key

Response Length Type Description

44 1 h Function Code

rc 1 h Return Code

ePPKn(PPKn+1) 8 B64 PIN Protect Key

eKMv1(PPKn+1) 8 B64 PIN Protect Key

This function generates a new random PIN Protect Key (PPKn+1) for an EFT Terminal.
For transmitting to the EFT Terminal, the key is returned encrypted under the supplied previous PIN Protect Key
(PPKn). It is also returned encrypted under KM Variant 1, for storage within the host system.

Note: This function is superceded by function EE0401.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 687
APPENDIX A Legacy Functions

PIN-OFF-AS (6A)
Request Length Type Description

6A 1 h Function Code

PVK-Index 1 d Index of PVK

ePPK(AS-PIN) 8 B64 AS/ANSI formatted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

PAN 8 h Primary Account Number

ANB 6 h Account Number Block

Response Length Type Description

6A 1 h Function Code

rc 1 h Return Code

Offset 6 h Returned PIN Offset Data

PINLEN 1 h Returned PIN Length

This function generates an Offset for an AS/ANSI formatted PIN. The PIN Block must be supplied encrypted under a
PIN Protect Key (PPK).
Offset digits for all PIN digits are returned. If CHKLEN is to be set to be less than the PINLEN in a PIN Verification
function, then the significant digits must be selected from the returned Offset. These digits must then be passed left
aligned and right padded in the Offset field of the appropriate PIN Verification function.
See IBM 3624 PIN Verification Method for a more detailed overview of the PIN verification procedure and for examples
on selecting significant Offset digits.

PVK-Index identifies the PVKn, DTn, and MINPINn appropriate to the PIN verification procedure.

AS-PIN is the AS/ANSI formatted PIN Block containing the PIN to be verified. It must be supplied encrypted
by a PIN Protect session key (PPK).

PAN the Primary Account Number used in the verification procedure. It must be padded appropriately prior
to input to this function.

ANB is the 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

A Return Code of 07 indicates that the format of the PIN Block in the request is incorrect. A Return Code of 0B
indicates that PINLEN is less than MINPIN.
The customer's current PIN should be verified before this function is called. The function will fail with Error Code 78 if
the ANSI/ISO 0 PIN block format is disabled.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 688
APPENDIX A Legacy Functions

The function performs a check that the ANB field and the PAN field (Validation Data) contain a number of consecutive
digits in common. The number of digits to check is in the range 0 to 12, as may be specified using a console operation,
and defaults to 8. If the number of digits to check has been set to 0 the check is disabled, and the function accepts any
supported PIN block format that is enabled. If the number of digits to check is greater than 0, then only ISO-0 and ISO-3
PIN blocks are allowed, if enabled. If the check fails, the function will fail with Return Code 79.

Note: This function is superceded by function EE0604.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 689
APPENDIX A Legacy Functions

PIN-OFF-PP (6B)
Request Length Type Description

6B 1 h Function Code

PVK-Index 1 d Index of PVK

ePPK(PP-PIN) 8 B64 IBM 3624 formatted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

PAN 8 h Primary Account Number

Response Length Type Description

6B 1 h Function Code

rc 1 h Return Code

Offset 6 h Returned PIN Offset Data

PINLEN 1 h Returned PIN Length

This function generates an Offset for a IBM 3624 formatted PIN. The PIN Block must be supplied encrypted under a
PIN Protect Key (PPK).
Offset digits for all PIN digits are returned. If CHKLEN is to be set to be less than the PINLEN in a PIN Verification
function, then the significant digits must be selected from the returned Offset. These digits must then be passed left
aligned and right padded in the Offset field of the appropriate PIN Verification function. See IBM 3624 PIN Verification
Method for a more detailed overview of the PIN verification procedure and for examples on selecting significant Offset
digits.

PVK-Index identifies the PVKn, DTn, and MINPINn appropriate to the PIN verification procedure.

PAN the Primary Account Number used in the verification procedure. It must be padded appropriately prior
to input to this function.

A Return Code of 07 indicates that the format of the PIN Block in the request is incorrect. A Return Code of 0B
indicates that PINLEN is less than MINPIN.
The current customer's PIN should be verified before this function is called.
The function will fail with Error Code 78 if the IBM 3624 PIN block format is disabled.
As the encrypted PIN block does not incorporate the account number (ANB) this function requires that the number of
consecutive digits in common between the ANB and PAN field (Validation Data) is set to 0, otherwise the function will
fail with Return Code 79. The number of digits to check is in the range 0 to 12, as may be specified using a console
operation, and defaults to 8.

Note: This function is superceded by function EE0604.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 690
APPENDIX A Legacy Functions

PIN-TRAN (60)
Request Length Type Description

60 1 h Function Code

PFi, PFo 1 h PIN Format(input/output)


(Formats: 00, 03)

ePPKi(PIN) 8 h PIN encrypted under PPKi

eKMv1(PPKi) 8 B64 Encrypted Input PPK

eKMv1(PPKo) 8 B64 Encrypted Output PPK

ANB 6 h Account Number Block

Response Length Type Description

60 1 h Function Code

rc 1 h Return Code

ePPKo(PIN) 8 B64 PIN encrypted under PPKo

This function allows translation of both the PIN Block format and the PIN encryption key.

PFi and PFo respectively specify the format of the supplied PIN Block and of the required PIN Block. If format
translation is not required, the PFi and PFo fields must be set to the same value. The valid field
values are:
1 = AS/ANSI format
3 = IBM 3624 format

PPKi and respectively specify the PIN Protect Key of the supplied PIN Block and of the required PIN Block.
PPKo If key translation is not required, PPKo must equal PPKi.

ANB is the 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

The function will fail with Error Code 78 if Pfi or PFo indicates a PIN block format that is disabled or conflicts with the
reformatting restrictions.

Note: This function is superceded by function EE0602.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 691
APPENDIX A Legacy Functions

PIN-TRAN-1 (94)
Request Length Type Description

94 1 h Function Code

ePPK(PIN) 8 B64 Encrypted PIN Block

eKMv1(PPK) 8 B64 PIN Protect Key

Response Length Type Description

94 1 h Function Code

rc 1 h Return Code

eAWK(PIN) 8 B64 Encrypted PIN

This function performs a PIN Translation from the local Key (PPK) to the Visa Acquirer Key (AWK).
The function will fail with Error Code 78 if the ANSI/ISO 0 PIN block format is disabled.

Note: This function is superceded by function EE0602.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 692
APPENDIX A Legacy Functions

PIN-TRAN-2-VISA (95)
Request Length Type Description

95 1 h Function Code

eIWK(PIN) 8 B64 Encrypted PIN

eKMv1(PPK) 8 B64 Encrypted PPK

Response Length Type Description

95 1 h Function Code

rc 1 h Return Code

ePPK(PIN) 8 B64 Encrypted PIN

This function performs a PIN Translation from a Visa Issuer Key (IWK) to the local Key (PPK).
The function will fail with Error Code 78 if the ANSI/ISO 0 PIN block format is disabled.

Note: This function is superceded by function EE0602.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 693
APPENDIX A Legacy Functions

PIN-VER-AS (61)
Request Length Type Description

61 1 h Function Code

PVK-Index 1 d Index of PVK

ePPK(AS-PIN) 8 B64 PIN Protect Key

eKMv1(PPK) 8 B64 Encrypted PPK

PAN 8 h Primary Account Number

ANB 6 h Account Number Block

Offset 6 h PIN Offset Data

Response Length Type Description

61 1 h Function Code

rc 1 h Return Code

This function performs the verification of a PIN in an AS/ANSI formatted PIN Block, using the IBM 3624 method.

PVK-Index identifies the PVKn, DTn, and MINPINn appropriate to the PIN verification procedure.

AS-PIN is the AS/ANSI formatted PIN Block containing the PIN to be verified. It must be supplied encrypted
by a PIN Protect session key (PPK).

PAN is the Primary Account Number (or other card data) used in the verification procedure. It must be
padded appropriately prior to input to this function.

ANB is the 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

Offset consists of up to 12 digits of Offset data. The significant digits must be left-justified in the field. Unused
digits are ignored. If Offsets are not used, the significant digits must be zeros.

The function will fail with Error Code 78 if the ANSI/ISO 0 PIN block format is disabled.

Note: This function is superceded by function EE0603.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 694
APPENDIX A Legacy Functions

PIN-VER-PP (62)
Request Length Type Description

62 1 h Function Code

PVK-Index 1 d Index of PVK

ePPK(PP-PIN) 8 B64 Encrypted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

PAN 8 h Primary Account Number

Offset 6 h PIN Offset Data

Response Length Type Description

62 1 h Function Code

rc 1 h Return Code

This function verifies a PIN in a IBM 3624 formatted PIN Block using the IBM 3624 method.

PVK-Index identifies the PVKn, DTn, and MINPINn appropriate to the PIN verification procedure.

PP-PIN is the formatted PIN Block containing the PIN to be verified. It must be supplied encrypted by a PIN
Protect session key (PPK).

PAN is the Primary Account Number (or other card data) used in the verification procedure. It must be
padded appropriately prior to input to this function.

Offset consists of up to 12 digits of Offset data. The significant digits must be left-justified in the field.
Unused digits are ignored. If Offsets are not used, the significant digits must be zeros.

In general, the function may be used to verify a IBM 3624 formatted PIN Block supplied encrypted by a host stored
PPK, if the PIN Block has been received either from a terminal or from an interchange. However, in the interchange
situation it is recommended that the Acquirer institution translates the PIN Block to AS/ANSI format prior to routing the
transaction to the Issuer. The Issuer would then use the PIN-VER function to verify the PIN.
The function will fail with Error Code 78 if the IBM 3624 PIN block format is disabled.

Note: This function is superceded by function EE0603.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 695
APPENDIX A Legacy Functions

PVV-CHANGE (9A)
Request Length Type Description

9A 1 h Function Code

PVVK-Index 1 d Index of PVVK

ePPK(AS-PIN) 8 B64 Encrypted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

ANB 6 h Account Number Block

TSP12 6 h Transformed Security Parameter

Response Length Type Description

9A 1 h Function Code

rc 1 h Return Code

PVV 2 h PIN Verification Value

This function generates a PVV for the encrypted PIN in the request. If the PIN is not in AS/ANSI format, a PIN format
error (Return Code 07) is returned in the response.
The request also includes an index to select the PVK-A/B pair that is to be used in the PVV generation process. The
PVKI that is contained in the TSP12 is no longer used as an index. This allows the host to dictate which key pairs are
associated with each card base.
The PVVK-index has a range of 1 to 36. The PVKI has a range of 1 to 6.

PVVK- identifies the PVK-A/B pair, which are to be used in the derivation of the PVV and must be in BCD
Index format.

AS-PIN is the AS 2805.3 1985 formatted PIN Block containing the PIN the PVV is to be generated for. It must
be supplied encrypted by a PIN Protect session Key (PPK).

ANB is the 12-digit Account Number Block (a PAN element of the clear PIN Block).

TSP12 is the leftmost 12 digits of the TSP and consists of 11 PAN digits followed by the appropriate one digit
PVKI.

The function will fail with Error Code 78 if the ANSI/ISO 0 PIN block format is disabled.
The function performs a check that the ANB field and the TSP12 field contain a number of consecutive digits in
common. The number of digits to check is in the range 0 to 12, as may be specified using a console operation, and
defaults to 8. If the number of digits to check has been set to 0 the check is disabled. If the check fails, the function will
fail with Return Code 79.

Note: This function is superceded by function EE0607.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 696
APPENDIX A Legacy Functions

PVV-GEN-1 (90)
Request Length Type Description

90 1 h Function Code

PVK-Index 1 d Index of PVK

PAN 8 h Primary Account Number

Offset4 2 h PIN Offset Data

TSP12 6 h Transformed Security Parameter

Response Length Type Description

90 1 h Function Code

rc 1 h Return Code

PVV 2 h PIN Verification Value

This function calculates the PVV by using the IBM 3624 method to produce the PIN. The four leftmost digits of the
derived or random PIN are appended to the TSP12 to form the TSP.

PVK-Index identifies the PVKn and DECTABn appropriate to the PIN Generation method.
Note: Whenever PVK keys are used a corresponding decimalization table is used. Additionally in some
functions, the PIN Length must exist. Therefore when entering PVKs the user should also enter the
corresponding decimalization table PIN Length for each PVK.

PAN is the 16-digit field which is encrypted using PVKn and decimalized using DECTABn to produce the
leftmost four digits of the derived PIN.

Offset4 is the leftmost 4 digits of Offset data which is modulo-10 added to the derived PIN to produce the
random PIN. If random PINs are not used this field should be set to zeros.

TSP12 is the leftmost 12 digits of the TSP and consists of 11 PAN digits followed by the appropriate one digit
PVKI.

The PVV is calculated using an HSM stored PVK-A/B pair. This function uses the PVKI as the PVK-A/B index, hence
only the first six of the thirty-six key pairs may be referenced.

Note: This function is superceded by function EE0606.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 697
APPENDIX A Legacy Functions

PVV-GEN-2 (96)
Request Length Type Description

96 1 h Function Code

PVVK-Index 1 d Index of PVVK

PVK-Index 1 d Index of PVK

PAN 8 h Primary Account Number

Offset 4 2 h PIN Offset Data

TSP12 6 h Transformed Security Parameter

Response Length Type Description

96 1 h Function Code

rc 1 h Return Code

PVV 2 h PIN Verification Value

This function is similar to the Visa function PVV-GEN-1 (Function Code 90), except that the request includes an index
to select the PVK-A/B pair, which is to be used in the verification process. The PVKI that is contained in the TSP12 is
no longer used as an index. This allows the host to dictate which key pairs are associated with each card base.
The PVVK-index has a range of 1 to 36. The PVKI has a range of 1 to 6.

PVVK-Index identifies the PVK-A/B pair that is to be used in the derivation of the PIN and must be in BCD format.

PVK-Index identifies the PVKn and DECTABn appropriate to the PIN Generation method.
Note: Whenever PVK keys are used a corresponding decimalization table is used. Additionally in
some functions, the PIN Length must exist. Therefore when entering PVKs the user should also enter
the corresponding decimalization table PIN Length for each PVK.

PAN is the 16-digit field which is encrypted using PVKn and decimalized using DECTABn to produce the
leftmost four digits of the derived PIN.

Offset4 is the leftmost 4 digits of Offset data which is modulo-10 added to the derived PIN to produce the
random PIN. If random PINs are not used this field should be set to zeros.

TSP12 is the leftmost 12 digits of the TSP and consists of 11 PAN digits followed by the appropriate one digit
PVKI.

Note: This function is superceded by function EE0606.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 698
APPENDIX A Legacy Functions

PVV-VER-1 (91)
Request Length Type Description

91 1 h Function Code

eIWK(AS-PIN) 8 B64 Encrypted PIN Block

ANB 6 h Account Number Block

TSP12 6 h Transformed Security Parameter

PVV 2 h PIN Verification Value

Response Length Type Description

91 1 h Function Code

rc 1 h Return Code

This function verifies an Issuer AS 2805.3 1985 formatted PIN by using the Visa PVV method.

AS-PIN is the AS 2805.3 1985 formatted PIN Block containing the PIN to be verified.

ANB is the 12-digit Account Number Block (a PAN element of the clear PIN Block).

TSP12 is the leftmost 12 digits of the TSP and consists of 11 PAN digits followed by the appropriate one digit
PVKI.

PVV is the PIN Verification Value used to verify the calculated PVV.

The PVKI is used as the PVK-A/B index, hence only the first six of the thirty-six key pairs may be referenced.
The function will fail with Error Code 78 if the ANSI/ISO 0 PIN block format is disabled.

Note: This function is superceded by function EE0605.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 699
APPENDIX A Legacy Functions

PVV-VER-2 (92)
Request Length Type Description

92 1 h Function Code

ePPK(AS-PIN) 8 B64 Encrypted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

ANB 6 h Account Number Block

TSP12 6 h Transformed Security Parameter

PVV 2 h PIN Verification Value

Response Length Type Description

92 1 h Function Code

rc 1 h Return Code

This function performs a local PIN verification of a PIN in an AS 2805.3 1985 formatted PIN Block using the Visa PVV
method.

AS-PIN is the AS 2805.3 1985 formatted PIN Block containing the PIN to be verified. It must be supplied
encrypted by a PIN Protect session key (PPK).

ANB is the 12-digit Account Number Block (a PAN element of the clear PIN Block).

TSP12 is the leftmost 12 digits of the TSP and consists of 11 PAN digits followed by the appropriate one digit
PVKI.

PVV is the PIN Verification Value used to verify the calculated PVV.

The PVKI is used as the PVK-A/B index, hence only the first six of the thirty-six key pairs may be referenced.
The function will fail with Error Code 78 if the ANSI/ISO 0 PIN block format is disabled.

Note: This function is superceded by function EE0605.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 700
APPENDIX A Legacy Functions

PVV-VER-3 (93)
Request Length Type Description

93 1 h Function Code

ePPK(PP-PIN) 8 B64 Encrypted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

TSP12 6 h Transformed Security Parameter

PVV 2 h PIN Verification Value

Response Length Type Description

93 1 h Function Code

rc 1 h Return Code

This function performs a local PIN verification of a IBM 3624 formatted PIN by using the Visa PVV method (PIN must
be left-justified).

PP-PIN is the IBM 3624 formatted PIN Block containing the PIN to be verified. It must be supplied encrypted by a
PIN Protect session key (PPK).

TSP12 is the leftmost 12 digits of the TSP and consists of 11 PAN digits followed by the appropriate one digit
PVKI.

PVKI is the PIN Verification Key Indicator used to identify the PVK pair (PVK-A and PVK-B) and to build the
Transformed Security Parameter (TSP) for the PIN verification procedure.

PVV is the PIN Verification Value used to verify the calculated PVV.

The PVKI is used as the PVK-A/B index, hence only the first six of the thirty-six key pairs may be referenced.
The function will fail with Error Code 78 if the IBM 3624 PIN block format is disabled.

Note: This function is superceded by function EE0605

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 701
APPENDIX A Legacy Functions

PVV-VER-4 (97)
Request Length Type Description

97 1 h Function Code

PVVK-Index 1 d Index of PVVK

eIWK(AS-PIN) 8 B64 Encrypted PIN Block

ANB 6 h Account Number Block

TSP12 6 h Transformed Security Parameter

PVV 2 h PIN Verification Value

Response Length Type Description

97 1 h Function Code

rc 1 h Return Code

This function is similar to the Visa function PVV-VER-1 (Function Code 91), except that the request includes an index
to select the PVK-A/B pair which is to be used in the verification process. The PVKI which is contained in the TSP12 is
no longer used as an index. This allows the host to dictate which key pairs are associated with each card base.
The PVVK-index has a range of 1 to 36. The PVKI has a range of 1 to 6.
A Return Code of 00 indicates that the PIN is verified. A 07 indicates that the format of the PIN Block in the request is
incorrect, and a 08 indicates PIN verification failure.

PVVK-Index identifies the PVK-A/B pair, which are to be used in the derivation of the PVV and must be in BCD
format.

AS-PIN is the AS2805.3 1985 formatted PIN Block containing the PIN to be verified.

ANB is the 12-digit Account Number Block (a PAN element of the clear PIN Block).

TSP12 is the leftmost 12 digits of the TSP and consists of 11 PAN digits followed by the appropriate one digit
PVKI.

PVV is the PIN Verification Value used to verify the calculated PVV.

The function will fail with Error Code 78 if the ANSI/ISO 0 PIN block format is disabled.

Note: This function is superceded by function EE0605.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 702
APPENDIX A Legacy Functions

PVV-VER-5 (98)
Request Length Type Description

98 1 h Function Code

PVVK-Index 1 d Index of PVVK

ePPK(AS-PIN) 8 B64 Encrypted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

ANB 6 h Account Number Block

TSP12 6 h Transformed Security Parameter

PVV 2 h PIN Verification Value

Response Length Type Description

98 1 h Function Code

rc 1 h Return Code

This function is similar to the Visa function PVV-VER-2 (Function Code 92), except that the request includes an index
to select the PVK-A/B pair that is to be used in the verification process. The PVKI that is contained in the TSP12 is no
longer used as an index. This allows the host to dictate which key pairs are associated with each card base.
The PVVK-index has a range of 1 to 36. The PVKI has a range of 1 to 6.
A Return Code of 00 indicates that the PIN is verified. A 07 indicates that the format of the PIN Block in the request is
incorrect, and a 08 indicates PIN verification failure.

PVVK-Index identifies the PVK-A/B pair, which are to be used in the derivation of the PVV and must be in BCD
format.

AS-PIN is the AS 2805.3 1985 formatted PIN Block containing the PIN to be verified. It must be supplied
encrypted by a PIN Protect session key (PPK).

ANB is the 12-digit Account Number Block (a PAN element of the clear PIN Block).

TSP12 is the leftmost 12 digits of the TSP and consists of 11 PAN digits followed by the appropriate one digit
PVKI.

PVV is the PIN Verification Value used to verify the calculated PVV.

The function will fail with Error Code 78 if the ANSI/ISO 0 PIN block format is disabled.

Note: This function is superceded by function EE0605.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 703
APPENDIX A Legacy Functions

PVV-VER-6 (99)
Request Length Type Description

99 1 h Function Code

PVVK-Index 1 d Index of PVVK

ePPK(PP-PIN) 8 B64 Encrypted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

TSP12 6 h Transformed Security Parameter

PVV 2 h PIN Verification Value

Response Length Type Description

99 1 h Function Code

rc 1 h Return Code

This function is similar to the Visa function PVV-VER-3 (Function Code 93), except that the request includes an index
to select the PVK-A/B pair that is to be used in the verification process. The PVKI that is contained in the TSP12 is no
longer used as an index. This allows the host to dictate which key pairs are associated with each card base.
The PVVK-index has a range of 1 to 36. The PVKI has a range of 1 to 6.
A Return Code of 00 indicates that the PIN is verified. A 07 indicates that the format of the PIN Block in the request is
incorrect, and a 08 indicates PIN verification failure.

PVVK-Index identifies the PVK-A/B pair that is to be used in the derivation of the PVV and must be in BCD format.

PP-PIN is the IBM 3624 formatted PIN Block containing the PIN to be verified. It must be supplied encrypted
by a PIN Protect session key (PPK).

TSP12 is the leftmost 12 digits of the TSP and consists of 11 PAN digits followed by the appropriate one digit
PVKI.

PVV is the PIN Verification Value used to verify the calculated PVV.

The function will fail with Error Code 78 if the IBM 3624 0 PIN block format is disabled.

Note: This function is superceded by function EE0605.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 704
APPENDIX A Legacy Functions

TermKeyInit-6.4 (3130)
This function randomly generates a set of initial keys and data for an Australian Standard AS2805.6.4 2001 terminal
(*KEK1, *KEK2, PPASN). These keys are encrypted under *KTK for transmission to the terminal and the appropriate
variants of KM for storage on the host.

Request Length Type Description

3130 2 h Function Code

Msg ID 2 x Message Identifier

n 1 h Index of *KTK

PPID 8 d PIN Pad Identification Number

Response Length Type Description

3130 2 h Function Code

Msg ID 2 x Message Identifier

rc 1 h Return Code

e*KTK(*KEK1) 16 x Terminal Master Key 1 encrypted under KTK

e*KTK(*KEK2) 16 x Terminal Master Key 2 encrypted under KTK

e*KTK(PPASN) 8 x PIN Pad Security Number encrypted under KTK

e*KTK(PPID) 8 x PIN Pad Identification Number encrypted under KTK

e*KMv7(*KEK1) 17 D-Key Terminal Master Key 1

e*KMv7(*KEK2) 17 D-Key Terminal Master Key 2

e*KMv9(PPASN) 9 S-Key PIN Pad Security Number

This host function is used for Australian Major Bank (AMB).

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 705
APPENDIX A Legacy Functions

TERM-VER (4C)
Request Length Type Description

4C 1 h Function Code

n 1 d KTM Index

SEC-No 8 h Security Number

Logon-Data 8 h Logon Data

Response Length Type Description

4C 1 h Function Code

rc 1 h Return Code

This function verifies the validity of an EFT terminal by checking that the Logon-Data is equal to the result of encrypting
its Security Number (SEC-No) under its Base Key.

Note: This function is superceded by function EE0406.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 706
APPENDIX A Legacy Functions

VAR-PIN-VER (67)
Request Length Type Description

67 1 h Function Code

PVK-Index 1 d Index of PVK

ePPK(AS-PIN) 8 B64 Encrypted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

PAN 8 h Primary Account Number

ANB 6 h Account Number Block

CHKLEN 1 h PIN Check Length – 04 - 12

Offset 6 h PIN Offset Data

Response Length Type Description

67 1 h Function Code

rc 1 h Return Code

This function verifies an AS/ANSI formatted PIN. The PIN Block must be supplied encrypted under a PIN Protect Key
(PPK).

PVK-index identifies the PVKn, DTn, and MINPINn appropriate to the PIN verification procedure.

AS-PIN is the AS/ANSI formatted PIN Block containing the PIN to be verified. It must be supplied encrypted by
a PIN Protect session key (PPK).

PAN the Primary Account Number used in the verification procedure. It must be padded appropriately prior to
input to this function.

ANB is the 12-digit Account Number Block used in the formation of the clear AS/ANSI PIN Block.

CHKLEN the CHKLEN field contains the number of PIN digits to be checked and may be less than, or equal to,
the actual length of the PIN. The significant Offset digits must be supplied left aligned and right padded
in the Offset field.

Offset consists of up to 12 digits of Offset data. The significant digits must be left- justified in the field. Unused
digits are ignored. If Offsets are not used, the significant digits must be zeros.

The function will fail with Error Code 78 if the ANSI/ISO 0 PIN block format is disabled.
See IBM 3624 PIN Verification Method for a more detailed overview of the PIN verification procedure.

Note: This function is superceded by function EE0603.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 707
APPENDIX A Legacy Functions

VAR-PIN-VER-PP (68)
Request Length Type Description

68 1 h Function Code

PVK-Index 1 d Index of PVK

ePPK(PP-PIN) 8 B64 IBM 3624 formatted PIN Block

eKMv1(PPK) 8 B64 Encrypted PPK

PAN 8 h Primary Account Number

CHKLEN 1 h PIN Check Length – 04 - 12

Offset 6 h PIN Offset Data

Response Length Type Description

68 1 h Function Code

rc 1 h Return Code

This function verifies a IBM 3624 formatted PIN. The PIN Block must be supplied encrypted under a PIN Protect Key
(PPK).

PVK-Index identifies the PVKn, DTn, and MINPINn appropriate to the PIN verification procedure.

PAN the Primary Account Number used in the verification procedure. It must be padded appropriately prior to
input to this function.

CHKLEN The CHKLEN field contains the number of PIN digits to be checked and may be less than, or equal to,
the actual length of the PIN. The significant Offset digits must be supplied left aligned and right padded
in the Offset field.

Offset consists of up to 12 digits of Offset data. The significant digits must be left- justified in the field.
Unused digits are ignored. If Offsets are not used, the significant digits must be zeros.

The function will fail with Error Code 78 if the IBM 3624 PIN block format is disabled.
See IBM 3624 PIN Verification Method for a more detailed overview of the PIN verification procedure.

Note: This function is superceded by function EE0603.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 708
APPENDIX B
Standards and Support

This section helps you understand various standards supported by Luna EFT.
• 3-D Secure Support
• AS2805.6.3 Support
• American Express Support
• CEPS Support
• Clear PIN Support
• Contactless Payment Card Support
• EMV Support
• Global Platform Support
• Italian Banking and Debit Card Support
• Japan PIN Support
• MasterCard Support
• MasteCard Cloud Based Payment Support
• Online Banking Support
• Remote ATM Initialization
• Smart Card Support
• Visa Support
• Visa Cloud-Based Payments Support
• Visa Data Secure Platform with Point to Point Encryption
• ZKA Support

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 709
3-D SecureTM Support
Luna EFT host functions provide support for Visa 3-D SecureTM and MasterCard SecureCode protocols for payment
transactions. Luna EFT host functions offer the following support for 3-D SecureTM:
• Calculation of CAVV (Card Authentication Verification Value),
• Calculation of MACs (Message Authentication Code) and Keyed Hash Message Authentication Code (HMAC)
used in 3D-Secure implementations,
• Digital signature calculation for PARes (Payer Authentication Request and Response) messages, and
• Providing TLS1 (Transport Layer Security) related crypto-operations.
• The host functions provide the crypto functionality as required by TLS protocol (defined in reference [49] of Mark II)
and are mapped onto PKCS#11 functions using the mechanisms in support of TLS (defined in section 12.32 of
reference [54] of Mark II, in this guide).
Luna EFT Mark II host functions already have the capability to calculate CAVV (EE0802, EE0803), transaction stains
and MAC as specified in 3-D secure protocol (refer section 2.5 of reference [51] of Mark II). The digital signature
calculation for PARes messages can also be achieved by existing Mark II functions (EE9005, EE9006).

Supported Host Functions


Functionality Function Name Function Code

Key Generation TLS-PRE-MASTER-KEY-GENERATION EE6000

Key Encryption and TLS-PRE-MASTER-KEY-SEND EE6001


Transport

Key Decryption TLS-PRE-MASTER-KEY-RECEIVE EE6002

Key Derivation TLS-MASTER-KEY-DERIVATION EE6003

Key Derivation TLS-ENCRYPTION-AND-MAC-KEY- EE6004


DERIVATION

1Transport Layer Security, a 3-D Secure protocol, and a successor to Secure Sockets Layer (SSL). The Mark II
functions include support for TLS as required for the transport of 3-D Secure messages.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 710
AS2805.6.3 Support
AS2805 is an Australian Transaction Key Scheme1 supported by Luna EFT that allows Inquirers and Card Issuers to
use Luna EFT and the host computer to perform the security functions defined in Australian Standard (AS) 2805 Parts
4, 6.2, and 6.3.

Supported Host Functions


Functionality Function Name Function Code

AS2805.6.3 Support GETPUBLICKEY EE3030

KIS-SEND EE3031

KIR-REC EE3032

NODEPROOF EE3033

NODERESP EE3034

1The transaction Key Scheme, typically of use in EFTPOS systems, is a technique in which data-encrypting keys
change with each transaction in a manner that cannot be followed by a third party.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 711
American Express (AMEX) Support
Luna EFT host functions calculate and verify CSC values to support CSC algorithms for both v1.0 and 2.0.
Additionally, the host functions provide support for the use and storage of CSCKs from a host database. The following
outlines a few of the cryptographic operations performed by Luna EFT to support the AMEX functionality.
• Generating CSC 1.0 values
• Verifying the computed CSC 1.0 values
• Generating CSC 2.0 values
• Verifying the computed CSC 2.0 values
• Generating the iCSC values
• Verifying the computed iCSC values
• Generating a CSCK and encrypting it under the shared KEK
• Validating the CSCK
• Distributing the CSCK
Refer to American Express Examples for a series of function examples. These can be used to verify correct
implementation of the functionality.
For details related to support for the use and storage of CSCKs, refer to the section Card Security Code Keys (CSCK).

Supported Host Functions


Functionality Function Name Function Code

CSC Calculation CALCULATE-CSC A8

CSC Creation CREATE-CSCK A9

CSC Export EXPORT-CSCK AA

CSC Import IMPORT-CSCK AB

CSC calculation to support CSC CALC-CSC EE0501


algorithm v2.0

CSC Verification VERIFY-CSC EE0502

Card Security Code Keys (CSCK)


The HSM supports a table of 20 CSC double-length DES keys that are used for the generation of CSC values. CSCKs
can be stored in HSM secure memory via console operations.
Additionally, host functions provide support for the use and storage of CSCKs from a host database.

Distribution of CSC keys in encrypted form


The CSC keys are distributed between American Express and the Card Issuer in an encrypted form. These keys are
encrypted by a double-length key-encrypting key which is denoted the Zone Master Key (ZMK) in some documents.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 712
In the Mark II HSM, the key-encrypting keys which are used to encrypt other keys for distribution between institutions
are denoted as Interchange Keys. Both uni-directional key management and bi-directional key management is
supported, therefore separate Interchange Sending Keys (KIS) and Interchange Receiving Keys (KIR) are provided
along with bi-directional interchange key-encrypting key (KI).
An HSM KIS or KIR is functionally equivalent to a ZMK, with the additional restriction of being used for key distribution
in one direction only. For example to send an encrypted key to another institution a KIS is used, e.g. eKIS(CSCK). At
the receiving institution an encrypted key is received encrypted by a KIR, e.g. eKIR(CSCK).
The Interchange Key functionality supports single and double length keys, with a maximum number of keys set to 99
sending and 99 receiving keys.
For mailing or electronic transmission of a CSC key, a double-length KIS is used i.e. eKIS(CSCK). At the receiving
institution a double-length KIR would be used, i.e. eKIR(CSCK).

Use of KIS and KIR for distribution of CSCKs


As mentioned in the introduction, a CSCK is distributed between American Express and a Card Issuer encrypted by a
KIS or KIR. These keys are functionally equivalent to the key denoted ZMK.
The HSM supports 99 single- or double-length Interchange Sending Keys (KIS) and 99 single- or double-length
Interchange Receiving Keys (KIR). For distribution of a CSCK, a double-length KIS or KIR will be used.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 713
CEPS Support
Luna EFT’s advanced security functionality to provide CEPS-compliant e-purse transaction processing for the
European market, supports host functions to perform the following operations:
• Offline Transactions involving mutual authentication of card and terminal using RSA signatures.
• Online Transactions as mentioned below, involving mutual authentication of card and card issuer using RSA
signatures.
• Load transactions
• Unload transactions
• Currency exchange transactions
• On-line batch processing involving the usage of DES signatures.

Supported Host Functions


Functionality Function Name Function Code

VCEPS VCEPS-VER-S1-GEN-S2 EF0701

VCEPS-VER-SN EF0702

VCEPS-GEN-SN EF0703

VCEPS-MAC-VER-LSAM EF0704

VCEPS-GEN-HASH-CEP EF0F01

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 714
Clear PIN Support
Luna EFT host function offers support for the following:
• Formats a clear PIN into an ANSI PIN Block and encrypts it using the supplied PPK.

Supported Host Functions


Functionality Function Name Function Code

Clear PIN CLEAR-PIN-ENCRYPT EE0600

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 715
Contactless Payment Card Support

Luna EFT is a cornerstone component in card management, responsible for securely storing the secret keys and
processing cryptographic computations. It provides various functions related to card management, that are classified
as:
Card Issuance: Including Issuer key Pair Initialization, card personalization, and
Card Verification: Including card authentication (Static Data Authentication, Dynamic Data Authentication)

Supported Host Functions


Functionality Function Name Function Code

CVC3 Generation CVC3-GENERATE EE0010

CVC3 Verification CVC3-VERIFY EE0011

Derive ICC CVC3 Data DERIVE-CVC3-KD-IV EE0012


Key

Create ICC Certificate CREATE-ADDI-ICC-CERTIFICATE EE0013

Luna EFT supports the standards of some of the best known payment cards, such as MasterCard® PayPass™, and
Visa payWave™.

MasterCard PayPass
Calculation of the PayPass CVC3 uses a unique-per-card derived key, KDCVC3, which is derived from a Master Key,
IMKCVC.The extension defined here supports:
• Console operations for user management of the IMKCVC.
• A host function that derives the KDCVC3 and calculates IVCVC3 (for personalization of the ICC).
• A host function that derives the KDCVC3 from IMKCVC and then generates the CVC3.
• A host function that derives the KDCVC3 from IMKCVC and then verifies the CVC3.
The calculation of a CVC3 differs from that of a static CVC (or CVV) in that it is a 3DES encryption of a single 8-byte
block, and the CVC3 is the rightmost 4 hex digits (2-bytes) rather than the left 3 digits after decimalization.
A card that supports both EMV debit/credit and PayPass requires 2 public key certificates in support of DDA. A
function is provided that creates an additional certificate, thereby supplementing the existing CI functions that generate
the ICC key pair and certificate.

Supported Host Functions


Functionality Function Name Function Code

CVC3 Generation CVC3-GENERATE EE0010

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 716
Functionality Function Name Function Code

CVC3 Verification CVC3-VERIFY EE0011

Derive ICC CVC3 Data DERIVE-CVC3-KD-IV EE0012


Key

Create ICC Certificate CREATE-ADDI-ICC-CERTIFICATE EE0013

Visa payWave
Visa payWave embraces three contactless card technologies: Magnetic Stripe Data (MSD), qVSDC and contactless
VSDC.
In MSD, the contactless card presents a virtual magnetic stripe to the reader. The significant difference from a real
magnetic stripe is that the virtual magnetic stripe contains a dynamic CVV (dCVV) rather than a static CVV. The dCVV
is calculated using a card-stored Unique Derived Key (UDK). As for the UDKs in VSDC, this key value is unique per
card and is derived from a Master Derivation Key (MDK). This is the significant difference from the calculation of a
static CVV; there is also a difference in the data involved in the calculation, but this is of no consequence to the HSM
processing. The algorithm is identical to that for a static CVV.
Note: The IMKCVC will be used for the Visa payWave as MDK.

Supported Host Functions


Functionality Function Name Function Code

CVV Generation dCVV-GENERATE EE0014

CVV Verification dCVV-VERIFY EE0015

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 717
EMV Support
Luna EFT specifically meets the needs of payment processors, card issuers, acquirers, merchants, and e-payment
solution providers who need to adhere to EMV security standards. Luna EFT offers comprehensive EMV support from
transaction processing to card issuance capabilities.
• Support for Application cryptogram verification (ARQC, TC, AAC) and response cryptogram generation (ARPC)
• Support for major EMV implementations - M/Chip, VSDC, AEIPS, J/Smart, EMV 4.1, 4.2 including Common Core
Definition (CCD) and ZKA SECCOS
The EMV Function Examples documents a series of function examples that can be used to verify correct
implementation of EMV functionality.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 718
Supported Host Functions
Functionality Function Name Function Code

Transaction Processing GEN-RANDOM EE0002

EMV-AC-GEN EE2000

EMV-AC-VERIFY EE2001

EMV-DAC-GEN EE2002

EMV-DAC-VERIFY EE2003

EMV-ICC-DN-GEN EE2004

EMV-ICC-DN-VERIFY EE2005

EMV-ARPC-GEN EE2006

EMV-SCRIPT-CRYPTO EE2007

EMV-VERIFY-AC-EMV-2000 EF2010

EMV-VERIFY-AC-VISA EF2011

EMV-GENERATE-ARPC EF2012

EMV-SCRIPT-CRYPTO-EMV-2000 EF2013

EMV-SCRIPT-CRYPTO-VISA EF2014

EMV-PIN-CHANGE-UNBLOCK-VISA EF2015

EMV-PIN-CHANGE-UNBLOCK EE2016

EMV-PIN-CHANGE-UNBLOCK-EMV- EE2017
2000

EMV-VERIFY-AC-GEN-ARPC EE2018

EMV-AC-GEN-MULTI EE2019

EMV-SCRIPT-CRYPTO-MULTI EE2020

EMV-PIN-CHANGE-UNBLOCK-MULTI EE2021

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 719
Functionality Function Name Function Code

Card Issuance GENERATE-ISSUER-KEY-PAIR EE2040

SELF-CERT-ISSUER-PUBLIC-KEY EE2041

VERIFY-CA-PUBLIC-KEY-MC EE2042

VERIFY-ISSUER-PK-CERT-MC EE2043

SELF-SIGN-ISSUER-PK-VISA EE2044

VERIFY-CA-PK-VISA EE2045

VERIFY-ISSUER-PK-CERT-VISA EE2046

VERIFY-DETACHED-CERT-VISA EE2047

GENERATE-ICC-KEYPAIR EE2048

GENERATE-ICC-CRT-KEYPAIR EE2058

VERIFY-ICC-CERTIFICATE EE2049

DERIVE-ICC-MASTER-KEY EE204A

SIGN-ICC-STATIC-DATA EE204B

VERIFY-ICC-STATIC-DATA EE204C

VERIFY-ICC-DYNAMIC-DATA EE204D

RSA-ENCIPHER-PIN EE204E

GENERATE-RANDOM-PIN-EMV EE204F

EXPORT-PIN-EMV EE2050

KTK-KEY-EXPORT EE2051

DERIVE-NEW-ICC-KEY-SET EE2052

DERIVE-NEW-ICC-KEY EE2053

GENERATE-DCV EE2054

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 720
Global Platform Support
Luna EFT host functions performs the following operations for secure key generation, protection of data between data
preparation and card personalization systems, and the generation and protection of PINs. to support the crypto
processing as defined in the Global Platform specifications:
• Mutual Authentication of Secure Channel Protocols (SCP) to protect secure channels being used for all Global
Platform sensitive commands. For example, content loading, installation, and CVM management etc.
• Personalizing cards at Issuance and during Post-Issuance involves the loading of a cryptographic key. The
transport key that secures the transmission must be at least as strong as the key being transmitted. Luna EFT host
functions support the same by providing secure key transport.
• The host functions perform Key data encryption when transmitting key’s sensitive data to the card.
• PIN generation and protection.

Supported Host Functions


Functionality Function Name Function Code

PIN Management TRANSLATE-SENSITIVE-DATA EE0645

Mutual Authentication GP-MUTUAL-AUTHENTICATION EE2059

Card Cryptogram Calculation GP-CALC-CARD-CRYPTOGRAM EE2060

Secure Messaging - Send GP-SECURE-MESSAGING-COMMAND EE2061

Secure Messaging - Receive GP-SECURE-MESSAGING-RESPONSE EE2062

Key Transport GP-SCP10-SESSION-KEY-TRANSPORT EE2063

Hash Calculation GP-SCP10-CALC-HASH-OF-KEY EE2064

Mutual Authentication - SCP03 GP-MUTUAL-AUTHENTICATION-SCP03 EE2065

Secure Messaging - SCP03 GP-SECURE-MESSAGING-COMMAND- EE2066


SCP03

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 721
Italian Banking and Debit Card Support
Luna EFT supports the Italian Debit functionality with associated support from Global Platform and EMV CPS
specifications to secure transactions for ABI (Italian Banking Associations) Debit cards. Luna EFT’s ABI Debit Card
functions perform the following operations to support the debit card transactions:
• Generating Italian 5 digit PIN according to IBM 3624 methods.
• Computing the Authentication Parameter for the input encrypted PIN Block while encrypting the PIN Block and
using the authentication parameter algorithm with the input ABI code, Card Secure Code and PAN data to compute
the Authentication Parameter.
• Random key generation.
• Translating sensitive key or PIN data, such as the Authentication Parameter1.

Supported Host Functions


Functionality Function Name Function Code

PIN Generation PIN-GENERATION EF0616

Authentication Parameter AUTH-PARAM-GENERATE EF0617


Generation

1Authentication Parameter (AP), a sort of Italian proprietary PIN block needs to travel from the POS to the issuer where
the issuer authorizes a transaction by checking the received AP. In this case the encrypted Authentication Parameter
(AP) needs to be translated under the same key type (DPK) so that the translated encrypted AP is identical to the value
stored in the Issuer's data base. However, this scenario may be different for different banks.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 722
Japan PIN Support
Luna EFT host function offers support for the following:
• Encryption of a clear/encrypted PIN.
• Translation of a PIN from encryption under a PPK to encryption under another PPK.
• Decryption of a PIN from encryption under a PPK to yield a clear PIN.

Supported Host Functions


Functionality Function Name Function Code

Japan PIN JAPPINTRAN EF0601

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 723
MasterCard® Support
Luna EFT supports both manual key management and online key exchange, and consist of a set of console operations
for the key management, and a set of host functions for the transaction processing.
Consistent with existing practice, long-term keys being stored within HSM key memory, and short-term (session) keys
being stored/encrypted in the host computer, the console operations allow two keys to be input and stored in key
memory. The memory may be configured so that these keys are either Key Exchange Keys, for online key exchange, or
PIN Encryption Keys for manual key management. The keys are input as a number of components, which are
combined to form the required key. On successful key entry the Key Check Value (KCV) for the key is displayed.
Additionally, host functions are available for:
• Manual Key Management: One of the host functions allow an acquirer institution to perform PIN translation for
routing an encrypted PIN to the MasterCard Switch center. Another function permits an issuer to verify an
encrypted PIN received from the MasterCard Switch center.
• Online Key Exchange: One of the host functions allow a PIN Encryption Key (KPE) received from the
MasterCard Switch center to be re-encrypted for host storage and subsequently used with the standard HSM PIN
management functions. Another function generates an encrypted random KPE. This is not required by a member
institution for normal transaction processing, as the PIN Encryption Keys are generated only by the MCS.
However, the function may be valuable during system testing.

MasterCard 3DES Support


Generic HSM keys and associated console operations and host functions can be used to support double-length keys on
the MasterCard International network.
The tables below give the generic keys, console operations and host functions to be used when 3DES functionality is
required in place of the MasterCard specific equivalents that apply when DES is used.
The following 3DES functionality is not currently supported:
• Triple-length keys
• 3624 Offset PIN verification using a 3DES PVK
• Export/import of PVKs using a 3DES key

Equivalent keys
Key Type Visa Key HSM Key

Key encrypting key KEK KIS / KIR

PIN encrypting key KPE PPK

Supported Host Functions


Functionality Function Name Function Code

Generate Random PIN Encryption Key (KPE) MT-KPE-GEN A0

Encrypt Encryption Key (KPE) MT-KPE-RCV A1

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 724
Functionality Function Name Function Code

PIN Translation MT-PIN-TRAN A2

PIN Verification MT-PIN-VER A3

PIN Verification using PVV Method MT-PIN-VER-PVV A7

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 725
MasterCard Cloud-Based Payments Support
Luna EFT’s support for cloud-based payment solutions is based on the MasterCard cloud-based payments (MCBP)
standard and provides a tamper-resistant environment for performing secure cryptographic processing, and key
management. It serves as a strong component for supported cloud-based solutions by providing encryption, user
authentication, secure storage of keys and user credentials. It thus enables credential issuers, retailers, acquires and
switches to securely:
• Issue digital cards to the cloud using tokenization and HCE or to mobile phones with secure elements.
• Provision any card or credential including credit, debit, prepaid.
• Manage cards remotely with strong cryptographic support on card management and synchronization on cloud.

Supported Host Functions


Functionality Function Name Function Code

Validate Authentication Code CHECK-AUTHENTICATION-CODE EE3050

Derive Card Master Keys DERIVE-CLOUD-CMK EE3051

Derive Session keys and DERIVE-CBP-SESSION-KEYS EE3052


Restricted Use keys

Verify Application Cryptogram VALIDATE-CLOUD-AC-GENERATE- EE3053


and generate ARPC ARPC

Verify CVC3 VALIDATE-CBP-CVC3 EE3054

Calculate IDN CALCULATE-IDN EE3055

PIN Translation - Payment PROTECT-CLEAR-MOBILE-PIN EE3056


Application
PROTECT-ENCRYPTED-MOBILE- EE3057
PIN

PIN Verification - Payment CHECK-CLEAR-MOBILE-PIN EE3058


Application
CHECK-ENCRYPTED-MOBILE-PIN EE3059

Key Translation IMPORT-RSA-ENC-KEY EE3060

EXPORT-KEY-2 EE3061

Derive Mobile Session Key DERIVE-MOBILE-SESSION-KEY EE305A

Message encryption/decryption WEB-SERVICE-MESSAGE EE305B

Protect card parameters PROTECT-DC-FILE EE305C

CBC counter mode encryption, CCM-ENCRYPT EE305D


decryption
CCM-DECRYPT EE305E

Remote Notification Service RNS-MESSAGE EE305F


Message

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 726
See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 727
Online Banking Support
Luna EFT’s Online Banking Module provides true end-to-end encryption security to sensitive information used in
Internet transactions, such as online banking. Encryption is initiated at the customer’s computing device (PC, mobile
phone etc) creating a secured channel between the customer’s PC and the host computing system, all the way beyond
the web server. The Online Banking Module functions support the RSA data encryption algorithm to perform the
operations to support RSA key generation, signing and verification. In addition to providing secure login through RSA-
encrypting the PIN/password, SNMP is also supported, facilitating resource management from your central monitoring
service.
Luna EFT protects online banking credentials, ensuring that access codes and card numbers are processed only on a
secure HSM platform.

Supported Host Functions


Functionality Function Name Function Code

Key Retrieval OBM-GET-PUBLIC-KEY EE3000

Random Number Generation OBM-GEN-RANDOM-NUMBER EE3001

PIN Verification OBM-VERIFY-PIN-3624 EE3002

PIN Change OBM-CHANGE-PIN-3624 EE3003

Set OBM Password OBM-SET-PIN EE3004

Verify OBM Password OBM-VERIFY-PIN-HASH EE3005

Change OBM Password OBM-CHANGE-PIN-HASH EE3006

Print OBM Password OBM-PRINT-PIN EE3008

Reference Password OBM-MIGRATE-PIN-3624-TPV EE3009


Calculation

Generate Print Token OBM-GET-PRINT-TOKEN EE3016

Generate Random PIN OBM-GENERATE-RANDOM-PIN EE3017

Print Encrypted PIN OBM-PRINT-ENCRYPTED-PIN EE3018

PIN Translate OBM-TRANSLATE-PIN EE3019

Set PIN OBM-SET-PIN-TPV EE3020

Generate Random PIN OBM-GENERATE-RANDOM-PIN-2 EE3021

Decrypt RSA encrypted data OBM-DECRYPT-DATA-RSA EE3022

Decrypt encrypted data OBM-DECRYPT-DATA- EE3023


SYMMETRIC

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 728
Data Item Representation in Request/Response Messages
Refer to Function Construction for a list of operators and qualifying letters that may be used in request and response
content. The following additional qualifier is used in request and response content for the online banking module.

Type Description

Struct Represents a field that contains a ‘structure’ that is made up of any number and variety of
the other fields. EPB Processing Unit and CTPV Processing Unit, described below, are
examples of the struct operator.

EPB Processing Unit


Field Length Type Description

SK-Spec Var K-Spec Key specifier for RSA Private Key (HSM-stored) Provides the index
into the key table in Secure Memory where the key is stored.

C Var h RSA-encrypted PIN Block.

P Var h PKCS#1 parameter string

RN Var h Random Number

Pre-requisites: None
Process: Decrypt and decode the RSA-encrypted PIN Block.
Result: Error Code or Plaintext PIN Block (M).
Processing Steps
1. Retrieve the index from the key specifier: SK-Spec. Read the RSA private key (SK) from the entry in the RSA Key
Pair table indicated by the index.
2. Decrypt the RSA-encrypted PIN Block, C, using SK.
3. Decode the resulting PIN Block, in accordance with PKCS #1 and using parameter string P, and thereby recovering
the message M.
4. Check that the header byte is equal to 1 or 2.
5. Check that the PIN Blocks contained in M are valid Format 2 or Format 12 PIN Blocks. If not, return an appropriate
value in Error Code.
6. Compare the provided random number, RN, with the rightmost bytes of M. If the values do not agree, return an
appropriate value of Error Code.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 729
CTPV Processing Unit
Field Length Type Description

Algorithm Identifier 1 h Format = two nibbles xy, where:


x is the encryption algorithm identifier;
y is the hash algorithm identifier.
Valid values for x:
= 0: no encryption;
= 1: DES/3DES, CBC.
Valid values for y:
= 0: no hash;
= 1: MD5;
= 2: SHA-1.
= 3: SHA-224.
= 4: SHA-256.
= 5: SHA-384.
= 6: SHA-512.
Invalid combinations of x and y:
xy = 00.

DataA Var h Data used in the hashing of the PIN, or in the formatting of the PIN
Block for encryption.
May be zero-length field.

DataB Var h Data used in the hashing of the PIN.


May be zero-length field.

KTPV-Spec Var K-Spec KTPV used to encrypt the hashed PIN or formatted PIN Block. Or
zero-length field if no encryption.
Allowed key spec for KTPV are 0-3,10,11,12,13,14,17,18
(Algorithm Identifier = 0x).

Pre-requisites: A plaintext format 2 or 12 PIN Block


Process: Calculate a Transformed PIN Value by hashing and/or encrypting the PIN recovered from the supplied
plaintext PIN Block.
Result: Error Code. Transformed PIN Value.
Processing Steps
1. If Algorithm Identifier indicates that the PIN is to be hashed (= x1 or x2 x3 or x4 or x5 or x6):
Extract the PIN from the PIN Block. If Format 2, unpack the digits and convert to ASCII. Build the hash data,
consisting of DataA (if present) followed by the ASCII PIN followed by DataB (if present), and execute the
appropriate hash function to obtain the hash result.
If no encryption is required (Algorithm Identifier = 01 or 02), supply the hash result as the Transformed PIN Value.
2. If Algorithm Identifier indicates that the PIN is to be hashed and encrypted (= 11 or 12 or 13 or 14 or 15 or 16):
If the hash algorithm is SHA-1, pad the hash result to the left with 4 bytes of zeroes to make the length a multiple of
8 bytes. Encrypt the 16 bytes (MD5) or 24 bytes (SHA-1 or 28 bytes (SHA-224) or 32 bytes (SHA-256) or 48 bytes

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 730
(SHA-384) or 64 bytes (SHA-512) using the KTPV from KTPV-Spec, the CBC mode of operation and an IV of
zeroes. Supply the resulting ciphertext as the Transformed PIN Value.
3. If Algorithm Identifier indicates that the PIN is to be encrypted only (= 10):
If the PIN Block is Format 2, convert to Format 0 using the data provided in DataA and DataB, (i.e. XOR DataA and
DataB and XOR the result onto the PIN Block). Encrypt the result using the KTPV from KTPV-Spec. Supply the
resulting encrypted PIN Block as the Transformed PIN Value.
Otherwise (Format 12), XOR DataA and DataB and XOR the result onto the PIN Block – excluding the first two
bytes of the PIN Block. [This is similar to the formatting for the format 0 PIN Block.] Encrypt the resulting formatted
PIN Block using the KTPV from KTPV-Spec, the CBC mode of operation and an IV of zeroes. Supply the resulting
ciphertext as the Transformed PIN Value.

NOTES
– The characters of DataA and DataB are XOR'd with the PIN Block. If more data is available in the field than is
required, the leftmost characters are used; if insufficient characters are supplied they will be right-justified and
padded to the left with zeroes. No demand has been made that the correct number of characters are supplied,
as the application may not know whether a Format 2 or 12 PIN Block has been recovered or the length of the
Format 12 Block.
– In case the encryption algorithm and hash algorithm are non-zero, the result of hashing will be padded with 0s
to the left to make it a multiple of block size.

PKCS#1 Parameter String


To enable PKCS#1 parameter string P, to specify the hash algorithm used in OAEP encoding, P can be in one of the
following formats:
• Variable length string without any formatting.
• Variable length string in following format:

Request Length Type Description

Header 2 h = X’5A5A’

Format 1 h =1

OAEP Hash 1 h = 2: SHA-1


Algorithm = 4: SHA-256
= 5: SHA-384
= 6: SHA-512

OAEP MGF 1 h = 12: MGF1 SHA-1


= 14: MGF1 SHA-256
= 15: MGF1 SHA-384
= 16: MGF1 SHA-512

OAEP P Var h PKCS#1 parameter string

Trailer 2 h = X’A5A5’

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 731
If the Header and Trailer fields do not match then P is treated as an unstructured variable length string encoded using
SHA-1 and MGF1 SHA1 . If they do match but any other fields are not as specified, then an appropriate error code is
returned.

Note: P is assumed to be a string of 32 hex digits (16 bytes).

PIN Block Format 12

Note: This format is specific to OBM host functions.

Alpha-numeric PIN of 4 – 30 characters will be placed in a Format 12 PIN block.


A format 12 PIN block consists of a number of 8-byte blocks in order to accommodate the clear password. The PIN
block accommodates an alpha-numeric password of 4 or more characters.

block 1 block 2 .......... block 4

CS L P P P P P/ P/ 8xP/F 8xP/F
F F

C = Control nibble, value = X'C' (decimal 12)


S = Secondary control nibble, value = X'1'
L = password length in range 4 to 30, i.e. X'04' <= L <= X'1E'
P = password character, any character X'00' <= P <= X'FF'
P / F = password or filler characters. The filler character is X'FF'
The PIN block consists of the minimum number of blocks that will accommodate the alpha-numeric PIN. A single block
accommodates a PIN from 4 to 6 characters, whereas 4 blocks would be required to accommodate a PIN of 23 to 30
characters.

OBM Message Data Format


OBM provides RSA-encryption of a message, M, to form a ciphertext C. Initially M is encoded using OAEP encoding,
as specified in PKCS#1, to form the encoded message, E(M), which is then encrypted using an RSA public key,
resulting in C.
Earlier, M used to incorporate the concatenation of one or two plaintext PIN blocks (PB) and a random number (RN).
The format is now extended to facilitate encryption of data by defining further values of the control byte. Possible
additional values of the control byte are:

Control value Contents of M

1 1 || PB || RN

2 2 || PB1 || PB2 || RN

3 3 || Data

4 4 || Alg || Mode || Symmetric key || IV

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 732
Format 1

Field Length Type Description

Control 1 h =1

PB Multiple of h PIN Block Format 12.


8

RN >=8 h Random Number

PB incorporates a PIN block consisting of 8, 16, 24 or 32 bytes that contains an alpha-numeric PIN (password) using a
non-standard Format 12 PIN block (explained above). The random number (RN) consists of at least 8 bytes from a
random bit stream.
The maximum length of Random Number (RN) depends on the RSA key length and the length of the hash result
produced in the PKCS#1 encoding.

Format 2

Field Length Type Description

Control 1 h =2

PB1 Multiple of h PIN Block Format 12


8

PB2 Multiple of h PIN Block Format 12


8

RN >=8 h Random Number

PB1 and PB2 incorporate a PIN block consisting of 8, 16, 24 or 32 bytes that contains an alpha-numeric PIN
(password) using a non-standard Format 12 PIN block (explained above). The random number (RN) consists of at least
8 bytes from a random bit stream.
The maximum length of Random Number (RN) depends on the RSA key length and the length of the hash result
produced in the PKCS#1 encoding.

Format 3

Field Length Type Description

Control 1 h =3

Data Var h User Data

The plaintext block contains the user data that is to be directly encrypted, and subsequently recovered using an HSM
host function. The maximum length of Data depends on the RSA key length and the length of the hash result produced
in the PKCS#1 encoding.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 733
Format 4

Field Length Type Description

Control 1 h =4

Alg 1 h = 1: 3DES

Mode 1 h = 1: ECB
= 2: CBC

K Var h Key of specified


algorithm.If 3DES,
length is 16 or 24.

IV Var h Initialization Vector. If


ECB, length is 0. If
3DES, CBC length is 8.

The plaintext block contains the encryption parameters used in the encryption of user data. (The enciphered data must
be transported separately.)

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 734
Remote ATM Initialization
Luna EFT provides RSA based functions to support remote key loading for NCR and Diebold ATMs. This enables the
initialization of ATM master keys to be automated, hence providing significant cost savings.

Supported Host Functions


Following is a list of host functions that support Remote ATM Initialization for Diebold and NCR.

Functionality Function Name Function Code

Diebold GENERATE-KEY-DIEBOLD EE9101

VERIFY-ATM-RESPONSE- EE9102
DIEBOLD

NCR GENERATE-KTM-NCR EE9201

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 735
Smart Card Support
Luna EFT provides various functions related to the card issuance processes for smart cards. Some of them are:

Issuer key Pair Initialization


• Generate issuer key pair: The issuer must generate and store an Issuer Key Pair (PI and SI). The public key and
associated data must be self-signed and delivered to the Certification Authority (e.g. on diskette).
• Verify CA Public Key (PCA): The issuer must receive, verify and store a self-signed CA public key, and use it to
verify issuer public key certificates provided by the CA.
• Verify Issuer Public Key certificate: The issuer must verify the certificates provided by the CA (using PCA) prior
to storing the certificate on an ICC.

Supported Host Functions


Functionality Function Name Function Code

Issuer Key Pair GENERATE-ISSUER-KEY-PAIR EE2040


Initialization
SELF-CERT-ISSUER-PUBLIC- EE2041
KEY

VERIFY-CA-PUBLIC-KEY-MC EE2042

VERIFY-ISSUER-PK-CERT-MC EE2043

SELF-SIGN-ISSUER-PK-VISA EE2044

VERIFY-CA-PK-VISA EE2045

VERIFY-ISSUER-PK-CERT-VISA EE2046

VERIFY-DETACHED-CERT-VISA EE2047

Static Data Authentication


• Sign ICC static data: The issuer must produce a digital signature (using SI) for card static data.
• Verify ICC static data: The issuer does not usually need to verify the ICC static data. Nevertheless, it may be
beneficial to perform such verification (using PI) to confirm that an ICC is functioning correctly, prior to issue.

Supported Host Functions


Functionality Function Name Function Code

Static Data SIGN-ICC-STATIC-DATA EE204B


Authentication
VERIFY-ICC-STATIC- EE204C
DATA

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 736
Dynamic Data Authentication
• Generate ICC key pair / Create ICC public key certificate: For each card that is to use Dynamic Data
Authentication, the issuer must generate a card key pair (PIC and SIC).
A certificate must be produced (using SI), which incorporates PIC and associated data, including the ICC static
data.
• Verify card certificate: The issuer does not usually need to verify the ICC certificate. Nevertheless, it may be
beneficial to perform such verification (using PI) to confirm that an ICC is functioning correctly, prior to issue.
• Verify card dynamic data: The issuer does not usually need to verify the dynamic data. Nevertheless, it may be
beneficial to perform such verification (using PIC) to confirm that an ICC is functioning correctly, prior to issue.

Supported Host Functions:


Functionality Function Name Function Code

Dynamic Data GENERATE-ICC-KEYPAIR EE2048


Authentication
GENERATE-ICC-CRT- EE2058
KEYPAIR

VERIFY-ICC-CERTIFICATE EE2049

DERIVE-ICC-MASTER-KEY EE204A

VERIFY-ICC-DYNAMIC-DATA EE204D

Offline PIN Encipherment


• Generate PIN encipherment key pair / Create PIN encipherment public key certificate: For each card that
supports an offline enciphered PIN, the issuer must either generate a card key pair (PPE and SPE) or use the key
pair generated for DDA for PIN encipherment as well.
In the former case, a certificate must be produced (using SI), which incorporates the PIN encipherment public key
and associated data.
• Verify PIN encipherment public key certificate: The issuer does not usually need to verify the PIN
encipherment public key certificate. Nevertheless, it may be beneficial to perform such verification (using PI) to
confirm that an ICC is functioning correctly, prior to issue.
• Encipher PIN: The issuer does not usually need to produce and enciphered PIN - enciphered by the card's public
key. Nevertheless, it may be beneficial to perform such encipherment (using PIC or PPE) to confirm that an ICC is
functioning correctly, prior to issue.

Supported Host Functions:


Functionality Function Name Function
Code

Offline PIN RSA-ENCIPHER-PIN EE204E


Encipherment

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 737
Reference PIN management
PIN issuance: A reference PIN needs to be generated, provided to the cardholder and stored on the card for offline PIN
processing. Facilities are provided that can be used to generate and print the PIN, and calculate an Offset or PVV.
An Unblock Code (or associated data) may also need to be generated and stored on the card.

Supported Host Functions:


Functionality Function Name Function Code

Reference PIN GENERATE-RANDOM-PIN- EE204F


Management EMV

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 738
Visa Support
The following outline a few of the operations followed by Luna EFT host functions to comply with Visa standards:
• PVV Generation
• PIN Verification using the PVV method
• PIN Translation (i.e. PIN Block re-encryption)
PIN Translation is required as the HSM supports PIN Blocks encrypted by (short-term) session keys known as
PIN Protect Keys (PPK). The following re-encryptions are supported:
• PPK --> AWK
• IWK --> PPK
• Translation from AWK to IWK is not supported as this is only performed at the Network Central Security Module.
• CVV Generation
• CVV Verification.
• The PIN Management functionality of Luna EFT offers high performance with upto Up to 1600 Visa PIN Verify
(PVV) operations per second.
• The generic HSM keys and associated console operations and host functions can be used to support double-length
keys on VisaNet.

Visa 3DES Support


Generic HSM keys and associated console operations and host functions can be used to support double-length keys on
VisaNet.
The following 3DES functionality is not currently supported:
• Triple-length keys
• 3624 Offset PIN verification using a 3DES PVK
• Export/import of PVKs using a 3DES key

Equivalent keys
Key Type Visa Key HSM Key

Key encrypting key ZCMK KIS / KIR

PIN encrypting key AWK / IWK PPK

PIN verification key (PVV method) PVK-A / PVK-


B

Card validation key (CVV method) CVK-A / CVK-


B

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 739
Supported Host Functions
Functionality Function Name Function Code

PIN Verification using PVV PVV-VER EE0605


Method

Visa PVV Calculation from a PVV-CALC-3624 EE0606


PIN's IBM Offset data

Visa PVV for a PIN PVV-CALC EE0607

PIN Verification PIN-TRANS-SEED-DES EE0615

CVV Generation CVV-GENERATE EE0802

CVV Verification CVV-VERIFY EE0803

Visa Function Return Code


The following Return Code is specific to Visa functionality.

Return Code Meaning

0F Invalid Visa PIN Verification Key Indicator (PVKI)

Note: A Return Code of 0A (meaning, uninitialized key accessed), will be returned whenever
an attempt is made to access an AWK or IWK which has been stored in the HSM but is not
currently selected.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 740
Visa Cloud-Based Payments Support
Luna EFT’s mobile payment functionality is based on the Visa cloud-based payments (VCBP) standard and provides a
tamper-resistant environment for performing secure cryptographic processing, and key management. Luna EFT
supports card issuance to mobile devices using Cloud with HCE and tokenization or Secure Element for flexible
deployment options in various processing environments. It thus enables credential issuers, retailers, acquires and
switches to securely:
• Issue digital cards to the cloud using tokenization and HCE or to mobile phones with secure elements.
• Provision any card or credential including credit, debit, prepaid.
• Manage cards remotely with strong cryptographic support on card management and synchronization on cloud.

Supported Host Functions


Functionality Function Name Function Code

Derive Card Master Keys DERIVE-CLOUD-CMK EE3051

Derive Session keys and DERIVE-CBP-SESSION-KEYS EE3052


Restricted Use keys

Verify Application Cryptogram VALIDATE-CLOUD-AC-GENERATE- EE3053


and generate ARPC ARPC

See "Luna EFT Keys for Supported Cloud-Based Payments".

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 741
Visa Data Secure Platform (VDSP) with Point to Point Encryption
(P2PE)
Luna EFT provides support for encrypting/decrypting and translating the data protected with VDSP. VDSP uses
DUKPT key management at the point of service where the sensitive payment details are encrypted. It also provides
support for zone encryption, where fixed or dynamic keys are used for encryption of sensitive payment data between
parties.

Supported Host Functions


Functionality Function Name Function Code

Data Encryption/Decryption VFPE-ENCRYPT EE080A

VFPE-DECRYPT EE080B

Data Translation TRANSLATE-DATA-P2PE EE080C

TRANSLATE-VFPE-DATA-TO- EE080D
ALPHABET

TRANSLATE-VFPE-ALPHABET-TO- EE080E
DATA

PIN Translation PIN-TRAN-2 EE0602

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 742
ZKA Support
Luna EFT’s ZKA host functions perform the following operations to secure the debit card transactions:
• PIN verification with the help of two national PIN verification values, PVN 1 and PVN 2,
• MAC generation,
• Importing ZKA Master key through a key management function,
• PIN Translation, and
• PIN Verification

Session Key Derivation


The following data is entered into the derivation of the Session Key:

MK MKLEFT MKRIGHT

CV CVLEFT CVRIGHT

RND RNDLEFT RNDRIGHT

Note: There is only one MK. But there are separate values for the CV and RND data, depending on the type of Session
Key (MAC or PAC) - there is a CVMAC and CVPAC and RNDMES and RNDPAC
To derive the Session Key using above definitions, the following steps are required:
• TK1 = XOR (MKLEFT | CVLEFT)
• TK2 = XOR (MKRIGHT | CVLEFT )
• TK3 = XOR (MKLEFT | CVRIGHT)
• TK4 = XOR (MKRIGHT | CVRIGHT)
• SKLEFT =d*TK1 | TK2 ( RNDLEFT )
• SKRIGHT = d*TK3 | TK4 ( RNDRIGHT )
• SK = SKLEFT | SKRIGHT

PIN Verification
PIN verification is performed with the help of two national PIN verification values, PVN 1 and PVN 2, which can be
placed on the magnetic stripe of the ec-card instead of offset 1 and offset 2. It's also possible to verify the PIN without
using the PVNs on the magnetic stripe if these are stored in a "Positive-File" in the authorization system database. In
this case only one PVN is required.
Each PVN is generated with the help of a bank specific Master Key *KKBLZ, which is valid for a particular area and card
specific data. Within this BLZ area customer account numbers are unique and multiple cards per account are
identifiable via the card sequence number. The keys can be changed depending on the card's expiration year so that a
compromise of this key is restricted in time (1 year) and scope (this bank).
PVN is calculated as follows:
PVN = e* KKBLZ (X)
The value X is formed as follows:
• All values are encoded in binary form.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 743
• The 10-digit account number is binary encoded. At maximum, 34 bits are required. In the case of less than 34
effective bits, leading zeroes are pre-pended.
Example:
The binary representation of the 10-digit account number 8589939303 is:
10 00000000 00000000 00010010 01100111
The card sequence number can be encoded by 4 bits. A leading zero bit may be pre-pended.
Example:
The card sequence number 7 is represented in binary as follows:
0111
The PIN length is encoded by 2 bits:
Length 4: 00
Length 5: 01
Length 6: 10
The last digit of the expiration year of the card is encoded by 4 bits (the same as the card sequence number)
Example:
The 8 in the expiration year 1998 is encoded as:
1000
The PIN is interpreted as a maximum 6-digit number and can be represented in binary by a maximum of 20 bits.
Example:
The 6-digit PIN 291255 is encoded as follows:
0100 01110001 10110111
In their binary representation, 4-digit PINs are pre-pended with leading zeroes.
The 64-bit value X is formed by the concatenation of the bits.
PIN length | Account Number | Card Sequence Number | Last Digit Expiration Year | PIN
For the above example the 64-bit value of X is:
10|10 0000 0000 0000 0000 0001 0010 0110 0111| 0111|1000|0100 0111 0001 1011 0111

Field Length Raw Value Converted Value

PIN Length 2 bits 4 10

Account Number 34 bits 8589939303 10 0000 0000 0000 0000 0001 0010 0110 0111

Card Sequence Number 4 bits 7 0111

Last digit Expiration Year 4 bits 8 1000

PIN 20 bits 291255 0100 0111 0001 1011 0111

X contains unique account number information and the PIN, so that the verification value within the validity scope of the
key *KKBLZ cannot be compromised.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 744
For larger banking organizations with several branch and BLZ areas, identical account numbers for several areas may
occur. In this case it is not permitted to use only one key for PIN verification for all areas of the bank.
As the account numbers within a specific BLZ area are unique, a unique key *KKBLZ has to be selected for each BLZ
area. If for organizational reasons, it isn't desirable to generate these keys independently of each other, they can be
derived by means of a Master Key.
For calculation of *KKBLZ two Master Keys - *KGKBank 1 and *KGKBank 2 are selected by a random process.
A Triple-DES key *KKBLZ is calculated for the desired BLZ area of the bank institution as follows:
e*KGKBank 1 (BLZ | BLZ) = *KKBLZ 1
e*KGKBank 2 (BLZ | BLZ) = *KKBLZ 2
and it is *KKBLZ = *KKBLZ1 | *KKBLZ 2
Decimalization is achieved as follows:
I = 1;
FOR j = 1 TO 16;
IF Cj .{0,…,9} THEN {
PVN [I] = Cj;
i = I + 1} ;
IF I == 5 THEN pvn_ok ( )
NEXT j ;
FOR j = 1 to 16;
IF Cj .{A,B,C,D,E,F} THEN {
PVN [i] = Cj - 10;
i = i + 1} ;
IF i = = 5 THEN pvn_ok ( )
NEXT j

Message Authentication Functions


The MAC key generation / recovery may be performed within the MAC generation / verification functions. The standard
function MAC-VER-FINAL (and MAC-UPDATE if required) can be used with a received RND by utilizing the key
specifier format defined above.
Function ZKA-MAC-GEN generates RND and uses the associated clear MAC key to generate the MAC.

Key Management Functions


This customization assumes that the session key is usually recovered or generated within the PIN or MAC function and
therefore no separate key management function need be used.
A key management function (ZKA-IMPORT-MK ) is provided though for the import of the ZKA Master Key.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 745
Supported Host Functions
Functionality Function Name Function Code

Key Translation ZKA-IMPORT-MK EE0210

PIN Translation ZKA-PIN-TRANS EE0610

PIN Verification ZKA-PIN-VER EE0611

PVN Calculation ZKA-CALC-PVN EE0612

PIN Block Format and PIN Encryption key ZKA-PIN-TRANS-1 EE0613


translation

Random Key Generation ZKA-MAC-GEN EE0710

Random Key Generation ZKA-MAC-GEN-1 EE0711

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 746
APPENDIX C
Error Codes

Luna EFT Error Codes


Error Code Description

00 No error

01 DES Fault (system disabled)

02 Illegal Function Code.


Either, PIN mailing, or Log archiving is not enabled on console.
Function is disabled in console.

03 Incorrect message length

04 Invalid data in message: Character not in range (0-9, A-F)

05 Invalid key index: Index not defined, key with this Index not stored or incorrect key
length

06 Invalid PIN format specifier: only AS/ANSI = 1 & IBM 3624 = 3 specified

07 PIN format error: PIN does not comply with the AS2805.3 1985 specification, is in an
invalid IBM 3624 format, or is in an invalid Docutel format

08 Verification failure

09 Contents of key memory destroyed: e.g. the Luna EFT was tampered or all Keys
deleted

0A Uninitiated key accessed. Key or decimalization table (DT) is not stored in the Luna
EFT.

0B Checklength Error. Customer PIN length is less than the minimum PVK length or less
than Checklen in function.

0C Inconsistent Request Fields: inconsistent field size.

0F Invalid VISA Index. Invalid VISA PIN verification key indicator.

10 Internal Error

11 Errlog file does not exist

12 Errlog internal error

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 747
APPENDIX C Error Codes

Error Code Description

13 Errlog request length invalid

14 Errlog file number invalid

15 Errlog index number invalid

16 Errlog date time invalid

17 Errlog before/after flag invalid

19 Unsupported key type

1A Duplicate key or record

20 Invalid key specifier length

21 Unsupported key specifier

22 Invalid key specifier content

23 Invalid key specifier format

24 Invalid Function Modifier. Invalid = 00

25 Invalid key attributes

27 Hash process failed

28 Invalid key type

29 Unsupported triple Des index

30 Invalid administrator signature

32 No administration session

33 Invalid file type

34 Invalid signature

35 KKL disabled

36 No PIN pad

37 Pin pad timeout

39 Public key pair not available

3A Public key pair generating

3B RSA cipher error

40 Unsupported HSM stored SEED key

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 748
APPENDIX C Error Codes

Error Code Description

50 Invalid variant scheme

50 Invalid SDF

51 Invalid hash indicator

52 Invalid public key algorithm

53 Public key pair incompatible

54 RSA key length error

55 PIN generation failed

60 Software already Loaded

61 Software being loaded from CD ROM

62 Software data segment too large

63 Invalid offset value

64 Software loading not initiated

65 Unsupported file id

66 Unsupported control id

67 Software image is being verified

70 Invalid PIN block flag

71 Invalid PIN block random padding

72 Invalid PIN block delimiter

73 Invalid PIN block RB

74 Invalid PIN block. Random number invalid

75 Invalid PIN block RA

76 Invalid PIN Block PIN

77 Invalid PIN Block PIN length

78 PIN Block format disabled or requested reformatting not allowed

79 Validation data check failed

7F Invalid print token

80 OAEP decode error

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 749
APPENDIX C Error Codes

Error Code Description

81 OAEP invalid header byte

82 OAEP invalid PIN block

83 OAEP invalid random number

84 OAEP message too long

90 General printer error

F0 Zero length PIN

91 Invalid key block version Id

92 Key block key authentication failure

93 Invalid key usage

94 Invalid algorithms

95 Invalid mode of use

96 Invalid version number

97 Invalid export flag

98 Invalid key length

99 Invalid reserve field

9A Invalid number of optional block

9B Invalid optional block header

9C Repeated optional block

9D Invalid key block

9E Invalid padding indicator

9F PIN generation failure

A0 PIN brute force attack detected

A1 Key translation not permitted

A2 Exportability not permitted

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 750
APPENDIX C Error Codes

AMB Error Codes


Error Code Description

00 SUCCESSFUL RESPONSE
This code is returned (by Luna EFT or host) when a request has been successfully completed and
any validation requirements have been successful. This is not an error condition.

03 TAMPER ERROR
Luna EFT has detected that it has been tampered or lost power to its long-term storage.

04 STORAGE FULL
A request has been made to store information in Luna EFT’s long term storage, but no space exists.

05 NO RESOURCES
Luna EFT is unable to complete the request owing to insufficient resources. This condition may be
transitory.

08 DES CIPHER PROCESSOR ERROR


An error has been detected during a DES cipher operation

09 VALIDATION ERROR

20 INVALID MESSAGE LENGTH


The request message length is invalid for the function.

21 REQUESTED FUNCTION NOT SUPPORTED


The request contained an inactive, invalid or unknown function code.

22 INVALID FIELD CONTENT


Luna EFT has detected a field within the request that has invalid data content (eg. non-numeric input
in a numeric only field) and a more specific error code is not applicable.
This error is also returned when keys are rejected as function input. For further information on the
conditions that lead to the rejection of keys see the section XClear Text KeysX.

23 INVALID VARIANT INDEX


The request contained a variant index that is not in the appropriate range.

24 KM REQUESTED NOT HELD


The request contained a reference to a KM which is not held within Luna EFT storage (That is, no
match has been found for the KM identifier within the request).

25 KPV REQUESTED NOT HELD


The request contained a reference to a KPV that is either out of range (00 to 0F) or referred to a KPV
that has not been loaded into Luna EFT.

26 INVALID MAC
For the MACVERIFY functions, the MAC field in the request did not match the MAC calculated on
the input data field.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 751
APPENDIX C Error Codes

Error Code Description

27 INVALID PADDING IN MAC RESIDUE


For the 6.2 functions, the MAC residue was incorrectly padded.

28 INVALID PIN
The PIN data within the transaction does not verify according to the PIN Verification method.

29 INVALID PIN BLOCK CONTENT


The PIN block does not conform to the validity checks applied to the decrypted block. This
response is equivalent to a return of invalid PIN.

2A INPUT BUFFER OVERFLOW


The request message length has exceeded the input buffer length.

2B ZERO PIN LENGTH ENTERED


The PIN length is zero. This is to cater for credit card transactions that do not have a PIN.

2C INVALID KEY SPECIFIER LENGTH


The length of the key field does not correspond to the length implied by the Key Specifier.

2D UNSUPPORTED KEY SPECIFIER


The Key Specifier is not supported by the function.

2E INVALID KEY SPECIFIER CONTENT


The content of the key specifier filed is inconsistent wit the key specifier format supplied. .

2F INVALID KEY SPECIFIER FORMAT


The format of the Key Specifier is invalid.

30 TERMPROOF FAILURE
The TERMPROOF function found a mismatch during the verify/check procedure.

31 PUBLIC KEY PAIR NOT AVAILABLE


A public key pair was not available from Luna EFT.

32 KVC ERROR
The KVC supplied was incorrect.

33 KPV VALIDATION ERROR


The random number validation test in the KPVSEND function failed.

34 KPVV REQUESTED NOT HELD


The request contained a reference to a KPVV that is either out of range or which is not held within
Luna EFT.

35 KPV NOT TRANSFERABLE


An attempt was made to transfer a KPV, which was stored in non transferable storage, to another
node via the KPVSEND function

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 752
APPENDIX C Error Codes

Error Code Description

36 KPVV FOREIGN OR NOT TRANSFERABLE


An attempt was made to exchange a KPVV, which was not entered at this node, to another node via
the KPVVSEND function.

37 MINIMUM PIN LENGTH REQUESTED NOT HELD


The request contained a reference to an associated PIN length that is either out of range or which is
not held within Luna EFT.

38 DECIMALIZATION TABLE REQUESTED NOT HELD


The request contained a reference to an associated Decimalization table that is either out of range
or which is not held within Luna EFT.

39 ITEM REQUESTED NOT HELD


A data item, other than those specifically mentioned in other return codes, was referenced but is not
held.

3A SIGNATURE VALIDATION FAILURE


The concatenation random number signature failed to materialize after decryption.

3B RSA CIPHER ERROR


RSA cipher operation has failed.

3C KEY TAG ERROR


The supplied key tag is incorrect.

3E DEA DISABLED
All pre-APCA functions that support DEA and do not have replacement/superseded function are not
removed. Single DES operations in such functions return an error response DEA DISABLED

40 RANDOM NUMBER VALIDATION ERROR


The encrypted Random Number supplied does not match the clear Random Number supplied.

41 PPID VALIDATION ERROR


The encrypted PPID supplied does not match the clear PPID supplied.

42 INVALID SIGNED DATA FORMAT


The signed data format value is not 0x03.

43 DEA 2 KEY LENGTH AND DATA MISMATCH


The length of the data supplied is not an integral multiple of the length of the relevant DEA 2 key
modulus (all lengths in bytes)

48 KEY BLOCK FORMAT ERROR


The ‘zero’ fill characters have been changed.

49 HASH BLOCK FORMAT ERROR


The ‘zero’ fill characters have been changed.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 753
APPENDIX C Error Codes

Error Code Description

4A KEY BLOCK TAG ERROR


The TAG is incorrect.

4B HASH BLOCK TAG ERROR


The TAG is incorrect.

4C PUBLIC KEY PAIR GENERATION


A Public key pair generation is in progress.

4D INVALID PUBLIC KEY


The request contained an invalid public key. The public key must have a modulus length of 2048 bits
and the exponent must have a value of 65537 (10001hex).

50 DATA FIELD INCORRECT LENGTH


The varying length data field for an Encryption or MAC operation was not a multiple of 8 bytes (64
bits) long. For a future algorithm, the field length was not a multiple of the specified block size. For a
DEA2 operation the length did not match the number of 8 byte blocks specified.

51 KEY SPECIFIER FORMAT NOT VALID FOR FUNCTION


The format specified in a K-Spec input field is either non-existent or is not valid for this function or is
not enabled.

52 PUBLIC KEY SIGNATURE VERIFICATION FAILED


The verification of public key signed data was unsuccessful.

53 INVALID PIN FORMAT SPECIFIER


The request contained an invalid PIN format.

60 SOFTWARE ALREADY LOADED


A Software load operation has failed because HSM box already have loaded software.

61 SOFTWARE BEING LOADED FROM CD ROM


A Software load operation has failed because Software upgrade from CD Rom is in progress.

62 SOFTWARE DATA SEGMENT TOO LARGE


A Software load function call has failed.

63 INVALID OFFSET VALUE


A Software load function call has failed.

64 SOFTWARE LOADING NOT INITIATED


A Software load function call has failed.

65 UNSUPPORTED FILE ID
A Software load function call has failed.

66 UNSUPPORTED CONTROL ID A Software load function call has failed.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 754
APPENDIX C Error Codes

Error Code Description

67 SOFTWARE IS BEING VERIFIED


A Software load function call has failed because already transferred Software image is being
verified.

0xA0 PIN BRUTE FORCE ATTACK


The PIN verification failure count has reached its maximum limit.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 755
APPENDIX D
References

Reference (A)
1 Integrated Circuit Card Application Specification For Debit and Credit on Chip, Version 2.0, MasterCard
International.

2 EMV ’96 Version 3.1.1, May 31, 1998 Integrated Circuit Card Application Specification for Payment Systems

3 EMV ’96 Version 3.1.1, May 31, 1998 Integrated Circuit Card Specification for Payment Systems Part IV –
Security Aspects; Annexes E and F.

4 EMV Draft version 0.5 October 31, 2000 Issuer Security Guidelines

5 EMV2000 Version 4.0 December 2000 Integrated Circuit Card Specification for Payment Systems Book 2 –
Security and Key Management

6 Europay Int'l Version 2.1 October 1999 Integrated Circuit Card (ICC) Application Specification for Pay Now
(Debit) and Pay Later (Credit) cards

7 MasterCard Int'l Version 2.1 November 1999 MasterCard Chip— Recommended Specifications for Debit and
Credit

8 Visa Int'l Version 1.4.0 October 2001 Visa Integrated Circuit Card Application Overview

9 Visa Int'l Version 1.4.0 October 2001 Visa Integrated Circuit Card (ICC) Specification

10 Common Electronic Purse Specifications – Technical Specification Version 2.3 March 2001

11 Joint Specification for Common Electronic Purse Cards Version 2.1.3 February, 2001

12 Joint Card Interface Specification for Issuers of Common Electronic Purse Cards –Volume 1 – Load,
Currency Exchange and POS Transaction Processing Version 1.0 April 2000

13 Visa Cash Electronic Purse Specifications – Technical Specification – Volume 1, Version 4.1 September
2000

14 Visa Cash Electronic Purse Specifications – Technical Specification – Volume 2, Version 4.1 January 2001

15 Visa International CEPS PSAM Creator Version 1.0

16 PSAM DES Key Card Version 1.10 April 5, 2002

17 Diebold, Certificate Management, Rev. 1.4, 24 Jun 02

18 Diebold, Remote Key Management, Rev. 1.4, 24 Jun 02

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 756
APPENDIX D References

19 Diebold, Triple DES Requirements, FIRST Key – 91x Message Formats, Rev. 1.5, 26 Jun 02

20 NCR, Modifications to NDC+ to support: EPP, RSA Initial Key loading, ISO PIN Block formats, 17 Jul 01

21 RSA Laboratories, PKCS#1: RSA Cryptography Standard, v2.0, 01 Oct 98

22 RSA Laboratories, PKCS#10: Certification Request Syntax Standard, v1.7, 26 May 00

23 RSA Laboratories, PKCS#7: Cryptographic Message Syntax Standard, v1.5, 01 Nov 93

24 X9.24 Part II, Symmetric Key Management, using asymmetric techniques for the distribution of symmetric
keys, V1.0., ..03

25 ANSI X9, TR-31 2004: Interoperable Secure Key Exchange Key Block Specification for Symmetric
Algorithms, Draft, 7 Nov 03

26 Vendor Group (ACI WorldWide, HP Atalla, Diebold, Thales e-Security, Verifone Inc.), Global Interoperable
Secure Key Exchange key Block, V2.3, 6 Dec 02

27 Verfione, Global Interoperable Secure Key Exchange (GISKE) Key Block Specification, VPN 22986 Rev C,
data unknown

28 ISO 9564-1-2002 Banking - Personal Identification Number - PIN - management and security - Part 1- Basic
principles and requirements for online PIN handling in ATM and POS systems.

29 ISO 9564-3-2003 Banking - Personal Identification Number management and security - Part 3- Requirements
for offline PIN handling in ATM and POS systems.

30 ANS X9.24-1 Retail Financial Services Symmetric Key Management Part 1 :Using Symmetric Techniques:
2004

31 MasterCard SecureCode Chip Authentication Program: Functional Architecture: Sept, 2004.

32 Common Personalization Specification,Visa International, Version 1.5, January 2002.

33 Global Platform Card Specification, Global Platform, Version 2.1, June 2001.

34 Schnittstellen Spezifikation für die ZKA-Chipkarte: Secure Chip Card Operating System (SECCOS), Version
5.0, June 2001.

35 EMV Integrated Circuit Card Specification for Payment Systems: Book 2 – Security and Key Management,
Version 4.1, May 2004.

36 Specification Update Bulletin No. 46 Replacement of EMV Session Key Derivation Method First Edition
October 2005

37 American Express Global Network Services AEIPS Chip Card Specification 4.0 March 2003

38 JCB Int’l JCB IC Card Specification 2.0 April 2002

39 Visa Int'l Version 1.3.2 Visa Integrated Circuit Card Card (ICC) Specification July 1999

40 ZKA Interface Specifications for the SECCOS ICC Version 6.2 18.09.2007 with revisions.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 757
APPENDIX D References

41 PayPass – M/Chip Technical Specifications

42 VISA Contactless Payment Specification version 2.0.2 Jul 2006

43 ANSI_X9_TR-31_Final_2005

44 Support for Derived Unique Key per Transaction (DUKPT), Version 0.3, Apr 2004

45 ISO/IEC 9797-1:1999 Information technology - Security techniques – Message Authentication Codes


(MACs) - Part 1: Mechanisms using a block cipher

46 AEIPS Hardware Security Module (HSM) Specification by American Express, Version 4.1, May 2010

47 Network Specifications by American Express, October 2009

48 China Union Pay Financial Integrated Circuit (IC) Card Specification Part VII: Security Specification for
Debit/Credit Application, December 2009.

49 RFC 2246: The TLS Protocol Version 1.0 by IETF, January 1999

50 RFC 2104: HMAC: Keyed-Hashing for Message Authentication by IETF, February 1997

51 SPA Algorithm for the MasterCard Implementation of 3-D Secure v1.04 by MasterCard Int’l, 27th May 2004

52 MasterCard SecureCode Member Enrollment and Implementation Guide by MasterCard Int’l

53 FIPS PUB 198: The Keyed-Hash Message Authentication Code (HMAC) by NIST, 06th March 2002.

54 PKCS #11: Cryptographic Token Interface Standard v2.20 by RSA Laboratories, 28th June 2004

55 PKCS #1: RSA Cryptography Standard v2.0 by RSA Laboratories, 01st October, 1998

56 3-D Secure: System Overview v1.0.2 by Visa International, 01 May 2003

57 3-D Secure: Protocol Specification – Core Functions v1.0.2 with errata by Via International, 20th Jan 2004

58 3-D Secure: Functional Requirements – Access Control Server v1.0.2 with errata by Via International, 20th
Jan 2004

59 3-D Secure: Functional Requirements – Merchant Server Plug-in v1.0.2/1.0.1 with errata by Visa
International, 20th Jan 2004

60 3-D Secure: Functional Specification – Chip Card Authentication v1.0 by Visa International, 06th August 2001

61 3-D Secure: Protocol Specification – Extension for Mobile Internet Devices v1.0.2/1.0.1 with errata by Visa
International, 06th January 2003

62 3-D Secure: Protocol Specification – Extension for Voice and Messaging Channels by Visa International

63 3-D Secure: Security Requirements – Enrollment and Access Control Servers v1.1 by Visa International,
01st January 2004

64 XML Signature Syntax and Processing second edition by W3C, 10th June 2008

65 FIPS Publication 180-3 Secure Hash Standard (SHS) by NIST, October 2008

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 758
APPENDIX D References

66 FIPS Publication 198 The Keyed-Hash Message Authentication Code (HMAC) by NIST, March 2002

67 TR-31 200x Interoperable Secure Key Exchange Key Block Specification for Symmetric Algorithms, 2010.

68 Interface specification for ZKA Chip Card v5.0.1 by ZKA, 2003.

69 PKCS #7: Cryptography Message Syntax Standard by RSA Laboratories, Version 1.5, 1st November 93.

70 BPS; a Format-Preserving Encryption Proposal, by Eric Brier, Thomas Peyrin and Jacques Stern, France.

71 DKV - 7.5 PIN Code Algorithm DKV SELECTION CARD ISO code 704310, extracted from file DKV-spec-
Englisch_v2.12.pdf, Version 2.12.

72 HSM Security Requirements, by Beat Zeller, Version 0.1

73 Erdöl-Vereinigung (EV) IFSF Implementation Guidelines (EV) Guidelines Security by Franz Sidler/Reldis
Engineering AG, Version 1.0, 08 July 2010

74 EMV Integrated Circuit Card Specifications for Payment Systems, by EMVCo, LLC, Version 4.2, June 2008

75 GlobalPlatform Card Technology Secure Channel Protocol 03 Card Specification v 2.2 – Amendment D by
Global Platform version 1.1, September 2009

76 Special Publication 800-38B Recommendation for Block Cipher Modes of Operation: The CMAC Mode for
Authentication by NIST, May 2005

77 Special Publication 800-108 Recommendation for Key Derivation Using Pseudorandom Functions (Revised)
by NIST, October 2009

79 Specification Update Bulletin No. 74 AES option in EMV second edition by EMVCo, Jul 2010

80 National Standard Indonesian Chip Card Specification (NSICCS) – ATM/Debit Application Specification for
the HSM by NSICCS, June 2008

81 Retail Financial Services Symmetric Key Management Part 1: Using Symmetric Techniques by ANS X9.24-
1, October 2009

82 PKCS #1 v2.1: RSA Cryptography Standard by RSA Laboratories, 14th June 2002

83 Issuer Cryptographic Algorithms by MasterCard, Version 1.1

84 Issuer Cryptographic Algorithms v1.1 Erratum by MasterCard, November 2014

85 Erratum for MCBP ICA v1.1 by MasterCard, December 2014

86 Visa Cloud-Based Payments Contactless Specification by Visa Int’l, Version 1.3, July 2014

87 Visa Cloud Based Payments Program- Minimum requirements and Guidelines by Visa Int’l, Version 1.1, May
2014

88 Visa Cloud Based Payments Program Description by Visa Int’l, Version 1.1, May 2014

89 Visa Data Secure Platform with Point to Point Encryption (VDSP with P2PE) Hardware Security Module
Guide, Version 3.3, June, 2014

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 759
APPENDIX D References

90 Payment Card Industry (PCI) Point-to-Point Encryption Solution Requirements and Testing Procedures:
Encryption, Decryption, and Key Management within Secure Cryptographic Devices, Version 1.1.1, July
2013

91 3-D Secure Functional Requirements: Access Control Server, Version 1.0.2, July 16, 2002

92 Schlüsselausgabe mit AES-Schlüsseln by Bank-Verlag GmbH, Version 1.3, Feb 2015

93 NIST Special Publication 800-38F, Dec 2012

94 EMV, Book 1 Application Independent ICC to Terminal Interface Requirements, Version 4.3, Nov 2011

95 EMV, Book 2 Security and Key Management, Version 4.3, Nov 2011

96 EMV, Book 3 Application Specification, Version 4.3, Nov 2011

97 EMV, Book 4 Cardholder, Attendant, and Acquirer Interface Requirements, Version 4.3, Nov 2011

98 SECCOS, Interface Specifications for the SECCOS ICC, Version 7.1, July 2014

Reference (B)
1 Integrated Circuit Card Application Specification For Debit and Credit on Chip, Version 2.0, MasterCard
International.

2 EMV ’96 Version 3.1.1, May 31, 1998, Integrated Circuit Card Application Specification for Payment
Systems.

3 EMV ’96 Version 3.1.1, May 31, 1998, Integrated Circuit Card Specification for Payment Systems Part IV –
Security Aspects; Annexes E and F.

4 EMV Draft version 0.5, October 31, 2000, Issuer Security Guidelines.

5 EMV2000 Version 4.0, December 2000, Integrated Circuit Card Specification for Payment Systems Book 2 –
Security and Key Management.

6 Europay Int'l Version 2.1, October 1999, Integrated Circuit Card (ICC) Application Specification for Pay Now
(Debit) and Pay Later (Credit) cards.

7 MasterCard Int'l Version 2.1, November 1999, MasterCard Chip— Recommended Specifications for Debit
and Credit.

8 Visa Int'l Version 1.4.0, October 2001, Visa Integrated Circuit Card Application Overview.

9 Visa Int'l Version 1.4.0, October 2001, Visa Integrated Circuit Card (ICC) Specification.

10 Common Electronic Purse Specifications – Technical Specification, Version 2.3, March 2001.

11 Joint Specification for Common Electronic Purse Cards, Version 2.1.3, February 2001.

12 Joint Card Interface Specification for Issuers of Common Electronic Purse Cards –Volume 1 – Load,
Currency Exchange and POS Transaction Processing, Version 1.0, April 2000.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 760
APPENDIX D References

13 Visa Cash Electronic Purse Specifications – Technical Specification – Volume 1, Version 4.1, September
2000.

14 Visa Cash Electronic Purse Specifications – Technical Specification – Volume 2, Version 4.1, January 2001.

15 Visa International CEPS PSAM Creator, Version 1.0.

16 PSAM DES Key Card, Version 1.10, April 5, 2002.

17 Registration Authority (RA) Interface Specification, Europay International, Version 2.1, November 2000.

18 Visa Certificate Authority User's Guide Visa International, Version 1.2, 31 March 2001.

19 Common Personalization Specification, Visa International, Version 1.5, January 2002.

20 Global Platform Card Specification, Global Platform, Version 2.1, June 2001.

21 Diebold, Certificate Management, Rev. 1.4, 24 Jun 02

22 Diebold, Remote Key Management, Rev. 1.4, 24 Jun 02

23 Diebold, Triple DES Requirements


FIRST Key – 91x Message Formats, Rev. 1.5, 26 Jun 02

24 NCR, Modifications to NDC+ to support:


EPP
RSA Initial Key loading
ISO PIN block formats, , 17 Jul 01

25 RSA Laboratories, PKCS#1: RSA Cryptography Standard, v2.0, 01 Oct 98

26 RSA Laboratories, PKCS#10: Certification Request Syntax Standard, v1.7, 26 May 00

27 RSA Laboratories, PKCS#7: Cryptographic Message Syntax Standard, v1.5, 01 Nov 93

28 X9.24 Part II, Symmetric Key Management, using asymmetric techniques for the distribution of symmetric
keys, V1.0., ..03

29 Visa Int'l Visa Smart Debit Card (VSDC) Technical Guide to Visa’s Applet for GlobalPlatform Cards.
November 2003.

30 ISO 9564-1-2002 Banking - Personal Identification Number - PIN - management and security - Part 1- Basic
principles and requirements for online PIN handling in ATM and POS systems.

31 ISO 9564-3-2003 Banking - Personal Identification Number management and security - Part 3- Requirements
for offline PIN handling in ATM and POS systems.

32 Visa International – Common Personalization Specification, V1.5. January 2002.

33 EMV Card Personalization Specification, V1.1, July 2007.

34 EMVCo: EMV Card Personalization Specification Version 1.0, June 2003

35 Global Platform: Card Configuration and Script Builder Specification, Version 2.0.2, November 2000

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 761
APPENDIX D References

36 Global Platform: Card Specification, Version 2.1.1, March 2003

37 Global Platform: Card Specification, Version 2.2, March 2006

38 Global Platform: Card Technology Secure Channel Protocol 03 Card Specification v 2.2 – Amendment D,
Version 1.1, September 2009

39 Global Platform: Guide to Common Personalization, Version 1.0, March 2003

40 RSA Laboratories: PKCS#11, RSA Cryptography Standard, Version 2.1, June 2002

41 Visa International: Common Personalization Specification, Version 1.5, January 2002

42 Visa International: Common Personalization Technical Requirements for Visa Smart Debit and Credit
(VSDC), Version 1.2, December 2001

Reference (C)
1 MasterCard Int'l: MChip/4 Security and Key Management, June 2006

2 EMVCo: EMV2000 Integrated Circuit Card Specification for Payment Systems Book 2 – Security and
Key management, Version 4.1, May 2004

4 Visa Int'l: Visa Integrated Circuit Card Specification, Version 1.4.0, September 2005

5 ZKA: Schnittstellen Spezifikation für die ZKA-Chipkarte Secure Chip Card Operating System
(SECCOS), Version 5.0, June 2001

6 American Express, Global Network Services: AEIPS Chip Card Specification, Version 4.0, March 2003

7 JCB Int'l: JCB IC Card Specification, Version 2.0, April 2002

9 MasterCard Int'l: MasterCard Chip - Recommended Specifications for Debit and Credit, Version 2.1,
November 1999

10 EMVCo: EMV2000 Integrated Circuit Card Specification for Payment Systems; Book 2 - Security and
Key management, Version 4.0, December 2000

11 Visa Int'l: Visa Integrated Circuit Card Specification, Version 1.3.2, July 1999

12 ZKA: Interface specifications for the SECCOS ICC, Version 6.2, September 2007

13 EMVCo: Specification Update Bulletin No. 46 Replacement of EMV session key derivation method,
Version 1, October 2005

14 PayPass: M/Chip Technical Specifications

15 VISA: Contactless Payment Specification, Version 2.0.2, July 2006

16 American Express: AEIPS Hardware Security Module (HSM) Specification by American Express,
Version 4.1, May 2010

17 American Express: Network Specifications by American Express, October 2009

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 762
APPENDIX E
How to Create and Print a PostScript File

This section details the steps to create, load and then print a postscript file. These steps are further divided as the
following:
1. Creating a postscript file
2. Configuring settings for printing the postscript file
3. Loading the postscript file
4. Printing the postscript file

Steps to Create, Load and then Print a PostScript File


1. Create a PostScript file: This step helps you to create a postscript template file.
– Create a text file with any random data with six place holders (XXXXLINE1, XXXXLINE2, XXXXLINE3,
XXXXDATE, XXXXSALUTE, and XXXXPIN).
– Convert the generated text file to hexadecimal format. The resultant data is then loaded to Luna EFT in the form
of postscript file.
The maximum size of this postscript file must not exceed 20MB.
2. Configure settings for printing the PostScript file
– Configure your USB printer.
– Enable the Postscript PIN Mailer option.
3. Load the PostScript file: Using the host function EE0E02 (LOAD_PS), copy the data to be printed to LunaEFT, in
the postscript file created using step 1.
– Divide the post script template file into a chunk of N bytes.
– Send the first file with mode 00 and thereafter send files with 01, and 02 modes. Indicate the end of file mode.
– The function concatenates the data sent in files and creates a postscript template file for future use.
4. Print the PostScript file: Use the host function EE0E03 (PRINT_PS) to read the postscript template file copied on
to Luna EFT by host function EE0E02. The function replaces the place holder with actual PIN, and other sensitive
information and generates the final format before printing it using a postscript printer connected on a USB port.

References
• Console Guide for details on Printer Settings and the Postscript PIN Mailer option.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 763
APPENDIX F
Luna EFT and Cloud Based Payments (CBP)

Introduction
This section provides a detailed understanding of SafeNet’s Luna EFT implementation with MasterCard and Visa cloud
based payment specification. The information provided in this section are meant for issuers who are using MasterCard
and Visa cloud based payment for account enablement, credential management, and transaction management.

Account Enablement
Responsible for managing cardholder identification and verification process, and card digitization process.

Implementation Steps Function Name Function Code Description

Digitize the card to enable user Generate Issuer Master Key


mobile device(s) to perform (IMK) using lunash command:
payments keyMgmt generate hsm
imk

DERIVE-CLOUD-CMK EE3051 Derives Card Master Keys


(CMK) for contactless and
remote payments on cloud.

CCM-ENCRYPT EE305D Used for enciphering in CBC-


Counter mode.

Manage and secure the mobile PROTECT-CLEAR- EE3056 Encrypts the clear mobile PIN.
PIN for Mobile Payment MOBILE-PIN
Application (MPA)
PROTECT- EE3057 Translates the encrypted
ENCRYPTED-MOBILE- mobile PIN from one set of
PIN protection key to another.

Validate mobile PIN CHECK-CLEAR- EE3058 Verifies the encrypted mobile


MOBILE-PIN PIN with clear mobile PIN.

CHECK-ENCRYPTED- EE3059 Verifies the provided mobile


MOBILE-PIN PIN against the reference
mobile PIN.

Share keys securely with CCM-ENCRYPT EE305D Used for enciphering in CBC-
Transaction Management Counter mode.
System (TMS)
CCM-DECRYPT EE305E Used for deciphering using
CBC-Counter mode.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 764
APPENDIX F Luna EFT and Cloud Based Payments (CBP)

Credential Management
Provisions the remote management of mobile payment application (MPA). It encompasses the delivery of payment
credentials to the MPA, necessary to support transactions.

Implementation Steps Function Name Function Code Description

Generate single use key unique ADVANCED-RANDOM- EE0619 Generates a random key of any
to each mobile device KEY-GENERATION key type and encrypts under
the respective KM variant.

Distribute encrypted mobile CHECK- EE3050 Validates the authentication


master keys AUTHENTICATION- code involving encrypted data.
CODE

IMPORT-RSA-ENC-KEY EE3060 Translates a key from


encryption under an
asymmetric key to encryption
under AES Domain Master
Key.

EXPORT-KEY-2 EE3061 Translates a key from


encryption under Domain
Master Key to encryption under
specified KEK.

Generate initial set of CCM-DECRYPT EE305E Used for deciphering using


parameters for keys CBC-Counter mode.

DERIVE-CBP-SESSION- EE3052 Derives session keys and


KEYS restricted use keys for
contactless and remote
payments on cloud.

CALCULATE-IDN EE3055 Derives IDN number for cloud


based payments.

PROTECT-DC-FILE EE305C Prepare the file containing keys


used for AC generation in cloud
based payments.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 765
APPENDIX F Luna EFT and Cloud Based Payments (CBP)

Implementation Steps Function Name Function Code Description

Transfer data from CMS to MPA RNS-MESSAGE EE305F Prepares Remote Notification
Service Message and provide
DPK encrypted Session Id to
be used in CBP as derivation
and verification data.

DERIVE-MOBILE- EE305A Derives mobile session keys


SESSION-KEY from the mobile master keys.

WEB-SERVICE- EE305B Used for both encryption and


MESSAGE authentication for sending
message as well as verification
and decryption of received
message.

Intercommunication with other CCM-ENCRYPT EE305D Used for enciphering in CBC-


components Counter mode.

CCM-DECRYPT EE305E Used for deciphering using


CBC-Counter mode.

Transaction Management
Responsible for validating transaction performed using a digitized card.

Implementation Steps Function Name Function Code Description

Verify cryptograms VALIDATE-CLOUD-AC- EE3053 Verifies the application


GENERATE-ARPC cryptogram for cloud based
payments.

Verify CVC3 VALIDATE-CBP-CVC3 EE3054 Verifies the CVC3 generated


for magstripe cards used in
cloud based payments.

Intercommunication with other CCM-ENCRYPT EE305D Used for enciphering in CBC-


components Counter mode.

CCM-DECRYPT EE305E Used for deciphering using


CBC-Counter mode.

Luna EFT 2.0.6 Product Documentation


Copyright 2016 SafeNet, Inc. All rights reserved. 766

You might also like