crypto.py: rm {En,De}codeAES_base64. instead use {En,De}codeAES_bytes
This commit is contained in:
@@ -167,12 +167,6 @@ def aes_decrypt_with_iv(key: bytes, iv: bytes, data: bytes) -> bytes:
|
||||
raise InvalidPassword()
|
||||
|
||||
|
||||
def EncodeAES_base64(secret: bytes, msg: bytes) -> bytes:
|
||||
"""Returns base64 encoded ciphertext."""
|
||||
e = EncodeAES_bytes(secret, msg)
|
||||
return base64.b64encode(e)
|
||||
|
||||
|
||||
def EncodeAES_bytes(secret: bytes, msg: bytes) -> bytes:
|
||||
assert_bytes(msg)
|
||||
iv = bytes(os.urandom(16))
|
||||
@@ -180,11 +174,6 @@ def EncodeAES_bytes(secret: bytes, msg: bytes) -> bytes:
|
||||
return iv + ct
|
||||
|
||||
|
||||
def DecodeAES_base64(secret: bytes, ciphertext_b64: Union[bytes, str]) -> bytes:
|
||||
ciphertext = bytes(base64.b64decode(ciphertext_b64))
|
||||
return DecodeAES_bytes(secret, ciphertext)
|
||||
|
||||
|
||||
def DecodeAES_bytes(secret: bytes, ciphertext: bytes) -> bytes:
|
||||
assert_bytes(ciphertext)
|
||||
iv, e = ciphertext[:16], ciphertext[16:]
|
||||
|
||||
@@ -16,7 +16,7 @@ import sys
|
||||
import time
|
||||
import copy
|
||||
|
||||
from electrum.crypto import sha256d, EncodeAES_base64, EncodeAES_bytes, DecodeAES_bytes, hmac_oneshot
|
||||
from electrum.crypto import sha256d, EncodeAES_bytes, DecodeAES_bytes, hmac_oneshot
|
||||
from electrum.bitcoin import public_key_to_p2pkh
|
||||
from electrum.bip32 import BIP32Node, convert_bip32_intpath_to_strpath, is_all_public_derivation
|
||||
from electrum import ecc
|
||||
@@ -706,9 +706,10 @@ class DigitalBitboxPlugin(HW_PluginBase):
|
||||
assert self.is_mobile_paired(), "unexpected mobile pairing error"
|
||||
url = 'https://digitalbitbox.com/smartverification/index.php'
|
||||
key_s = base64.b64decode(self.digitalbitbox_config[ENCRYPTION_PRIVKEY_KEY])
|
||||
ciphertext = EncodeAES_bytes(key_s, json.dumps(payload).encode('ascii'))
|
||||
args = 'c=data&s=0&dt=0&uuid=%s&pl=%s' % (
|
||||
self.digitalbitbox_config[CHANNEL_ID_KEY],
|
||||
EncodeAES_base64(key_s, json.dumps(payload).encode('ascii')).decode('ascii'),
|
||||
base64.b64encode(ciphertext).decode('ascii'),
|
||||
)
|
||||
try:
|
||||
text = Network.send_http_on_proxy('post', url, body=args.encode('ascii'), headers={'content-type': 'application/x-www-form-urlencoded'})
|
||||
|
||||
Reference in New Issue
Block a user