Documentation
¶
Overview ¶
Package keys implements a unified interface for key handling.
The key types crypto/ecdsa, crypto/ed25519, crypto/rsa are supported.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrivatesEqual ¶
func PrivatesEqual(privateKey1 crypto.PrivateKey, privateKey2 crypto.PrivateKey) bool
PrivatesEqual checks whether the two given private keys are equal.
func PublicFromPrivate ¶
func PublicFromPrivate(privateKey crypto.PrivateKey) crypto.PublicKey
PublicFromPrivate gets the public key associated with the given private key.
Types ¶
type Algorithm ¶
type Algorithm uint
const ( UnknownAlgorithm Algorithm = 0 RSA2048 Algorithm = 1 // RSA cipher 2048 bit key lenght RSA3072 Algorithm = 2 // RSA cipher 3072 bit key lenght RSA4096 Algorithm = 3 // RSA cipher 4096 bit key lenght RSA8192 Algorithm = 4 // RSA cipher 8192 bit key lenght ECDSA224 Algorithm = 5 // ECDSA cipher P-224 curve ECDSA256 Algorithm = 6 // ECDSA cipher P-256 curve ECDSA384 Algorithm = 7 // ECDSA cipher P-384 curve ECDSA521 Algorithm = 8 // ECDSA cipher P-521 curve ED25519 Algorithm = 9 // ED25519 cipher )
func AlgorithmFromKey ¶
AlgorithmFromKey determines the algorithm of the given public key.
func AlgorithmFromString ¶
AlgorithmFromString determines an algorithm from its name.
func (Algorithm) NewKeyPairFactory ¶
func (alg Algorithm) NewKeyPairFactory() KeyPairFactory
NewKeyPairFactory gets the KeyPairFactory for the given algorithm.
type Key ¶
type Key interface {
crypto.Signer
Verify(signature []byte, digest []byte, opts crypto.SignerOpts) bool
}
Key interface provides a unified way to key related serivces like crypto.Signer.
func KeyFromPrivate ¶
func KeyFromPrivate(privateKey crypto.PrivateKey) Key
KeyFromPrivate wraps the given private key into a Key interface.
type KeyPair ¶
type KeyPair interface {
// Name returns this [KeyPair]'s algorithm.
Alg() Algorithm
// Private returns the private key of a key pair.
Private() crypto.PrivateKey
// Public returns the public key of a key pair.
Public() crypto.PublicKey
}
KeyPair interface provides unified access to a key pair.
type KeyPairFactory ¶
type KeyPairFactory interface {
// Name returns this [KeyPairFactory]'s algorithm.
Alg() Algorithm
// New generates a new key pair.
New() (KeyPair, error)
}
KeyPairFactory interface provides a unified way to create key pairs.