Ox: Allow also RSA key generation.

v0.4
Martin Dosch 2 years ago
parent b25ba60415
commit b092039ac3

@ -83,7 +83,7 @@ If no configuration file is present or if the values should be overridden it is
the account details via command line options:
```plain
Usage: go-sendxmpp [-cdilnt] [-f value] [--help] [--http-upload value] [-j value] [-m value] [--muc-password value] [--ox] [--ox-genprivkey] [--ox-import-privkey value] [--ox-passphrase value] [-p value] [--raw] [-r value] [--timeout value] [--tls-version value] [-u value] [--version] [parameters ...]
Usage: go-sendxmpp [-cdilnt] [-f value] [--help] [--http-upload value] [-j value] [-m value] [--muc-password value] [--ox] [--ox-genprivkey-rsa] [--ox-genprivkey-x25519] [--ox-import-privkey value] [--ox-passphrase value] [-p value] [--raw] [-r value] [--timeout value] [--tls-version value] [-u value] [--version] [parameters ...]
-c, --chatroom Send message to a chatroom.
-d, --debug Show debugging info.
-f, --file=value Set configuration file. (Default:
@ -102,9 +102,12 @@ Usage: go-sendxmpp [-cdilnt] [-f value] [--help] [--http-upload value] [-j value
-n, --no-tls-verify
Skip verification of TLS certificates (not recommended).
--ox Use "OpenPGP for XMPP" encryption (experimental).
--ox-genprivkey
Generate a public OpenPGP key for the given JID and publish
the corresponding public key.
--ox-genprivkey-rsa
Generate a public OpenPGP key (RSA 4096 bit) for the given
JID and publish the corresponding public key.
--ox-genprivkey-x25519
Generate a public OpenPGP key (x25519) for the given JID and
publish the corresponding public key.
--ox-import-privkey=value
Import an existing private OpenPGP key.
--ox-passphrase=value

@ -107,8 +107,12 @@ func main() {
flagVersion := getopt.BoolLong("version", 0, "Show version information.")
flagMUCPassword := getopt.StringLong("muc-password", 0, "", "Password for password protected MUCs.")
flagOx := getopt.BoolLong("ox", 0, "Use \"OpenPGP for XMPP\" encryption (experimental).")
flagOxGenPrivKey := getopt.BoolLong("ox-genprivkey", 0,
"Generate a public OpenPGP key for the given JID and publish the corresponding public key.")
flagOxGenPrivKeyRSA := getopt.BoolLong("ox-genprivkey-rsa", 0,
"Generate a public OpenPGP key (RSA 4096 bit) for the given JID and publish the "+
"corresponding public key.")
flagOxGenPrivKeyX25519 := getopt.BoolLong("ox-genprivkey-x25519", 0,
"Generate a public OpenPGP key (x25519) for the given JID and publish the "+
"corresponding public key.")
flagOxPassphrase := getopt.StringLong("ox-passphrase", 0, "",
"Passphrase for locking and unlocking the private OpenPGP key.")
flagOxImportPrivKey := getopt.StringLong("ox-import-privkey", 0, "",
@ -147,8 +151,9 @@ func main() {
// For listening or sending raw XML it's not required to specify a recipient except
// when sending raw messages to MUCs (go-sendxmpp will join the MUC automatically).
recipientsList := getopt.Args()
if (len(recipientsList) == 0 && !*flagRaw && !*flagListen && !*flagOxGenPrivKey &&
*flagOxImportPrivKey == "") || (len(recipientsList) == 0 && *flagChatroom) {
if (len(recipientsList) == 0 && !*flagRaw && !*flagListen && !*flagOxGenPrivKeyX25519 &&
!*flagOxGenPrivKeyRSA && *flagOxImportPrivKey == "") ||
(len(recipientsList) == 0 && *flagChatroom) {
log.Fatal("No recipient specified.")
}
@ -270,12 +275,22 @@ func main() {
}
switch {
case *flagOxGenPrivKey:
case *flagOxGenPrivKeyX25519:
validatedOwnJid, err := MarshalJID(user)
if err != nil {
log.Fatal(err)
}
err = oxGenPrivKey(validatedOwnJid, client, *flagOxPassphrase)
err = oxGenPrivKey(validatedOwnJid, client, *flagOxPassphrase, "x25519")
if err != nil {
log.Fatal(err)
}
os.Exit(0)
case *flagOxGenPrivKeyRSA:
validatedOwnJid, err := MarshalJID(user)
if err != nil {
log.Fatal(err)
}
err = oxGenPrivKey(validatedOwnJid, client, *flagOxPassphrase, "rsa")
if err != nil {
log.Fatal(err)
}

@ -38,7 +38,11 @@ You can either pipe a programs output to \fBgo\-sendxmpp\fR, write in your termi
.br
There is also no check whether the recipients key is trusted as there is no local keyring used\. Go\-sendxmpp just uses the most recent key that is provided via pubsub and checks that it is not expired\.
.P
\fB\-\-ox\-genprivkey\fR: Generate a public OpenPGP key for the given JID and publish the corresponding public key\. Go\-sendxmpp will save the key in \fB$XDG_DATA_HOME/go\-sendxmpp/oxprivkeys\fR or \fB$HOME/\.local/share/go\-sendxmpp/oxprivkeys\fR\. To protect the key a passphrase might be set using \fB\-\-ox\-passphrase\fR while generating the key\.
\fB\-\-ox\-genprivkey\-rsa\fR: Generate a private OpenPGP key (RSA 4096 bit) for the configured account (via config file or \fB\-u\fR and \fB\-p\fR) and publish the corresponding public key\. Go\-sendxmpp will save the key in \fB$XDG_DATA_HOME/go\-sendxmpp/oxprivkeys\fR or \fB$HOME/\.local/share/go\-sendxmpp/oxprivkeys\fR\. To protect the key a passphrase might be set using \fB\-\-ox\-passphrase\fR while generating the key\.
.br
If there is an existing private key for "OpenPGP for XMPP" created by another client (e\.g\. profanity) it might be imported using \fB\-\-ox\-import\-privkey\fR\.
.P
\fB\-\-ox\-genprivkey\-x25519\fR: Generate a private OpenPGP key (X25519) for the configured account (via config file or \fB\-u\fR and \fB\-p\fR) and publish the corresponding public key\. Go\-sendxmpp will save the key in \fB$XDG_DATA_HOME/go\-sendxmpp/oxprivkeys\fR or \fB$HOME/\.local/share/go\-sendxmpp/oxprivkeys\fR\. To protect the key a passphrase might be set using \fB\-\-ox\-passphrase\fR while generating the key\.
.br
If there is an existing private key for "OpenPGP for XMPP" created by another client (e\.g\. profanity) it might be imported using \fB\-\-ox\-import\-privkey\fR\.
.P

@ -134,8 +134,18 @@ file location is specified with <code>-f</code> or <code>--file</code>.</p>
Go-sendxmpp just uses the most recent key that is provided via pubsub and checks that it is not
expired.</p>
<p><code>--ox-genprivkey</code>:
Generate a public OpenPGP key for the given JID and publish the corresponding public key.
<p><code>--ox-genprivkey-rsa</code>:
Generate a private OpenPGP key (RSA 4096 bit) for the configured account (via config file or <code>-u</code> and <code>-p</code>)
and publish the corresponding public key.
Go-sendxmpp will save the key in <code>$XDG_DATA_HOME/go-sendxmpp/oxprivkeys</code> or
<code>$HOME/.local/share/go-sendxmpp/oxprivkeys</code>. To protect the key a passphrase might be set
using <code>--ox-passphrase</code> while generating the key. <br>
If there is an existing private key for "OpenPGP for XMPP" created by another client (e.g. profanity)
it might be imported using <code>--ox-import-privkey</code>.</p>
<p><code>--ox-genprivkey-x25519</code>:
Generate a private OpenPGP key (X25519) for the configured account (via config file or <code>-u</code> and <code>-p</code>)
and publish the corresponding public key.
Go-sendxmpp will save the key in <code>$XDG_DATA_HOME/go-sendxmpp/oxprivkeys</code> or
<code>$HOME/.local/share/go-sendxmpp/oxprivkeys</code>. To protect the key a passphrase might be set
using <code>--ox-passphrase</code> while generating the key. <br>

@ -59,8 +59,18 @@ file location is specified with `-f` or `--file`.
Go-sendxmpp just uses the most recent key that is provided via pubsub and checks that it is not
expired.
`--ox-genprivkey`:
Generate a public OpenPGP key for the given JID and publish the corresponding public key.
`--ox-genprivkey-rsa`:
Generate a private OpenPGP key (RSA 4096 bit) for the configured account (via config file or `-u` and `-p`)
and publish the corresponding public key.
Go-sendxmpp will save the key in `$XDG_DATA_HOME/go-sendxmpp/oxprivkeys` or
`$HOME/.local/share/go-sendxmpp/oxprivkeys`. To protect the key a passphrase might be set
using `--ox-passphrase` while generating the key.
If there is an existing private key for "OpenPGP for XMPP" created by another client (e.g. profanity)
it might be imported using `--ox-import-privkey`.
`--ox-genprivkey-x25519`:
Generate a private OpenPGP key (X25519) for the configured account (via config file or `-u` and `-p`)
and publish the corresponding public key.
Go-sendxmpp will save the key in `$XDG_DATA_HOME/go-sendxmpp/oxprivkeys` or
`$HOME/.local/share/go-sendxmpp/oxprivkeys`. To protect the key a passphrase might be set
using `--ox-passphrase` while generating the key.

@ -186,9 +186,10 @@ func oxStoreKey(location string, key string) error {
return nil
}
func oxGenPrivKey(jid string, client *xmpp.Client, passphrase string) error {
func oxGenPrivKey(jid string, client *xmpp.Client, passphrase string,
keyType string) error {
xmppURI := "xmpp:" + jid
key, err := crypto.GenerateKey(xmppURI, "", "x25519", 0)
key, err := crypto.GenerateKey(xmppURI, "", keyType, 4096)
if err != nil {
return err
}

Loading…
Cancel
Save