Documentation
¶
Index ¶
- Variables
- func GenerateKeys(bits int, opts ...KeyOption) (PrivateKey, PublicKey, error)
- type KeyConfig
- type KeyOption
- type PrivateKey
- func GeneratePrivateKey(bits int, opts ...KeyOption) (PrivateKey, error)
- func LoadPrivateKey(keyFile string, opts ...KeyOption) (PrivateKey, error)
- func MustLoadPrivateKey(keyFile string, opts ...KeyOption) PrivateKey
- func ParsePrivateKey(keyPem cryptox.Bytes, opts ...KeyOption) (PrivateKey, error)
- func ReadPrivateKey(keyReader io.Reader, opts ...KeyOption) (PrivateKey, error)
- type PrivateKeyDecoder
- type PrivateKeyEncoder
- type PublicKey
- func GeneratePublicKey(privateKey PrivateKey, opts ...KeyOption) (PublicKey, error)
- func LoadPublicKey(keyFile string, opts ...KeyOption) (PublicKey, error)
- func MustLoadPublicKey(keyFile string, opts ...KeyOption) PublicKey
- func ParsePublicKey(keyPem cryptox.Bytes, opts ...KeyOption) (PublicKey, error)
- func ReadPublicKey(keyReader io.Reader, opts ...KeyOption) (PublicKey, error)
- type PublicKeyDecoder
- type PublicKeyEncoder
Constants ¶
This section is empty.
Variables ¶
var (
// X509 is a x509Pem instance with X509 methods.
X509 = x509Pem{}
)
Functions ¶
func GenerateKeys ¶
func GenerateKeys(bits int, opts ...KeyOption) (PrivateKey, PublicKey, error)
GenerateKeys generates a key set of bits.
Types ¶
type KeyConfig ¶
type KeyConfig struct {
// contains filtered or unexported fields
}
KeyConfig stores all configurations of key.
type KeyOption ¶
type KeyOption func(cfg *KeyConfig)
KeyOption is an option for key config.
func WithPrivateKeyDecoder ¶
func WithPrivateKeyDecoder(decoder PrivateKeyDecoder) KeyOption
WithPrivateKeyDecoder sets private key decoder to cfg.
func WithPrivateKeyEncoder ¶
func WithPrivateKeyEncoder(encoder PrivateKeyEncoder) KeyOption
WithPrivateKeyEncoder sets private key encoder to cfg.
func WithPublicKeyDecoder ¶
func WithPublicKeyDecoder(decoder PublicKeyDecoder) KeyOption
WithPublicKeyDecoder sets public key decoder to cfg.
func WithPublicKeyEncoder ¶
func WithPublicKeyEncoder(encoder PublicKeyEncoder) KeyOption
WithPublicKeyEncoder sets public key encoder to cfg.
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func GeneratePrivateKey ¶
func GeneratePrivateKey(bits int, opts ...KeyOption) (PrivateKey, error)
GeneratePrivateKey generates a private key of bits.
func LoadPrivateKey ¶
func LoadPrivateKey(keyFile string, opts ...KeyOption) (PrivateKey, error)
LoadPrivateKey loads private key from a file.
func MustLoadPrivateKey ¶
func MustLoadPrivateKey(keyFile string, opts ...KeyOption) PrivateKey
MustLoadPrivateKey loads private key from a file or panic on failed.
func ParsePrivateKey ¶
func ParsePrivateKey(keyPem cryptox.Bytes, opts ...KeyOption) (PrivateKey, error)
ParsePrivateKey parses private key from pem.
func ReadPrivateKey ¶
func ReadPrivateKey(keyReader io.Reader, opts ...KeyOption) (PrivateKey, error)
ReadPrivateKey reads private key from a reader.
func (PrivateKey) Encoded ¶
func (pk PrivateKey) Encoded() cryptox.Bytes
func (PrivateKey) EqualsTo ¶
func (pk PrivateKey) EqualsTo(privateKey PrivateKey) bool
func (PrivateKey) Key ¶
func (pk PrivateKey) Key() *rsa.PrivateKey
func (PrivateKey) String ¶
func (pk PrivateKey) String() string
type PrivateKeyDecoder ¶
type PrivateKeyDecoder func(keyPem cryptox.Bytes) (*rsa.PrivateKey, error)
PrivateKeyDecoder decodes private key from pem bytes.
func (PrivateKeyDecoder) Decode ¶
func (pke PrivateKeyDecoder) Decode(keyPem cryptox.Bytes) (*rsa.PrivateKey, error)
Decode decodes private key from pem bytes.
type PrivateKeyEncoder ¶
type PrivateKeyEncoder func(key *rsa.PrivateKey) (cryptox.Bytes, error)
PrivateKeyEncoder encodes private key to pem bytes.
func (PrivateKeyEncoder) Encode ¶
func (pke PrivateKeyEncoder) Encode(key *rsa.PrivateKey) (cryptox.Bytes, error)
Encode encodes private key to pem bytes.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
func GeneratePublicKey ¶
func GeneratePublicKey(privateKey PrivateKey, opts ...KeyOption) (PublicKey, error)
GeneratePublicKey generates a public key from private key.
func LoadPublicKey ¶
LoadPublicKey loads public key from a file.
func MustLoadPublicKey ¶
MustLoadPublicKey loads public key from a file or panic on failed.
func ParsePublicKey ¶
ParsePublicKey parses public key from pem.
func ReadPublicKey ¶
ReadPublicKey reads public key from a reader.
type PublicKeyDecoder ¶
PublicKeyDecoder decodes public key from pem bytes.