Documentation
¶
Index ¶
- Constants
- func Base64Decode(data []byte) ([]byte, error)
- func Base64Encode(data []byte) []byte
- func CalculateSHA256(data []byte) []byte
- func CalculateSHA256Hmac(secret, data []byte) []byte
- func RandomBytes(size int) ([]byte, error)
- func SHA256AsHex(data []byte) []byte
- func SHA256HmacAsHex(secret, data []byte) []byte
- type AesGcm
- func (aesGcm AesGcm) Decrypt(data []byte) ([]byte, error)
- func (aesGcm AesGcm) DecryptWithTagSize(data []byte, authTagSize int) ([]byte, error)
- func (aesGcm AesGcm) Encrypt(data []byte) ([]byte, error)
- func (aesGcm AesGcm) EncryptWithIV(iv, data []byte) ([]byte, error)
- func (aesGcm AesGcm) EncryptWithIVAndTagSize(iv, data []byte, authTagSize int) ([]byte, error)
- type AsymDecryption
- type AsymEncryption
- type ECCMode
- type ECKeyPair
- type RsaKeyPair
Constants ¶
const DefaultNonceSize = 16
DefaultNonceSize The default nonce size for the TDF3 encryption.
const GcmStandardNonceSize = 12
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶
Base64Decode Decode the data using base64 decoding.
func Base64Encode ¶
Base64Encode Encode the data to base64 encoding. Note: bas64 encoding causing ~33% overhead.
func CalculateSHA256 ¶
CalculateSHA256 Calculate the SHA256 checksum of the data(32 bytes).
func CalculateSHA256Hmac ¶
CalculateSHA256Hmac Calculate the hmac of the data with given secret.
func RandomBytes ¶
RandomBytes Generates random bytes of given size.
func SHA256AsHex ¶
SHA256AsHex Calculate the SHA256 checksum of the data and return in hex format(64 bytes).
func SHA256HmacAsHex ¶
SHA256HmacAsHex Calculate the hmac of the data with given secret and return in hex format.
Types ¶
type AesGcm ¶
type AesGcm struct {
// contains filtered or unexported fields
}
func (AesGcm) Decrypt ¶
Decrypt decrypts data with symmetric key. NOTE: This method use nonce of 12 bytes and auth tag as aes block size(16 bytes) also expects IV as preamble of data.
func (AesGcm) DecryptWithTagSize ¶
DecryptWithTagSize decrypts data with symmetric key. NOTE: This method expects gcm standard nonce size(12) of iv.
func (AesGcm) Encrypt ¶
Encrypt encrypts data with symmetric key. NOTE: This method use nonce of 12 bytes and auth tag as aes block size(16 bytes).
func (AesGcm) EncryptWithIV ¶
EncryptWithIV encrypts data with symmetric key. NOTE: This method use default auth tag as aes block size(16 bytes) and expects iv of 16 bytes.
type AsymDecryption ¶
type AsymDecryption struct {
PrivateKey *rsa.PrivateKey
}
func NewAsymDecryption ¶
func NewAsymDecryption(privateKeyInPem string) (AsymDecryption, error)
NewAsymDecryption creates and returns a new AsymDecryption.
type AsymEncryption ¶
func NewAsymEncryption ¶
func NewAsymEncryption(publicKeyInPem string) (AsymEncryption, error)
NewAsymEncryption creates and returns a new AsymEncryption.
func (AsymEncryption) Encrypt ¶
func (asymEncryption AsymEncryption) Encrypt(data []byte) ([]byte, error)
Encrypt encrypts data with public key.
func (AsymEncryption) PublicKeyInPemFormat ¶
func (asymEncryption AsymEncryption) PublicKeyInPemFormat() (string, error)
PublicKeyInPemFormat Returns public key in pem format.
type ECKeyPair ¶
type ECKeyPair struct {
PrivateKey *ecdsa.PrivateKey
}
func NewECKeyPair ¶
NewECKeyPair Generates an EC key pair of the given bit size.
func (ECKeyPair) PrivateKeyInPemFormat ¶
PrivateKeyInPemFormat Returns private key in pem format.
func (ECKeyPair) PublicKeyInPemFormat ¶
PublicKeyInPemFormat Returns public key in pem format.
type RsaKeyPair ¶
type RsaKeyPair struct {
// contains filtered or unexported fields
}
func NewRSAKeyPair ¶
func NewRSAKeyPair(bits int) (RsaKeyPair, error)
NewRSAKeyPair Generates an RSA key pair of the given bit size.
func (RsaKeyPair) KeySize ¶
func (keyPair RsaKeyPair) KeySize() (int, error)
KeySize Return the size of this rsa key pair.
func (RsaKeyPair) PrivateKeyInPemFormat ¶
func (keyPair RsaKeyPair) PrivateKeyInPemFormat() (string, error)
PrivateKeyInPemFormat Returns private key in pem format.
func (RsaKeyPair) PublicKeyInPemFormat ¶
func (keyPair RsaKeyPair) PublicKeyInPemFormat() (string, error)
PublicKeyInPemFormat Returns public key in pem format.