예제 #1
0
    def test_uninitialized_behavior(self):
        T = TripleSec()
        self._test_encrypt(T.encrypt, VECTOR['plaintext'], VECTOR['key'])
        self.assertEqual(T.decrypt(VECTOR['ciphertext'], VECTOR['key']), VECTOR['plaintext'])

        T = TripleSec(b'foo')
        self._test_encrypt(T.encrypt, VECTOR['plaintext'], VECTOR['key'])
        self.assertEqual(T.decrypt(VECTOR['ciphertext'], VECTOR['key']), VECTOR['plaintext'])
예제 #2
0
def FuzzyPoro():

    extractor = FuzzyExtractor(10, 2)  # (CharacterLength, ErrorAllowed)
    BiometricData = "0123456789"  # Sample Biometric Data
    # Create the key and the helper
    key, helper = extractor.generate(BiometricData)

    print('Your key is: %s' % (key))

    # Runs your generated key through TripleSec
    KeyForTripleSec = TripleSec(key)
    EncryptedPrivateKey = KeyForTripleSec.encrypt(
        b"ThisWouldBeYourPrivateKey")  # Encrypts your private key

    print('Your encrypted private key is: %s' % (EncryptedPrivateKey))

    # The second time you scan your fingerprint/biometric data
    KeyRecover = input("Enter your key:")

    KeyReturn = extractor.reproduce(KeyRecover,
                                    helper)  # Creates your original key

    print('Your recovered key is: %s' % (KeyReturn))

    # Runs your regenerated key through TripleSec
    ExtractedKey = TripleSec(KeyReturn)

    print('Your private key is: ')
    # Decodes your EncryptedPrivateKey with your regenerated encryption key
    print(ExtractedKey.decrypt(EncryptedPrivateKey).decode())
예제 #3
0
 def test_missing_key(self):
     T = TripleSec()
     regex = 'You didn\'t initialize TripleSec with a key'
     self.assertRaisesRegexp(TripleSecError, regex, lambda: T.encrypt(b'xxx'))
     self.assertRaisesRegexp(TripleSecError, regex, lambda: T.decrypt(b'xxx'))
     self.assertRaisesRegexp(TripleSecError, regex, lambda: triplesec.encrypt(b'xxx'))
     self.assertRaisesRegexp(TripleSecError, regex, lambda: triplesec.decrypt(b'xxx'))
예제 #4
0
 def test_initialized_behavior(self):
     T = TripleSec(VECTOR['key'])
     self._test_encrypt(T.encrypt,
                        VECTOR['plaintext'],
                        VECTOR['key'],
                        pass_key=False)
     self.assertEqual(T.decrypt(VECTOR['ciphertext']), VECTOR['plaintext'])
예제 #5
0
 def test_data_type(self):
     T = TripleSec(VECTOR['key'])
     regex = r'The input data needs to be a binary string'
     for d in (u'xxx', 12, [12, 13]):
         self.assertRaisesRegexp(TripleSecError, regex,
                                 lambda: T.decrypt(d))
         self.assertRaisesRegexp(TripleSecError, regex,
                                 lambda: T.encrypt(d))
