//
// Copyright (c) alveus.dev. All rights reserved. Licensed under the MIT License.
//
using Astral.Services.Constants;
namespace Astral.Services.Interfaces;
///
/// Cryptographic operations.
///
public interface ICryptographyService
{
///
/// Generate a random salt.
///
/// Size of the salt to generate - if omitted, will use PwdHashSettings:HashSize config.
/// Byte array containing the generated salt.
byte[] GenerateSalt(int? size = null);
///
/// Hash a password string with the accompanying salt.
///
/// The password to hash.
/// The salt to use.
/// A byte array of PwdHashSettings:HashSize config size of the password.
byte[] HashPassword(string password, byte[] salt);
///
/// Verify that the given password matches the password hash and salt.
///
/// The password to test.
/// The password's accompanying salt.
/// The password hash to test again.
/// True if verified, false otherwise.
bool VerifyPassword(string password, byte[] salt, byte[] passwordHash);
///
/// Verify that the given password matches the password hash and salt.
///
/// The password to test.
/// The password's base64 encoded accompanying salt.
/// The password base64 hash to test again.
/// True if verified, false otherwise.
bool VerifyPassword(string password, string salt, string passwordHash);
///
/// Generate a cryptographically random string.
///
/// Length of string to create.
/// A random string.
string GenerateRandomString(int length);
///
/// Convert public key.
///
/// PKCS #1 key.
/// The type to convert to.
/// The converted key.
string ConvertPublicKey(byte[] pkcs1Key, PublicKeyType type);
///
/// Strip out header, footer and newlines from PEM RSA key.
///
/// Key to simplify.
/// Simplified form.
string SimplifyPemKey(string pemKey);
}