Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
docs: update documentation to account for the ECC changes
Kyle Evans committed 2 years ago
commit d8582c8d62a151e848e544c688b7fa50bace1da0
parent 542057c
2 files changed +261 -19
modified docs/pkg-key.8
@@ -14,28 +14,40 @@
.\"
.\"     @(#)pkg.8
.\"
-
.Dd January 14, 2021
+
.Dd March 6, 2024
.Dt PKG-KEY 8
.Os
.Sh NAME
.Nm "pkg key"
-
.Nd create or extract signing key details
+
.Nd signing key operations
.Sh SYNOPSIS
.Nm
-
.Op Fl -create | Fl -public
-
.Ar key-path
+
.Op Fl -create | Fl -public | Fl -sign
+
.Op Fl t Ar type
+
.Ar keyfile
.Sh DESCRIPTION
.Nm
-
is used to create or extract signing key details for use with
+
is used to create or extract signing keys for use with
.Xr pkg-repo 8 .
Cryptographically signing your package repository catalog is strongly
recommended.
.Pp
-
The default operation for
-
.Nm
-
is to write some useful information about the key at
-
.Ar key-path
-
to stdout.
+
One of the
+
.Fl -create ,
+
.Fl -public ,
+
or
+
.Fl -sign
+
operations must be specified.
+
Future work may write information about the
+
.Ar keyfile
+
out to
+
.Em stdout
+
when no key operation has been specified.
+
.Pp
+
See
+
.Xr pkg-repo
+
for some practical examples of using
+
.Nm .
.Sh OPTIONS
The following options are supported by
.Nm :
@@ -43,11 +55,149 @@ The following options are supported by
.It Fl -create
Create the named key.
Note that any file at
-
.Ar key-path
+
.Ar keyfile
will be overwritten.
+
.Nm
+
will
+
.Xr chmod 2
+
the
+
.Ar keyfile
+
to
+
.Li 0400
+
upon successful completion.
+
The corresponding public key will be written to
+
.Em stdout ,
+
note the caveats of this described with the
+
.Fl -public
+
option.
+
The
+
.Fl t
+
option should be used when generating keys to be explicit about the type of
+
key requested.
+
.Pp
+
Note that the
+
.Sy ecdsa
+
and
+
.Sy eddsa
+
keys generated by
+
.Nm
+
are not compatible with those generated by OpenSSL, but
+
.Xr pkg 8
+
can read
+
.Sy ecdsa
+
keys generated by OpenSSL.
.It Fl -public
-
Write the public key to stdout.
+
Write the public key corresponding to
+
.Ar keyfile
+
out to
+
.Em stdout .
+
Note that some signers may output keys in a binary format, so it is recommended
+
to redirect
+
.Em stdout
+
to a file.
+
.It Fl -sign
+
Signs the data ingested via
+
.Em stdin
+
with the named
+
.Ar keyfile ,
+
and writes the signature data to
+
.Em stdout .
+
As with
+
.Fl -public ,
+
note that the signature may be a binary format and it is recommended to redirect
+
.Em stdout
+
to a file.
+
.It Fl t Ar type
+
Specifies the
+
.Ar type
+
of signer to use for the given key.
+
.Nm
+
will not try to guess the correct signer that goes with a key in any case, so
+
it must be specified for every operation.
+
The
+
.Sy rsa
+
signer is assumed if
+
.Fl t
+
is not specified.
+
The following signers are currently supported:
+
.Bl -tag -width all
+
.It Sy rsa
+
Backend using RSA with keys created either by OpenSSL or by
+
.Nm
+
.Fl -create .
+
.It Sy ecc
+
An alias for the
+
.Sy eddsa
+
signer.
+
.It Sy ecdsa
+
Backend using ECDSA with keys created either by OpenSSL or by
+
.Nm
+
.Fl -create .
+
See
+
.Sx Elliptic Curve Cryptography
+
for more discussion.
+
.It Sy eddsa
+
Backend using EdDSA with keys created by
+
.Nm
+
.Fl -create .
+
See
+
.Sx Elliptic Curve Cryptography
+
for more discussion.
.El
+
.El
+
.Ss Elliptic Curve Cryptography
+
Elliptic Curve Cryptography, ECC, is supported by
+
.Xr pkg 8 ,
+
with limited compatibility with OpenSSL.
+
Signatures are output in a format that OpenSSL can handle, subject to the
+
constraints about curve choice outlined in the rest of this section.
+
.Pp
+
The
+
.Sy ecdsa
+
signer is expected to be interoperable with OpenSSL, but curve choice is more
+
limited than what OpenSSL provides.
+
In general, the curves provided must be supported both by OpenSSL and by the
+
.Lb libecc
+
used by
+
.Xr pkg 8 .
+
The criteria for curve selection is that they must be 256-bit or higher and
+
accepted by both implementations.
+
The following common curves are currently supported:
+
.Bl -bullet
+
.It
+
.Sy secp256k1
+
.It
+
.Sy secp384r1
+
.It
+
.Sy secp521r1
+
.It
+
.Sy brainpoolP256r1
+
.It
+
.Sy brainpoolP256t1
+
.It
+
.Sy brainpoolP320r1
+
.It
+
.Sy brainpoolP320t1
+
.It
+
.Sy brainpoolP384r1
+
.It
+
.Sy brainpoolP384t1
+
.It
+
.Sy brainpoolP512r1
+
.It
+
.Sy brainpoolP512t1
+
.El
+
.Pp
+
The
+
.Sy eddsa
+
signer is not compatible with OpenSSL due to limited curve selection provided
+
by
+
.Lb libecc
+
by default.
+
The only curve supported by
+
.Xr pkg 8
+
for EdDSA is
+
.Sy WEI25519 .
.Sh FILES
See
.Xr pkg.conf 5 .
modified docs/pkg-repo.8
@@ -25,13 +25,13 @@
.Op Fl lq
.Op Fl m Ar meta-file
.Op Fl o Ar output-dir
-
.Ao Ar repo-path Ac Op rsa: Ns Ao Ar rsa-key Ac | signing_command: Ao Ar the command Ac
+
.Ao Ar repo-path Ac Op Ar signer-type: Ns Ao Ar keyfile Ac | signing_command: Ao Ar the command Ac
.Pp
.Nm
.Op Cm --{list-files,quiet}
.Op Cm --meta-file Ar meta-file
.Op Cm --output-dir Ar output-dir
-
.Ao Ar repo-path Ac Op rsa: Ns Ao Ar rsa-key Ac | signing_command: Ao Ar the command Ac
+
.Ao Ar repo-path Ac Op Ar signer-type: Ns Ao Ar keyfile Ac | signing_command: Ao Ar the command Ac
.Sh DESCRIPTION
.Nm
is used to create a catalogue of the available
@@ -129,13 +129,41 @@ or
.Cm --output-dir Ar output-dir .
.Pp
Optionally, the repository catalogue may be cryptographically signed.
-
This is enabled either by specifying the path to an RSA private key as the
-
.Ar rsa-key
+
This is enabled either by specifying the path to a private key as the
+
.Ar keyfile
argument or by using an external command.
+
When a
+
.Ar keyfile
+
is being used, it may be prefixed by the signer type.
+
Currently, this may be one of
+
.Sy rsa ,
+
.Sy ecdsa ,
+
or
+
.Sy eddsa .
+
.Sy ecc
+
is also accepted as an alias of
+
.Sy eddsa .
+
Keys for the
+
.Sy rsa
+
and
+
.Sy ecdsa
+
signers may be generated by OpenSSL or by
+
.Xr pkg-key 8 .
+
Keys for the
+
.Dq eddsa
+
signer may only be generated by
+
.Xr pkg-key 8 .
.Pp
-
If
-
.Ar rsa-key
-
is used, the SHA256 of the repository is signed using the provided key.
+
If the
+
.Ar key
+
is used, a hash of the repository is signed using the provided key.
+
The
+
.Sy rsa
+
signer will sign the SHA256 hash of the repository, while the
+
.Sy ecdsa
+
and
+
.Sy eddsa
+
signers will sign the BLAKE2 hash of the repository.
The signature is added into the repository catalogue.
The client side should use
.Sy SIGNATURE_TYPE
@@ -151,6 +179,8 @@ The external command is passed the SHA256 of the repository
catalogue on its stdin.
It should output the following format:
.Bd -literal -offset indent
+
TYPE
+
signer type here (rsa, ecdsa, eddsa)
SIGNATURE
signature data here
CERT
@@ -158,6 +188,23 @@ public key data here
END
.Ed
.Pp
+
The
+
.Sy TYPE
+
field is optional if using
+
.Sy rsa ,
+
to remain compatible with external signing commands historically in use.
+
Note that the
+
.Sy SIGNATURE
+
field's data will may require an extra newline after it if the signature is
+
output in a binary format.
+
The
+
.Sy CERT
+
field may contain binary data, but
+
.Xr pkg 8
+
will search the tail of it for the missing
+
.Sy END
+
if it runs together.
+
.Pp
When using an external command, the client's
.Pa pkg.conf
must have
@@ -298,3 +345,48 @@ $ mkdir -p /usr/local/etc/pkg/fingerprints/myrepo/trusted
# Add 'fingerprint' into /usr/local/etc/pkg/fingerprints/myrepo/trusted

