Documentation ¶
Index ¶
- func DecodeEcdsaPrivateKeyFromPem(pemEncodedPrivKey []byte) (*ecdsa.PrivateKey, error)
- func DecryptUsingSymmKey(encryptedMsg, privKey []byte) ([]byte, error)
- func EncodeEcdsaPrivateKeyToPem(privateKey *ecdsa.PrivateKey) ([]byte, []byte, error)
- func EncryptUsingSymmKey(msg, privKey []byte) ([]byte, error)
- func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string
- func ExportRsaPrivateKeyToFile(fileName string, key *rsa.PrivateKey) error
- func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) string
- func ExportRsaPublicKeyToFile(fileName string, key *rsa.PublicKey) error
- func GenerateEcdsaKeyPair() (*ecdsa.PrivateKey, error)
- func GenerateRsaKeyPair(bits int) (*rsa.PrivateKey, error)
- func GetHash(msg []byte) []byte
- func HMAC(message, key []byte, hashFunc func() hash.Hash) []byte
- func ParseRsaPrivateKeyFromFile(fileName string) (*rsa.PrivateKey, error)
- func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error)
- func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error)
- func Sign(msg []byte, key *rsa.PrivateKey) (signature []byte, err error)
- func SignEcdsa(msg []byte, key *ecdsa.PrivateKey) ([]byte, error)
- func ValidMAC(message, key, messageMAC []byte, hashFunc func() hash.Hash) bool
- func Verify(msg []byte, sig []byte, pk *rsa.PublicKey) error
- func VerifyEcdsa(msg []byte, sig []byte, pk *ecdsa.PublicKey) bool
- type KeyStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeEcdsaPrivateKeyFromPem ¶
func DecodeEcdsaPrivateKeyFromPem(pemEncodedPrivKey []byte) (*ecdsa.PrivateKey, error)
DecodeEcdsaPrivateKeyFromPem decodes pem private key
func DecryptUsingSymmKey ¶
DecryptUsingSymmKey Decrypts data using ChaCha2020 TODO: Give option to change encryption algo
func EncodeEcdsaPrivateKeyToPem ¶
func EncodeEcdsaPrivateKeyToPem(privateKey *ecdsa.PrivateKey) ([]byte, []byte, error)
EncodeEcdsaPrivateKeyToPem encodes ecdsa private key to pem format
func EncryptUsingSymmKey ¶
EncryptUsingSymmKey Enrypts data using ChaCha2020 TODO: Give option to change encryption algo
func ExportRsaPrivateKeyAsPemStr ¶
func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string
ExportRsaPrivateKeyAsPemStr exports the rsa priv key in pem format
func ExportRsaPrivateKeyToFile ¶
func ExportRsaPrivateKeyToFile(fileName string, key *rsa.PrivateKey) error
ExportRsaPrivateKeyToFile exports the rsa priv key to a file
func ExportRsaPublicKeyAsPemStr ¶
ExportRsaPublicKeyAsPemStr exports the rsa pub key in pem format
func ExportRsaPublicKeyToFile ¶
ExportRsaPublicKeyToFile exports the rsa pub key to a file
func GenerateEcdsaKeyPair ¶
func GenerateEcdsaKeyPair() (*ecdsa.PrivateKey, error)
GenerateEcdsaKeyPair generates a pub/priv ecdsa key pair
func GenerateRsaKeyPair ¶
func GenerateRsaKeyPair(bits int) (*rsa.PrivateKey, error)
GenerateRsaKeyPair generates a pub/priv rsa key pair
func ParseRsaPrivateKeyFromFile ¶
func ParseRsaPrivateKeyFromFile(fileName string) (*rsa.PrivateKey, error)
ParseRsaPrivateKeyFromFile parses the priv key from the given file
func ParseRsaPrivateKeyFromPemStr ¶
func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error)
ParseRsaPrivateKeyFromPemStr parses the private key from the given pem string
func ParseRsaPublicKeyFromPemStr ¶
ParseRsaPublicKeyFromPemStr parses the pub key from the given pem string
func Sign ¶
func Sign(msg []byte, key *rsa.PrivateKey) (signature []byte, err error)
Sign returns a signature made by combining the message and the signers private key
func SignEcdsa ¶
func SignEcdsa(msg []byte, key *ecdsa.PrivateKey) ([]byte, error)
SignEcdsa returns a signature made by combining the message and the signers private key using ecdsa
Types ¶
type KeyStore ¶
type KeyStore struct {
// contains filtered or unexported fields
}
KeyStore is a as the name says a keystore which stores multiple privatekeys
func (*KeyStore) AddKeyFromFile ¶
AddKeyFromFile Adds a private rsa key to the keystore from the file