Cryptographic Calculator – Development menu

Introduction

The EFTtools set consist of applications supporting payment transaction service development, testing and benchmarking. It currently consists of following components: Cryptographic Calculator and HSM Commander.

This tutorial focuses on Cryptographic Calculator functionality and is provided in six separated parts as per functionality topics covered by its main menu – Generic, Cipher, Keys, Payments, EMV and Development tools. This tutorial also aspires to provide bits of basic history on algorithms in use.

Development tools

This set of tools focuses on how to make developers their work easier, when working with payment tools.

Secure Padding

This helps you to add and/or remove ZERO padding to the left to make the output data length modulo 16 equal 0. Input can be Base64 encoded or in hexadecimal form, hexadecimal for removing only.

Add padding

Add padding: finished
****************************************
Input Data: V2UsIGF0IEVGVExhYiwgYmVsaWV2ZSB0aGF0IHRlc3RpbmcgbXVzdCBlbXBvd2VyIGJ1c2luZXNzIGFuZCBub3Qgc2xvdyBpdCBkb3duLg==
—————————————-
Padded Data: 0057652C206174204546544C61622C2062656C6965766520746861742074657374696E67206D75737420656D706F77657220627573696E65737320616E64206E6F7420736C6F7720697420646F776E2E

Add padding: finished
****************************************
Input Data: 57652C206174204546544C61622C2062656C6965766520746861742074657374696E67206D75737420656D706F77657220627573696E65737320616E64206E6F7420736C6F7720697420646F776E2E
—————————————-
Padded Data: 0057652C206174204546544C61622C2062656C6965766520746861742074657374696E67206D75737420656D706F77657220627573696E65737320616E64206E6F7420736C6F7720697420646F776E2E

Remove padding

Remove padding: finished
****************************************
Input Data: 0057652C206174204546544C61622C2062656C6965766520746861742074657374696E67206D75737420656D706F77657220627573696E65737320616E64206E6F7420736C6F7720697420646F776E2E
—————————————-
Clear Data: 57652C206174204546544C61622C2062656C6965766520746861742074657374696E67206D75737420656D706F77657220627573696E65737320616E64206E6F7420736C6F7720697420646F776E2E

String builder

C++ developer screen to transform various data to the code. You may add an optional cast and/or wrap the output to fit the screen or match your coding standards.

Character encoding

Hexadecimal to char array initializer.

String Builder: done
****************************************
Data In: 57652C206174204546544C61622C2062656C6965766520746861742074657374696E67206D75737420656D706F77657220627573696E65737320616E64206E6F7420736C6F7720697420646F776E2E
—————————————-
Data Out:
(const unsigned char*)0x57, (const unsigned char*)0x65, (const unsigned char*)0x2C, (const unsigned char*)0x20, (const unsigned char*)0x61, (const unsigned char*)0x74, (const unsigned char*)0x20, (const unsigned char*)0x45, (const unsigned char*)0x46, (const unsigned char*)0x54, (const unsigned char*)0x4C, (const unsigned char*)0x61, (const unsigned char*)0x62, (const unsigned char*)0x2C, (const unsigned char*)0x20, (const unsigned char*)0x62,
(const unsigned char*)0x65, (const unsigned char*)0x6C, (const unsigned char*)0x69, (const unsigned char*)0x65, (const unsigned char*)0x76, (const unsigned char*)0x65, (const unsigned char*)0x20, (const unsigned char*)0x74, (const unsigned char*)0x68, (const unsigned char*)0x61, (const unsigned char*)0x74, (const unsigned char*)0x20, (const unsigned char*)0x74, (const unsigned char*)0x65, (const unsigned char*)0x73, (const unsigned char*)0x74,
(const unsigned char*)0x69, (const unsigned char*)0x6E, (const unsigned char*)0x67, (const unsigned char*)0x20, (const unsigned char*)0x6D, (const unsigned char*)0x75, (const unsigned char*)0x73, (const unsigned char*)0x74, (const unsigned char*)0x20, (const unsigned char*)0x65, (const unsigned char*)0x6D, (const unsigned char*)0x70, (const unsigned char*)0x6F, (const unsigned char*)0x77, (const unsigned char*)0x65, (const unsigned char*)0x72,
(const unsigned char*)0x20, (const unsigned char*)0x62, (const unsigned char*)0x75, (const unsigned char*)0x73, (const unsigned char*)0x69, (const unsigned char*)0x6E, (const unsigned char*)0x65, (const unsigned char*)0x73, (const unsigned char*)0x73, (const unsigned char*)0x20, (const unsigned char*)0x61, (const unsigned char*)0x6E, (const unsigned char*)0x64, (const unsigned char*)0x20, (const unsigned char*)0x6E, (const unsigned char*)0x6F,
(const unsigned char*)0x74, (const unsigned char*)0x20, (const unsigned char*)0x73, (const unsigned char*)0x6C, (const unsigned char*)0x6F, (const unsigned char*)0x77, (const unsigned char*)0x20, (const unsigned char*)0x69, (const unsigned char*)0x74, (const unsigned char*)0x20, (const unsigned char*)0x64, (const unsigned char*)0x6F, (const unsigned char*)0x77, (const unsigned char*)0x6E, (const unsigned char*)0x2E

