Documentation ¶
Index ¶
- Constants
- type Config
- type KeyPair
- func (p *KeyPair) DecryptOAEP(cipherText string) (string, error)
- func (p *KeyPair) DecryptPKCS1v15(cipherText string) (string, error)
- func (p *KeyPair) EncryptOAEP(plainText string) (string, error)
- func (p *KeyPair) EncryptPKCS1v15(plainText string) (string, error)
- func (p *KeyPair) SignPKCS1v15(payload string) (string, error)
- func (p *KeyPair) SignPSS(payload string) (string, error)
- func (p *KeyPair) VerifyPKCS1v15(payload, signature64 string) error
- func (p *KeyPair) VerifyPSS(payload, signature64 string) error
Constants ¶
const ( DefaultDotKeys = ".keys" DefaultIDRsa = "id_rsa" DefaultIDRsaPub = "id_rsa.pub" DefaultKeySize = 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { DotKeys string // DotKeys represents the parent dir of IDRsa and IDRsaPub IDRsa string // IDRsa represents private key file IDRsaPub string // IDRsaPub represents public key file KeySize int // KeySize represents the bit size of key pair }
Config stores key pair file path and key size.
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig return Config with default params.
func (*Config) GenerateKeyPair ¶
func (c *Config) GenerateKeyPair() (*rsa.PrivateKey, error)
GenerateKeyPair generates a pair of rsa key pair with the given key size defined in Config.
func (*Config) LoadPrivateKey ¶
LoadPrivateKey return a KeyPair object contains private key from Config.IDRsa
func (*Config) LoadPublicKey ¶
LoadPublicKey return a KeyPair object contains public key from Config.IDRsaPub
func (*Config) SaveKeyPair ¶
func (c *Config) SaveKeyPair(keyPair *rsa.PrivateKey) error
SaveKeyPair save key pair to local path defined in Config.
type KeyPair ¶
type KeyPair struct {
// contains filtered or unexported fields
}
KeyPair stores key pair object
func (*KeyPair) DecryptOAEP ¶
DecryptOAEP decrypts ciphertext using RSA-OAEP.
func (*KeyPair) DecryptPKCS1v15 ¶
DecryptPKCS1v15 decrypts a plaintext using RSA and the padding scheme from PKCS #1 v1.5.
func (*KeyPair) EncryptOAEP ¶
EncryptOAEP encrypts the given message with RSA-OAEP.
func (*KeyPair) EncryptPKCS1v15 ¶
EncryptPKCS1v15 encrypts the given message with RSA and the padding scheme from PKCS #1 v1.5
func (*KeyPair) SignPKCS1v15 ¶
SignPKCS1v15 calculates the signature of hashed using RSASSA-PKCS1-V1_5-SIGN from RSA PKCS #1 v1.5.
func (*KeyPair) VerifyPKCS1v15 ¶
VerifyPKCS1v15 verifies an RSA PKCS #1 v1.5 signature.