Documentation
¶
Index ¶
- Constants
- Variables
- type FnGenOpt
- type FnOpt
- type GenerateOptions
- type Generator
- type KeyParseOptions
- type Parser
- type Private
- type PrivateKeyProvider
- type Public
- type PublicKeyProvider
- type Scheme
- type Signer
- type Type
- type VerificationResult
- type Verifier
- func (v *Verifier) VerifyDigest(pkeyProv PublicKeyProvider, digest, signature []byte) (bool, error)
- func (v *Verifier) VerifyDigestString(pkeyProv PublicKeyProvider, digestString string, signature []byte) (bool, error)
- func (v *Verifier) VerifyMessage(pkeyProv PublicKeyProvider, message, signature []byte) (bool, error)
Constants ¶
const ( RSA Type = "rsa" ECDSA Type = "ecdsa" ED25519 Type = "ed25519" RsaSsaPssSha256 Scheme = "rsassa-pss-sha256" RsaSsaPssSha384 Scheme = "rsassa-pss-sha384" RsaSsaPssSha512 Scheme = "rsassa-pss-sha512" EcdsaSha2nistP224 Scheme = "ecdsa-sha2-nistp224" EcdsaSha2nistP256 Scheme = "ecdsa-sha2-nistp256" EcdsaSha2nistP384 Scheme = "ecdsa-sha2-nistp384" EcdsaSha2nistP521 Scheme = "ecdsa-sha2-nistp521" EcdsaSha256nistP256 Scheme = "ecdsa-sha256-nistp256" EcdsaSha384nistP384 Scheme = "ecdsa-sha384-nistp384" Ed25519 Scheme = "ed25519" )
Variables ¶
var ( ErrUnknownScheme = errors.New("unknown key scheme") ErrIncorrectKeySchema = errors.New("unable to set key scheme, incorrect key type") ErrIncorrectEllipticCurve = errors.New("schema curve does not match key") ErrUnknownEllipticCurve = errors.New("unsupported elliptic curve") )
var DefaultGenerateOptions = GenerateOptions{ Type: ECDSA, Curve: elliptic.P256(), RSAHashType: crypto.SHA256, KeyLength: 4096, }
DefaultGenerateOptions default key generation options
Functions ¶
This section is empty.
Types ¶
type FnGenOpt ¶
type FnGenOpt func(*GenerateOptions) error
func WithEllipticCurve ¶
func WithKeyLength ¶
func WithKeyType ¶
type FnOpt ¶
type FnOpt func(*KeyParseOptions)
type GenerateOptions ¶
type Generator ¶
type Generator struct{}
Generator is a key generator that returns keys wrapped in our key wrappers. The key generator supports ECDSA, RSA and ED25519 and some basic options such as key length and defininig the elliptic curve to use.
func NewGenerator ¶
func NewGenerator() *Generator
type KeyParseOptions ¶
type KeyParseOptions struct {
Scheme Scheme
}
type Private ¶
type Private struct {
Type Type
Scheme Scheme
HashType crypto.Hash
Data string
Key crypto.PublicKey
}
Private abstracts a private key use mainly to sign.
func (*Private) PrivateKey ¶
PrivateKey implements the PrivateKeyProvider interface
type PrivateKeyProvider ¶
type Public ¶
type Public struct {
Type Type
Scheme Scheme
HashType crypto.Hash
Data string
Key crypto.PublicKey
}
Public key abstracts a public key data and all its features required to verify. After parsing, the original key data is preserved in the srtuct.
func (*Public) Curve ¶
Curve returns the nist name of elliptic curve used in the key. If it cannot be read or the key is not an elliptic curve key then this function returns an empty string.
type PublicKeyProvider ¶
type Signer ¶
type Signer struct{}
func (*Signer) SignDigest ¶
func (s *Signer) SignDigest(keyProvider PrivateKeyProvider, digest []byte) ([]byte, error)
SignDigest signs the digest byte sequence using the key obtained from a key provider
func (*Signer) SignDigestString ¶
func (s *Signer) SignDigestString(keyProvider PrivateKeyProvider, digestString string) ([]byte, error)
SignDigestString signs a digest in hex string representation
func (*Signer) SignMessage ¶
func (s *Signer) SignMessage(keyProvider PrivateKeyProvider, message []byte) ([]byte, error)
SignMessage signs a supplied message
type VerificationResult ¶
type VerificationResult struct {
Key *Public
Time time.Time
Digest map[string]string
Verified bool
}
VerificationResult captures the key verification result
type Verifier ¶
type Verifier struct{}
func NewVerifier ¶
func NewVerifier() *Verifier
func (*Verifier) VerifyDigest ¶
func (v *Verifier) VerifyDigest(pkeyProv PublicKeyProvider, digest, signature []byte) (bool, error)
VerifyDigest checks a sigest signature against a digest byte slice
func (*Verifier) VerifyDigestString ¶
func (v *Verifier) VerifyDigestString(pkeyProv PublicKeyProvider, digestString string, signature []byte) (bool, error)
VerifyDigestString verifies the signature from a digest string. The provided string must be a hex encoded string of a hash produced by algorithm defined in the public key abstraction.
func (*Verifier) VerifyMessage ¶
func (v *Verifier) VerifyMessage(pkeyProv PublicKeyProvider, message, signature []byte) (bool, error)
VerifyMessage verifies the signature by getting the whole message