Pass defhash about.
Without this, attempts to use these new arrangements (in particular,
keyset_load when there are rsa1 keys involved, which will be the usual
new arrangement) would segfault.
This fixes the bug introduced in:
site: Read public peer keys from key file
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
/* filled in during setup: */
struct cloc loc; /* line is runtime */
struct log_if *log;
+ struct hash_if *defhash;
struct buffer_if *data_buf;
struct peer_keyset *building;
/* runtime: */
bool_t ok=c->scheme->loadpub(c->scheme,c->data_buf,
&pubkey,c->log,c->loc);
if (!ok) break;
+ if (pubkey->sethash) {
+ if (!c->defhash) {
+ pubkey->dispose(pubkey->st);
+ DOSKIP("public key requires default hash to load");
+ }
+ pubkey->sethash(pubkey->st,c->defhash);
+ }
memcpy(c->building->keys[c->building->nkeys].id.b,
c->grpid,
GRPIDSZ);
extern struct peer_keyset *
keyset_load(const char *path, struct buffer_if *data_buf,
- struct log_if *log, int logcl_enoent) {
+ struct log_if *log, int logcl_enoent,
+ struct hash_if *defhash) {
assert(!c->building);
c->log=log;
+ c->defhash=defhash;
c->loc.file=path;
pkyyin = fopen(path, "r");
if (!pkyyin) {
extern struct peer_keyset *
keyset_load(const char *path, struct buffer_if *data_buf,
- struct log_if *log, int logcl_enoent);
+ struct log_if *log, int logcl_enoent,
+ struct hash_if *defhash);
extern void keyset_dispose(struct peer_keyset **ks);
int logcl_enoent)
{
struct peer_keyset *atsuffix=
- keyset_load(file,&st->scratch,st->log,logcl_enoent);
+ keyset_load(file,&st->scratch,st->log,logcl_enoent,st->defhash);
if (!atsuffix) return;
if (st->peerkeys_current &&
pathprefix_template_init(&st->peerkeys_tmpl,st->peerkeys_path,
PEERKEYS_SUFFIX_MAXLEN + 1 /* nul */);
st->peerkeys_current=keyset_load(st->peerkeys_path,
- &st->scratch,st->log,M_ERR);
+ &st->scratch,st->log,M_ERR,
+ st->defhash);
if (fixed_pubkey) {
fixed_pubkey->dispose(fixed_pubkey->st);
}