docs: def deserialize_wrapped_key(wrapping_algorithm, wrapping_key_id, wrapped_encrypted_key):
      """Extracts and deserializes EncryptedData from a Wrapped EncryptedDataKey.
  
      :param wrapping_algorithm: Wrapping Algorithm with which to wrap plaintext_data_key
      :type wrapping_algorithm: aws_encryption_sdk.identifiers.WrappingAlgorithm
      :param bytes wrapping_key_id: Key ID of wrapping MasterKey
      :param wrapped_encrypted_key: Raw Wrapped EncryptedKey
      :type wrapped_encrypted_key: aws_encryption_sdk.structures.EncryptedDataKey
      :returns: EncryptedData of deserialized Wrapped EncryptedKey
      :rtype: aws_encryption_sdk.internal.structures.EncryptedData
      :raises SerializationError: if wrapping_key_id does not match deserialized wrapping key id
      :raises SerializationError: if wrapping_algorithm IV length does not match deserialized IV length
      """
      if wrapping_key_id == wrapped_encrypted_key.key_provider.key_info:
          encrypted_wrapped_key = EncryptedData(iv=None, ciphertext=wrapped_encrypted_key.encrypted_data_key, tag=None)
      else:
          if not wrapped_encrypted_key.key_provider.key_info.startswith(wrapping_key_id):
              raise SerializationError("Master Key mismatch for wrapped data key")
          _key_info = wrapped_encrypted_key.key_provider.key_info[len(wrapping_key_id) :]
          try:
              tag_len, iv_len = struct.unpack(">II", _key_info[:8])
          except struct.error:
              raise SerializationError("Malformed key info: key info missing data")
          tag_len //= 8  # Tag Length is stored in bits, not bytes
          if iv_len != wrapping_algorithm.algorithm.iv_len:
              raise SerializationError("Wrapping AlgorithmSuite mismatch for wrapped data key")
          iv = _key_info[8:]
          if len(iv) != iv_len:
              raise SerializationError("Malformed key info: incomplete iv")
          ciphertext = wrapped_encrypted_key.encrypted_data_key[: -1 * tag_len]
          tag = wrapped_encrypted_key.encrypted_data_key[-1 * tag_len :]
          if not ciphertext or len(tag) != tag_len:
              raise SerializationError("Malformed key info: incomplete ciphertext or tag")
          encrypted_wrapped_key = EncryptedData(iv=iv, ciphertext=ciphertext, tag=tag)
      return encrypted_wrapped_key