protonmail: add cipherFunctionString
This commit is contained in:
parent
6f5f315be9
commit
905b9e170b
|
@ -35,7 +35,7 @@ type Address struct {
|
||||||
Receive int
|
Receive int
|
||||||
Status AddressStatus
|
Status AddressStatus
|
||||||
Type AddressType
|
Type AddressType
|
||||||
Order int
|
Order int64
|
||||||
DisplayName string
|
DisplayName string
|
||||||
Signature string // HTML
|
Signature string // HTML
|
||||||
HasKeys int
|
HasKeys int
|
||||||
|
|
|
@ -491,6 +491,19 @@ func (set *MessagePackageSet) Encrypt(mimeType string, signed *openpgp.Entity) (
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cipherFunctionString(cipherFunc packet.CipherFunction) string {
|
||||||
|
switch cipherFunc {
|
||||||
|
case packet.CipherAES128:
|
||||||
|
return "aes128"
|
||||||
|
case packet.CipherAES192:
|
||||||
|
return "aes192"
|
||||||
|
case packet.CipherAES256:
|
||||||
|
return "aes256"
|
||||||
|
default:
|
||||||
|
panic("protonmail: unsupported cipher function")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (set *MessagePackageSet) AddCleartext(addr string) (*MessagePackage, error) {
|
func (set *MessagePackageSet) AddCleartext(addr string) (*MessagePackage, error) {
|
||||||
pkg := &MessagePackage{
|
pkg := &MessagePackage{
|
||||||
Type: MessagePackageCleartext,
|
Type: MessagePackageCleartext,
|
||||||
|
@ -501,7 +514,7 @@ func (set *MessagePackageSet) AddCleartext(addr string) (*MessagePackage, error)
|
||||||
|
|
||||||
if set.BodyKey == nil || set.AttachmentKeys == nil {
|
if set.BodyKey == nil || set.AttachmentKeys == nil {
|
||||||
set.BodyKey = &MessageBodyKey{
|
set.BodyKey = &MessageBodyKey{
|
||||||
Algorithm: "aes256",
|
Algorithm: cipherFunctionString(set.bodyKey.CipherFunc),
|
||||||
Key: base64.StdEncoding.EncodeToString(set.bodyKey.Key),
|
Key: base64.StdEncoding.EncodeToString(set.bodyKey.Key),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue