Other: Fix wrong encoding used for public key during sending

The newer liteapi contact code saves keys as *crypto.Key, however the
legacy code expects them to be strings. There was a bug in connecting
the new code to the legacy code: it was assumed these strings were meant
to be a base64 encoded string but they were actually just raw string
bytes.
This commit is contained in:
James Houlahan
2022-10-31 15:49:57 +01:00
parent 88ad98ed37
commit 075e1ef236
3 changed files with 6 additions and 15 deletions

View File

@ -18,7 +18,6 @@
package user
import (
"encoding/base64"
"fmt"
"github.com/ProtonMail/gluon/rfc822"
@ -62,23 +61,15 @@ func newContactSettings(settings liteapi.ContactSettings) *contactSettings {
}
if settings.Scheme != nil {
switch *settings.Scheme {
switch *settings.Scheme { // nolint:exhaustive
case liteapi.PGPMIMEScheme:
metadata.Scheme = pgpMIME
case liteapi.PGPInlineScheme:
metadata.Scheme = pgpInline
case liteapi.InternalScheme:
fallthrough
case liteapi.EncryptedOutsideScheme:
fallthrough
case liteapi.ClearScheme:
fallthrough
case liteapi.ClearMIMEScheme:
fallthrough
default:
break
panic("unknown scheme")
}
}
@ -89,7 +80,7 @@ func newContactSettings(settings liteapi.ContactSettings) *contactSettings {
panic(err)
}
metadata.Keys = append(metadata.Keys, base64.StdEncoding.EncodeToString(b))
metadata.Keys = append(metadata.Keys, string(b))
}
}