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 ¶
GenerateRSAPems generates RSA key pair and the PEM encoding of them.
func ParseRSAPrivateKeyFromPem ¶
func ParseRSAPrivateKeyFromPem(data []byte) (*rsa.PrivateKey, error)
Types ¶
type AESEncryptDecrypter ¶
type AESEncryptDecrypter struct {
// contains filtered or unexported fields
}
func NewAESEncryptDecrypter ¶
func NewAESEncryptDecrypter(keyFile string) (*AESEncryptDecrypter, error)
NewAESEncryptDecrypter reads the specified key file and returns an AES EncryptDecrypter.
type EncryptDecrypter ¶
type HybridDecrypter ¶
type HybridDecrypter struct {
// contains filtered or unexported fields
}
func NewHybridDecrypter ¶
func NewHybridDecrypter(key []byte) (*HybridDecrypter, error)
func (*HybridDecrypter) Decrypt ¶
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 ¶
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 ¶
func NewHybridEncrypter(key []byte) (*HybridEncrypter, error)
func (*HybridEncrypter) Encrypt ¶
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 ¶
type RSADecrypter struct {
// contains filtered or unexported fields
}
func NewRSADecrypter ¶
func NewRSADecrypter(key []byte) (*RSADecrypter, error)
type RSAEncrypter ¶
type RSAEncrypter struct {
// contains filtered or unexported fields
}
func NewRSAEncrypter ¶
func NewRSAEncrypter(key []byte) (*RSAEncrypter, error)