Documentation ¶
Index ¶
- Variables
- func GenerateKeys(bits int, opts ...KeyOption) (PrivateKey, PublicKey, error)
- type Config
- type KeyConfig
- type KeyOption
- type Option
- 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(keyBytes cryptox.Bytes, opts ...KeyOption) (PrivateKey, error)
- func ReadPrivateKey(keyReader io.Reader, opts ...KeyOption) (PrivateKey, error)
- func (pk PrivateKey) Bytes() cryptox.Bytes
- func (pk PrivateKey) DecryptOAEP(msg cryptox.Bytes, label cryptox.Bytes, opts ...Option) (cryptox.Bytes, error)
- func (pk PrivateKey) DecryptPKCS1v15(msg cryptox.Bytes, opts ...Option) (cryptox.Bytes, error)
- func (pk PrivateKey) DecryptPKCS1v15SessionKey(msg cryptox.Bytes, sessionKey cryptox.Bytes, opts ...Option) error
- func (pk PrivateKey) EqualsTo(privateKey PrivateKey) bool
- func (pk PrivateKey) Key() *rsa.PrivateKey
- func (pk PrivateKey) SignPKCS1v15(hashed cryptox.Bytes, opts ...Option) (cryptox.Bytes, error)
- func (pk PrivateKey) SignPSS(digest cryptox.Bytes, saltLength int, opts ...Option) (cryptox.Bytes, error)
- func (pk PrivateKey) String() string
- 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(keyBytes cryptox.Bytes, opts ...KeyOption) (PublicKey, error)
- func ReadPublicKey(keyReader io.Reader, opts ...KeyOption) (PublicKey, error)
- func (pk PublicKey) Bytes() cryptox.Bytes
- func (pk PublicKey) EncryptOAEP(msg cryptox.Bytes, label cryptox.Bytes, opts ...Option) (cryptox.Bytes, error)
- func (pk PublicKey) EncryptPKCS1v15(msg cryptox.Bytes, opts ...Option) (cryptox.Bytes, error)
- func (pk PublicKey) EqualsTo(publicKey PublicKey) bool
- func (pk PublicKey) Key() *rsa.PublicKey
- func (pk PublicKey) String() string
- func (pk PublicKey) VerifyPKCS1v15(hashed cryptox.Bytes, signature cryptox.Bytes, opts ...Option) error
- func (pk PublicKey) VerifyPSS(digest cryptox.Bytes, signature cryptox.Bytes, saltLength int, opts ...Option) 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 KeyOption ¶
type KeyOption func(conf *KeyConfig)
func WithPrivateKeyDecoder ¶
func WithPrivateKeyDecoder(decoder PrivateKeyDecoder) KeyOption
WithPrivateKeyDecoder sets private key decoder to conf.
func WithPrivateKeyEncoder ¶
func WithPrivateKeyEncoder(encoder PrivateKeyEncoder) KeyOption
WithPrivateKeyEncoder sets private key encoder to conf.
func WithPublicKeyDecoder ¶
func WithPublicKeyDecoder(decoder PublicKeyDecoder) KeyOption
WithPublicKeyDecoder sets public key decoder to conf.
func WithPublicKeyEncoder ¶
func WithPublicKeyEncoder(encoder PublicKeyEncoder) KeyOption
WithPublicKeyEncoder sets public key encoder to conf.
type Option ¶
type Option func(conf *Config)
func WithCryptoHash ¶
WithCryptoHash sets crypto hash to conf.
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 a private key from a file.
func MustLoadPrivateKey ¶
func MustLoadPrivateKey(keyFile string, opts ...KeyOption) PrivateKey
MustLoadPrivateKey loads private key from a file or panic if failed.
func ParsePrivateKey ¶
func ParsePrivateKey(keyBytes cryptox.Bytes, opts ...KeyOption) (PrivateKey, error)
ParsePrivateKey parses a private key from pem bytes.
func ReadPrivateKey ¶
func ReadPrivateKey(keyReader io.Reader, opts ...KeyOption) (PrivateKey, error)
ReadPrivateKey reads a private key from a reader.
func (PrivateKey) DecryptOAEP ¶
func (pk PrivateKey) DecryptOAEP(msg cryptox.Bytes, label cryptox.Bytes, opts ...Option) (cryptox.Bytes, error)
DecryptOAEP decrypts msg with oaep.
func (PrivateKey) DecryptPKCS1v15 ¶
DecryptPKCS1v15 decrypts msg with pkcs1 v15.
func (PrivateKey) DecryptPKCS1v15SessionKey ¶
func (pk PrivateKey) DecryptPKCS1v15SessionKey(msg cryptox.Bytes, sessionKey cryptox.Bytes, opts ...Option) error
DecryptPKCS1v15SessionKey decrypts msg using a session key with pkcs1 v15.
func (PrivateKey) EqualsTo ¶
func (pk PrivateKey) EqualsTo(privateKey PrivateKey) bool
EqualsTo returns if pk equals to privateKey.
func (PrivateKey) SignPKCS1v15 ¶
SignPKCS1v15 signs hashed data with pkcs1 v15.
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 a public key from a file.
func MustLoadPublicKey ¶
MustLoadPublicKey loads public key from a file or panic if failed.
func ParsePublicKey ¶
ParsePublicKey parses a public key from pem bytes.
func ReadPublicKey ¶
ReadPublicKey reads a public key from a reader.
func (PublicKey) EncryptOAEP ¶
func (pk PublicKey) EncryptOAEP(msg cryptox.Bytes, label cryptox.Bytes, opts ...Option) (cryptox.Bytes, error)
EncryptOAEP encrypts msg with oaep.
func (PublicKey) EncryptPKCS1v15 ¶
EncryptPKCS1v15 encrypts msg with pkcs1 v15.
type PublicKeyDecoder ¶
PublicKeyDecoder decodes public key from pem bytes.