String Builder: done
****************************************
Data In: 57652C206174204546544C61622C2062656C6965766520746861742074657374696E67206D75737420656D706F77657220627573696E65737320616E64206E6F7420736C6F7720697420646F776E2E
—————————————-
Data Out:
0x57, 0x65, 0x2C, 0x20, 0x61, 0x74, 0x20, 0x45, 0x46, 0x54, 0x4C, 0x61, 0x62, 0x2C, 0x20, 0x62,
0x65, 0x6C, 0x69, 0x65, 0x76, 0x65, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x74, 0x65, 0x73, 0x74,
0x69, 0x6E, 0x67, 0x20, 0x6D, 0x75, 0x73, 0x74, 0x20, 0x65, 0x6D, 0x70, 0x6F, 0x77, 0x65, 0x72,
0x20, 0x62, 0x75, 0x73, 0x69, 0x6E, 0x65, 0x73, 0x73, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x6E, 0x6F,
0x74, 0x20, 0x73, 0x6C, 0x6F, 0x77, 0x20, 0x69, 0x74, 0x20, 0x64, 0x6F, 0x77, 0x6E, 0x2E

Trace parser

Helps to extract HEX and Binary data from a trace. For TCP dump you may want to collect the data with -XX parameter e.g. ‘$sudo tcpdump -XX port 51002’ and use the output. From BP-Sim you may just copy and paste the data from a trace.

