Documentation
¶
Overview ¶
Package algorithms implements JWT signing algorithm support for use with Vault's Transit engine.
The package provides a registry of supported algorithms and their implementations. Each algorithm handles its specific signing parameters and verification logic.
Supported Algorithms: - ECDSA
- ES256 (P-256 + SHA-256)
- ES384 (P-384 + SHA-384)
- ES512 (P-521 + SHA-512)
- RSA PKCS1v15
- RS256 (RSA-2048 + SHA-256)
- RS384 (RSA-3072 + SHA-384)
- RS512 (RSA-4096 + SHA-512)
- RSA-PSS
- PS256 (RSA-2048 + SHA-256)
- PS384 (RSA-3072 + SHA-384)
- PS512 (RSA-4096 + SHA-512)
Each algorithm implementation: - Provides appropriate Vault signing parameters - Handles signature verification - Specifies required key types - Manages cryptographic operations
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Algorithm ¶
type Algorithm interface { // Name returns the algorithm name (e.g., "ES256", "RS256") Name() string // Hash returns the hash function used by the algorithm Hash() crypto.Hash // VaultKeyType returns the required Vault Transit key type // Examples: "ecdsa-p256", "rsa-2048" VaultKeyType() string // SigningParams returns algorithm-specific Vault signing parameters // Including base params (prehashed, hash_algorithm) and algorithm specific ones // All algorithms use marshaling_algorithm=jws SigningParams() map[string]interface{} // Verify verifies the signature against the message using given public key // Key must be *ecdsa.PublicKey or *rsa.PublicKey matching the algorithm Verify(message, signature []byte, key interface{}) error // KeyCheck validates the key type for verification // Returns ErrInvalidKeyType if key type doesn't match algorithm KeyCheck(key interface{}) error }
Algorithm defines how different signing algorithms process signatures
func Get ¶
Get retrieves an algorithm from the registry by name Returns ErrUnsupportedAlgorithm if algorithm not found Supported algorithms: - ES256, ES384, ES512 (ECDSA) - RS256, RS384, RS512 (RSA PKCS1v15) - PS256, PS384, PS512 (RSA-PSS)
func NewECDSAAlgorithm ¶
NewECDSAAlgorithm creates a new ECDSA algorithm instance Supported names: ES256, ES384, ES512 Each algorithm requires the corresponding Vault key type: - ES256: ecdsa-p256 - ES384: ecdsa-p384 - ES512: ecdsa-p521
func NewRSAAlgorithm ¶
NewRSAAlgorithm creates a new RSA algorithm instance Supports both PKCS1v15 (RS*) and PSS (PS*) padding Required Vault key types based on hash size: - SHA-256: rsa-2048 - SHA-384: rsa-3072 - SHA-512: rsa-4096
type BaseAlgorithm ¶
type BaseAlgorithm struct {
// contains filtered or unexported fields
}
BaseAlgorithm provides common functionality for all algorithms
func (*BaseAlgorithm) Hash ¶
func (b *BaseAlgorithm) Hash() crypto.Hash
func (*BaseAlgorithm) KeyCheck ¶
func (b *BaseAlgorithm) KeyCheck(key interface{}) error
func (*BaseAlgorithm) Name ¶
func (b *BaseAlgorithm) Name() string
func (*BaseAlgorithm) SigningParams ¶
func (b *BaseAlgorithm) SigningParams() map[string]interface{}
func (*BaseAlgorithm) VaultKeyType ¶
func (b *BaseAlgorithm) VaultKeyType() string
type ECDSAAlgorithm ¶
type ECDSAAlgorithm struct { BaseAlgorithm // contains filtered or unexported fields }
NewECDSAAlgorithm creates a new ECDSA algorithm instance
func (*ECDSAAlgorithm) SigningParams ¶
func (e *ECDSAAlgorithm) SigningParams() map[string]interface{}
SigningParams returns algorithm-specific Vault signing parameters
func (*ECDSAAlgorithm) Verify ¶
func (e *ECDSAAlgorithm) Verify(message, signature []byte, key interface{}) error
Verify verifies an ECDSA signature in raw R||S format
type ECDSASignature ¶
ECDSASignature represents the R and S components of an ECDSA signature
type RSAAlgorithm ¶
type RSAAlgorithm struct { BaseAlgorithm // contains filtered or unexported fields }
RSAAlgorithm implements the Algorithm interface for RSA signatures
func (*RSAAlgorithm) SigningParams ¶
func (r *RSAAlgorithm) SigningParams() map[string]interface{}
SigningParams returns algorithm-specific Vault signing parameters
func (*RSAAlgorithm) Verify ¶
func (r *RSAAlgorithm) Verify(message, signature []byte, key interface{}) error
Verify verifies an RSA signature