|
|
@ -19,9 +19,7 @@ import (
|
|
|
|
"github.com/mattn/go-xmpp" // BSD-3-Clause
|
|
|
|
"github.com/mattn/go-xmpp" // BSD-3-Clause
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func oxDeleteNodes(jid string, client *xmpp.Client,
|
|
|
|
func oxDeleteNodes(jid string, client *xmpp.Client, iqc chan xmpp.IQ) error {
|
|
|
|
iqc chan xmpp.IQ,
|
|
|
|
|
|
|
|
) error {
|
|
|
|
|
|
|
|
nodeListRequest := etree.NewDocument()
|
|
|
|
nodeListRequest := etree.NewDocument()
|
|
|
|
nodeListRequest.WriteSettings.AttrSingleQuote = true
|
|
|
|
nodeListRequest.WriteSettings.AttrSingleQuote = true
|
|
|
|
query := nodeListRequest.CreateElement("query")
|
|
|
|
query := nodeListRequest.CreateElement("query")
|
|
|
@ -73,9 +71,7 @@ func oxDeleteNodes(jid string, client *xmpp.Client,
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func oxDecrypt(m xmpp.Chat, client *xmpp.Client, iqc chan xmpp.IQ,
|
|
|
|
func oxDecrypt(m xmpp.Chat, client *xmpp.Client, iqc chan xmpp.IQ, user string, oxPrivKey *crypto.Key) (string, time.Time, error) {
|
|
|
|
user string, oxPrivKey *crypto.Key,
|
|
|
|
|
|
|
|
) (string, time.Time, error) {
|
|
|
|
|
|
|
|
var cryptMsgByte []byte
|
|
|
|
var cryptMsgByte []byte
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
sender := strings.Split(m.Remote, "/")[0]
|
|
|
|
sender := strings.Split(m.Remote, "/")[0]
|
|
|
@ -155,9 +151,7 @@ func isOxMsg(m xmpp.Chat) bool {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func oxImportPrivKey(jid string, privKeyLocation string, client *xmpp.Client,
|
|
|
|
func oxImportPrivKey(jid string, privKeyLocation string, client *xmpp.Client, iqc chan xmpp.IQ) error {
|
|
|
|
iqc chan xmpp.IQ,
|
|
|
|
|
|
|
|
) error {
|
|
|
|
|
|
|
|
xmppURI := "xmpp:" + jid
|
|
|
|
xmppURI := "xmpp:" + jid
|
|
|
|
buffer, err := readFile(privKeyLocation)
|
|
|
|
buffer, err := readFile(privKeyLocation)
|
|
|
|
if errors.Unwrap(err) != nil {
|
|
|
|
if errors.Unwrap(err) != nil {
|
|
|
@ -226,9 +220,7 @@ func oxImportPrivKey(jid string, privKeyLocation string, client *xmpp.Client,
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func oxPublishPubKey(jid string, client *xmpp.Client, iqc chan xmpp.IQ,
|
|
|
|
func oxPublishPubKey(jid string, client *xmpp.Client, iqc chan xmpp.IQ, pubKey *crypto.Key) error {
|
|
|
|
pubKey *crypto.Key,
|
|
|
|
|
|
|
|
) error {
|
|
|
|
|
|
|
|
keyCreated := time.Now().UTC().Format("2006-01-02T15:04:05Z")
|
|
|
|
keyCreated := time.Now().UTC().Format("2006-01-02T15:04:05Z")
|
|
|
|
fingerprint := strings.ToUpper(pubKey.GetFingerprint())
|
|
|
|
fingerprint := strings.ToUpper(pubKey.GetFingerprint())
|
|
|
|
keySerialized, err := pubKey.Serialize()
|
|
|
|
keySerialized, err := pubKey.Serialize()
|
|
|
@ -490,9 +482,7 @@ func oxGenPrivKey(jid string, client *xmpp.Client, iqc chan xmpp.IQ,
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func oxRecvPublicKeys(client *xmpp.Client, iqc chan xmpp.IQ, recipient string,
|
|
|
|
func oxRecvPublicKeys(client *xmpp.Client, iqc chan xmpp.IQ, recipient string, fingerprint string) (*crypto.KeyRing, error) {
|
|
|
|
fingerprint string,
|
|
|
|
|
|
|
|
) (*crypto.KeyRing, error) {
|
|
|
|
|
|
|
|
opkr := etree.NewDocument()
|
|
|
|
opkr := etree.NewDocument()
|
|
|
|
opkr.WriteSettings.AttrSingleQuote = true
|
|
|
|
opkr.WriteSettings.AttrSingleQuote = true
|
|
|
|
opkrPs := opkr.CreateElement("pubsub")
|
|
|
|
opkrPs := opkr.CreateElement("pubsub")
|
|
|
@ -561,9 +551,7 @@ func oxRecvPublicKeys(client *xmpp.Client, iqc chan xmpp.IQ, recipient string,
|
|
|
|
return keyring, nil
|
|
|
|
return keyring, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func oxGetPublicKeyRing(client *xmpp.Client, iqc chan xmpp.IQ,
|
|
|
|
func oxGetPublicKeyRing(client *xmpp.Client, iqc chan xmpp.IQ, recipient string) (*crypto.KeyRing, error) {
|
|
|
|
recipient string,
|
|
|
|
|
|
|
|
) (*crypto.KeyRing, error) {
|
|
|
|
|
|
|
|
publicKeyRing, err := crypto.NewKeyRing(nil)
|
|
|
|
publicKeyRing, err := crypto.NewKeyRing(nil)
|
|
|
|
if errors.Unwrap(err) != nil {
|
|
|
|
if errors.Unwrap(err) != nil {
|
|
|
|
return nil, fmt.Errorf("oxGetPublicKeyRing: failed to create a new keyring: %w", err)
|
|
|
|
return nil, fmt.Errorf("oxGetPublicKeyRing: failed to create a new keyring: %w", err)
|
|
|
@ -702,9 +690,7 @@ func oxGetPublicKeyRing(client *xmpp.Client, iqc chan xmpp.IQ,
|
|
|
|
return pubKeyRing, nil
|
|
|
|
return pubKeyRing, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func oxEncrypt(client *xmpp.Client, oxPrivKey *crypto.Key,
|
|
|
|
func oxEncrypt(client *xmpp.Client, oxPrivKey *crypto.Key, recipient string, keyRing *crypto.KeyRing, message string) (string, error) {
|
|
|
|
recipient string, keyRing *crypto.KeyRing, message string,
|
|
|
|
|
|
|
|
) (string, error) {
|
|
|
|
|
|
|
|
if message == "" {
|
|
|
|
if message == "" {
|
|
|
|
return "", nil
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|