pyecsca.sca.target.ectester module¶
Provides an ECTester target class.
- class pyecsca.sca.target.ectester.KeypairEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
ShiftableFlag
ECTester’s KeyPair type.
- KEYPAIR_LOCAL = 1¶
- KEYPAIR_REMOTE = 2¶
- KEYPAIR_BOTH = 3¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.InstructionEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
ECTester’s instruction (INS).
- INS_ALLOCATE = 90¶
- INS_CLEAR = 91¶
- INS_SET = 92¶
- INS_TRANSFORM = 93¶
- INS_GENERATE = 94¶
- INS_EXPORT = 95¶
- INS_ECDH = 112¶
- INS_ECDH_DIRECT = 113¶
- INS_ECDSA = 114¶
- INS_ECDSA_SIGN = 115¶
- INS_ECDSA_VERIFY = 116¶
- INS_CLEANUP = 117¶
- INS_ALLOCATE_KA = 118¶
- INS_ALLOCATE_SIG = 119¶
- INS_GET_INFO = 120¶
- INS_SET_DRY_RUN_MODE = 121¶
- INS_BUFFER = 122¶
- INS_PERFORM = 123¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.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¶
- BUILD_KEYBUILDER = 2¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.ExportEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
ECTester’s export boolean.
- EXPORT_TRUE = 255¶
- EXPORT_FALSE = 0¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.RunModeEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
ECTester’s run mode.
- MODE_NORMAL = 170¶
- MODE_DRY_RUN = 187¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.KeyEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
ShiftableFlag
ECTester’s key enum.
- PUBLIC = 1¶
- PRIVATE = 2¶
- BOTH = 3¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.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¶
- BASE_222 = 546¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.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¶
- ALG_EC_FP = 5¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.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¶
- ALG_EC_SVDP_DH_KDF = 1¶
- ALG_EC_SVDP_DHC = 2¶
- ALG_EC_SVDP_DHC_KDF = 2¶
- ALG_EC_SVDP_DH_PLAIN = 3¶
- ALG_EC_SVDP_DHC_PLAIN = 4¶
- ALG_EC_PACE_GM = 5¶
- ALG_EC_SVDP_DH_PLAIN_XY = 6¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.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¶
- ALG_ECDSA_SHA_224 = 37¶
- ALG_ECDSA_SHA_256 = 33¶
- ALG_ECDSA_SHA_384 = 34¶
- ALG_ECDSA_SHA_512 = 38¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.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¶
- FIXED = 1¶
- FULLRANDOM = 2¶
- ONEBYTERANDOM = 4¶
- ZERO = 8¶
- ONE = 16¶
- MAX = 32¶
- INCREMENT = 64¶
- INFINITY = 128¶
- COMPRESS = 256¶
- COMPRESS_HYBRID = 512¶
- MASK_04 = 1024¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.FormatEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
ECTester’s point format types.
- UNCOMPRESSED = 0¶
- COMPRESSED = 1¶
- HYBRID = 2¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.CurveEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
ECTester’s curve constants.
- default = 0¶
- external = 255¶
- secp112r1 = 1¶
- secp128r1 = 2¶
- secp160r1 = 3¶
- secp192r1 = 4¶
- secp224r1 = 5¶
- secp256r1 = 6¶
- secp384r1 = 7¶
- secp521r1 = 8¶
- sect163r1 = 9¶
- sect233r1 = 10¶
- sect283r1 = 11¶
- sect409r1 = 12¶
- sect571r1 = 13¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- class pyecsca.sca.target.ectester.ParameterEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
ShiftableFlag
ECTester’s parameter ids.
- NONE = 0¶
- FP = 1¶
- F2M = 2¶
- A = 4¶
- B = 8¶
- G = 16¶
- R = 32¶
- K = 64¶
- W = 128¶
- S = 256¶
- DOMAIN_FP = 125¶
- DOMAIN_F2M = 126¶
- KEYPAIR = 384¶
- ALL = 511¶
- as_integer_ratio()¶
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)
- bit_count()¶
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
- bit_length()¶
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()¶
Returns self, the complex conjugate of any int.
- denominator¶
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)¶
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.
- imag¶
the imaginary part of a complex number
- numerator¶
the numerator of a rational number in lowest terms
- real¶
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)¶
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.
- exception pyecsca.sca.target.ectester.ChunkingException[source]¶
Bases:
Exception
An exception that is raised if an error happened during the chunking process of a large APDU.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class pyecsca.sca.target.ectester.AllocateKaResponse(resp)[source]¶
Bases:
Response
A response to the KeyAgreement allocation command.
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
-
error:
- class pyecsca.sca.target.ectester.AllocateSigResponse(resp)[source]¶
Bases:
Response
A response to the Signature allocation command.
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
-
error:
- class pyecsca.sca.target.ectester.AllocateResponse(resp, keypair)[source]¶
Bases:
Response
A response to the KeyPair allocation command.
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
-
error:
- class pyecsca.sca.target.ectester.ClearResponse(resp, keypair)[source]¶
Bases:
Response
A response to the Clear key command.
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
-
error:
- class pyecsca.sca.target.ectester.SetResponse(resp, keypair)[source]¶
Bases:
Response
A response to the Set command.
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
-
error:
- class pyecsca.sca.target.ectester.TransformResponse(resp, keypair)[source]¶
Bases:
Response
A response to the Transform command.
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
-
error:
- class pyecsca.sca.target.ectester.GenerateResponse(resp, keypair)[source]¶
Bases:
Response
A response to the Generate command.
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
-
error:
- class pyecsca.sca.target.ectester.ExportResponse(resp, keypair, key, params)[source]¶
Bases:
Response
A response to the Export command, contains the exported parameters/values.
-
keypair:
KeypairEnum
¶
-
parameters:
ParameterEnum
¶
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
-
keypair:
- class pyecsca.sca.target.ectester.ECDHResponse(resp, export)[source]¶
Bases:
Response
A response to the ECDH and ECDH_direct KeyAgreement commands.
- property secret¶
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
- class pyecsca.sca.target.ectester.ECDSAResponse(resp, export)[source]¶
Bases:
Response
A response to the ECDSA and ECDSA sign and ECDSA verify commands.
- property signature¶
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
- class pyecsca.sca.target.ectester.CleanupResponse(resp)[source]¶
Bases:
Response
A response to the Cleanup command.
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
-
error:
- class pyecsca.sca.target.ectester.RunModeResponse(resp)[source]¶
Bases:
Response
A response to the Set run mode command.
-
error:
bool
= False¶
-
success:
bool
= True¶
-
resp:
ResponseAPDU
¶
-
sws:
List
[int
]¶
-
params:
List
[bytes
]¶
-
error:
- class pyecsca.sca.target.ectester.ECTesterTarget[source]¶
Bases:
ISO7816Target
,ABC
Smartcard target which communicates with the ECTester sapplet on smartcards of the JavaCard platform using PCSC.
- CLA_ECTESTER = 176¶
- AID_PREFIX = b'ECTester'¶
- AID_CURRENT_VERSION = b'033'¶
- AID_SUFFIX_221 = b'b'¶
- AID_SUFFIX_222 = b'x'¶
- AID_SUFFIX_304 = b'\x94'¶
-
chunking:
bool
¶
- connect(protocol=None)[source]¶
Connect to the card.
- Parameters:
protocol¶ (
Optional
[CardProtocol
]) – CardProtocol to use.
- abstract property atr: bytes¶
Return the ATR (Answer To Reset) of the target.
- abstract disconnect()¶
Disconnect from the target device.
- abstract select(aid)¶
Select an applet with
aid
.- Parameters:
aid¶ (
bytes
) – The AID of the applet to select.- Return type:
bool
- Returns:
Whether the selection was successful.
- abstract send_apdu(apdu)¶
Send an APDU to the selected applet.
- Parameters:
apdu¶ (
CommandAPDU
) – The APDU to send.- Return type:
- Returns:
The response.
- select_applet(latest_version=b'033', count_back=10)[source]¶
Select the ECTester applet, with a specified version or older.
- 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:
- Returns:
The response.
- allocate_sig(sig_type)[source]¶
Send the Allocate Signature command.
- Parameters:
sig_type¶ (
SignatureEnum
) – Which Signature type to allocate.- Return type:
- 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:
- Returns:
The response.
- clear(keypair)[source]¶
Send the Clear key command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to clear.- Return type:
- 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:
- Returns:
The response.
- transform(keypair, key, params, transformation)[source]¶
Send the Transform command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to transform.params¶ (
ParameterEnum
) – Which parameters to transform.transformation¶ (
TransformationEnum
) – What transformation to apply.
- Return type:
- Returns:
The response.
- generate(keypair)[source]¶
Send the Generate command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to generate.- Return type:
- Returns:
The response.
- export(keypair, key, params)[source]¶
Send the Export command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to export from.params¶ (
ParameterEnum
) – Which parameters to export.
- Return type:
- 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:
- 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:
- 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:
- 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:
- 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:
- Returns:
The response.
- class pyecsca.sca.target.ectester.ECTesterTargetPCSC(reader)[source]¶
Bases:
ECTesterTarget
,PCSCTarget
An ECTester-applet-based target that is connected via a PCSC-compatible reader.
- AID_CURRENT_VERSION = b'033'¶
- AID_PREFIX = b'ECTester'¶
- AID_SUFFIX_221 = b'b'¶
- AID_SUFFIX_222 = b'x'¶
- AID_SUFFIX_304 = b'\x94'¶
- CLA_ECTESTER = 176¶
- allocate(keypair, builder, key_length, key_class)¶
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:
- Returns:
The response.
- allocate_ka(ka_type)¶
Send the Allocate KeyAgreement command.
- Parameters:
ka_type¶ (
KeyAgreementEnum
) – Which KeyAgreement type to allocate.- Return type:
- Returns:
The response.
- allocate_sig(sig_type)¶
Send the Allocate Signature command.
- Parameters:
sig_type¶ (
SignatureEnum
) – Which Signature type to allocate.- Return type:
- Returns:
The response.
- property atr: bytes¶
Return the ATR (Answer To Reset) of the target.
- cleanup()¶
Send the Cleanup command.
- Return type:
- Returns:
The response.
- clear(keypair)¶
Send the Clear key command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to clear.- Return type:
- Returns:
The response.
- connect(protocol=None)¶
Connect to the card.
- Parameters:
protocol¶ (
Optional
[CardProtocol
]) – CardProtocol to use.
- disconnect()¶
Disconnect from the target device.
- ecdh(pubkey, privkey, export, transformation, ka_type)¶
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:
- Returns:
The response.
- ecdh_direct(privkey, export, transformation, ka_type, pubkey)¶
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:
- Returns:
The response.
- ecdsa(keypair, export, sig_type, data)¶
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:
- Returns:
The response.
- ecdsa_sign(keypair, export, sig_type, data)¶
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:
- Returns:
The response.
- ecdsa_verify(keypair, sig_type, sig, data)¶
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:
- Returns:
The response.
- static encode_parameters(params, obj)¶
Encode values from obj into the byte parameters that the ECTester applet expects.
- Return type:
Mapping
[ParameterEnum
,bytes
]
- export(keypair, key, params)¶
Send the Export command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to export from.params¶ (
ParameterEnum
) – Which parameters to export.
- Return type:
- Returns:
The response, containing the exported parameters.
- generate(keypair)¶
Send the Generate command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to generate.- Return type:
- Returns:
The response.
- info()¶
Send the Info command.
- Return type:
InfoResponse
- Returns:
The response.
- run_mode(run_mode)¶
Send the Run mode command.
- Return type:
- Returns:
The response.
- select(aid)¶
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)¶
Select the ECTester applet, with a specified version or older.
- send(apdu)¶
- Return type:
- send_apdu(apdu)¶
Send an APDU to the selected applet.
- Parameters:
apdu¶ (
CommandAPDU
) – The APDU to send.- Return type:
- Returns:
The response.
- set(keypair, curve, params, values=None)¶
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:
- Returns:
The response.
- transform(keypair, key, params, transformation)¶
Send the Transform command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to transform.params¶ (
ParameterEnum
) – Which parameters to transform.transformation¶ (
TransformationEnum
) – What transformation to apply.
- Return type:
- Returns:
The response.
- chunking: bool¶
- class pyecsca.sca.target.ectester.ECTesterTargetLEIA(leia)[source]¶
Bases:
ECTesterTarget
,LEIATarget
An ECTester-applet-based target that is connected via the LEIA board.
- AID_CURRENT_VERSION = b'033'¶
- AID_PREFIX = b'ECTester'¶
- AID_SUFFIX_221 = b'b'¶
- AID_SUFFIX_222 = b'x'¶
- AID_SUFFIX_304 = b'\x94'¶
- CLA_ECTESTER = 176¶
- allocate(keypair, builder, key_length, key_class)¶
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:
- Returns:
The response.
- allocate_ka(ka_type)¶
Send the Allocate KeyAgreement command.
- Parameters:
ka_type¶ (
KeyAgreementEnum
) – Which KeyAgreement type to allocate.- Return type:
- Returns:
The response.
- allocate_sig(sig_type)¶
Send the Allocate Signature command.
- Parameters:
sig_type¶ (
SignatureEnum
) – Which Signature type to allocate.- Return type:
- Returns:
The response.
- property atr: bytes¶
Return the ATR (Answer To Reset) of the target.
- property card_present: bool¶
- cleanup()¶
Send the Cleanup command.
- Return type:
- Returns:
The response.
- clear(keypair)¶
Send the Clear key command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to clear.- Return type:
- Returns:
The response.
- connect(protocol=None)¶
Connect to the card.
- Parameters:
protocol¶ (
Optional
[CardProtocol
]) – CardProtocol to use.
- disconnect()¶
Disconnect from the target device.
- ecdh(pubkey, privkey, export, transformation, ka_type)¶
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:
- Returns:
The response.
- ecdh_direct(privkey, export, transformation, ka_type, pubkey)¶
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:
- Returns:
The response.
- ecdsa(keypair, export, sig_type, data)¶
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:
- Returns:
The response.
- ecdsa_sign(keypair, export, sig_type, data)¶
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:
- Returns:
The response.
- ecdsa_verify(keypair, sig_type, sig, data)¶
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:
- Returns:
The response.
- static encode_parameters(params, obj)¶
Encode values from obj into the byte parameters that the ECTester applet expects.
- Return type:
Mapping
[ParameterEnum
,bytes
]
- export(keypair, key, params)¶
Send the Export command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to export from.params¶ (
ParameterEnum
) – Which parameters to export.
- Return type:
- Returns:
The response, containing the exported parameters.
- generate(keypair)¶
Send the Generate command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to generate.- Return type:
- Returns:
The response.
- info()¶
Send the Info command.
- Return type:
InfoResponse
- Returns:
The response.
- run_mode(run_mode)¶
Send the Run mode command.
- Return type:
- Returns:
The response.
- select(aid)¶
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)¶
Select the ECTester applet, with a specified version or older.
- send(apdu)¶
- Return type:
- send_apdu(apdu)¶
Send an APDU to the selected applet.
- Parameters:
apdu¶ (
CommandAPDU
) – The APDU to send.- Return type:
- Returns:
The response.
- set(keypair, curve, params, values=None)¶
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:
- Returns:
The response.
- transform(keypair, key, params, transformation)¶
Send the Transform command.
- Parameters:
keypair¶ (
KeypairEnum
) – Which keypair to transform.params¶ (
ParameterEnum
) – Which parameters to transform.transformation¶ (
TransformationEnum
) – What transformation to apply.
- Return type:
- Returns:
The response.
-
chunking:
bool
¶