docs: def _ecc_static_length_signature(key, algorithm, digest):
      """Calculates an elliptic curve signature with a static length using pre-calculated hash.
  
      :param key: Elliptic curve private key
      :type key: cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey
      :param algorithm: Master algorithm to use
      :type algorithm: aws_encryption_sdk.identifiers.Algorithm
      :param bytes digest: Pre-calculated hash digest
      :returns: Signature with required length
      :rtype: bytes
      """
      pre_hashed_algorithm = ec.ECDSA(Prehashed(algorithm.signing_hash_type()))
      signature = b""
      while len(signature) != algorithm.signature_len:
          _LOGGER.debug(
              "Signature length %d is not desired length %d.  Recalculating.", len(signature), algorithm.signature_len
          )
          signature = key.sign(digest, pre_hashed_algorithm)
          if len(signature) != algorithm.signature_len:
              # Most of the time, a signature of the wrong length can be fixed
              # by negating s in the signature relative to the group order.
              _LOGGER.debug(
                  "Signature length %d is not desired length %d.  Negating s.", len(signature), algorithm.signature_len
              )
              r, s = decode_dss_signature(signature)
              s = _ECC_CURVE_PARAMETERS[algorithm.signing_algorithm_info.name].order - s
              signature = encode_dss_signature(r, s)
      return signature