Fix gomobile compilation ssues (#81)
Co-authored-by: marin thiercelin <marin.thiercelin@pm.me>
This commit is contained in:
parent
16024c21ec
commit
2b8d58d357
3 changed files with 24 additions and 14 deletions
|
|
@ -184,6 +184,28 @@ func DecryptBinaryMessageArmored(privateKey string, passphrase []byte, ciphertex
|
||||||
return message.GetBinary(), nil
|
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
|
// DecryptVerifyArmoredDetached decrypts an armored pgp message
|
||||||
// and verify a detached armored signature
|
// and verify a detached armored signature
|
||||||
// given a publicKey, and a privateKey with its passphrase.
|
// given a publicKey, and a privateKey with its passphrase.
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ func EncryptSignArmoredDetachedMobile(
|
||||||
publicKey, privateKey string,
|
publicKey, privateKey string,
|
||||||
passphrase, plainData []byte,
|
passphrase, plainData []byte,
|
||||||
) (wrappedTuple *EncryptSignArmoredDetachedMobileResult, err error) {
|
) (wrappedTuple *EncryptSignArmoredDetachedMobileResult, err error) {
|
||||||
ciphertext, signature, err := EncryptSignArmoredDetached(publicKey, privateKey, passphrase, plainData)
|
ciphertext, signature, err := encryptSignArmoredDetached(publicKey, privateKey, passphrase, plainData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,17 +63,5 @@ func EncryptSignArmoredDetached(
|
||||||
publicKey, privateKey string,
|
publicKey, privateKey string,
|
||||||
passphrase, plainData []byte,
|
passphrase, plainData []byte,
|
||||||
) (ciphertext, signature string, err error) {
|
) (ciphertext, signature string, err error) {
|
||||||
var message *crypto.PlainMessage = crypto.NewPlainMessage(plainData)
|
return encryptSignArmoredDetached(publicKey, privateKey, passphrase, 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
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue