to server encryption
This commit is contained in:
parent
0becc091a1
commit
86f222a7df
4
peer.go
4
peer.go
@ -139,7 +139,7 @@ func ReadQr(fielname string) ContactCard {
|
|||||||
return contact
|
return contact
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Peer) CreateMessage(Message []byte) (lookupK string, EncryptedMsg []byte, Signature []byte, Servers []Server, err error) {
|
func (p *Peer) AsymEncryptMessage(Message []byte) (lookupK string, EncryptedMsg []byte, Signature []byte, Servers []Server, err error) {
|
||||||
// prepares a message to send to a specific peer contact
|
// prepares a message to send to a specific peer contact
|
||||||
EncryptedMsg, Signature, err = EncryptAndSign(p.Contact.EncryptionPublicKey, p.Me.Private, Message)
|
EncryptedMsg, Signature, err = EncryptAndSign(p.Contact.EncryptionPublicKey, p.Me.Private, Message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -149,7 +149,7 @@ func (p *Peer) CreateMessage(Message []byte) (lookupK string, EncryptedMsg []byt
|
|||||||
return p.LookupKp.Public, EncryptedMsg, Signature, p.Contact.PullServers, err
|
return p.LookupKp.Public, EncryptedMsg, Signature, p.Contact.PullServers, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Peer) ReadMessage(Message []byte, Signature []byte) (DecryptedMsg []byte, err error) {
|
func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMsg []byte, err error) {
|
||||||
// reads a message from a specific peer contact
|
// reads a message from a specific peer contact
|
||||||
DecryptedMsg, err = DecryptAndCheck(p.Me.Private, p.Contact.ContactPublicKey, Message, Signature)
|
DecryptedMsg, err = DecryptAndCheck(p.Me.Private, p.Contact.ContactPublicKey, Message, Signature)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
25
server.go
25
server.go
@ -1,6 +1,9 @@
|
|||||||
package meowlib
|
package meowlib
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type InternalServer struct {
|
type InternalServer struct {
|
||||||
ServerData Server `json:"server_data,omitempty"`
|
ServerData Server `json:"server_data,omitempty"`
|
||||||
@ -28,3 +31,23 @@ func (sl *ServerList) AddUrls(urls []string) {
|
|||||||
sl.Servers = append(sl.Servers, *ServerFromUrl(url))
|
sl.Servers = append(sl.Servers, *ServerFromUrl(url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ints *InternalServer) AsymEncryptMessage(Message []byte) (EncryptedMsg []byte, Signature []byte, err error) {
|
||||||
|
// prepares a message to send to a specific internal server
|
||||||
|
EncryptedMsg, Signature, err = EncryptAndSign(ints.ServerData.PublicKey, ints.Me.Private, Message)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
return EncryptedMsg, Signature, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ints *InternalServer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMsg []byte, err error) {
|
||||||
|
// reads a message from a specific internal server
|
||||||
|
DecryptedMsg, err = DecryptAndCheck(ints.Me.Private, ints.ServerData.PublicKey, Message, Signature)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return DecryptedMsg, err
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user