Documentation ¶
Index ¶
- Variables
- func EncodeToPEM(privateKey crypto.PrivateKey, pwd string) ([]byte, error)
- func GetDir(path string) string
- func GetFilenamesFromString(pk string) (string, string)
- func GetFilenamesFromType(t Type) (pk string, pub string)
- func MakeDir(path string) error
- func TypesToString() string
- func WriteToFile(b []byte, path string) error
- func Writekeys(publicKey []byte, privateKey []byte, opts *Options) error
- type ECDSAGenerator
- type ECDSAKeySize
- type ED25519Generator
- type ED25519KeySize
- type Generator
- type KeySize
- type Options
- type RSAGenerator
- type RSAKeySize
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotImplementedKeyType = errors.New("this type of key is not yet implemented") ErrInvalidKeySize = errors.New("invalid key size") ErrInvalidKeyType = errors.New("invalid key type. Type should be equal to rsa, dsa, ecdsa or ed25519") ErrPrivateKeyNotGenerated = errors.New("private key must be generated before generating the public key") ErrKeySizeNotValid = errors.New("key size is not valid") ErrKeyOverrideNotAllowed = errors.New("overriding the key is not allowed") )
Keys errors
var Types = []Type{RSA, ECDSA, ED25519}
Types contains the list of key types
Functions ¶
func EncodeToPEM ¶
func EncodeToPEM(privateKey crypto.PrivateKey, pwd string) ([]byte, error)
EncodeToPEM encodes the key into PEM
func GetFilenamesFromString ¶
GetFilenamesFromString returns a pair of string based on user's input The first value is the name of the private key The second value is the name of the public key
func GetFilenamesFromType ¶
GetFilenamesFromType returns a pair of string based on the type of key The first value is the name of the private key The second value is the name of the public key
func TypesToString ¶
func TypesToString() string
TypesToString returns the list of key types separated by a comma
func WriteToFile ¶
WriteToFile writes the key to a file
Types ¶
type ECDSAGenerator ¶
type ECDSAGenerator struct {
// contains filtered or unexported fields
}
ECDSAGenerator generates ECDSA private and public keys
func (*ECDSAGenerator) GenPrivateKey ¶
func (g *ECDSAGenerator) GenPrivateKey() ([]byte, error)
GenPrivateKey generates a ECDSA private key
func (*ECDSAGenerator) GenPublicKey ¶
func (g *ECDSAGenerator) GenPublicKey() ([]byte, error)
GenPublicKey generates a ECDSA public key
type ECDSAKeySize ¶
type ECDSAKeySize struct{}
ECDSAKeySize ECDSA complexity implementation
func (*ECDSAKeySize) GetDefault ¶
func (c *ECDSAKeySize) GetDefault() string
GetDefault returns the default complexity
func (*ECDSAKeySize) GetValue ¶
func (c *ECDSAKeySize) GetValue(s string) interface{}
GetValue returns the complexity value
func (*ECDSAKeySize) GetValues ¶
func (c *ECDSAKeySize) GetValues() []string
GetValues returns the available complexity values
type ED25519Generator ¶
type ED25519Generator struct {
// contains filtered or unexported fields
}
ED25519Generator generates RSA private and public keys
func (*ED25519Generator) GenPrivateKey ¶
func (g *ED25519Generator) GenPrivateKey() ([]byte, error)
GenPrivateKey generates a ED25519 private key
func (*ED25519Generator) GenPublicKey ¶
func (g *ED25519Generator) GenPublicKey() ([]byte, error)
GenPublicKey generates a ED25519 public key
type ED25519KeySize ¶
type ED25519KeySize struct{}
ED25519KeySize ED25519 complexity implementation
func (*ED25519KeySize) GetDefault ¶
func (c *ED25519KeySize) GetDefault() string
GetDefault returns the default complexity
func (*ED25519KeySize) GetValue ¶
func (c *ED25519KeySize) GetValue(s string) interface{}
GetValue returns the complexity value
func (*ED25519KeySize) GetValues ¶
func (c *ED25519KeySize) GetValues() []string
GetValues returns the available complexity values
type Generator ¶
Generator interface describing what is a generator
func GetGenerator ¶
GetGenerator returns the generator matching the type of key
type KeySize ¶
KeySize interface describing how to retrieve KeySize struct
func GetKeySize ¶
GetKeySize returns the generator matching the type of key
type Options ¶
type Options struct { KeyType Type Host string PassPhrase string PrivateKey string PublicKey string Directory string KeySize interface{} }
Options keys options
type RSAGenerator ¶
type RSAGenerator struct {
// contains filtered or unexported fields
}
RSAGenerator generates RSA private and public keys
func (*RSAGenerator) GenPrivateKey ¶
func (g *RSAGenerator) GenPrivateKey() ([]byte, error)
GenPrivateKey generates a RSA private key
func (*RSAGenerator) GenPublicKey ¶
func (g *RSAGenerator) GenPublicKey() ([]byte, error)
GenPublicKey generates a RSA public key
type RSAKeySize ¶
type RSAKeySize struct{}
RSAKeySize RSA complexity implementation
func (*RSAKeySize) GetDefault ¶
func (c *RSAKeySize) GetDefault() string
GetDefault returns the default complexity
func (*RSAKeySize) GetValue ¶
func (c *RSAKeySize) GetValue(s string) interface{}
GetValue returns the complexity value
func (*RSAKeySize) GetValues ¶
func (c *RSAKeySize) GetValues() []string
GetValues returns the available complexity values