Ejemplo n.º 1
0
    def get_encrypted_pin(self, clear_pin, card_number):
        """
        Get PIN block in ISO 0 format, encrypted with the terminal key
        """
        if not self.terminal_key:
            print('Terminal key is not set')
            return ''

        if self.pinblock_format == '01':
            try:
                pinblock = bytes.fromhex(get_pinblock(clear_pin, card_number))
                #print('PIN block: {}'.format(raw2str(pinblock)))
            except TypeError:
                return ''

            encrypted_pinblock = self.tpk_cipher.encrypt(pinblock)
            return raw2str(encrypted_pinblock)

        else:
            print('Unsupported PIN Block format')
            return ''
Ejemplo n.º 2
0
 def test_get_pinblock_invalid_data(self):
     self.assertEqual(get_pinblock('IDDQD', 'BBPE'), '')
Ejemplo n.º 3
0
 def test_get_pinblock_length_5(self):
     self.assertEqual(get_pinblock('92389', '4000001234562'),
                      '0592789fffedcba9')
Ejemplo n.º 4
0
 def test_get_pinblock_length_4(self):
     self.assertEqual(get_pinblock('1234', '8998811234567890'),
                      '0412bceedcba9876')
Ejemplo n.º 5
0
 def test_get_pinblock_cardnumber_passed_as_int(self):
     self.assertEqual(get_pinblock('1234', 4000001234562000),
                      '041234fedcba9dff')
Ejemplo n.º 6
0
 def test_get_pinblock_pin_passed_as_int(self):
     self.assertEqual(get_pinblock(1234, '4000001234562000'),
                      '041234fedcba9dff')
Ejemplo n.º 7
0
 def test_get_pinblock_empty_pan(self):
     self.assertEqual(get_pinblock('1234', ''), None)
Ejemplo n.º 8
0
 def test_get_pinblock_empty_pin(self):
     self.assertEqual(get_pinblock('', '4000001234562000'), None)