Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative signing system #1878

Merged
merged 75 commits into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
84c8164
Add libsodium dependency
d4s Jun 15, 2019
edbbe1c
lib/sign: initial implementation
d4s Jul 28, 2019
c3608aa
sign: add new builtin for signing
d4s Jul 30, 2019
e133cb7
sign: allow to sign commits from CLI
d4s Jul 31, 2019
c09df18
lib/sign: enable verification for pulling
d4s Aug 1, 2019
9e8f0f4
tests: add test for commits sign/verification
d4s Aug 1, 2019
2303202
sign: API changes for public keys and CLI keys format
d4s Aug 9, 2019
06cfcd9
builtin/sign: allow to provide the file with public keys
d4s Aug 18, 2019
0b55db9
tests/sign: check public keys load from file
d4s Aug 18, 2019
4b9232b
builtin/sign: remove libsodium-specific code
d4s Aug 19, 2019
2d39126
sign: fix unneeded objects creation
d4s Aug 26, 2019
a8521a7
sign: fix error return for dummy module
d4s Aug 26, 2019
fe3a839
builtin/sign: remove libsodium dependency
d4s Aug 26, 2019
2831028
sign: fixes for ed25519 for loading public keys from files
d4s Aug 26, 2019
3386893
sign: check signatures for pulled commits
d4s Aug 26, 2019
82c7737
tests/sign: add initial test for pulling
d4s Aug 26, 2019
91cc294
lib/sign: disable mandatory signature check
d4s Aug 26, 2019
073876d
lib/sign: add support of file with valid keys for remote
d4s Aug 26, 2019
9444761
lib/sign: read ed25519 public keys from well known places
d4s Aug 28, 2019
36e4667
builtin/sign: allow to sign with keys from secret file
d4s Aug 28, 2019
5fc2ddf
tests/gpg: skip test in JS if GPG is not supported
d4s Aug 29, 2019
557f423
sign: fix memory leaks and code cleanup
d4s Sep 4, 2019
ea291a0
builtin/sign: allow to use multiple public keys for verification
d4s Sep 5, 2019
95ab57c
lib/sign-ed25519: cleanup unneeded code
d4s Oct 6, 2019
bc44886
lib/sign: public API optimisation
d4s Oct 6, 2019
f0181ad
lib/sign: allow to add keys as base64 string for ed25519
d4s Oct 7, 2019
7fa7c3c
sign: use common function for loading public keys during pulling
d4s Oct 7, 2019
eb8e501
lib/sign: minor optimisation for ed25519
d4s Oct 27, 2019
ceaf6d7
lib/sign: add ostree_seign_clear_keys function
d4s Oct 27, 2019
ee12b7e
lib/sign: add revoking mechanism for ed25519 keys
d4s Oct 27, 2019
200efd7
builtin/sign: add option 'keys-dir'
d4s Oct 29, 2019
7e71f87
tests/sign: check system-wide config and revoked keys
d4s Oct 29, 2019
0c89055
man: document `ostree sign`
d4s Oct 31, 2019
e9b1ebf
bash-completion: add completion for `ostree sign`
d4s Nov 1, 2019
908a2cd
apidoc: add API documentation for signing interface
d4s Nov 10, 2019
e799186
man: document commit signing
d4s Nov 10, 2019
2fd9438
bin/pull-local: add --sign-verify
d4s Nov 17, 2019
a9df634
tests/libtest: add functions for ed25519 tests
d4s Nov 17, 2019
e474033
tests/sign: use library functions for ed25519 keys
d4s Nov 17, 2019
72d81d7
tests/local-pull: test "--sign-verify" option
d4s Nov 17, 2019
6608436
bin/remote-add: added "--no-sign-verify" option
d4s Nov 17, 2019
68aa135
tests: use option "--no-sign-verify" for adding remote
d4s Nov 17, 2019
fbd2666
tests/sign: disable GPG for alternatively signed pull
d4s Nov 18, 2019
485ff73
lib/sign: allow to build with glib version less than 2.44
d4s Nov 18, 2019
3063a0a
lib/sign: use separate public and secret keys for 'dummy'
d4s Nov 25, 2019
5dca74f
tests/sign: add verification key for pulling with dummy
d4s Nov 25, 2019
5cd822a
lib/sign: fix the false failure while loading keys
d4s Nov 25, 2019
acace9b
tests/sign: allow to start pull test without libsodium
d4s Nov 26, 2019
0bdcf14
lib/sign: new function for summary file signing
d4s Nov 26, 2019
137306f
bin/summary: add signing with alternative mechanism
d4s Nov 26, 2019
40b8034
lib/repo-pull: verify signature on summary pull
d4s Nov 26, 2019
1de2efa
tests/sign: new test for summary file verification
d4s Nov 26, 2019
65c16a8
man: add signature options for ostree summary
d4s Nov 26, 2019
809176b
gpg: do not fail GPG-related configuration get for remote
d4s Nov 27, 2019
df36984
lib/repo-pull: change sign supporting functions
d4s Nov 27, 2019
c69dce3
lib/repo-pull: set default for sign-verify-summary
d4s Nov 27, 2019
b97ab81
lib/repo-pull: add signature check while fetching summary
d4s Nov 27, 2019
8b3b35a
bin/pull-local: add --sign-verify-summary
d4s Nov 27, 2019
4d0e3a6
lib/sign: make dummy engine non-public
d4s Dec 4, 2019
b4050b4
lib/sign: make ed25519 engine non-public
d4s Dec 4, 2019
dd27461
lib/sign: better error handling of ed25519 initialization
d4s Dec 6, 2019
194ab36
lib/repo-pull: return error from signing engine
d4s Dec 6, 2019
59b9e64
lib/repo-pull: return errors from signature engines
d4s Dec 7, 2019
fbc5927
build-sys: Print libsodium status at end of configure
cgwalters Jan 29, 2020
2a0edcc
sign-ed25519: Convert some functions to new style
cgwalters Jan 29, 2020
e2bd2ab
sign-dummy: Convert to current code style
cgwalters Feb 14, 2020
9d02199
signing: Remove g_debug(__FUNCTION__)
cgwalters Feb 14, 2020
09d5b47
tests/sign: added check with file and single key on pull
d4s Jan 31, 2020
aaf73f6
sign-ed25519: Convert functions to new style
d4s Feb 17, 2020
1e3bdef
sign-dummy: optimize ostree_sign_dummy_data_verify
d4s Feb 17, 2020
e16faa5
lib/sign: convert ostree_sign_summary to new style
d4s Feb 17, 2020
5a39281
tests/sign: check pull failure with invalid remote options
d4s Feb 19, 2020
584ad40
lib/sign: return false for non-implemented functions
d4s Feb 20, 2020
cce3864
sign-pull: improve error handling
d4s Feb 20, 2020
e2c6016
ostree-repo: improve error handling
d4s Mar 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile-libostree-defines.am
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ libostree_public_headers = \
src/libostree/ostree-repo-finder-mount.h \
src/libostree/ostree-repo-finder-override.h \
src/libostree/ostree-kernel-args.h \
src/libostree/ostree-sign.h \
src/libostree/ostree-sign-ed25519.h \
$(NULL)

