コード例 #1
0
 def _get_signature(self) -> bytes:
     """Sign the DAR data using SignatureProvider."""
     signature = super()._get_signature()
     r, s = crypto.utils_cryptography.decode_dss_signature(signature)
     public_numbers = crypto.EllipticCurvePublicNumbers(r, s, crypto.ec.SECP256R1())
     signature = ecc_public_numbers_to_bytes(public_numbers=public_numbers, length=66)
     return signature
コード例 #2
0
 def sign(self) -> None:
     """Sign the DC data using SignatureProvider."""
     super().sign()
     assert self.signature, "Debug Credential Signature is not set in base class"
     r, s = crypto.utils_cryptography.decode_dss_signature(self.signature)
     public_numbers = crypto.EllipticCurvePublicNumbers(r, s, self.CURVE)
     self.signature = ecc_public_numbers_to_bytes(
         public_numbers=public_numbers, length=self.CORD_LENGTH)
コード例 #3
0
    def _get_signature(data: bytes, rotk_priv_path: str) -> bytes:
        """Creates a cryptographic signature over the data.

        :return: binary representing the signature
        """
        priv_rotk = crypto.load_private_key(file_path=rotk_priv_path)
        assert isinstance(priv_rotk,
                          crypto.EllipticCurvePrivateKeyWithSerialization)
        signature = priv_rotk.sign(data,
                                   crypto.ec.ECDSA(crypto.hashes.SHA256()))
        r, s = utils_cryptography.decode_dss_signature(signature)
        public_numbers = crypto.EllipticCurvePublicNumbers(
            r, s, priv_rotk.curve)
        return ecc_public_numbers_to_bytes(public_numbers=public_numbers)