Trace parsing: done
****************************************
Source format:
BP-Sim binary trace
Data In:
0000(0000) 01 F9 31 31 30 30 B0 30 05 40 20 E1 8A 00 00 00 ..1100.0.@ …..
0016(0010) 00 00 00 00 00 03 30 30 30 30 30 30 30 30 30 30 ……0000000000
0032(0020) 30 30 30 30 30 31 30 30 30 30 33 36 38 37 31 37 0000010000368717
0048(0030) 30 32 31 30 30 39 30 38 30 35 42 31 30 32 30 31 0210090805B10201
0064(0040) 32 30 30 31 34 43 32 30 30 35 35 34 31 33 37 34 20014C2005541374
0080(0050) 30 32 35 30 30 30 30 30 30 30 30 38 30 30 35 64 025000000008005d
0096(0060) 31 33 30 38 31 30 31 30 30 30 30 30 36 37 34 30 1308101000006740
0112(0070) 30 30 30 30 38 30 30 30 30 30 30 32 38 31 31 32 0000800000028112
0128(0080) 33 34 35 36 37 38 39 30 31 30 32 32 37 42 41 42 3456789010227BAB
0144(0090) 59 4C 4F 4E 20 4F 46 46 49 43 45 5C 32 32 5C 4C YLON OFFICE\22\L
0160(00A0) 6F 6E 64 6F 6E 5C 55 4B 30 35 38 30 84 00 00 04 ondon\UK0580….
0176(00B0) 00 00 00 64 65 30 30 30 30 30 30 30 30 30 31 33 …de00000000013
0192(00C0) 33 34 36 35 38 34 35 30 33 33 30 33 30 38 39 31 3465845033030891
0208(00D0) 31 3D 31 31 30 31 32 30 31 34 39 32 30 30 30 30 1=11012014920000
0224(00E0) 30 30 33 33 31 38 32 36 33 34 01 01 61 67 8D CE 0033182634..ag..
0240(00F0) 17 33 E1 D5 24 84 7C 03 24 38 72 F1 11 E5 A2 DF .3..$.|.$8r…..
0256(0100) C2 6C 1C 20 24 73 94 BB 3F 4E 30 B3 31 32 30 9F .l. $s..?N0.120.
0272(0110) 27 01 80 9F 34 03 00 20 00 9F 26 08 04 D2 F6 B5 ‘…4.. ..&…..
0288(0120) 2A D0 C2 47 9F 10 07 02 00 00 00 DA C9 99 9F 37 *..G………..7
0304(0130) 04 97 E1 B8 FF 9F 36 02 00 01 95 05 00 00 00 80 ……6………
0320(0140) 00 82 02 5C 00 9F 33 03 60 40 20 9F 1A 02 08 26 …\..3.`@ ….&
0336(0150) 9F 35 01 14 9F 03 06 00 00 00 00 00 00 9A 03 17 .5…………..
0352(0160) 02 10 9C 01 00 9F 02 06 00 00 00 00 01 08 5F 2A ………….._*
0368(0170) 02 08 26 9F 09 02 01 84 0E 31 50 41 59 2E 53 59 ..&……1PAY.SY
0384(0180) 53 2E 44 44 46 30 31 31 30 35 B0 00 00 00 00 00 S.DDF01105……
0400(0190) 00 00 33 31 31 31 32 30 30 30 30 30 31 31 31 31 ..31112000001111
0416(01A0) 31 30 30 30 30 30 31 30 30 30 30 30 30 30 30 30 1000001000000000
0432(01B0) 31 31 32 30 31 30 30 30 30 30 30 34 0E 00 23 00 112010000004..#.
0448(01C0) 30 34 38 FD 59 01 C3 D4 66 11 16 63 A4 93 B0 95 048.Y…f..c….
0464(01D0) FD 03 2E 51 7F 4C 15 0E 7F C7 7F E8 61 00 99 92 …Q.L……a…
0480(01E0) D0 5D 5E 7D DB B3 D0 F0 98 7C 13 8D 2D DB 04 35 .]^}…..|..-..5
0496(01F0) 15 36 88 E8 60 0D 41 52 C3 DF 34 .6..`.AR..4
—————————————-
Hexadecimal data (1014):
01F931313030B030054020E18A0000000000000000033030303030303030303030303030303130303030333638373137303231303039303830354231303230313230303134433230303535343133373430323530303030303030303830303564313330383130313030303030363734303030303038303030303030323831313233343536373839303130323237424142594C4F4E204F46464943455C32325C4C6F6E646F6E5C554B30353830840000040000006465303030303030303030313333343635383435303333303330383931313D313130313230313439323030303030303333313832363334010161678DCE1733E1D524847C03243872F111E5A2DFC26C1C20247394BB3F4E30B33132309F2701809F34030020009F260804D2F6B52AD0C2479F100702000000DAC9999F370497E1B8FF9F360200019505000000800082025C009F33036040209F1A0208269F3501149F03060000000000009A031702109C01009F02060000000001085F2A0208269F090201840E315041592E5359532E4444463031313035B0000000000000003331313132303030303031313131313030303030313030303030303030303131323031303030303030340E002300303438FD5901C3D466111663A493B095FD032E517F4C150E7FC77FE861009992D05D5E7DDBB3D0F0987C138D2DDB0435153688E8600D4152C3DF34

Binary data (507):
..1100.0.@ ………..000000000000000100003687170210090805B1020120014C2005541374025000000008005d130810100000674000008000000281123456789010227BABYLON OFFICE\22\London\UK0580…….de0000000001334658450330308911=110120149200000033182634..ag…3..$.|.$8r……l. $s..?N0.120.’…4.. ..&…..*..G………..7……6…………\..3.`@ ….&.5………………………._*..&……1PAY.SYS.DDF01105……..311120000011111000001000000000112010000004..#.048.Y…f..c…….Q.L……a….]^}…..|..-..5.6..`.AR..4

