review3 renames
This commit is contained in:
24
asymcrypt.go
24
asymcrypt.go
@ -37,8 +37,8 @@ func NewKeyPair() KeyPair {
|
||||
return kp
|
||||
}
|
||||
|
||||
func (keyPair *KeyPair) GetCryptoKeyObject() *crypto.Key {
|
||||
priv, err := base64.StdEncoding.DecodeString(keyPair.Private)
|
||||
func (Kp *KeyPair) GetCryptoKeyObject() *crypto.Key {
|
||||
priv, err := base64.StdEncoding.DecodeString(Kp.Private)
|
||||
if err != nil {
|
||||
log.Error().Msg("Create key from armoured b64 failed")
|
||||
}
|
||||
@ -49,8 +49,8 @@ func (keyPair *KeyPair) GetCryptoKeyObject() *crypto.Key {
|
||||
return key
|
||||
}
|
||||
|
||||
func Encrypt(publicKey string, data []byte) ([]byte, error) {
|
||||
pub, err := base64.StdEncoding.DecodeString(publicKey)
|
||||
func Encrypt(PublicKey string, data []byte) ([]byte, error) {
|
||||
pub, err := base64.StdEncoding.DecodeString(PublicKey)
|
||||
if err != nil {
|
||||
log.Error().Msg("Message encryption b64 failed")
|
||||
}
|
||||
@ -61,8 +61,8 @@ func Encrypt(publicKey string, data []byte) ([]byte, error) {
|
||||
return []byte(armor), err
|
||||
}
|
||||
|
||||
func Decrypt(privateKey string, data []byte) ([]byte, error) {
|
||||
priv, err := base64.StdEncoding.DecodeString(privateKey)
|
||||
func Decrypt(PrivateKey string, data []byte) ([]byte, error) {
|
||||
priv, err := base64.StdEncoding.DecodeString(PrivateKey)
|
||||
if err != nil {
|
||||
log.Error().Msg("Message decryption b64 failed")
|
||||
}
|
||||
@ -73,12 +73,12 @@ func Decrypt(privateKey string, data []byte) ([]byte, error) {
|
||||
return []byte(decrypted), err
|
||||
}
|
||||
|
||||
func EncryptAndSign(publicEncKey string, privateSignKey string, data []byte) ([]byte, []byte, error) {
|
||||
pub, err := base64.StdEncoding.DecodeString(publicEncKey)
|
||||
func EncryptAndSign(PublicEncryptionKey string, PrivateSignatureKey string, data []byte) ([]byte, []byte, error) {
|
||||
pub, err := base64.StdEncoding.DecodeString(PublicEncryptionKey)
|
||||
if err != nil {
|
||||
log.Error().Msg("Message encryption and sign b64 failed")
|
||||
}
|
||||
priv, err := base64.StdEncoding.DecodeString(privateSignKey)
|
||||
priv, err := base64.StdEncoding.DecodeString(PrivateSignatureKey)
|
||||
if err != nil {
|
||||
log.Error().Msg("Message encryption and sign b64 failed")
|
||||
}
|
||||
@ -89,16 +89,16 @@ func EncryptAndSign(publicEncKey string, privateSignKey string, data []byte) ([]
|
||||
return []byte(encrypted), []byte(signature), err
|
||||
}
|
||||
|
||||
func DecryptAndCheck(MyPrivateEncryptionKey string, peerContactPublicKey string, data []byte, signature []byte) (DecryptedMessage []byte, err error) {
|
||||
func DecryptAndCheck(MyPrivateEncryptionKey string, MyContactPublicKey string, data []byte, Signature []byte) (DecryptedMessage []byte, err error) {
|
||||
pub, err := base64.StdEncoding.DecodeString(MyPrivateEncryptionKey)
|
||||
if err != nil {
|
||||
log.Error().Msg("Message decryption and sign b64 failed")
|
||||
}
|
||||
priv, err := base64.StdEncoding.DecodeString(peerContactPublicKey)
|
||||
priv, err := base64.StdEncoding.DecodeString(MyContactPublicKey)
|
||||
if err != nil {
|
||||
log.Error().Msg("Message decryption and sign b64 failed")
|
||||
}
|
||||
DecryptedMessage, err = helper.DecryptVerifyBinaryDetached(string(pub), string(priv), nil, data, string(signature))
|
||||
DecryptedMessage, err = helper.DecryptVerifyBinaryDetached(string(pub), string(priv), nil, data, string(Signature))
|
||||
if err != nil {
|
||||
log.Error().Msg("Message decryption and sign failed")
|
||||
}
|
||||
|
Reference in New Issue
Block a user