Skip to content

Commit

Permalink
fixup! lib/sign: add revoking mechanism for ed25519 keys
Browse files Browse the repository at this point in the history
  • Loading branch information
d4s committed Oct 31, 2019
1 parent fcae2c0 commit 0d52fb3
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/libostree/ostree-sign-ed25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ struct _OstreeSignEd25519
GList *revoked_keys;
};

typedef gboolean (*add_key_func) (OstreeSign *, GVariant *, GError **);

static void
ostree_sign_ed25519_iface_init (OstreeSignInterface *self);

Expand Down Expand Up @@ -502,34 +500,31 @@ _load_pk_from_stream (OstreeSign *self,
gsize len = 0;
g_autofree char *line = g_data_input_stream_read_line (key_data_in, &len, NULL, error);
g_autoptr (GVariant) pk = NULL;
gboolean added = FALSE;

if (*error != NULL)
goto err;

if (line == NULL)
goto out;
goto out;

/* Read the key itself */
/* base64 encoded key */
pk = g_variant_new_string (line);

add_key_func fptr;
if (trusted)
fptr = &ostree_sign_ed25519_add_pk;
added = ostree_sign_ed25519_add_pk (self, pk, error);
else
fptr = &_ed25519_add_revoked;
added = _ed25519_add_revoked (self, pk, error);

if ( (*fptr) (self, pk, error))
{
ret = TRUE;
g_debug ("Added %s key: %s",
trusted ? "public" : "revoked",
line);
}
else
g_debug ("Invalid %s key: %s",
trusted ? "public" : "revoked",
line);
g_debug ("%s %s key: %s",
added ? "Added" : "Invalid",
trusted ? "public" : "revoked",
line);

/* Mark what we load at least one key */
if (added)
ret = TRUE;
}

out:
Expand Down

0 comments on commit 0d52fb3

Please sign in to comment.