static const char *hexchars="0123456789abcdef";
-static void rsa_sethash(struct rsacommon *c, struct hash_if *hash,
+static void rsa_sethash(struct load_ctx *l,
+ struct rsacommon *c,
const struct hash_if **in_ops)
{
- free(c->hashbuf);
+ struct hash_if *hash=0;
+ if (l->deprdict)
+ hash=find_cl_if(l->deprdict,"hash",CL_HASH,False,"site",l->loc);
+ if (!hash)
+ hash=sha1_hash_if;
c->hashbuf=safe_malloc(hash->hlen, "generate_msg");
*in_ops=hash;
}
-static void rsa_pub_sethash(void *sst, struct hash_if *hash)
-{
- struct rsapub *st=sst;
- rsa_sethash(&st->common, hash, &st->ops.hash);
-}
-static void rsa_priv_sethash(void *sst, struct hash_if *hash)
-{
- struct rsapriv *st=sst;
- rsa_sethash(&st->common, hash, &st->ops.hash);
-}
+
static void rsacommon_dispose(struct rsacommon *c)
{
free(c->hashbuf);
st->cl.apply=NULL;
st->cl.interface=&st->ops;
st->ops.st=st;
- st->ops.sethash=rsa_pub_sethash;
st->common.hashbuf=NULL;
st->ops.unpick=rsa_sig_unpick;
st->ops.check=rsa_sig_check;
RSAPUB_BNS(RSAPUB_LOADCORE_GETBN)
+ rsa_sethash(l,&st->common,&st->ops.hash);
+
return st;
error_out:
st->cl.apply=NULL;
st->cl.interface=&st->ops;
st->ops.st=st;
- st->ops.sethash=rsa_priv_sethash;
st->common.hashbuf=NULL;
st->ops.sign=rsa_sign;
st->ops.hash=0;
fatal_perror("rsa-private (%s:%d): ferror",loc.file,loc.line);
}
+ rsa_sethash(l,&st->common,&st->ops.hash);
+
/*
* Now verify the validity of the key, and set up the auxiliary
* values for fast CRT signing.
if (!f) {
if (just_check_config) {
Message(M_WARNING,"rsa-private (%s:%d): cannot open keyfile "
- "\"%s\"; assuming it's valid while we check the "
- "rest of the configuration\n",loc.file,loc.line,filename);
+ "\"%s\" (%s); assuming it's valid while we check the "
+ "rest of the configuration\n",
+ loc.file,loc.line,filename,strerror(errno));
+ return list_new();
} else {
fatal_perror("rsa-private (%s:%d): cannot open file \"%s\"",
loc.file,loc.line,filename);