Documentation ¶
Index ¶
- Variables
- func Base64ToKey(base64Key string) ([]byte, error)
- func DecodeSecret(secret string) ([]byte, error)
- func EncodeSecret(secret []byte) string
- func GenerateSecret() []byte
- func GetSignAlgorithmNames() []string
- func HashSecret(secret []byte) []byte
- func KeyToBase64(key []byte) string
- func PemToKey(pemBytes []byte) ([]byte, error)
- func PrivateKeyToPem(pk []byte, out io.Writer)
- func PublicKeyToPem(pk []byte, out io.Writer)
- func RegisterSignAlgorithm(alg SignAlgorithm)
- type DerKeys
- type SignAlgorithm
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidKeyType = errors.New("invalid key type")
View Source
var ErrInvalidSignature = errors.New("invalid signature")
View Source
var ErrKeyMustBePEMEncoded = errors.New("key must be PEM encoded")
Functions ¶
func Base64ToKey ¶
func DecodeSecret ¶
func EncodeSecret ¶
func GenerateSecret ¶
func GenerateSecret() []byte
func GetSignAlgorithmNames ¶
func GetSignAlgorithmNames() []string
func HashSecret ¶
func KeyToBase64 ¶
func PrivateKeyToPem ¶
func PublicKeyToPem ¶
func RegisterSignAlgorithm ¶
func RegisterSignAlgorithm(alg SignAlgorithm)
Types ¶
type SignAlgorithm ¶
type SignAlgorithm interface { Name() string /* Generate keypair in DER format. */ Generate() (DerKeys, error) /* Validate data signature. publicKey should be in PKIX DER format signature should be in binary format Return null if signature is valid, error otherwise. */ ValidateSignature(publicKey []byte, signature []byte, data []byte) error /* Sign the data. Private key should be in PKCS8 DER format. */ Sign(privateKey []byte, data []byte) ([]byte, error) }
func GetSignAlgorithm ¶
func GetSignAlgorithm(name string) SignAlgorithm
Click to show internal directories.
Click to hide internal directories.