pyecsca.codegen.client module

pyecsca.codegen.client.cmd_init_prng(seed)[source]
Return type:

str

pyecsca.codegen.client.cmd_set_params(params)[source]
Return type:

str

pyecsca.codegen.client.cmd_generate()[source]
Return type:

str

pyecsca.codegen.client.cmd_set_privkey(privkey)[source]
Return type:

str

pyecsca.codegen.client.cmd_set_pubkey(pubkey)[source]
Return type:

str

pyecsca.codegen.client.cmd_scalar_mult(scalar, point)[source]
Return type:

str

pyecsca.codegen.client.cmd_ecdh(pubkey)[source]
Return type:

str

pyecsca.codegen.client.cmd_ecdsa_sign(data)[source]
Return type:

str

pyecsca.codegen.client.cmd_ecdsa_verify(data, sig)[source]
Return type:

str

pyecsca.codegen.client.cmd_set_trigger(actions)[source]
Return type:

str

pyecsca.codegen.client.cmd_debug()[source]
Return type:

str

class pyecsca.codegen.client.DeviceTarget(model, coords, platform, **kwargs)[source]

Bases: ImplTarget, ChipWhispererTarget

A ChipWhisperer-based device target.

connect()

Connect to the target device.

debug()
Return type:

Tuple[str, str]

disconnect()

Disconnect from the target device.

ecdh(other_pubkey)
Return type:

bytes

ecdsa_sign(data)
Return type:

bytes

ecdsa_verify(data, signature)
Return type:

bool

flash(fw_path)

Flash the firmware at fw_path to the target.

Parameters:

fw_path (str) – The path to the firmware blob.

Return type:

bool

Returns:

Whether the flashing was successful.

generate()
Return type:

Tuple[int, Point]

init_prng(seed)
Return type:

None

quit()
read(num=0, timeout=0)

Read upto num bytes or until timeout milliseconds from the target’s serial output.

Parameters:
  • num (int) – The number of bytes to read, 0 for all available.

  • timeout (int) – The timeout in milliseconds.

Return type:

bytes

Returns:

The bytes read.

recv_msgs(timeout)

Receive SimpleSerialMessage messages, while waiting upto timeout seconds.

Parameters:

timeout (int) – How long to wait.

Return type:

Mapping[str, SimpleSerialMessage]

Returns:

The received messages with their char.

reset()
scalar_mult(scalar, point)
Return type:

Point

send_cmd(cmd, timeout)

Send a SimpleSerialMessage and receive the response messages that the command produces, within a timeout.

Parameters:
  • cmd (SimpleSerialMessage) – The command message to send.

  • timeout (int) – The timeout value to wait for the responses.

Return type:

Mapping[str, SimpleSerialMessage]

Returns:

A mapping of the starting character of the message to the message.

set_params(params)
Return type:

None

set_privkey(privkey)
Return type:

None

set_pubkey(pubkey)
Return type:

None

set_trigger(actions)
Return type:

None

write(data)

Write the data bytes to the target’s serial input.

Parameters:

data (bytes) – The data to write.

Return type:

None

model: CurveModel
coords: CoordinateModel
seed: Optional[bytes]
params: Optional[DomainParameters]
privkey: Optional[int]
pubkey: Optional[Point]
trigger: Optional[Triggers]
timeout: int
class pyecsca.codegen.client.HostTarget(model, coords, **kwargs)[source]

Bases: ImplTarget, BinaryTarget

A host-based target, will just run the binary on your machine and communicate with it via stdin/stdout.

connect()

Connect to the target device.

debug()
Return type:

Tuple[str, str]

disconnect()

Disconnect from the target device.

ecdh(other_pubkey)
Return type:

bytes

ecdsa_sign(data)
Return type:

bytes

ecdsa_verify(data, signature)
Return type:

bool

generate()
Return type:

Tuple[int, Point]

init_prng(seed)
Return type:

None

process: Optional[Popen] = None
quit()
read(num=0, timeout=0)

Read upto num bytes or until timeout milliseconds from the target’s serial output.

Parameters:
  • num (int) – The number of bytes to read, 0 for all available.

  • timeout (int) – The timeout in milliseconds.

Return type:

bytes

Returns:

The bytes read.

recv_msgs(timeout)

Receive SimpleSerialMessage messages, while waiting upto timeout seconds.

Parameters:

timeout (int) – How long to wait.

Return type:

Mapping[str, SimpleSerialMessage]

Returns:

The received messages with their char.

scalar_mult(scalar, point)
Return type:

Point

send_cmd(cmd, timeout)

Send a SimpleSerialMessage and receive the response messages that the command produces, within a timeout.

Parameters:
  • cmd (SimpleSerialMessage) – The command message to send.

  • timeout (int) – The timeout value to wait for the responses.

Return type:

Mapping[str, SimpleSerialMessage]

Returns:

A mapping of the starting character of the message to the message.

set_params(params)
Return type:

None

set_privkey(privkey)
Return type:

None

set_pubkey(pubkey)
Return type:

None

set_trigger(actions)
Return type:

None

write(data)

Write the data bytes to the target’s serial input.

Parameters:

data (bytes) – The data to write.

Return type:

None

model: CurveModel
coords: CoordinateModel
seed: Optional[bytes]
params: Optional[DomainParameters]
privkey: Optional[int]
pubkey: Optional[Point]
trigger: Optional[Triggers]
timeout: int
binary: List[str]
debug_output: bool