trust: add draft seperate public/secret loading
It isn't clear where secret keys will be located at but this should at least allow for cleaner seperation in lists.cute-signatures
parent
5b020ec9ef
commit
1c54a3fbb4
|
@ -1180,7 +1180,7 @@ int adb_trust_write_signatures(struct apk_trust *trust, struct adb *db, struct a
|
|||
struct adb_sign_v0 v0;
|
||||
unsigned char buf[ADB_MAX_SIGNATURE_LEN];
|
||||
} sig;
|
||||
struct apk_trust_key *tkey;
|
||||
struct apk_trust_secret_key *tkey;
|
||||
apk_blob_t md;
|
||||
size_t siglen;
|
||||
int r;
|
||||
|
|
|
@ -18,7 +18,7 @@ struct apk_trust_key {
|
|||
char *filename;
|
||||
};
|
||||
|
||||
struct apk_trust_secret {
|
||||
struct apk_trust_secret_key {
|
||||
struct list_head key_node;
|
||||
struct apk_secret_key key;
|
||||
char *filename;
|
||||
|
|
23
src/trust.c
23
src/trust.c
|
@ -21,6 +21,25 @@ static struct apk_trust_key *apk_trust_load_public(int dirfd, const char *filena
|
|||
return key;
|
||||
}
|
||||
|
||||
static struct apk_trust_secret_key *apk_trust_load_secret(int dirfd, const char *filename)
|
||||
{
|
||||
struct apk_trust_secret_key *key;
|
||||
int r;
|
||||
|
||||
key = calloc(1, sizeof *key);
|
||||
if (!key) return ERR_PTR(-ENOMEM);
|
||||
|
||||
r = apk_secret_key_load(&key->key, dirfd, filename);
|
||||
if (r != 0) {
|
||||
free(key);
|
||||
return ERR_PTR(r);
|
||||
}
|
||||
|
||||
list_init(&key->key_node);
|
||||
key->filename = strdup(filename);
|
||||
return key;
|
||||
}
|
||||
|
||||
static int __apk_trust_load_pubkey(void *pctx, int dirfd, const char *filename)
|
||||
{
|
||||
struct apk_trust *trust = pctx;
|
||||
|
@ -93,11 +112,11 @@ static int option_parse_signing(void *ctx, struct apk_ctx *ac, int optch, const
|
|||
{
|
||||
struct apk_trust *trust = &ac->trust;
|
||||
struct apk_out *out = &ac->out;
|
||||
struct apk_trust_key *key;
|
||||
struct apk_trust_secret_key *key;
|
||||
|
||||
switch (optch) {
|
||||
case OPT_SIGN_sign_key:
|
||||
key = apk_trust_load_public(AT_FDCWD, optarg);
|
||||
key = apk_trust_load_secret(AT_FDCWD, optarg);
|
||||
if (IS_ERR(key)) {
|
||||
apk_err(out, "Failed to load signing key: %s: %s",
|
||||
optarg, apk_error_str(PTR_ERR(key)));
|
||||
|
|
Loading…
Reference in New Issue