예제 #1
0
 def test_aes_decode_with_invalid_password(self):
     """pw_decode raises an Exception when supplied an invalid password."""
     payload = u"blah"
     password = u"uber secret"
     wrong_password = u"not the password"
     enc = crypto.pw_encode(payload, password)
     with self.assertRaises(InvalidPassword):
         crypto.pw_decode(enc, wrong_password)
예제 #2
0
 def test_aes_homomorphic(self):
     """Make sure AES is homomorphic."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     password = u'secret'
     enc = crypto.pw_encode(payload, password)
     dec = crypto.pw_decode(enc, password)
     self.assertEqual(dec, payload)
예제 #3
0
def check_legacy_parent_of_imported_privkey_wallet(wallet: Wallet,
        keypairs: Optional[Dict[str, str]]=None, password: Optional[str]=None) -> None:
    assert len(wallet.get_accounts()) == 1
    account: ImportedPrivkeyAccount = wallet.get_accounts()[0]

    parent_keystores = wallet.get_keystores()
    assert len(parent_keystores) == 0
    child_keystores = account.get_keystores()
    assert len(child_keystores) == 1
    assert child_keystores[0] is not None

    assert not child_keystores[0].has_masterkey()
    with pytest.raises(IncompatibleWalletError):
        child_keystores[0].to_masterkey_row()
    with pytest.raises(IncompatibleWalletError):
        child_keystores[0].to_derivation_data()
    keyinstance_datas = child_keystores[0].get_keyinstance_derivation_data()
    assert len(keyinstance_datas) == 1
    if keypairs is not None:
        for key_id, data in keyinstance_datas:
            assert pw_decode(data['prv'], password) == keypairs[data['pub']]
예제 #4
0
 def test_aes_deencode_without_password(self):
     """When not passed a password, pw_decode is noop on the payload."""
     payload = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
     enc = crypto.pw_decode(payload, None)
     self.assertEqual(payload, enc)