Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Sign ¶
Sign generates a digital signature for the given data using the provided private key and hash algorithm. It supports RSA and Ed25519 private keys. Returns the signature as a byte slice or an error if signing fails.
Types ¶
type EdDSAKeyStrategy ¶
type EdDSAKeyStrategy struct{}
EdDSAKeyStrategy implements the KeyAlgorithmStrategy interface for the EdDSA algorithm using ed25519 keys.
func (*EdDSAKeyStrategy) Export ¶
func (s *EdDSAKeyStrategy) Export(privateKey any) (string, error)
Export exports an Ed25519 private key into a PEM-encoded PKCS#8 format string. Returns the PEM-encoded private key string or an error if the input key type is invalid or marshalling fails.
type KeyAlgorithmStrategy ¶
type KeyAlgorithmStrategy interface {
Generate(now time.Time) (*KeyPair, error)
Import(serializedPrivateKey string) (any, any, error)
Export(privateKey any) (string, error)
}
KeyAlgorithmStrategy defines the behavior for generating, importing, and exporting cryptographic key pairs.
func GetKeyStrategy ¶
func GetKeyStrategy(jwa string) KeyAlgorithmStrategy
GetKeyStrategy returns the appropriate KeyAlgorithmStrategy for the given JWA algorithm or panics if unsupported.
type KeyPair ¶
type KeyPair struct {
// contains filtered or unexported fields
}
KeyPair represents a cryptographic key pair consisting of a public key, private key, key ID, and creation timestamp.
func (*KeyPair) CreatedAt ¶
CreatedAt returns the timestamp indicating when the KeyPair was created.
func (*KeyPair) PrivateKey ¶
func (k *KeyPair) PrivateKey() crypto.PrivateKey
PrivateKey returns the private key of the KeyPair.
type RSAKeyStrategy ¶
type RSAKeyStrategy struct{}
RSAKeyStrategy implements the KeyAlgorithmStrategy interface for generating, importing, and exporting RSA key pairs.
func (*RSAKeyStrategy) Export ¶
func (s *RSAKeyStrategy) Export(privateKey any) (string, error)
Export converts an RSA private key to its PEM-encoded string representation. Returns the PEM-encoded private key or an error if the input is not a valid *rsa.PrivateKey.