mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-09-13 14:29:09 +00:00
allow empty Client for Registration
This commit is contained in:
parent
279d245d86
commit
3f4ed25a83
3 changed files with 39 additions and 16 deletions
|
@ -1,19 +1,34 @@
|
|||
package api
|
||||
|
||||
import "github.com/ProtonMail/gopenpgp/v2/helper"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ProtonMail/gopenpgp/v2/helper"
|
||||
)
|
||||
|
||||
// EncryptMessage encrypts a message using the users public key and then signes the message using the users private key
|
||||
func (c *Client) EncryptMessage(message string) (string, error) {
|
||||
if c.userPrivateKey == "" {
|
||||
return "", fmt.Errorf("Client has no Private Key")
|
||||
} else if c.userPublicKey == "" {
|
||||
return "", fmt.Errorf("Client has no Public Key")
|
||||
}
|
||||
return helper.EncryptSignMessageArmored(c.userPublicKey, c.userPrivateKey, c.userPassword, message)
|
||||
}
|
||||
|
||||
// EncryptMessageWithPublicKey encrypts a message using the provided public key and then signes the message using the users private key
|
||||
func (c *Client) EncryptMessageWithPublicKey(publickey, message string) (string, error) {
|
||||
if c.userPrivateKey == "" {
|
||||
return "", fmt.Errorf("Client has no Private Key")
|
||||
}
|
||||
return helper.EncryptSignMessageArmored(publickey, c.userPrivateKey, c.userPassword, message)
|
||||
}
|
||||
|
||||
// DecryptMessage decrypts a message using the users Private Key
|
||||
func (c *Client) DecryptMessage(message string) (string, error) {
|
||||
if c.userPrivateKey == "" {
|
||||
return "", fmt.Errorf("Client has no Private Key")
|
||||
}
|
||||
// We cant Verify the signature as we don't store other users public keys locally and don't know which user did encrypt it
|
||||
//return helper.DecryptVerifyMessageArmored(c.userPublicKey, c.userPrivateKey, c.userPassword, message)
|
||||
return helper.DecryptMessageArmored(c.userPrivateKey, c.userPassword, message)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue