pyecsca.sca.target.ectester module

Provides an ECTester target class.

class KeypairEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: ShiftableFlag

ECTester’s KeyPair type.

KEYPAIR_LOCAL = 1[source]
KEYPAIR_REMOTE = 2[source]
KEYPAIR_BOTH = 3[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class InstructionEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ECTester’s instruction (INS).

INS_ALLOCATE = 90[source]
INS_CLEAR = 91[source]
INS_SET = 92[source]
INS_TRANSFORM = 93[source]
INS_GENERATE = 94[source]
INS_EXPORT = 95[source]
INS_ECDH = 112[source]
INS_ECDH_DIRECT = 113[source]
INS_ECDSA = 114[source]
INS_ECDSA_SIGN = 115[source]
INS_ECDSA_VERIFY = 116[source]
INS_CLEANUP = 117[source]
INS_ALLOCATE_KA = 118[source]
INS_ALLOCATE_SIG = 119[source]
INS_GET_INFO = 120[source]
INS_SET_DRY_RUN_MODE = 121[source]
INS_BUFFER = 122[source]
INS_PERFORM = 123[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class KeyBuildEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ECTester’s key builder type.

BUILD_KEYPAIR = 1[source]
BUILD_KEYBUILDER = 2[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class ExportEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ECTester’s export boolean.

EXPORT_TRUE = 255[source]
EXPORT_FALSE = 0[source]
classmethod from_bool(val)[source]

Construct an ExportEnum from a boolean.

conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class RunModeEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ECTester’s run mode.

MODE_NORMAL = 170[source]
MODE_DRY_RUN = 187[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class KeyEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: ShiftableFlag

ECTester’s key enum.

PUBLIC = 1[source]
PRIVATE = 2[source]
BOTH = 3[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class AppletBaseEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ECTester’s JavaCard applet base version.

BASE_221 = 545[source]
BASE_222 = 546[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class KeyClassEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

JavaCard EC-based key class.

ALG_EC_F2M = 4[source]
ALG_EC_FP = 5[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class KeyAgreementEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

JavaCard KeyAgreement type values.

ALG_EC_SVDP_DH = 1[source]
ALG_EC_SVDP_DH_KDF = 1[source]
ALG_EC_SVDP_DHC = 2[source]
ALG_EC_SVDP_DHC_KDF = 2[source]
ALG_EC_SVDP_DH_PLAIN = 3[source]
ALG_EC_SVDP_DHC_PLAIN = 4[source]
ALG_EC_PACE_GM = 5[source]
ALG_EC_SVDP_DH_PLAIN_XY = 6[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class SignatureEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

JavaCard Signature type values.

ALG_ECDSA_SHA = 17[source]
ALG_ECDSA_SHA_224 = 37[source]
ALG_ECDSA_SHA_256 = 33[source]
ALG_ECDSA_SHA_384 = 34[source]
ALG_ECDSA_SHA_512 = 38[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class TransformationEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: ShiftableFlag

ECTester’s point/value transformation types.

NONE = 0[source]
FIXED = 1[source]
FULLRANDOM = 2[source]
ONEBYTERANDOM = 4[source]
ZERO = 8[source]
ONE = 16[source]
MAX = 32[source]
INCREMENT = 64[source]
INFINITY = 128[source]
COMPRESS = 256[source]
COMPRESS_HYBRID = 512[source]
MASK_04 = 1024[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class FormatEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ECTester’s point format types.

UNCOMPRESSED = 0[source]
COMPRESSED = 1[source]
HYBRID = 2[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class CurveEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

ECTester’s curve constants.

default = 0[source]
external = 255[source]
secp112r1 = 1[source]
secp128r1 = 2[source]
secp160r1 = 3[source]
secp192r1 = 4[source]
secp224r1 = 5[source]
secp256r1 = 6[source]
secp384r1 = 7[source]
secp521r1 = 8[source]
sect163r1 = 9[source]
sect233r1 = 10[source]
sect283r1 = 11[source]
sect409r1 = 12[source]
sect571r1 = 13[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

class ParameterEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: ShiftableFlag

ECTester’s parameter ids.

NONE = 0[source]
FP = 1[source]
F2M = 2[source]
A = 4[source]
B = 8[source]
G = 16[source]
R = 32[source]
K = 64[source]
W = 128[source]
S = 256[source]
DOMAIN_FP = 125[source]
DOMAIN_F2M = 126[source]
KEYPAIR = 384[source]
ALL = 511[source]
conjugate()[source]

Returns self, the complex conjugate of any int.

bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()[source]

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real[source]

the real part of a complex number

imag[source]

the imaginary part of a complex number

numerator[source]

the numerator of a rational number in lowest terms

denominator[source]

the denominator of a rational number in lowest terms

exception ChunkingException[source]

Bases: Exception

An exception that is raised if an error happened during the chunking process of a large APDU.

add_note()[source]

Exception.add_note(note) – add a note to the exception

args[source]
with_traceback()[source]

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class AllocateKaResponse(resp)[source]

Bases: Response

A response to the KeyAgreement allocation command.

error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class AllocateSigResponse(resp)[source]

Bases: Response

A response to the Signature allocation command.

error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class AllocateResponse(resp, keypair)[source]

Bases: Response

A response to the KeyPair allocation command.

error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class ClearResponse(resp, keypair)[source]

Bases: Response

A response to the Clear key command.

error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class SetResponse(resp, keypair)[source]

Bases: Response

A response to the Set command.

error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class TransformResponse(resp, keypair)[source]

Bases: Response

A response to the Transform command.

error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class GenerateResponse(resp, keypair)[source]

Bases: Response

A response to the Generate command.

error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class ExportResponse(resp, keypair, key, params)[source]

Bases: Response

A response to the Export command, contains the exported parameters/values.

keypair: KeypairEnum[source]
key: KeyEnum[source]
parameters: ParameterEnum[source]
get_index(keypair, param)[source]
Return type:

Optional[int]

get_param(keypair, param)[source]
Return type:

Optional[bytes]

error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class ECDHResponse(resp, export)[source]

Bases: Response

A response to the ECDH and ECDH_direct KeyAgreement commands.

property secret[source]
error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class ECDSAResponse(resp, export)[source]

Bases: Response

A response to the ECDSA and ECDSA sign and ECDSA verify commands.

property signature[source]
error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class CleanupResponse(resp)[source]

Bases: Response

A response to the Cleanup command.

error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class RunModeResponse(resp)[source]

Bases: Response

A response to the Set run mode command.

error: bool = False[source]
success: bool = True[source]
resp: ResponseAPDU[source]
sws: List[int][source]
params: List[bytes][source]
class ECTesterTarget[source]

Bases: ISO7816Target, ABC

Smartcard target which communicates with the ECTester sapplet on smartcards of the JavaCard platform using PCSC.

CLA_ECTESTER = 176[source]
AID_PREFIX = b'ECTester'[source]
AID_CURRENT_VERSION = b'033'[source]
AID_SUFFIX_221 = b'b'[source]
AID_SUFFIX_222 = b'x'[source]
AID_SUFFIX_304 = b'\x94'[source]
chunking: bool[source]
connect(protocol=None)[source]

Connect to the card.

Parameters:

protocol (Optional[CardProtocol]) – CardProtocol to use.

abstract property atr: bytes[source]

Return the ATR (Answer To Reset) of the target.

abstract disconnect()[source]

Disconnect from the target device.

abstract select(aid)[source]

Select an applet with aid.

Parameters:

aid (bytes) – The AID of the applet to select.

Return type:

bool

Returns:

Whether the selection was successful.

send(apdu)[source]
Return type:

ResponseAPDU

abstract send_apdu(apdu)[source]

Send an APDU to the selected applet.

Parameters:

apdu (CommandAPDU) – The APDU to send.

Return type:

ResponseAPDU

Returns:

The response.

select_applet(latest_version=b'033', count_back=10)[source]

Select the ECTester applet, with a specified version or older.

Parameters:
  • latest_version (bytes) – The latest version to try.

  • count_back (int) – How many versions back to try.

Return type:

bool

Returns:

Whether an applet was successfully selected.

static encode_parameters(params, obj)[source]

Encode values from obj into the byte parameters that the ECTester applet expects.

Return type:

Mapping[ParameterEnum, bytes]

allocate_ka(ka_type)[source]

Send the Allocate KeyAgreement command.

Parameters:

ka_type (KeyAgreementEnum) – Which KeyAgreement type to allocate.

Return type:

AllocateKaResponse

Returns:

The response.

allocate_sig(sig_type)[source]

Send the Allocate Signature command.

Parameters:

sig_type (SignatureEnum) – Which Signature type to allocate.

Return type:

AllocateSigResponse

Returns:

The response.

allocate(keypair, builder, key_length, key_class)[source]

Send the Allocate KeyPair command.

Parameters:
  • keypair (KeypairEnum) – Which keypair to allocate.

  • builder (KeyBuildEnum) – Which builder to use to allocate the keypair.

  • key_length (int) – Bit-size of the allocated keypair.

  • key_class (KeyClassEnum) – Type of the allocated keypair.

Return type:

AllocateResponse

Returns:

The response.

clear(keypair)[source]

Send the Clear key command.

Parameters:

keypair (KeypairEnum) – Which keypair to clear.

Return type:

ClearResponse

Returns:

The response.

set(keypair, curve, params, values=None)[source]

Send the Set command.

Parameters:
  • keypair (KeypairEnum) – Which keypair to set values on.

  • curve (CurveEnum) – Which pre-set curve to use to set values, or default or external.

  • params (ParameterEnum) – Which parameters to set on the keypair.

  • values (Optional[Mapping[ParameterEnum, bytes]]) – External values to set on the keypair.

Return type:

SetResponse

Returns:

The response.

transform(keypair, key, params, transformation)[source]

Send the Transform command.

Parameters:
Return type:

TransformResponse

Returns:

The response.

generate(keypair)[source]

Send the Generate command.

Parameters:

keypair (KeypairEnum) – Which keypair to generate.

Return type:

GenerateResponse

Returns:

The response.

export(keypair, key, params)[source]

Send the Export command.

Parameters:
Return type:

ExportResponse

Returns:

The response, containing the exported parameters.

ecdh(pubkey, privkey, export, transformation, ka_type)[source]

Send the ECDH command.

Parameters:
  • pubkey (KeypairEnum) – Which keypair to use the pubkey from, in the key-agreement.

  • privkey (KeypairEnum) – Which keypair to use the privkey from, in the key-agreement.

  • export (bool) – Whether to export the shared secret.

  • transformation (TransformationEnum) – The transformation to apply to the pubkey before key-agreement.

  • ka_type (KeyAgreementEnum) – The key-agreement type to use.

Return type:

ECDHResponse

Returns:

The response.

ecdh_direct(privkey, export, transformation, ka_type, pubkey)[source]

Send the ECDH direct command.

Parameters:
  • privkey (KeypairEnum) – Which keypair to use the privkey from, in the key-agreement.

  • export (bool) – Whether to export the shared secret.

  • transformation (TransformationEnum) – The transformation to apply to the pubkey before key-agreement.

  • ka_type (KeyAgreementEnum) – The key-agreement type to use.

  • pubkey (bytes) – The raw bytes that will be used as a pubkey in the key-agreement.

Return type:

ECDHResponse

Returns:

The response.

ecdsa(keypair, export, sig_type, data)[source]

Send the ECDSA command.

Parameters:
  • keypair (KeypairEnum) – The keypair to use.

  • export (bool) – Whether to export the signature.

  • sig_type (SignatureEnum) – The Signature type to use.

  • data (bytes) – The data to sign and verify.

Return type:

ECDSAResponse

Returns:

The response.

ecdsa_sign(keypair, export, sig_type, data)[source]

Send the ECDSA sign command.

Parameters:
  • keypair (KeypairEnum) – The keypair to use to sign.

  • export (bool) – Whether to export the signature.

  • sig_type (SignatureEnum) – The Signature type to use.

  • data (bytes) – The data to sign.

Return type:

ECDSAResponse

Returns:

The response.

ecdsa_verify(keypair, sig_type, sig, data)[source]

Send the ECDSA verify command.

Parameters:
  • keypair (KeypairEnum) – The keypair to use to verify.

  • sig_type (SignatureEnum) – The Signature type to use.

  • sig (bytes) – The signature to verify.

  • data (bytes) – The data.

Return type:

ECDSAResponse

Returns:

The response.

cleanup()[source]

Send the Cleanup command.

Return type:

CleanupResponse

Returns:

The response.

info()[source]

Send the Info command.

Return type:

InfoResponse

Returns:

The response.

run_mode(run_mode)[source]

Send the Run mode command.

Return type:

RunModeResponse

Returns:

The response.

class ECTesterTargetPCSC(reader)[source]

Bases: ECTesterTarget, PCSCTarget

An ECTester-applet-based target that is connected via a PCSC-compatible reader.

AID_CURRENT_VERSION = b'033'[source]
AID_PREFIX = b'ECTester'[source]
AID_SUFFIX_221 = b'b'[source]
AID_SUFFIX_222 = b'x'[source]
AID_SUFFIX_304 = b'\x94'[source]
CLA_ECTESTER = 176[source]
allocate(keypair, builder, key_length, key_class)[source]

Send the Allocate KeyPair command.

Parameters:
  • keypair (KeypairEnum) – Which keypair to allocate.

  • builder (KeyBuildEnum) – Which builder to use to allocate the keypair.

  • key_length (int) – Bit-size of the allocated keypair.

  • key_class (KeyClassEnum) – Type of the allocated keypair.

Return type:

AllocateResponse

Returns:

The response.

allocate_ka(ka_type)[source]

Send the Allocate KeyAgreement command.

Parameters:

ka_type (KeyAgreementEnum) – Which KeyAgreement type to allocate.

Return type:

AllocateKaResponse

Returns:

The response.

allocate_sig(sig_type)[source]

Send the Allocate Signature command.

Parameters:

sig_type (SignatureEnum) – Which Signature type to allocate.

Return type:

AllocateSigResponse

Returns:

The response.

property atr: bytes[source]

Return the ATR (Answer To Reset) of the target.

cleanup()[source]

Send the Cleanup command.

Return type:

CleanupResponse

Returns:

The response.

clear(keypair)[source]

Send the Clear key command.

Parameters:

keypair (KeypairEnum) – Which keypair to clear.

Return type:

ClearResponse

Returns:

The response.

connect(protocol=None)[source]

Connect to the card.

Parameters:

protocol (Optional[CardProtocol]) – CardProtocol to use.

disconnect()[source]

Disconnect from the target device.

ecdh(pubkey, privkey, export, transformation, ka_type)[source]

Send the ECDH command.

Parameters:
  • pubkey (KeypairEnum) – Which keypair to use the pubkey from, in the key-agreement.

  • privkey (KeypairEnum) – Which keypair to use the privkey from, in the key-agreement.

  • export (bool) – Whether to export the shared secret.

  • transformation (TransformationEnum) – The transformation to apply to the pubkey before key-agreement.

  • ka_type (KeyAgreementEnum) – The key-agreement type to use.

Return type:

ECDHResponse

Returns:

The response.

ecdh_direct(privkey, export, transformation, ka_type, pubkey)[source]

Send the ECDH direct command.

Parameters:
  • privkey (KeypairEnum) – Which keypair to use the privkey from, in the key-agreement.

  • export (bool) – Whether to export the shared secret.

  • transformation (TransformationEnum) – The transformation to apply to the pubkey before key-agreement.

  • ka_type (KeyAgreementEnum) – The key-agreement type to use.

  • pubkey (bytes) – The raw bytes that will be used as a pubkey in the key-agreement.

Return type:

ECDHResponse

Returns:

The response.

ecdsa(keypair, export, sig_type, data)[source]

Send the ECDSA command.

Parameters:
  • keypair (KeypairEnum) – The keypair to use.

  • export (bool) – Whether to export the signature.

  • sig_type (SignatureEnum) – The Signature type to use.

  • data (bytes) – The data to sign and verify.

Return type:

ECDSAResponse

Returns:

The response.

ecdsa_sign(keypair, export, sig_type, data)[source]

Send the ECDSA sign command.

Parameters:
  • keypair (KeypairEnum) – The keypair to use to sign.

  • export (bool) – Whether to export the signature.

  • sig_type (SignatureEnum) – The Signature type to use.

  • data (bytes) – The data to sign.

Return type:

ECDSAResponse

Returns:

The response.

ecdsa_verify(keypair, sig_type, sig, data)[source]

Send the ECDSA verify command.

Parameters:
  • keypair (KeypairEnum) – The keypair to use to verify.

  • sig_type (SignatureEnum) – The Signature type to use.

  • sig (bytes) – The signature to verify.

  • data (bytes) – The data.

Return type:

ECDSAResponse

Returns:

The response.

static encode_parameters(params, obj)[source]

Encode values from obj into the byte parameters that the ECTester applet expects.

Return type:

Mapping[ParameterEnum, bytes]

export(keypair, key, params)[source]

Send the Export command.

Parameters:
Return type:

ExportResponse

Returns:

The response, containing the exported parameters.

generate(keypair)[source]

Send the Generate command.

Parameters:

keypair (KeypairEnum) – Which keypair to generate.

Return type:

GenerateResponse

Returns:

The response.

info()[source]

Send the Info command.

Return type:

InfoResponse

Returns:

The response.

run_mode(run_mode)[source]

Send the Run mode command.

Return type:

RunModeResponse

Returns:

The response.

select(aid)[source]

Select an applet with aid.

Parameters:

aid (bytes) – The AID of the applet to select.

Return type:

bool

Returns:

Whether the selection was successful.

select_applet(latest_version=b'033', count_back=10)[source]

Select the ECTester applet, with a specified version or older.

Parameters:
  • latest_version (bytes) – The latest version to try.

  • count_back (int) – How many versions back to try.

Return type:

bool

Returns:

Whether an applet was successfully selected.

send(apdu)[source]
Return type:

ResponseAPDU

send_apdu(apdu)[source]

Send an APDU to the selected applet.

Parameters:

apdu (CommandAPDU) – The APDU to send.

Return type:

ResponseAPDU

Returns:

The response.

set(keypair, curve, params, values=None)[source]

Send the Set command.

Parameters:
  • keypair (KeypairEnum) – Which keypair to set values on.

  • curve (CurveEnum) – Which pre-set curve to use to set values, or default or external.

  • params (ParameterEnum) – Which parameters to set on the keypair.

  • values (Optional[Mapping[ParameterEnum, bytes]]) – External values to set on the keypair.

Return type:

SetResponse

Returns:

The response.

transform(keypair, key, params, transformation)[source]

Send the Transform command.

Parameters:
Return type:

TransformResponse

Returns:

The response.

chunking: bool[source]
class ECTesterTargetLEIA(leia)[source]

Bases: ECTesterTarget, LEIATarget

An ECTester-applet-based target that is connected via the LEIA board.

AID_CURRENT_VERSION = b'033'[source]
AID_PREFIX = b'ECTester'[source]
AID_SUFFIX_221 = b'b'[source]
AID_SUFFIX_222 = b'x'[source]
AID_SUFFIX_304 = b'\x94'[source]
CLA_ECTESTER = 176[source]
allocate(keypair, builder, key_length, key_class)[source]

Send the Allocate KeyPair command.

Parameters:
  • keypair (KeypairEnum) – Which keypair to allocate.

  • builder (KeyBuildEnum) – Which builder to use to allocate the keypair.

  • key_length (int) – Bit-size of the allocated keypair.

  • key_class (KeyClassEnum) – Type of the allocated keypair.

Return type:

AllocateResponse

Returns:

The response.

allocate_ka(ka_type)[source]

Send the Allocate KeyAgreement command.

Parameters:

ka_type (KeyAgreementEnum) – Which KeyAgreement type to allocate.

Return type:

AllocateKaResponse

Returns:

The response.

allocate_sig(sig_type)[source]

Send the Allocate Signature command.

Parameters:

sig_type (SignatureEnum) – Which Signature type to allocate.

Return type:

AllocateSigResponse

Returns:

The response.

property atr: bytes[source]

Return the ATR (Answer To Reset) of the target.

property card_present: bool[source]
cleanup()[source]

Send the Cleanup command.

Return type:

CleanupResponse

Returns:

The response.

clear(keypair)[source]

Send the Clear key command.

Parameters:

keypair (KeypairEnum) – Which keypair to clear.

Return type:

ClearResponse

Returns:

The response.

connect(protocol=None)[source]

Connect to the card.

Parameters:

protocol (Optional[CardProtocol]) – CardProtocol to use.

disconnect()[source]

Disconnect from the target device.

ecdh(pubkey, privkey, export, transformation, ka_type)[source]

Send the ECDH command.

Parameters:
  • pubkey (KeypairEnum) – Which keypair to use the pubkey from, in the key-agreement.

  • privkey (KeypairEnum) – Which keypair to use the privkey from, in the key-agreement.

  • export (bool) – Whether to export the shared secret.

  • transformation (TransformationEnum) – The transformation to apply to the pubkey before key-agreement.

  • ka_type (KeyAgreementEnum) – The key-agreement type to use.

Return type:

ECDHResponse

Returns:

The response.

ecdh_direct(privkey, export, transformation, ka_type, pubkey)[source]

Send the ECDH direct command.

Parameters:
  • privkey (KeypairEnum) – Which keypair to use the privkey from, in the key-agreement.

  • export (bool) – Whether to export the shared secret.

  • transformation (TransformationEnum) – The transformation to apply to the pubkey before key-agreement.

  • ka_type (KeyAgreementEnum) – The key-agreement type to use.

  • pubkey (bytes) – The raw bytes that will be used as a pubkey in the key-agreement.

Return type:

ECDHResponse

Returns:

The response.

ecdsa(keypair, export, sig_type, data)[source]

Send the ECDSA command.

Parameters:
  • keypair (KeypairEnum) – The keypair to use.

  • export (bool) – Whether to export the signature.

  • sig_type (SignatureEnum) – The Signature type to use.

  • data (bytes) – The data to sign and verify.

Return type:

ECDSAResponse

Returns:

The response.

ecdsa_sign(keypair, export, sig_type, data)[source]

Send the ECDSA sign command.

Parameters:
  • keypair (KeypairEnum) – The keypair to use to sign.

  • export (bool) – Whether to export the signature.

  • sig_type (SignatureEnum) – The Signature type to use.

  • data (bytes) – The data to sign.

Return type:

ECDSAResponse

Returns:

The response.

ecdsa_verify(keypair, sig_type, sig, data)[source]

Send the ECDSA verify command.

Parameters:
  • keypair (KeypairEnum) – The keypair to use to verify.

  • sig_type (SignatureEnum) – The Signature type to use.

  • sig (bytes) – The signature to verify.

  • data (bytes) – The data.

Return type:

ECDSAResponse

Returns:

The response.

static encode_parameters(params, obj)[source]

Encode values from obj into the byte parameters that the ECTester applet expects.

Return type:

Mapping[ParameterEnum, bytes]

export(keypair, key, params)[source]

Send the Export command.

Parameters:
Return type:

ExportResponse

Returns:

The response, containing the exported parameters.

generate(keypair)[source]

Send the Generate command.

Parameters:

keypair (KeypairEnum) – Which keypair to generate.

Return type:

GenerateResponse

Returns:

The response.

info()[source]

Send the Info command.

Return type:

InfoResponse

Returns:

The response.

run_mode(run_mode)[source]

Send the Run mode command.

Return type:

RunModeResponse

Returns:

The response.

select(aid)[source]

Select an applet with aid.

Parameters:

aid (bytes) – The AID of the applet to select.

Return type:

bool

Returns:

Whether the selection was successful.

select_applet(latest_version=b'033', count_back=10)[source]

Select the ECTester applet, with a specified version or older.

Parameters:
  • latest_version (bytes) – The latest version to try.

  • count_back (int) – How many versions back to try.

Return type:

bool

Returns:

Whether an applet was successfully selected.

send(apdu)[source]
Return type:

ResponseAPDU

send_apdu(apdu)[source]

Send an APDU to the selected applet.

Parameters:

apdu (CommandAPDU) – The APDU to send.

Return type:

ResponseAPDU

Returns:

The response.

set(keypair, curve, params, values=None)[source]

Send the Set command.

Parameters:
  • keypair (KeypairEnum) – Which keypair to set values on.

  • curve (CurveEnum) – Which pre-set curve to use to set values, or default or external.

  • params (ParameterEnum) – Which parameters to set on the keypair.

  • values (Optional[Mapping[ParameterEnum, bytes]]) – External values to set on the keypair.

Return type:

SetResponse

Returns:

The response.

transform(keypair, key, params, transformation)[source]

Send the Transform command.

Parameters:
Return type:

TransformResponse

Returns:

The response.

chunking: bool[source]