Data Decimalization

Help to decimalize output data with a decimalization tab specified for each of ‘0123456789ABCDEF’ characters.

Also you may specify how the decimalization output is reported, one option is to decimalize the data and report the output ‘As is’.

Decimalize: derivation finished
****************************************
Data: A12B34C56D78E90F
Decimalisation table: 0123456789012345
Offset: 0000000000000000
Decimalisation type: As Is
—————————————-
Decimalized Data: 0121342563784905

Finalized Data: 0121342563784905


Or you may take the numbers first and then do the decimalization, so the ‘A-F’ decimalized numbers will be on the end.

Decimalize: derivation finished
****************************************
Data: ABCDE01234567890
Decimalisation table: 0123456789012345
Offset: 0000000000000000
Decimalisation type: Numbers first
—————————————-
Decimalized Data: 0123456789012345

Finalized Data: 0123456789012345


BUT there is a difference when the ‘A-F’ character has possition greater than 5 in the input data, then we do use HSM conversion logic with following rule:
for each ‘A-F’ character add 5 and make the result modulo 10.
Example:
Expecting decimalization table:
0123456789ABCDEF
0123456789123456
Then A would normally be decimalized as ‘1’, ‘B’->’2′, ‘C’->’3′, ‘D’->’4′, ‘E’->’5′, ‘F’->’6′
The final used rule is:
A -> (1+5)%10 = 6;
B -> (2+5)%10 = 7;
C -> (3+5)%10 = 8;
D -> (4+5)%10 = 9;
E -> (5+5)%10 = 0;
F -> (6+5)%10 = 1

Decimalize: derivation finished
****************************************
Data: 0123456789ABCDEF
Decimalisation table: 0123456789123456
Offset: 0000000000000000
Decimalisation type: Numbers first
—————————————-
Decimalized Data: 0123456789678901

Finalized Data: 0123456789678901


There is an option to add an Offset to the result.

Decimalize: derivation finished
****************************************
Data: 0123456789ABCDEF
Decimalisation table: 0123456789012345
Offset: 0000000000000000
Decimalisation type: As Is
—————————————-
Decimalized Data: 0123456789012345

Finalized Data: 0123456789012345

Same result with offset value applied.

Decimalize: derivation finished
****************************************
Data: 0123456789ABCDEF
Decimalisation table: 0123456789012345
Offset: 1111111155555555
Decimalisation type: As Is
—————————————-
Decimalized Data: 0123456789012345

Finalized Data: 1234567834567890

Bit shift

The bit shifts are sometimes considered bitwise operations, because they treat a value as a series of bits rather than as a numerical quantity.

In these operations the digits are moved, or shifted, to the left or right.
Registers in a computer processor have a fixed width, so some bits will be “shifted out” of the register at one end, while the same number of bits are “shifted in” from the other end; the differences between bit shift operators lie in how they determine the values of the shifted-in bits.
Limitations: Binary output comes with a limitation of 64bits (trimmed), while other values are supported up to 128.

Left shift 1

Bit Shift ( << 1 ): operation finished
****************************************
Data: AFFABCCB
—————————————-
Decimal: 2952445131
Hexa: AFFABCCB
Binary: 10101111111110101011110011001011
—————————————-
After Bit Shift:
Decimal: 5904890262
Hexa: 15FF57996
Binary: 101011111111101010111100110010110

Right shift 3

Bit Shift ( >> 3 ): operation finished
****************************************
Data: AFFABCCB
—————————————-
Decimal: 2952445131
Hexa: AFFABCCB
Binary: 10101111111110101011110011001011
—————————————-
After Bit Shift:
Decimal: 369055641
Hexa: 15FF5799
Binary: 10101111111110101011110011001

Summary

In this article, we went through the functionality of Cryptographic Calculator covered by the Development Menu.

Cryptographic Calculator and other tools covered in EFTtools suite were designed to help and assist payment industry people in their day to day tasks and make their work the most effective. Our team would be grateful if you would suggest any improvements to our applications or report completely new functionality needed. Feedback from our users like this is exactly what drives the development of its and helps us to share our experience to wide public.