Move encrypt detached helper to avoid building on mobile (#79)

This commit is contained in:
wussler 2020-09-14 09:19:33 +02:00 committed by GitHub
parent 55c4bd994d
commit 16024c21ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 22 deletions

View file

@ -184,28 +184,6 @@ func DecryptBinaryMessageArmored(privateKey string, passphrase []byte, ciphertex
return message.GetBinary(), nil
}
// EncryptSignArmoredDetached takes a public key for encryption,
// a private key and its passphrase for signature, and the plaintext data
// Returns an armored ciphertext and a detached armored signature.
func EncryptSignArmoredDetached(
publicKey, privateKey string,
passphrase, plainData []byte,
) (ciphertext, signature string, err error) {
var message *crypto.PlainMessage = crypto.NewPlainMessage(plainData)
// We encrypt the message
if ciphertext, err = encryptMessageArmored(publicKey, message); err != nil {
return "", "", err
}
// We sign the message
if signature, err = signDetachedArmored(privateKey, passphrase, message); err != nil {
return "", "", err
}
return ciphertext, signature, nil
}
// DecryptVerifyArmoredDetached decrypts an armored pgp message
// and verify a detached armored signature
// given a publicKey, and a privateKey with its passphrase.

View file

@ -55,3 +55,25 @@ func EncryptSignAttachment(
return packets.GetBinaryKeyPacket(), packets.GetBinaryDataPacket(), signatureObj.GetBinary(), nil
}
// EncryptSignArmoredDetached takes a public key for encryption,
// a private key and its passphrase for signature, and the plaintext data
// Returns an armored ciphertext and a detached armored signature.
func EncryptSignArmoredDetached(
publicKey, privateKey string,
passphrase, plainData []byte,
) (ciphertext, signature string, err error) {
var message *crypto.PlainMessage = crypto.NewPlainMessage(plainData)
// We encrypt the message
if ciphertext, err = encryptMessageArmored(publicKey, message); err != nil {
return "", "", err
}
// We sign the message
if signature, err = signDetachedArmored(privateKey, passphrase, message); err != nil {
return "", "", err
}
return ciphertext, signature, nil
}