Documentation ¶
Index ¶
- Constants
- func Base64Decode(data []byte) ([]byte, error)
- func Base64Encode(data []byte) []byte
- func CalculateHKDF(salt []byte, secret []byte) ([]byte, error)
- func CalculateSHA256(data []byte) []byte
- func CalculateSHA256Hmac(secret, data []byte) []byte
- func CompressedECPublicKey(mode ECCMode, pubKey ecdsa.PublicKey) ([]byte, error)
- func ComputeECDHKey(privateKeyInPem []byte, publicKeyInPem []byte) ([]byte, error)
- func ComputeECDHKeyFromEC(publicKey *ecdsa.PublicKey, privateKey *ecdsa.PrivateKey) ([]byte, error)
- func ComputeECDHKeyFromECDHKeys(publicKey *ecdh.PublicKey, privateKey *ecdh.PrivateKey) ([]byte, error)
- func ComputeECDSASig(digest []byte, privKey *ecdsa.PrivateKey) ([]byte, []byte, error)
- func ConvertToECDHPrivateKey(key interface{}) (*ecdh.PrivateKey, error)
- func ConvertToECDHPublicKey(key interface{}) (*ecdh.PublicKey, error)
- func ECPrivateKeyFromPem(privateECKeyInPem []byte) (*ecdh.PrivateKey, error)
- func ECPrivateKeyInPemFormat(privateKey ecdsa.PrivateKey) (string, error)
- func ECPubKeyFromPem(pemECPubKey []byte) (*ecdh.PublicKey, error)
- func ECPublicKeyInPemFormat(publicKey ecdsa.PublicKey) (string, error)
- func GetECCurveFromECCMode(mode ECCMode) (elliptic.Curve, error)
- func RandomBytes(size int) ([]byte, error)
- func SHA256AsHex(data []byte) []byte
- func SHA256HmacAsHex(secret, data []byte) []byte
- func UncompressECPubKey(curve elliptic.Curve, compressedPubKey []byte) (*ecdsa.PublicKey, error)
- func VerifyECDSASig(digest, r, s []byte, pubKey *ecdsa.PublicKey) bool
- type AesGcm
- func (aesGcm AesGcm) Decrypt(data []byte) ([]byte, error)
- func (aesGcm AesGcm) DecryptWithIVAndTagSize(iv, data []byte, authTagSize int) ([]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 CalculateHKDF ¶ added in v0.1.1
CalculateHKDF generate a key using key derivation function.
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 CompressedECPublicKey ¶ added in v0.1.4
CompressedECPublicKey - return a compressed key from the supplied curve and public key
func ComputeECDHKey ¶ added in v0.1.1
ComputeECDHKey calculate shared secret from public key from one party and the private key from another party.
func ComputeECDHKeyFromEC ¶ added in v0.1.4
func ComputeECDHKeyFromECDHKeys ¶ added in v0.1.4
func ComputeECDSASig ¶ added in v0.1.4
ComputeECDSASig compute ecdsa signature
func ConvertToECDHPrivateKey ¶ added in v0.1.1
func ConvertToECDHPrivateKey(key interface{}) (*ecdh.PrivateKey, error)
ConvertToECDHPrivateKey convert the ec private key to ECDH private key
func ConvertToECDHPublicKey ¶ added in v0.1.1
ConvertToECDHPublicKey convert the ec public key to ECDH public key
func ECPrivateKeyFromPem ¶ added in v0.1.1
func ECPrivateKeyFromPem(privateECKeyInPem []byte) (*ecdh.PrivateKey, error)
ECPrivateKeyFromPem generate ec private from pem format
func ECPrivateKeyInPemFormat ¶ added in v0.1.4
func ECPrivateKeyInPemFormat(privateKey ecdsa.PrivateKey) (string, error)
ECPrivateKeyInPemFormat Returns private key in pem format.
func ECPubKeyFromPem ¶ added in v0.1.1
ECPubKeyFromPem generate ec public from pem format
func ECPublicKeyInPemFormat ¶ added in v0.1.4
ECPublicKeyInPemFormat Returns public key in pem format.
func GetECCurveFromECCMode ¶ added in v0.1.5
GetECCurveFromECCMode return elliptic curve from ecc mode
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.
func UncompressECPubKey ¶ added in v0.1.5
UncompressECPubKey create EC public key from compressed form
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) DecryptWithIVAndTagSize ¶ added in v0.1.4
DecryptWithIVAndTagSize decrypts data with symmetric key. NOTE: This method expects gcm standard nonce size(12) of iv.
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 FromRSA ¶ added in v0.1.4
func FromRSA(k *rsa.PrivateKey) RsaKeyPair
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.