예제 #6
0
def FuzzyPoro():

    extractor = FuzzyExtractor(10, 3)  # (CharacterLength, ErrorAllowed)
    # Sample Biometric Data
    BiometricData = input("Enter biometric data (10 characters):")
    BiometricData = BiometricData.encode('utf-8')
    PrivateKey = input("Enter your private key:")
    PrivateKey = PrivateKey.encode('utf-8')
    # Create the key and the helper
    key, helper = extractor.generate(BiometricData)

    print('Your key is: %s' % (key))

    # Runs your generated key through TripleSec
    KeyForTripleSec = TripleSec(key)
    EncryptedPrivateKey = KeyForTripleSec.encrypt(
        PrivateKey)  # Encrypts your private key

    # Writes a local file with your encrypted private key in it. This file
    #gets uploaded to IPFS and you get to keep a local backup. You can delete it if you want.
    FileWrite = open("EncryptedKey.txt", "w+")
    FileWrite.write(str(EncryptedPrivateKey))
    FileWrite.close()

    print('Your encrypted private key is: %s' % (EncryptedPrivateKey))

    # The second time you scan your fingerprint/biometric data
    KeyRecover = input("Enter your biometric data again:")
    KeyReturn = extractor.reproduce(KeyRecover,
                                    helper)  # Creates your original key

    print('Your recovered key is: %s' % (KeyReturn))

    # Runs your regenerated key through TripleSec
    ExtractedKey = TripleSec(KeyReturn)

    try:
        print('Your private key is: ')

        # Decodes your EncryptedPrivateKey with your regenerated encryption key
        print(ExtractedKey.decrypt(EncryptedPrivateKey).decode())
    except:
        print('Wrong encryption key :(')
예제 #7
0
 def test_data_type(self):
     T = TripleSec(VECTOR['key'])
     regex = r'The input data needs to be a binary string'
     for d in (u'xxx', 12, [12, 13]):
         self.assertRaisesRegexp(TripleSecError, regex, lambda: T.decrypt(d))
         self.assertRaisesRegexp(TripleSecError, regex, lambda: T.encrypt(d))
예제 #8
0
 def test_initialized_behavior(self):
     T = TripleSec(VECTOR['key'])
     self._test_encrypt(T.encrypt, VECTOR['plaintext'], VECTOR['key'], pass_key=False)
     self.assertEqual(T.decrypt(VECTOR['ciphertext']), VECTOR['plaintext'])
예제 #9
0
    # The second time you scan your fingerprint/biometric data
    KeyRecover = input("Enter your biometric data again:")

    KeyReturn = extractor.reproduce(
        KeyRecover, helper)  # Creates your original key

    print ('Your recovered key is: %s' % (KeyReturn))

    # Runs your regenerated key through TripleSec
    ExtractedKey = TripleSec(KeyReturn)

    try:
        print ('Your private key is: ')

        # Decodes your EncryptedPrivateKey with your regenerated encryption key
        print(ExtractedKey.decrypt(EncryptedPrivateKey).decode())
    except:
        print ('Wrong encryption key BAD BAD BAD')


def IPFS():
    try:
        api = ipfsapi.connect('127.0.0.1', 5001)
        print(api)

    except ipfsapi.exceptions.ConnectionError as ce:
        print(str(ce))

    UploadKey = api.add('EncryptedKey.txt')
    print(UploadKey)
    hash = api.cat(UploadKey['Hash'])
예제 #10
0
        # Sample Biometric Data
        BiometricData = raw_input("Enter a biometric data (10 characters):")
        PrivateKey = raw_input("Enter your private key:")
        # Create the key and the helper
        key, helper = extractor.generate(BiometricData)

    print ('Your key is: %s' % (key))

        KeyForTripleSec = TripleSec(key) #Runs your generated key through TripleSec
        EncryptedPrivateKey = KeyForTripleSec.encrypt(PrivateKey) #Encrypts your private key

    print ('Your encrypted private key is: %s' % (EncryptedPrivateKey))

        KeyRecover = input("Enter your key:") #The second time you scan your fingerprint/biometric data

        KeyReturn = extractor.reproduce(KeyRecover, helper) #Creates your original key

    print ('Your recovered key is: %s' % (KeyReturn))

        ExtractedKey = TripleSec(KeyReturn) #Runs your regenerated key through TripleSec

        try:     
                        print ('Your private key is: ')

                        print(ExtractedKey.decrypt(EncryptedPrivateKey).decode()) #Decodes your EncryptedPrivateKey with your regenerated encryption key
        except:
                        print ('Wrong encryption key BAD BAD BAD')

FuzzyPoro()