Documentation ¶
Index ¶
- func CreateRSAKeyPair(password []byte) (string, string, error)
- func CreateVPNKeyPair(vpnType string) (string, string, error)
- func KeyFromPassphrase(passphrase string, seed int64) []byte
- func RandomKey(len int) ([]byte, error)
- func ReseedKey(key []byte, origSeed, newSeed int64) []byte
- type Crypt
- func (c *Crypt) Decrypt(cipherData []byte) ([]byte, error)
- func (c *Crypt) DecryptB64(cipherDataB64 string) (string, error)
- func (c *Crypt) DecryptB64Raw(cipherDataB64 string) ([]byte, error)
- func (c *Crypt) Encrypt(plainData []byte) ([]byte, error)
- func (c *Crypt) EncryptB64(plainData string) (string, error)
- func (c *Crypt) EncryptB64Raw(plainData []byte) (string, error)
- type ECDHKey
- type RSAKey
- func (k *RSAKey) Decrypt(ciphertext []byte) ([]byte, error)
- func (k *RSAKey) DecryptBase64(ciphertext string) ([]byte, error)
- func (k *RSAKey) DecryptUnpack(cipherData []byte) ([]byte, error)
- func (k *RSAKey) EncryptPack(data []byte) ([]byte, error)
- func (k *RSAKey) GetEncryptedPrivateKeyPEM(password []byte) (string, error)
- func (k *RSAKey) GetPrivateKeyPEM() (string, error)
- func (k *RSAKey) GetPublicKeyPEM() (string, error)
- func (k *RSAKey) PublicKey() *RSAPublicKey
- type RSAPublicKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateRSAKeyPair ¶
creates a private key, public key pem encoded pair
func CreateVPNKeyPair ¶
creates a key pair for the given vpn type
func KeyFromPassphrase ¶
in: passphrase - pass phrase to use to create the key in: seed - a seed value used to scramble the returned key hash out: a 32 byte key hash of the passphrase
Types ¶
type ECDHKey ¶
type ECDHKey struct {
// contains filtered or unexported fields
}
func (*ECDHKey) PublicKeyForNodeJS ¶
retrieves base64 encoded public key that can be used by nodejs crypto library
func (*ECDHKey) SharedSecret ¶
retrieves a shared secret with another ECDH key using that key's public key
type RSAKey ¶
type RSAKey struct {
// contains filtered or unexported fields
}
func NewRSAKeyFromFile ¶
func NewRSAKeyFromPEM ¶
creates a new RSA key from PEM encoded data
func (*RSAKey) DecryptBase64 ¶
decrypts a base64 encoded encrypted string
func (*RSAKey) DecryptUnpack ¶
decrypts and unpacks a payload encrypted using the above algorithm
func (*RSAKey) EncryptPack ¶
compresses and encrypts the given data payload with AES, encrypts and prepends the 256 bit AES key to the encrypted result using the RSA key
func (*RSAKey) GetEncryptedPrivateKeyPEM ¶
returns the PEM encoded private key
func (*RSAKey) GetPrivateKeyPEM ¶
returns the PEM encoded private key
func (*RSAKey) GetPublicKeyPEM ¶
returns the PEM encoded public key
func (*RSAKey) PublicKey ¶
func (k *RSAKey) PublicKey() *RSAPublicKey
returns the encapsulated public key
type RSAPublicKey ¶
type RSAPublicKey struct { // a key id used to identify the private key // required to decrypt ciphertext encrypted // using this public key. KeyID string // contains filtered or unexported fields }
func NewPublicKeyFromFile ¶
func NewPublicKeyFromFile(pemFilePath string) (*RSAPublicKey, error)
func NewPublicKeyFromPEM ¶
func NewPublicKeyFromPEM(publicKeyPEM string) (*RSAPublicKey, error)
creates a new RSA key from PEM encoded data
func (*RSAPublicKey) Encrypt ¶
func (k *RSAPublicKey) Encrypt(plaintext []byte) ([]byte, error)
encrypts plain text using an RSA public key
func (*RSAPublicKey) EncryptBase64 ¶
func (k *RSAPublicKey) EncryptBase64(plaintext []byte) (string, error)
encrypt plain text and return the cipher text as base64 encoded text