protonmail: Key -> PrivateKey
This commit is contained in:
parent
c6b479b01a
commit
70186f326f
|
@ -6,6 +6,23 @@ type (
|
|||
AddressType int
|
||||
)
|
||||
|
||||
const (
|
||||
AddressSendDisabled AddressSend = iota
|
||||
AddressSendPrimary
|
||||
AddressSendSecondary
|
||||
)
|
||||
|
||||
const (
|
||||
AddressDisabled AddressStatus = iota
|
||||
AddressEnabled
|
||||
)
|
||||
|
||||
const (
|
||||
AddressOriginal AddressType = iota
|
||||
AddressAlias
|
||||
AddressCustom
|
||||
)
|
||||
|
||||
type Address struct {
|
||||
ID string
|
||||
DomainID string
|
||||
|
@ -17,5 +34,5 @@ type Address struct {
|
|||
DisplayName string
|
||||
Signature string // HTML
|
||||
HasKeys int
|
||||
Keys []*Key
|
||||
Keys []*PrivateKey
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"golang.org/x/crypto/openpgp"
|
||||
)
|
||||
|
||||
type Key struct {
|
||||
type PrivateKey struct {
|
||||
ID string
|
||||
Version int
|
||||
PublicKey string
|
||||
|
@ -18,6 +18,17 @@ type Key struct {
|
|||
Activation interface{} // TODO
|
||||
}
|
||||
|
||||
func (priv *PrivateKey) Entity() (*openpgp.Entity, error) {
|
||||
keyRing, err := openpgp.ReadArmoredKeyRing(strings.NewReader(priv.PrivateKey))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(keyRing) == 0 {
|
||||
return nil, errors.New("private key is empty")
|
||||
}
|
||||
return keyRing[0], nil
|
||||
}
|
||||
|
||||
type RecipientType int
|
||||
|
||||
const (
|
||||
|
|
|
@ -196,6 +196,15 @@ type MessageKeyPacket struct {
|
|||
|
||||
type MessagePackageType int
|
||||
|
||||
const (
|
||||
MessagePackageInternal MessagePackageType = 1
|
||||
MessagePackageEncryptedOutside = 2
|
||||
MessagePackageClear = 4
|
||||
MessagePackageInlinePGP = 8
|
||||
MessagePackagePGPMIME = 16
|
||||
MessagePackageMIME = 32
|
||||
)
|
||||
|
||||
type MessagePackage struct {
|
||||
Address string
|
||||
Type MessagePackageType
|
||||
|
@ -210,10 +219,14 @@ type MessagePackage struct {
|
|||
type MessageOutgoing struct {
|
||||
ID string
|
||||
|
||||
// Only if there's a recipient without a public key
|
||||
ClearBody string
|
||||
ExpirationTime int64
|
||||
AttachmentKeys []*AttachmentKey
|
||||
Packages []*MessagePackage
|
||||
|
||||
// Only if message expires
|
||||
ExpirationTime int // duration in seconds
|
||||
|
||||
Packages []*MessagePackage
|
||||
}
|
||||
|
||||
func (c *Client) SendMessage(msg *MessageOutgoing) (sent, parent *Message, err error) {
|
||||
|
|
|
@ -61,7 +61,7 @@ type User struct {
|
|||
VPN interface{} // TODO
|
||||
Delinquent int
|
||||
Addresses []*Address
|
||||
Keys []*Key
|
||||
Keys []*PrivateKey
|
||||
}
|
||||
|
||||
func (c *Client) GetCurrentUser() (*User, error) {
|
||||
|
|
Loading…
Reference in New Issue