// Generated by Lisette bindgen
// Source: crypto (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.12
import "go:hash"
import "go:io"
pub enum Hash: uint {
BLAKE2b_256 = 17,
BLAKE2b_384 = 18,
BLAKE2b_512 = 19,
BLAKE2s_256 = 16,
MD4 = 1,
MD5 = 2,
MD5SHA1 = 8,
RIPEMD160 = 9,
SHA1 = 3,
SHA224 = 4,
SHA256 = 5,
SHA384 = 6,
SHA3_224 = 10,
SHA3_256 = 11,
SHA3_384 = 12,
SHA3_512 = 13,
SHA512 = 7,
SHA512_224 = 14,
SHA512_256 = 15,
}
pub const BLAKE2b_256: Hash = 17
pub const BLAKE2b_384: Hash = 18
pub const BLAKE2b_512: Hash = 19
pub const BLAKE2s_256: Hash = 16
pub const MD4: Hash = 1
pub const MD5: Hash = 2
pub const MD5SHA1: Hash = 8
pub const RIPEMD160: Hash = 9
pub const SHA1: Hash = 3
pub const SHA224: Hash = 4
pub const SHA256: Hash = 5
pub const SHA384: Hash = 6
pub const SHA3_224: Hash = 10
pub const SHA3_256: Hash = 11
pub const SHA3_384: Hash = 12
pub const SHA3_512: Hash = 13
pub const SHA512: Hash = 7
pub const SHA512_224: Hash = 14
pub const SHA512_256: Hash = 15
/// RegisterHash registers a function that returns a new instance of the given
/// hash function. This is intended to be called from the init function in
/// packages that implement hash functions.
pub fn RegisterHash(h: Hash, f: fn() -> hash.Hash)
/// SignMessage signs msg with signer. If signer implements [MessageSigner],
/// [MessageSigner.SignMessage] is called directly. Otherwise, msg is hashed
/// with opts.HashFunc() and signed with [Signer.Sign].
pub fn SignMessage(
signer: Signer,
rand: io.Reader,
msg: Slice<uint8>,
opts: SignerOpts,
) -> Result<Slice<uint8>, error>
/// Decrypter is an interface for an opaque private key that can be used for
/// asymmetric decryption operations. An example would be an RSA key
/// kept in a hardware module.
pub interface Decrypter {
fn Decrypt(rand: io.Reader, msg: Slice<uint8>, opts: DecrypterOpts) -> Result<Slice<uint8>, error>
fn Public() -> PublicKey
}
pub interface DecrypterOpts {}
/// MessageSigner is an interface for an opaque private key that can be used for
/// signing operations where the message is not pre-hashed by the caller.
/// It is a superset of the Signer interface so that it can be passed to APIs
/// which accept Signer, which may try to do an interface upgrade.
///
/// MessageSigner.SignMessage and MessageSigner.Sign should produce the same
/// result given the same opts. In particular, MessageSigner.SignMessage should
/// only accept a zero opts.HashFunc if the Signer would also accept messages
/// which are not pre-hashed.
///
/// Implementations which do not provide the pre-hashed Sign API should implement
/// Signer.Sign by always returning an error.
pub interface MessageSigner {
fn Public() -> PublicKey
fn Sign(rand: io.Reader, digest: Slice<uint8>, opts: SignerOpts) -> Result<Slice<uint8>, error>
fn SignMessage(rand: io.Reader, msg: Slice<uint8>, opts: SignerOpts) -> Result<Slice<uint8>, error>
}
/// PrivateKey represents a private key using an unspecified algorithm.
///
/// Although this type is an empty interface for backwards compatibility reasons,
/// all private key types in the standard library implement the following interface
///
/// interface{
/// Public() crypto.PublicKey
/// Equal(x crypto.PrivateKey) bool
/// }
///
/// as well as purpose-specific interfaces such as [Signer] and [Decrypter], which
/// can be used for increased type safety within applications.
pub interface PrivateKey {}
/// PublicKey represents a public key using an unspecified algorithm.
///
/// Although this type is an empty interface for backwards compatibility reasons,
/// all public key types in the standard library implement the following interface
///
/// interface{
/// Equal(x crypto.PublicKey) bool
/// }
///
/// which can be used for increased type safety within applications.
pub interface PublicKey {}
/// Signer is an interface for an opaque private key that can be used for
/// signing operations. For example, an RSA key kept in a hardware module.
pub interface Signer {
fn Public() -> PublicKey
fn Sign(rand: io.Reader, digest: Slice<uint8>, opts: SignerOpts) -> Result<Slice<uint8>, error>
}
/// SignerOpts contains options for signing with a [Signer].
pub interface SignerOpts {
fn HashFunc() -> Hash
}
impl Hash {
/// Available reports whether the given hash function is linked into the binary.
fn Available(self) -> bool
/// HashFunc simply returns the value of h so that [Hash] implements [SignerOpts].
fn HashFunc(self) -> Hash
/// New returns a new hash.Hash calculating the given hash function. New panics
/// if the hash function is not linked into the binary.
fn New(self) -> hash.Hash
/// Size returns the length, in bytes, of a digest resulting from the given hash
/// function. It doesn't require that the hash function in question be linked
/// into the program.
fn Size(self) -> int
fn String(self) -> string
}