rsa

package
v0.2.1-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

func (KeyOption) ApplyTo

func (ko KeyOption) ApplyTo(opts *KeyConfig)

ApplyTo applies key option to key config.

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

func LoadPublicKey(keyFile string, opts ...KeyOption) (PublicKey, error)

LoadPublicKey loads public key from a file.

func MustLoadPublicKey

func MustLoadPublicKey(keyFile string, opts ...KeyOption) PublicKey

MustLoadPublicKey loads public key from a file or panic on failed.

func ParsePublicKey

func ParsePublicKey(keyPem cryptox.Bytes, opts ...KeyOption) (PublicKey, error)

ParsePublicKey parses public key from pem.

func ReadPublicKey

func ReadPublicKey(keyReader io.Reader, opts ...KeyOption) (PublicKey, error)

ReadPublicKey reads public key from a reader.

func (PublicKey) Encoded

func (pk PublicKey) Encoded() cryptox.Bytes

func (PublicKey) EqualsTo

func (pk PublicKey) EqualsTo(publicKey PublicKey) bool

func (PublicKey) Key

func (pk PublicKey) Key() *rsa.PublicKey

func (PublicKey) String

func (pk PublicKey) String() string

type PublicKeyDecoder

type PublicKeyDecoder func(keyPem cryptox.Bytes) (*rsa.PublicKey, error)

PublicKeyDecoder decodes public key from pem bytes.

func (PublicKeyDecoder) Decode

func (pke PublicKeyDecoder) Decode(keyPem cryptox.Bytes) (*rsa.PublicKey, error)

Decode decodes public key from pem bytes.

type PublicKeyEncoder

type PublicKeyEncoder func(key *rsa.PublicKey) (cryptox.Bytes, error)

PublicKeyEncoder encodes public key to pem bytes.

func (PublicKeyEncoder) Encode

func (pke PublicKeyEncoder) Encode(key *rsa.PublicKey) (cryptox.Bytes, error)

Encode encodes public key to pem bytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL