aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/codegen/client.py
diff options
context:
space:
mode:
authorJ08nY2020-02-27 13:38:47 +0100
committerJ08nY2020-02-27 13:38:47 +0100
commit4eafe2d49fc7406861609c5af12b850741bbe5a0 (patch)
tree49355d5cce44be8bd100fa8260b3b488f15be4a5 /pyecsca/codegen/client.py
parenta071822d9966ac150e7ed3d4efffbf3feaa500f5 (diff)
downloadpyecsca-codegen-4eafe2d49fc7406861609c5af12b850741bbe5a0.tar.gz
pyecsca-codegen-4eafe2d49fc7406861609c5af12b850741bbe5a0.tar.zst
pyecsca-codegen-4eafe2d49fc7406861609c5af12b850741bbe5a0.zip
Proper LED thingies.
Diffstat (limited to 'pyecsca/codegen/client.py')
-rw-r--r--pyecsca/codegen/client.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/pyecsca/codegen/client.py b/pyecsca/codegen/client.py
index e166704..c9f7b67 100644
--- a/pyecsca/codegen/client.py
+++ b/pyecsca/codegen/client.py
@@ -203,9 +203,13 @@ class ImplTarget(SimpleSerialTarget):
model, coords = unhexlify(resp.data).decode().split(",")
return model, coords
+ def disconnect(self):
+ self.write(b"x\n")
+ super().disconnect()
+
@public
-class DeviceTarget(ImplTarget, ChipWhispererTarget):
+class DeviceTarget(ImplTarget, ChipWhispererTarget): # pragma: no cover
def __init__(self, model: CurveModel, coords: CoordinateModel, platform: Platform, **kwargs):
scope = cw.scope()
@@ -291,15 +295,15 @@ def get_pubkey(ctx: click.Context, param, value: Optional[str]) -> Point:
return None
ctx.ensure_object(dict)
curve: DomainParameters = ctx.obj["params"]
- if re.match("04([0-9a-fA-F]{2})+", value):
+ if re.match("^04([0-9a-fA-F]{2})+$", value):
value = value[2:]
plen = len(value) // 2
x = int(value[:plen], 16)
y = int(value[plen:], 16)
- elif re.match("[0-9]+,[0-9]+", value):
- x, y = value.split(",")
- x = int(x)
- y = int(y)
+ elif re.match("^[0-9]+,[0-9]+$", value):
+ xs, ys = value.split(",")
+ x = int(xs)
+ y = int(ys)
else:
raise click.BadParameter("Couldn't parse pubkey: {}.".format(value))
x = Mod(x, curve.curve.prime)
@@ -334,6 +338,7 @@ def ecdh(ctx: click.Context, timeout, curve, pubkey):
@public
def ecdsa_sign(ctx: click.Context, timeout, curve):
ctx.ensure_object(dict)
+ # TODO
@main.command("ecdsa-verify")
@@ -341,8 +346,9 @@ def ecdsa_sign(ctx: click.Context, timeout, curve):
@click.argument("curve", required=True, callback=get_curve)
@click.pass_context
@public
-def ecdsa_sign(ctx: click.Context, timeout, curve):
+def ecdsa_verify(ctx: click.Context, timeout, curve):
ctx.ensure_object(dict)
+ # TODO
if __name__ == "__main__":