  def GenerateSSHKeyPair(self, vm_name: str) -> Tuple[str, str]:
    """Generate a SSH key pair and returns its name and private key.

    Args:
      vm_name (str): The VM name for which to generate the key pair.

    Returns:
      Tuple[str, str]: A tuple containing the key name and the private key for
          the generated SSH key pair.

    Raises:
      ValueError: If vm_name is None.
      ResourceCreationError: If the key could not be created.
    """

    if not vm_name:
      raise ValueError('Parameter vm_name must not be None.')

    # SSH key names need to be unique, therefore we add a random 10 chars hex
    # string.
    key_name = '{0:s}-{1:s}-ssh'.format(
        vm_name, binascii.b2a_hex(os.urandom(10)).decode('utf-8'))
    client = self.aws_account.ClientApi(common.EC2_SERVICE)
    try:
      key = client.create_key_pair(KeyName=key_name)
    except client.exceptions.ClientError as exception:
      raise errors.ResourceCreationError(
          'Could not create SSH key pair: {0!s}'.format(
              exception), __name__) from exception
    # If the call was successful, the response contains key information
    return key['KeyName'], key['KeyMaterial']
Generate a SSH key pair and returns its name and private key.

Args:
vm_name (str): The VM name for which to generate the key pair.

Returns:
Tuple[str, str]: A tuple containing the key name and the private key for
the generated SSH key pair.

Raises:
ValueError: If vm_name is None.
ResourceCreationError: If the key could not be created.
libcloudforensics/providers/aws/internal/ec2.py