# This one is generated via configure.ac, and the gtk-doc
Expand Down
14 changes: 14 additions & 0 deletions Makefile-libostree.am
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,20 @@ libostree_1_la_CFLAGS += $(OT_DEP_SELINUX_CFLAGS)
libostree_1_la_LIBADD += $(OT_DEP_SELINUX_LIBS)
endif

libostree_1_la_SOURCES += \
d4s marked this conversation as resolved.
Show resolved Hide resolved
src/libostree/ostree-sign.c \
src/libostree/ostree-sign.h \
src/libostree/ostree-sign-dummy.c \
src/libostree/ostree-sign-dummy.h \
src/libostree/ostree-sign-ed25519.c \
d4s marked this conversation as resolved.
Show resolved Hide resolved
src/libostree/ostree-sign-ed25519.h \
$(NULL)

if USE_LIBSODIUM
libostree_1_la_CFLAGS += $(OT_DEP_LIBSODIUM_CFLAGS)
libostree_1_la_LIBADD += $(OT_DEP_LIBSODIUM_LIBS)
endif # USE_LIBSODIUM

# XXX: work around clang being passed -fstack-clash-protection which it doesn't understand
# See: https://bugzilla.redhat.com/show_bug.cgi?id=1672012
INTROSPECTION_SCANNER_ENV = CC=gcc
Expand Down
2 changes: 1 addition & 1 deletion Makefile-man.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ostree-commit.1 ostree-create-usb.1 ostree-export.1 \
ostree-config.1 ostree-diff.1 ostree-find-remotes.1 ostree-fsck.1 \
ostree-init.1 ostree-log.1 ostree-ls.1 ostree-prune.1 ostree-pull-local.1 \
ostree-pull.1 ostree-refs.1 ostree-remote.1 ostree-reset.1 \
ostree-rev-parse.1 ostree-show.1 ostree-summary.1 \
ostree-rev-parse.1 ostree-show.1 ostree-sign.1 ostree-summary.1 \
ostree-static-delta.1
if USE_LIBSOUP
man1_files += ostree-trivial-httpd.1
Expand Down
7 changes: 6 additions & 1 deletion Makefile-ostree.am
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ostree_SOURCES = src/ostree/main.c \
src/ostree/ot-builtin-remote.c \
src/ostree/ot-builtin-reset.c \
src/ostree/ot-builtin-rev-parse.c \
src/ostree/ot-builtin-sign.c \
d4s marked this conversation as resolved.
Show resolved Hide resolved
src/ostree/ot-builtin-summary.c \
src/ostree/ot-builtin-show.c \
src/ostree/ot-builtin-static-delta.c \
Expand Down Expand Up @@ -112,7 +113,6 @@ ostree_SOURCES += \
$(NULL)
endif


