diff --git a/helper/helper.go b/helper/helper.go index da13d7d..016bc33 100644 --- a/helper/helper.go +++ b/helper/helper.go @@ -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. diff --git a/helper/sign_attachment.go b/helper/sign_detached.go similarity index 71% rename from helper/sign_attachment.go rename to helper/sign_detached.go index 6b66e38..216ebe2 100644 --- a/helper/sign_attachment.go +++ b/helper/sign_detached.go @@ -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 +}