1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-04 05:42:34 +00:00

trezorlib: disable encrypt/decrypt message functionality

it is disabled in Trezors and its utility is unclear
This commit is contained in:
matejcik 2018-06-14 16:09:19 +02:00
parent 7e90e89e69
commit 00617817c3
3 changed files with 39 additions and 39 deletions

View File

@ -716,36 +716,36 @@ def decrypt_keyvalue(connect, address, key, value):
return client.decrypt_keyvalue(address_n, key, binascii.unhexlify(value)) return client.decrypt_keyvalue(address_n, key, binascii.unhexlify(value))
@cli.command(help='Encrypt message.') # @cli.command(help='Encrypt message.')
@click.option('-c', '--coin', default='Bitcoin') # @click.option('-c', '--coin', default='Bitcoin')
@click.option('-d', '--display-only', is_flag=True) # @click.option('-d', '--display-only', is_flag=True)
@click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/0'/0/0") # @click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/0'/0/0")
@click.argument('pubkey') # @click.argument('pubkey')
@click.argument('message') # @click.argument('message')
@click.pass_obj # @click.pass_obj
def encrypt_message(connect, coin, display_only, address, pubkey, message): # def encrypt_message(connect, coin, display_only, address, pubkey, message):
client = connect() # client = connect()
pubkey = binascii.unhexlify(pubkey) # pubkey = binascii.unhexlify(pubkey)
address_n = tools.parse_path(address) # address_n = tools.parse_path(address)
res = client.encrypt_message(pubkey, message, display_only, coin, address_n) # res = client.encrypt_message(pubkey, message, display_only, coin, address_n)
return { # return {
'nonce': binascii.hexlify(res.nonce), # 'nonce': binascii.hexlify(res.nonce),
'message': binascii.hexlify(res.message), # 'message': binascii.hexlify(res.message),
'hmac': binascii.hexlify(res.hmac), # 'hmac': binascii.hexlify(res.hmac),
'payload': base64.b64encode(res.nonce + res.message + res.hmac), # 'payload': base64.b64encode(res.nonce + res.message + res.hmac),
} # }
@cli.command(help='Decrypt message.') # @cli.command(help='Decrypt message.')
@click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/0'/0/0") # @click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/0'/0/0")
@click.argument('payload') # @click.argument('payload')
@click.pass_obj # @click.pass_obj
def decrypt_message(connect, address, payload): # def decrypt_message(connect, address, payload):
client = connect() # client = connect()
address_n = tools.parse_path(address) # address_n = tools.parse_path(address)
payload = base64.b64decode(payload) # payload = base64.b64decode(payload)
nonce, message, msg_hmac = payload[:33], payload[33:-8], payload[-8:] # nonce, message, msg_hmac = payload[:33], payload[33:-8], payload[-8:]
return client.decrypt_message(address_n, nonce, message, msg_hmac) # return client.decrypt_message(address_n, nonce, message, msg_hmac)
# #

View File

@ -33,17 +33,17 @@ def verify_message(client, coin_name, address, signature, message):
return isinstance(resp, proto.Success) return isinstance(resp, proto.Success)
@expect(proto.EncryptedMessage) # @expect(proto.EncryptedMessage)
def encrypt_message(client, pubkey, message, display_only, coin_name, n): # def encrypt_message(client, pubkey, message, display_only, coin_name, n):
if coin_name and n: # if coin_name and n:
return client.call(proto.EncryptMessage(pubkey=pubkey, message=message, display_only=display_only, coin_name=coin_name, address_n=n)) # return client.call(proto.EncryptMessage(pubkey=pubkey, message=message, display_only=display_only, coin_name=coin_name, address_n=n))
else: # else:
return client.call(proto.EncryptMessage(pubkey=pubkey, message=message, display_only=display_only)) # return client.call(proto.EncryptMessage(pubkey=pubkey, message=message, display_only=display_only))
@expect(proto.DecryptedMessage) # @expect(proto.DecryptedMessage)
def decrypt_message(client, n, nonce, message, msg_hmac): # def decrypt_message(client, n, nonce, message, msg_hmac):
return client.call(proto.DecryptMessage(address_n=n, nonce=nonce, message=message, hmac=msg_hmac)) # return client.call(proto.DecryptMessage(address_n=n, nonce=nonce, message=message, hmac=msg_hmac))
@session @session

View File

@ -481,8 +481,8 @@ class ProtocolMixin(object):
sign_tx = MovedTo(btc.sign_tx) sign_tx = MovedTo(btc.sign_tx)
sign_message = MovedTo(btc.sign_message) sign_message = MovedTo(btc.sign_message)
verify_message = MovedTo(btc.verify_message) verify_message = MovedTo(btc.verify_message)
encrypt_message = MovedTo(btc.encrypt_message) # encrypt_message = MovedTo(btc.encrypt_message)
decrypt_message = MovedTo(btc.decrypt_message) # decrypt_message = MovedTo(btc.decrypt_message)
# CoSi functionality # CoSi functionality
cosi_commit = MovedTo(cosi.commit) cosi_commit = MovedTo(cosi.commit)