if USE_CURL_OR_SOUP
ostree_SOURCES += src/ostree/ot-remote-builtin-add-cookie.c \
src/ostree/ot-remote-builtin-delete-cookie.c \
Expand Down Expand Up @@ -162,3 +162,8 @@ if USE_LIBARCHIVE
ostree_CFLAGS += $(OT_DEP_LIBARCHIVE_CFLAGS)
ostree_LDADD += $(OT_DEP_LIBARCHIVE_LIBS)
endif

if USE_LIBSODIUM
ostree_CFLAGS += $(OT_DEP_LIBSODIUM_CFLAGS)
ostree_LDADD += $(OT_DEP_LIBSODIUM_LIBS)
endif # USE_LIBSODIUM
3 changes: 3 additions & 0 deletions Makefile-tests.am
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ _installed_or_uninstalled_test_scripts = \
tests/test-summary-collections.sh \
tests/test-pull-collections.sh \
tests/test-config.sh \
tests/test-signed-commit.sh \
tests/test-signed-pull.sh \
tests/test-signed-pull-summary.sh \
$(NULL)

if USE_GPGME
Expand Down
1 change: 1 addition & 0 deletions apidoc/ostree-docs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<xi:include href="xml/ostree-sepolicy.xml"/>
<xi:include href="xml/ostree-sysroot-upgrader.xml"/>
<xi:include href="xml/ostree-gpg-verify-result.xml"/>
<xi:include href="xml/ostree-sign.xml"/>
<xi:include href="xml/ostree-bootconfig-parser.xml"/>
<xi:include href="xml/ostree-chain-input-stream.xml"/>
<xi:include href="xml/ostree-checksum-input-stream.xml"/>
Expand Down
20 changes: 20 additions & 0 deletions apidoc/ostree-sections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -705,3 +705,23 @@ ostree_kernel_args_from_string
ostree_kernel_args_to_strv
ostree_kernel_args_to_string
</SECTION>