.Ed
+
.Pp
+
The above examples can be repeated with OpenSSL creating a key pair for ECDSA:
+
.Bd -literal -offset indent
+
% openssl ecparam -genkey -name secp256k1 -out repo.key -outform DER
+
% chmod 0400 repo.key
+
% openssl ec -in repo.key -out repo.pub -pubout -outform DER
+
.Ed
+
.Pp
+
Prefixing the later
+
.Pa repo.key
+
reference with
+
.Dq ecdsa :
+
.Pp
+
.Dl pkg repo /usr/ports/packages ecdsa:repo.key
+
.Pp
+
The signing server example can be used mostly as-is, but with the following text
+
placed before the
+
.Sy SIGNATURE
+
section in the signing server output:
+
.Bd -literal -offset indent
+
TYPE
+
ecdsa
+
.Ed
+
.Pp
+
For EdDSA instead, create an EdDSA key pair:
+
.Bd -literal -offset indent
+
% pkg key --create -t eddsa repo.key > repo.pub
+
.Ed
+
.Pp
+
Create a repository and sign it with a local key.
+
As with the RSA example above, the public key would be shared on all client
+
servers with
+
.Sy SIGNATURE_TYPE
+
set to
+
.Dv PUBKEY
+
and its path set via the
+
.Sy PUBKEY
+
option in the repository configuration file:
+
.Pp
+
.Dl pkg repo /usr/ports/packages eddsa:repo.key
+
.Pp
+
A signing server for EdDSA could be constructed with the
+
.Xr pkg-key 8
+
.Fl -sign
+
option.