Documentation
¶
Index ¶
- func GenerateKeys(bits int, opts ...KeyOption) (PrivateKey, PublicKey, error)
- func StorePrivateKey(file string, privateKey PrivateKey, opts ...KeyOption) error
- func StorePublicKey(file string, publicKey PublicKey, opts ...KeyOption) error
- func WritePrivateKey(writer io.Writer, privateKey PrivateKey, opts ...KeyOption) error
- func WritePublicKey(writer io.Writer, publicKey PublicKey, opts ...KeyOption) error
- type Config
- type KeyConfig
- type KeyOption
- func WithKeyDecodePrivate(decode func(data []byte) (*rsa.PrivateKey, error)) KeyOption
- func WithKeyDecodePublic(decode func(data []byte) (*rsa.PublicKey, error)) KeyOption
- func WithKeyEncodePrivate(encode func(key *rsa.PrivateKey) ([]byte, error)) KeyOption
- func WithKeyEncodePublic(encode func(key *rsa.PublicKey) ([]byte, error)) KeyOption
- func WithKeyRandom(random io.Reader) KeyOption
- type Option
- type PrivateKey
- func (pk PrivateKey) DecryptOAEP(data []byte, label []byte, opts ...Option) ([]byte, error)
- func (pk PrivateKey) DecryptPKCS1v15(data []byte, opts ...Option) ([]byte, error)
- func (pk PrivateKey) DecryptPKCS1v15SessionKey(data []byte, sessionKey []byte, opts ...Option) error
- func (pk PrivateKey) SignPKCS1v15(hashed []byte, opts ...Option) ([]byte, error)
- func (pk PrivateKey) SignPSS(digest []byte, opts ...Option) ([]byte, error)
- type PublicKey
- func (pk PublicKey) EncryptOAEP(data []byte, label []byte, opts ...Option) ([]byte, error)
- func (pk PublicKey) EncryptPKCS1v15(data []byte, opts ...Option) ([]byte, error)
- func (pk PublicKey) VerifyPKCS1v15(hashed []byte, sign []byte, opts ...Option) error
- func (pk PublicKey) VerifyPSS(digest []byte, sign []byte, opts ...Option) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKeys ¶
func GenerateKeys(bits int, opts ...KeyOption) (PrivateKey, PublicKey, error)
GenerateKeys generates a private key of bits and a public key.
func StorePrivateKey ¶ added in v0.5.2
func StorePrivateKey(file string, privateKey PrivateKey, opts ...KeyOption) error
StorePrivateKey stores the private key to the file.
func StorePublicKey ¶ added in v0.5.2
StorePublicKey stores the public key to the file.
func WritePrivateKey ¶ added in v0.5.2
func WritePrivateKey(writer io.Writer, privateKey PrivateKey, opts ...KeyOption) error
WritePrivateKey writes the private key to the writer.
Types ¶
type KeyOption ¶
type KeyOption func(conf *KeyConfig)
func WithKeyDecodePrivate ¶ added in v0.5.2
func WithKeyDecodePrivate(decode func(data []byte) (*rsa.PrivateKey, error)) KeyOption
WithKeyDecodePrivate sets decode to key config.
func WithKeyDecodePublic ¶ added in v0.5.2
WithKeyDecodePublic sets decode to key config.
func WithKeyEncodePrivate ¶ added in v0.5.2
func WithKeyEncodePrivate(encode func(key *rsa.PrivateKey) ([]byte, error)) KeyOption
WithKeyEncodePrivate sets encode to key config.
func WithKeyEncodePublic ¶ added in v0.5.2
WithKeyEncodePublic sets encode to key config.
func WithKeyRandom ¶ added in v0.5.2
WithKeyRandom sets random to key config.
type Option ¶
type Option func(conf *Config)
func WithBase64 ¶ added in v0.5.2
func WithBase64() Option
WithBase64 sets base64 encoding to config.
func WithCryptoHash ¶
WithCryptoHash sets crypto hash to config.
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func LoadPrivateKey ¶
func LoadPrivateKey(file string, opts ...KeyOption) (PrivateKey, error)
LoadPrivateKey loads the private key from the file.
func ReadPrivateKey ¶
func ReadPrivateKey(reader io.Reader, opts ...KeyOption) (PrivateKey, error)
ReadPrivateKey reads the private key from the reader.
func (PrivateKey) DecryptOAEP ¶
DecryptOAEP decrypts data with oaep.
func (PrivateKey) DecryptPKCS1v15 ¶
func (pk PrivateKey) DecryptPKCS1v15(data []byte, opts ...Option) ([]byte, error)
DecryptPKCS1v15 decrypts data with pkcs1 v15.
func (PrivateKey) DecryptPKCS1v15SessionKey ¶
func (pk PrivateKey) DecryptPKCS1v15SessionKey(data []byte, sessionKey []byte, opts ...Option) error
DecryptPKCS1v15SessionKey decrypts data using a session key with pkcs1 v15.
func (PrivateKey) SignPKCS1v15 ¶
func (pk PrivateKey) SignPKCS1v15(hashed []byte, opts ...Option) ([]byte, error)
SignPKCS1v15 signs hashed with pkcs1 v15.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
func LoadPublicKey ¶
LoadPublicKey loads the public key from the file.
func ReadPublicKey ¶
ReadPublicKey reads the public key from the reader.
func (PublicKey) EncryptOAEP ¶
EncryptOAEP encrypts data with oaep.
func (PublicKey) EncryptPKCS1v15 ¶
EncryptPKCS1v15 encrypts data with pkcs1 v15.
func (PublicKey) VerifyPKCS1v15 ¶
VerifyPKCS1v15 verifies hashed with pkcs1 v15.