<SECTION>
<FILE>ostree-sign</FILE>
OstreeSign
ostree_sign_list_names
ostree_sign_commit
ostree_sign_commit_verify
ostree_sign_data
ostree_sign_data_verify
ostree_sign_get_by_name
ostree_sign_get_name
ostree_sign_add_pk
ostree_sign_clear_keys
ostree_sign_load_pk
ostree_sign_set_pk
ostree_sign_set_sk
ostree_sign_summary
<SUBSECTION Standard>
ostree_sign_get_type
</SECTION>
43 changes: 43 additions & 0 deletions bash/ostree
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,48 @@ _ostree_show() {
return 0
}

_ostree_sign() {
local boolean_options="
$main_boolean_options
--delete -d
--verify -v
"

local options_with_args="
--sign-type
--keys-file
--keys-dir
--repo
"

local options_with_args_glob=$( __ostree_to_extglob "$options_with_args" )

case "$prev" in
--keys-file|--keys-dir|--repo)
__ostree_compreply_dirs_only
return 0
;;
$options_with_args_glob )
return 0
;;
esac

case "$cur" in
-*)
local all_options="$boolean_options $options_with_args"
__ostree_compreply_all_options
;;
*)
local argpos=$( __ostree_pos_first_nonflag $( __ostree_to_alternatives "$options_with_args" ) )

if [ $cword -eq $argpos ]; then
__ostree_compreply_commits
fi
esac

return 0
}

