Documentation
¶
Index ¶
- Constants
- type WzAES
- type WzCryptoBundle
- func (wcb *WzCryptoBundle) GetAES() *WzAES
- func (wcb *WzCryptoBundle) GetRSA() *WzRSA
- func (wcb *WzCryptoBundle) GetUtils() *WzCryptoUtils
- func (wcb *WzCryptoBundle) InitPkiDir(pkiDir string) (bool, bool)
- func (wcb *WzCryptoBundle) SignMessage(msg *wzlib_transport.WzGenericMessage) ([]byte, error)
- func (wcb *WzCryptoBundle) VerifyMessageSignature(keypem []byte, msg *wzlib_transport.WzGenericMessage) bool
- type WzCryptoUtils
- type WzRSA
- func (wk *WzRSA) Decrypt(cipher []byte) ([]byte, error)
- func (wk *WzRSA) Encrypt(msg []byte) ([]byte, error)
- func (wk *WzRSA) GenerateKeyPair(pkiDir string) error
- func (wk *WzRSA) GetPubFp() string
- func (wk *WzRSA) GetPublicPEMKey(pkiDir string) (pem []byte, err error)
- func (wk *WzRSA) LoadPEMKeyPair(pkiDir string) error
- func (wk *WzRSA) Sign(data []byte) ([]byte, error)
- func (wk *WzRSA) VerifyPem(pubkey []byte, data []byte, signature []byte) (bool, error)
Constants ¶
const ( RSA_PEM_PUBKEY = "public.pem" RSA_PEM_PRIVKEY = "private.pem" RSA_BIN_PUBKEY = "public.key" RSA_BIN_PRIVKEY = "private.key" )
const AES_TOKEN = "token.aes"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WzAES ¶
type WzAES struct {
// contains filtered or unexported fields
}
func (*WzAES) Decrypt ¶
Decrypt decrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Expects input form nonce|ciphertext|tag where '|' indicates concatenation.
func (*WzAES) Encrypt ¶
Encrypt encrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Output takes the form nonce|ciphertext|tag where '|' indicates concatenation.
func (*WzAES) GenerateKey ¶
GenerateKey generates a random 256-bit key
type WzCryptoBundle ¶
type WzCryptoBundle struct { wzlib_logger.WzLogger // contains filtered or unexported fields }
WzClientCrypto class for all RSA/AES operations
func NewWzCryptoBundle ¶
func NewWzCryptoBundle() *WzCryptoBundle
func (*WzCryptoBundle) GetUtils ¶
func (wcb *WzCryptoBundle) GetUtils() *WzCryptoUtils
GetUtils returns crypto utils
func (*WzCryptoBundle) InitPkiDir ¶
func (wcb *WzCryptoBundle) InitPkiDir(pkiDir string) (bool, bool)
InitPkiDir initialises the PKI directory with RSA keypair and AES token. Returns bool/bool, equivalent to rsa/aes accordingly.
func (*WzCryptoBundle) SignMessage ¶
func (wcb *WzCryptoBundle) SignMessage(msg *wzlib_transport.WzGenericMessage) ([]byte, error)
SignMessage signs all message content, return serialised byte array
func (*WzCryptoBundle) VerifyMessageSignature ¶
func (wcb *WzCryptoBundle) VerifyMessageSignature(keypem []byte, msg *wzlib_transport.WzGenericMessage) bool
VerifyMessageSignature from RSA PEM key
type WzCryptoUtils ¶
type WzCryptoUtils struct {
wzlib_logger.WzLogger
}
func NewWzCryptoUtils ¶
func NewWzCryptoUtils() *WzCryptoUtils
func (*WzCryptoUtils) PEMKeyFingerprintFromBytes ¶
func (wcu *WzCryptoUtils) PEMKeyFingerprintFromBytes(key []byte) string
PEMKeyFingerprintFromBytes reads PEM key from an array of bytes and returns SHA256 fingerprint.
func (*WzCryptoUtils) PEMKeyFingerprintFromFile ¶
func (wcu *WzCryptoUtils) PEMKeyFingerprintFromFile(keypath string) string
PEMKeyFingerprintFromFile reads PEM key from a file and returns SHA256 fingerprint
func (*WzCryptoUtils) PEMKeyFingerprintFromString ¶
func (wcu *WzCryptoUtils) PEMKeyFingerprintFromString(key string) string
PEMKeyFingerprintFromString reads PEM key from a string and returns SHA256 fingerprint
type WzRSA ¶
type WzRSA struct {
// contains filtered or unexported fields
}
func NewWzRSA ¶
func NewWzRSA() *WzRSA
NewWzRSA creates an instance of a class that takes care of keypair management operations (generation, rotation, encrytion etc).
func (*WzRSA) GenerateKeyPair ¶
GenerateKeyPair generates all public and private keys in PEM and Gob formats.
func (*WzRSA) GetPublicPEMKey ¶
Read PEM version of the public RSA key and return it as an array of bytes
func (*WzRSA) LoadPEMKeyPair ¶
LoadPEMKeyPair loads previously generated pub/priv keys