def testGetLogins(self):
     key = crypto.getRandomKey()
     iv = crypto.getRandomIV()
     requestor = mock.Mock(
         return_value={
             'Entries': [{'key': crypto.encrypt('test', key, iv)}],
             'Nonce': iv,
         }
     )
     logins = protocol.getLogins('a', 'b', key, requestor)
     self.assertEqual([{'key': 'test'}], logins)
Beispiel #2
0
 def testGetLogins(self):
     key = crypto.getRandomKey()
     iv = crypto.getRandomIV()
     requestor = mock.Mock(
         return_value={
             'Entries': [{
                 'key': crypto.encrypt('test', key, iv)
             }],
             'Nonce': iv,
         })
     logins = protocol.getLogins('a', 'b', key, requestor)
     self.assertEqual([{'key': 'test'}], logins)
 def test_get_logins(self):
     key = crypto.get_random_key()
     iv = crypto.get_random_iv()
     requestor = mock.Mock(
         return_value={
             'Entries': [{
                 'key': crypto.encrypt(b'test', key, iv)
             }],
             'Nonce': iv,
         })
     logins = protocol.get_logins('a', 'b', key, requestor)
     logins = [{'key': crypto.decrypt(logins[0]['key'], key, iv)}]
     self.assertEqual([{'key': b'test'}], logins)
def getLogins(url, id_, key, requestor=None, print_output=False):
    """Query keepass for entries that match `url`"""
    requestor = requestor or DEFAULT_REQUESTOR
    iv = crypto.getRandomIV()
    input_data = {
        'RequestType': 'get-logins',
        'Url': crypto.encrypt(url, key, iv)
    }
    output = requestor(key, input_data, id_, iv=iv)
    if print_output:
        print output
    decrypted = [
        crypto.decryptDict(entry, key, output['Nonce'])
        for entry in output.get('Entries', [])
    ]
    # replace passwords here so that we don't
    # accidently print them
    return [password.replace(e) for e in decrypted]
def getLogins(url, id_, key, requestor=None, print_output=False):
    """Query keepass for entries that match `url`"""
    requestor = requestor or DEFAULT_REQUESTOR
    iv = crypto.getRandomIV()
    input_data = {
        'RequestType': 'get-logins',
        'Url': crypto.encrypt(url, key, iv)
    }
    output = requestor(key, input_data, id_, iv=iv)
    if print_output:
        print output
    decrypted = [
        crypto.decryptDict(entry, key, output['Nonce'])
        for entry in output.get('Entries', [])
    ]
    # replace passwords here so that we don't
    # accidently print them
    return [password.replace(e) for e in decrypted]
def checkVerifier(key, iv, verifier):
    return verifier == crypto.encrypt(iv, key, iv)
def getVerifier(iv, key):
    return crypto.encrypt(iv, key, iv)
Beispiel #8
0
 def test_encrypt(self):
     key = 'eZNUcE1mUHoHoMW40tfRB/DaYvpWGzojDOT7S0AVOQg='
     iv = 'FE+fTbKvoZjIP48W/yE8Dg=='
     data = crypto.encrypt(b'Sally sells seashells', key, iv)
     self.assertEqual(b'aNbyJgtqd33gFfQrYTkobm1xD6UApyC1x7RF32Hy64w=', data)
Beispiel #9
0
 def test_decrypt_reverses_encrypt_for_unicode_snowman(self):
     data = bytes('☃', 'utf-8')
     key = crypto.get_random_key()
     iv = crypto.get_random_iv()
     enc = crypto.encrypt(data, key, iv)
     self.assertEqual(data, crypto.decrypt(enc, key, iv))
 def test_get_verifier(self):
     iv = b'MOqFG9os2R0+IncvQbLVLA=='
     key = b'/HFqSCUJa4hmcpjyXyijyv+aNHYSBhBouJ/t2G3vy0k='
     self.assertEqual(crypto.encrypt(iv, key, iv),
                      protocol.get_verifier(iv, key))
Beispiel #11
0
def getVerifier(iv, key):
    return crypto.encrypt(iv, key, iv)
Beispiel #12
0
def checkVerifier(key, iv, verifier):
    return verifier == crypto.encrypt(iv, key, iv)
 def testDecryptReversesEncryptForUnicodeSnowman(self):
     data = '☃'
     key = crypto.getRandomKey()
     iv = crypto.getRandomIV()
     enc = crypto.encrypt(data, key, iv)
     self.assertEqual(data, crypto.decrypt(enc, key, iv))
 def testEncrypt(self):
     key='eZNUcE1mUHoHoMW40tfRB/DaYvpWGzojDOT7S0AVOQg='
     iv='FE+fTbKvoZjIP48W/yE8Dg=='
     data = crypto.encrypt('Sally sells seashells', key, iv)
     self.assertEqual('aNbyJgtqd33gFfQrYTkobm1xD6UApyC1x7RF32Hy64w=', data)
 def testDecryptReversesEncryptForUnicodeSnowman(self):
     data = '☃'
     key = crypto.getRandomKey()
     iv = crypto.getRandomIV()
     enc = crypto.encrypt(data, key, iv)
     self.assertEqual(data, crypto.decrypt(enc, key, iv))