_ostree_static_delta_apply_offline() {
local boolean_options="
$main_boolean_options
Expand Down Expand Up @@ -1747,6 +1789,7 @@ _ostree() {
reset
rev-parse
show
sign
static-delta
summary
"
Expand Down
16 changes: 16 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,21 @@ dnl to link to it directly.
)
AM_CONDITIONAL(USE_GPGME, test "x$have_gpgme" = xyes)


LIBSODIUM_DEPENDENCY="1.0.14"
AC_ARG_WITH(libsodium,
AS_HELP_STRING([--with-libsodium], [Use libsodium @<:@default=no@:>@]),
[], [with_libsodium=no])
AS_IF([test x$with_libsodium != xno], [
AC_DEFINE([HAVE_LIBSODIUM], 1, [Define if using libsodium])
PKG_CHECK_MODULES(OT_DEP_LIBSODIUM, libsodium >= $LIBSODIUM_DEPENDENCY, have_libsodium=yes, have_libsodium=no)
AS_IF([ test x$have_libsodium = xno ], [
AC_MSG_ERROR([Need LIBSODIUM version $LIBSODIUM_DEPENDENCY or later])
])
OSTREE_FEATURES="$OSTREE_FEATURES libsodium"
], with_libsodium=no )
AM_CONDITIONAL(USE_LIBSODIUM, test "x$have_libsodium" = xyes)

LIBARCHIVE_DEPENDENCY="libarchive >= 2.8.0"
# What's in RHEL7.2.
FUSE_DEPENDENCY="fuse >= 2.9.2"
Expand Down Expand Up @@ -626,6 +641,7 @@ echo "
cryptographic checksums: $with_crypto
systemd: $with_libsystemd
libmount: $with_libmount
libsodium (ed25519 signatures): $with_libsodium
libarchive (parse tar files directly): $with_libarchive
static deltas: yes (always enabled now)
O_TMPFILE: $enable_otmpfile
Expand Down
33 changes: 33 additions & 0 deletions man/ostree-commit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,39 @@ Boston, MA 02111-1307, USA.
POLICY is a boolean which specifies whether fsync should be used or not. Default to true.
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>-s, --sign-type</option></term>
<listitem><para>
Use particular signature engine. Currently
available <arg choice="plain">ed25519</arg> and <arg choice="plain">dummy</arg>
signature types.

The default is <arg choice="plain">ed25519</arg>.
</para></listitem>

</varlistentry>
<varlistentry>
<term><option>--sign</option>="KEY-ID"</term>
<listitem><para>
There <literal>KEY-ID</literal> is:
<variablelist>
<varlistentry>
<term><option>for ed25519:</option></term>
<listitem><para>
<literal>base64</literal>-encoded secret key for commit signing.
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>for dummy:</option></term>
<listitem><para>
ASCII-string used as secret key.
</para></listitem>
</varlistentry>
</variablelist>
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

Expand Down
152 changes: 152 additions & 0 deletions man/ostree-sign.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<!--
Copyright 2019 Denis Pynkin <[email protected]>

SPDX-License-Identifier: LGPL-2.0+

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-->

<refentry id="ostree">

<refentryinfo>
<title>ostree sign</title>
<productname>OSTree</productname>

<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Colin</firstname>
<surname>Walters</surname>
<email>[email protected]</email>
</author>
</authorgroup>
</refentryinfo>

<refmeta>
<refentrytitle>ostree sign</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>

<refnamediv>
<refname>ostree-sign</refname>
<refpurpose>Sign a commit</refpurpose>
</refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>ostree sign</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="req">COMMIT</arg> <arg choice="req" rep="repeat">KEY-ID</arg>
</cmdsynopsis>
</refsynopsisdiv>

<refsect1>
<title>Description</title>

<para>
Add a new signature to a commit.

Note that currently, this will append a new signature even if
the commit is already signed with a given key.
</para>

<para>
There are several "well-known" system places for `ed25519` trusted and revoked public keys -- expected single <literal>base64</literal>-encoded key per line.
</para>

<para>Files:
<itemizedlist>
<listitem><para><filename>/etc/ostree/trusted.ed25519</filename></para></listitem>
<listitem><para><filename>/etc/ostree/revoked.ed25519</filename></para></listitem>
<listitem><para><filename>/usr/share/ostree/trusted.ed25519</filename></para></listitem>
<listitem><para><filename>/usr/share/ostree/revoked.ed25519</filename></para></listitem>
</itemizedlist>
</para>

<para>Directories containing files with keys:
<itemizedlist>
<listitem><para><filename>/etc/ostree/trusted.ed25519.d</filename></para></listitem>
<listitem><para><filename>/etc/ostree/revoked.ed25519.d</filename></para></listitem>
<listitem><para><filename>/usr/share/ostree/trusted.ed25519.d</filename></para></listitem>
<listitem><para><filename>/usr/share/ostree/rvokeded.ed25519.d</filename></para></listitem>
</itemizedlist>
</para>
</refsect1>

<refsect1>
<title>Options</title>

<variablelist>
<varlistentry>
<term><option>KEY-ID</option></term>
<listitem><para>
<variablelist>
<varlistentry>
<term><option>for ed25519:</option></term>
<listitem><para>
<literal>base64</literal>-encoded secret (for signing) or public key (for verifying).
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>for dummy:</option></term>
<listitem><para>
ASCII-string used as secret key and public key.
</para></listitem>
</varlistentry>
</variablelist>
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--verify</option></term>
<listitem><para>
Verify signatures
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-s, --sign-type</option></term>
<listitem><para>
Use particular signature mechanism. Currently
available <arg choice="plain">ed25519</arg> and <arg choice="plain">dummy</arg>
signature types.

The default is <arg choice="plain">ed25519</arg>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--keys-file</option></term>
<listitem><para>
Read key(s) from file <filename>filename</filename>.
</para></listitem>

<listitem><para>
Valid for <literal>ed25519</literal> signature type.
For <literal>ed25519</literal> this file must contain <literal>base64</literal>-encoded
secret key(s) (for signing) or public key(s) (for verifying) per line.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--keys-dir</option></term>
<listitem><para>
Redefine the system path, where to search files and subdirectories with
well-known and revoked keys.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
Loading