Documentation
¶
Index ¶
- Constants
- func GenerateRSAPems(size int) (private, public []byte, err error)
- func ParseRSAPrivateKeyFromPem(data []byte) (*rsa.PrivateKey, error)
- func ParseRSAPublicKeyFromPem(data []byte) (*rsa.PublicKey, error)
- type AESEncryptDecrypter
- type Decrypter
- type EncryptDecrypter
- type Encrypter
- type HybridDecrypter
- type HybridEncrypter
- type RSADecrypter
- type RSAEncrypter
Constants ¶
const DefauleRSAKeySize = 2048
Variables ¶
This section is empty.
Functions ¶
func GenerateRSAPems ¶ added in v0.8.0
GenerateRSAPems generates RSA key pair and the PEM encoding of them.
func ParseRSAPrivateKeyFromPem ¶ added in v0.8.0
func ParseRSAPrivateKeyFromPem(data []byte) (*rsa.PrivateKey, error)
Types ¶
type AESEncryptDecrypter ¶ added in v0.8.0
type AESEncryptDecrypter struct {
// contains filtered or unexported fields
}
func NewAESEncryptDecrypter ¶ added in v0.8.0
func NewAESEncryptDecrypter(keyFile string) (*AESEncryptDecrypter, error)
NewAESEncryptDecrypter reads the specified key file and returns an AES EncryptDecrypter.
type EncryptDecrypter ¶ added in v0.8.0
type HybridDecrypter ¶ added in v0.8.0
type HybridDecrypter struct {
// contains filtered or unexported fields
}
func NewHybridDecrypter ¶ added in v0.8.0
func NewHybridDecrypter(key []byte) (*HybridDecrypter, error)
func (*HybridDecrypter) Decrypt ¶ added in v0.8.0
func (d *HybridDecrypter) Decrypt(encryptedText string) (string, error)
Decrypt performs a regular AES-GCM + RSA-OAEP decryption.
The implementation of this function was brought from well known Bitnami's SealedSecret library. https://github.com/bitnami-labs/sealed-secrets/blob/master/pkg/crypto/crypto.go#L86
type HybridEncrypter ¶ added in v0.8.0
type HybridEncrypter struct {
// contains filtered or unexported fields
}
HybridEncrypter uses RSA to encrypt a randomly generated key for a symmetric AES-GCM. RSA is able to encrypt only a very limited amount of data. In order to encrypt reasonable amounts of data a hybrid scheme is commonly used.
func NewHybridEncrypter ¶ added in v0.8.0
func NewHybridEncrypter(key []byte) (*HybridEncrypter, error)
func (*HybridEncrypter) Encrypt ¶ added in v0.8.0
func (e *HybridEncrypter) Encrypt(text string) (string, error)
Encrypt performs a regular AES-GCM + RSA-OAEP encryption. The output string is:
RSA ciphertext length || RSA ciphertext || AES ciphertext
The implementation of this function was brought from well known Bitnami's SealedSecret library. https://github.com/bitnami-labs/sealed-secrets/blob/master/pkg/crypto/crypto.go#L35
type RSADecrypter ¶ added in v0.8.0
type RSADecrypter struct {
// contains filtered or unexported fields
}
func NewRSADecrypter ¶ added in v0.8.0
func NewRSADecrypter(key []byte) (*RSADecrypter, error)
type RSAEncrypter ¶ added in v0.8.0
type RSAEncrypter struct {
// contains filtered or unexported fields
}
func NewRSAEncrypter ¶ added in v0.8.0
func NewRSAEncrypter(key []byte) (*RSAEncrypter, error)