mirror of
https://github.com/Coldcard/ckbunker.git
synced 2026-08-13 12:33:23 +02:00
USB encryption V2
This commit is contained in:
parent
ad188f265e
commit
fcb5940b0d
6 changed files with 31 additions and 8 deletions
12
conn.py
12
conn.py
|
|
@ -13,9 +13,10 @@ from hmac import HMAC
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
from ckcc.protocol import CCProtocolPacker, CCProtocolUnpacker, CCFramingError
|
from ckcc.protocol import CCProtocolPacker, CCFramingError
|
||||||
from ckcc.protocol import CCProtoError, CCUserRefused, CCBusyError
|
from ckcc.protocol import CCProtoError, CCUserRefused
|
||||||
from ckcc.client import ColdcardDevice, COINKITE_VID, CKCC_PID
|
from ckcc.constants import USB_NCRY_V2
|
||||||
|
from ckcc.client import ColdcardDevice
|
||||||
from ckcc.constants import (USER_AUTH_TOTP, USER_AUTH_HMAC, USER_AUTH_SHOW_QR, MAX_USERNAME_LEN)
|
from ckcc.constants import (USER_AUTH_TOTP, USER_AUTH_HMAC, USER_AUTH_SHOW_QR, MAX_USERNAME_LEN)
|
||||||
from ckcc.utils import calc_local_pincode
|
from ckcc.utils import calc_local_pincode
|
||||||
|
|
||||||
|
|
@ -52,8 +53,9 @@ class Connection(metaclass=Singleton):
|
||||||
else:
|
else:
|
||||||
sn = self.serial
|
sn = self.serial
|
||||||
|
|
||||||
d = ColdcardDevice(sn=sn)
|
ncry_ver = settings.USB_NCRY_VERSION
|
||||||
logging.info(f"Found Coldcard {d.serial}.")
|
d = ColdcardDevice(sn=sn, ncry_ver=ncry_ver)
|
||||||
|
logging.info(f"Found Coldcard {d.serial}. USB encryption version: {ncry_ver}")
|
||||||
|
|
||||||
await asyncio.get_running_loop().run_in_executor(executor, d.check_mitm)
|
await asyncio.get_running_loop().run_in_executor(executor, d.check_mitm)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,10 @@ there.
|
||||||
policy are captured and saved into the encrypted settings. This includes details
|
policy are captured and saved into the encrypted settings. This includes details
|
||||||
like the HSM text summary, user names, and other details that are know only
|
like the HSM text summary, user names, and other details that are know only
|
||||||
when the policy is created.
|
when the policy is created.
|
||||||
|
- USB Encryption should be set to version 2 if firmware supports this <some links to supported firmware>.
|
||||||
|
For now default version is still 1. To enable version 2:
|
||||||
|
`echo "USB_NCRY_VERSION: 2" > /tmp/ckbunker_ncryV2.yaml; ckbunker setup -c /tmp/ckbunker_ncryV2.yaml`. With version 2
|
||||||
|
enabled, in case of any ckbunker or communication failure, one needs to re-login to Coldcard
|
||||||
|
|
||||||
# Next Steps
|
# Next Steps
|
||||||
|
|
||||||
|
|
|
||||||
14
persist.py
14
persist.py
|
|
@ -56,6 +56,20 @@ class Settings(metaclass=Singleton):
|
||||||
# delay between retries connecting to missing/awol Coldcard
|
# delay between retries connecting to missing/awol Coldcard
|
||||||
RECONNECT_DELAY = 10 # seconds between retries
|
RECONNECT_DELAY = 10 # seconds between retries
|
||||||
PING_RATE = 15 # seconds between pings (CC status checks)
|
PING_RATE = 15 # seconds between pings (CC status checks)
|
||||||
|
USB_NCRY_VERSION = 0x01 # default ncry version is 1
|
||||||
|
|
||||||
|
# USB encryption versions (default 1)
|
||||||
|
#
|
||||||
|
# V2 introduces a new ncry version to close a potential attack vector:
|
||||||
|
#
|
||||||
|
# A malicious program may re-initialize the connection encryption by sending the ncry command a second time during USB operation.
|
||||||
|
# This may prove particularly harmful in HSM mode.
|
||||||
|
#
|
||||||
|
# Sending version 0x02 changes the behavior in two ways:
|
||||||
|
# * All future commands must be encrypted
|
||||||
|
# * Returns an error if the ncry command is sent again for the duration of the power cycle
|
||||||
|
#
|
||||||
|
# If using 0x02 and ckbunker is killed - you also need to re-login to Coldcard
|
||||||
|
|
||||||
def read(self, fobj):
|
def read(self, fobj):
|
||||||
t = yaml.safe_load(fobj)
|
t = yaml.safe_load(fobj)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
stem==1.8.0
|
stem==1.8.0
|
||||||
aiohttp>=3.7.4
|
aiohttp>=3.7.4
|
||||||
aiohttp-jinja2==1.2.0
|
aiohttp-jinja2>=1.2
|
||||||
ckcc-protocol>=1.0.1
|
ckcc-protocol>=1.0.1
|
||||||
pynacl==1.3.0
|
pynacl==1.3.0
|
||||||
aiohttp_session
|
aiohttp_session
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -27,7 +27,7 @@ setup(
|
||||||
'stem',
|
'stem',
|
||||||
'aiohttp',
|
'aiohttp',
|
||||||
'aiohttp-jinja2',
|
'aiohttp-jinja2',
|
||||||
'ckcc-protocol>=1.0.0',
|
'ckcc-protocol>=1.3.2',
|
||||||
],
|
],
|
||||||
entry_points='''
|
entry_points='''
|
||||||
[console_scripts]
|
[console_scripts]
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,10 @@ from persist import settings, BP
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from chain import broadcast_txn
|
from chain import broadcast_txn
|
||||||
from version import VERSION
|
from version import VERSION
|
||||||
from jinja2 import Markup
|
try:
|
||||||
|
from jinja2 import Markup
|
||||||
|
except ImportError:
|
||||||
|
from markupsafe import Markup
|
||||||
import policy
|
import policy
|
||||||
|
|
||||||
from ckcc.constants import USER_AUTH_TOTP, USER_AUTH_HMAC, USER_AUTH_SHOW_QR, MAX_USERNAME_LEN
|
from ckcc.constants import USER_AUTH_TOTP, USER_AUTH_HMAC, USER_AUTH_SHOW_QR, MAX_USERNAME_LEN
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue