/hsm-key-parts

HSM XOR key parts utilities

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

HSM XOR key parts utilities

Overview

Split and combine XOR keys for input into an HSM with any number of parts and calculate a KCV using 3DES or AES. For test keys only.

Dependencies

Examples

Split keys:

$ ./xor_split.py "1000 0000 0000 0000 0000 0000 0000 0001" -k 3des -t
Input: 1000 0000 0000 0000 0000 0000 0000 0001 (KCV 49 F9 E7)
Output 1: 4666 6666 6666 6666 6666 6666 6666 6665 (CCV F7 88 96)
Output 2: 5666 6666 6666 6666 6666 6666 6666 6664 (CCV 5B 9E 53)

$ ./xor_split.py "1000 0000 0000 0000 0000 0000 0000 0001" -k 3des -t -p 3
Input: 1000 0000 0000 0000 0000 0000 0000 0001 (KCV 49 F9 E7)
Output 1: 4161 6161 6161 6161 6161 6161 6161 6164 (CCV 3C B0 58)
Output 2: 1676 7676 7676 7676 7676 7676 7676 7674 (CCV 8E 15 AE)
Output 3: 4717 1717 1717 1717 1717 1717 1717 1711 (CCV 5A 10 DD)

Combine keys:

$ ./xor_merge.py "4666 6666 6666 6666 6666 6666 6666 6665" \
                 "5666 6666 6666 6666 6666 6666 6666 6664" -k 3des
Input 1: 4666 6666 6666 6666 6666 6666 6666 6665 (CCV F7 88 96)
Input 2: 5666 6666 6666 6666 6666 6666 6666 6664 (CCV 5B 9E 53)
Output: 1000 0000 0000 0000 0000 0000 0000 0001 (KCV 49 F9 E7)

$ ./xor_merge.py "4161 6161 6161 6161 6161 6161 6161 6164" \
                 "1676 7676 7676 7676 7676 7676 7676 7674" \
                 "4717 1717 1717 1717 1717 1717 1717 1711" -k 3des
Input 1: 4161 6161 6161 6161 6161 6161 6161 6164 (CCV 3C B0 58)
Input 2: 1676 7676 7676 7676 7676 7676 7676 7674 (CCV 8E 15 AE)
Input 3: 4717 1717 1717 1717 1717 1717 1717 1711 (CCV 5A 10 DD)
Output: 1000 0000 0000 0000 0000 0000 0000 0001 (KCV 49 F9 E7)

Combine and split keys in one operation:

$ ./xor_split.py "1777 7777 7777 7777 7777 7777 7777 7771" \
                 "0777 7777 7777 7777 7777 7777 7777 7770" -k 3des -t
Input 1: 1777 7777 7777 7777 7777 7777 7777 7771 (CCV 04 DA AB)
Input 2: 0777 7777 7777 7777 7777 7777 7777 7770 (CCV E1 65 41)
Input: 1000 0000 0000 0000 0000 0000 0000 0001 (KCV 49 F9 E7)
Output 1: 4666 6666 6666 6666 6666 6666 6666 6665 (CCV F7 88 96)
Output 2: 5666 6666 6666 6666 6666 6666 6666 6664 (CCV 5B 9E 53)

$ ./xor_split.py "1777 7777 7777 7777 7777 7777 7777 7771" \
                 "0777 7777 7777 7777 7777 7777 7777 7770" -k 3des -t -p 3
Input 1: 1777 7777 7777 7777 7777 7777 7777 7771 (CCV 04 DA AB)
Input 2: 0777 7777 7777 7777 7777 7777 7777 7770 (CCV E1 65 41)
Input: 1000 0000 0000 0000 0000 0000 0000 0001 (KCV 49 F9 E7)
Output 1: 4161 6161 6161 6161 6161 6161 6161 6164 (CCV 3C B0 58)
Output 2: 1676 7676 7676 7676 7676 7676 7676 7674 (CCV 8E 15 AE)
Output 3: 4717 1717 1717 1717 1717 1717 1717 1711 (CCV 5A 10 DD)