2018-06-13 17:04:18 +00:00
|
|
|
from . import messages as proto
|
2018-06-25 15:51:09 +00:00
|
|
|
from .tools import expect
|
2018-06-13 17:04:18 +00:00
|
|
|
|
|
|
|
|
2018-06-25 15:51:09 +00:00
|
|
|
@expect(proto.Entropy, field="entropy")
|
2018-06-13 17:04:18 +00:00
|
|
|
def get_entropy(client, size):
|
|
|
|
return client.call(proto.GetEntropy(size=size))
|
|
|
|
|
|
|
|
|
|
|
|
@expect(proto.SignedIdentity)
|
|
|
|
def sign_identity(client, identity, challenge_hidden, challenge_visual, ecdsa_curve_name=None):
|
|
|
|
return client.call(proto.SignIdentity(identity=identity, challenge_hidden=challenge_hidden, challenge_visual=challenge_visual, ecdsa_curve_name=ecdsa_curve_name))
|
|
|
|
|
2018-06-13 17:35:01 +00:00
|
|
|
|
2018-06-13 17:04:18 +00:00
|
|
|
@expect(proto.ECDHSessionKey)
|
|
|
|
def get_ecdh_session_key(client, identity, peer_public_key, ecdsa_curve_name=None):
|
|
|
|
return client.call(proto.GetECDHSessionKey(identity=identity, peer_public_key=peer_public_key, ecdsa_curve_name=ecdsa_curve_name))
|
|
|
|
|
|
|
|
|
2018-06-25 15:51:09 +00:00
|
|
|
@expect(proto.CipheredKeyValue, field="value")
|
2018-06-13 17:04:18 +00:00
|
|
|
def encrypt_keyvalue(client, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''):
|
|
|
|
return client.call(proto.CipherKeyValue(address_n=n,
|
2018-06-13 17:35:01 +00:00
|
|
|
key=key,
|
|
|
|
value=value,
|
|
|
|
encrypt=True,
|
|
|
|
ask_on_encrypt=ask_on_encrypt,
|
|
|
|
ask_on_decrypt=ask_on_decrypt,
|
|
|
|
iv=iv))
|
|
|
|
|
2018-06-13 17:04:18 +00:00
|
|
|
|
2018-06-25 15:51:09 +00:00
|
|
|
@expect(proto.CipheredKeyValue, field="value")
|
2018-06-13 17:04:18 +00:00
|
|
|
def decrypt_keyvalue(client, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''):
|
|
|
|
return client.call(proto.CipherKeyValue(address_n=n,
|
2018-06-13 17:35:01 +00:00
|
|
|
key=key,
|
|
|
|
value=value,
|
|
|
|
encrypt=False,
|
|
|
|
ask_on_encrypt=ask_on_encrypt,
|
|
|
|
ask_on_decrypt=ask_on_decrypt,
|
|
|
|
iv=iv))
|