Documentation
¶
Index ¶
Constants ¶
const ( AESKey128 = AESKeySize(16) AESKey192 = AESKeySize(24) AESKey256 = AESKeySize(32) )
const ( RSAKey2048 = RSAKeySize(2048) RSAKey4096 = RSAKeySize(4096) )
Variables ¶
This section is empty.
Functions ¶
func SetBase64Encoder ¶
func SetRandomReader ¶
Types ¶
type AES ¶ added in v0.0.2
type AES interface { SymmetricEncryption }
func AesCBCWithPKCS5Padding ¶ added in v0.0.3
func AesGCM ¶ added in v0.0.4
AesGCM return AES with Galois Counter Mode instance. It is using 12 bytes nonce and 16 bytes tag. additionalData is an optional parameter (used for authentication purpose). It can be nil or any size slice.
AesGCM.Encrypt will return bytes of base64encode(Nonce+CipherText+Tag). AesGCM.Decrypt requires bytes of base64encode(Nonce+CipherText+Tag) parameter.
type AESKey ¶ added in v0.0.2
type AESKey Key
func AesGenerateRandomKey ¶ added in v0.0.2
func AesGenerateRandomKey(keySize AESKeySize) AESKey
func AesLoadEncodedKey ¶ added in v0.0.2
AesLoadEncodedKey loads encoded base64 key into AESKey
type AESKeySize ¶ added in v0.0.2
type AESKeySize int
type AsymmetricEncryption ¶
type RSA ¶
type RSA interface { AsymmetricEncryption }
func RsaOAEPWithSHA256 ¶
func RsaOAEPWithSHA256(keyPair RSAKeyPair) (RSA, error)
func RsaOAEPWithSHA512 ¶
func RsaOAEPWithSHA512(keyPair RSAKeyPair) (RSA, error)
type RSAKeyPair ¶
type RSAKeyPair interface { KeyPair PublicRsa() *rsa.PublicKey PrivateRsa() *rsa.PrivateKey }
func RsaGenerateKeyPair ¶
func RsaGenerateKeyPair(bits RSAKeySize) (RSAKeyPair, error)
func RsaLoadEncodedKeyPair ¶
func RsaLoadEncodedKeyPair(privateKey []byte) (RSAKeyPair, error)
RsaLoadEncodedKeyPair loads base64 encoded privateKey into RSAKeyPair. It will create RSAKeyPair instance with private and public keys loaded.
func RsaLoadEncodedPublicKey ¶ added in v0.0.2
func RsaLoadEncodedPublicKey(publicKey []byte) (RSAKeyPair, error)
RsaLoadEncodedPublicKey loads base64 encoded publicKey only into RSAKeyPair. It will create RSAKeyPair instance without a private key.
**NOTE** This RSAKeyPair is used for encryption only.
type RSAKeySize ¶
type RSAKeySize int