/* This file is in the public domain. */ #include #include #include #include "algs.h" #include "config.h" #include "keyfiles.h" #include "stdio-util.h" #include "priv-crypto.h" #include "hostkey.h" int read_host_key(HKALG *alg, void **pubdp, int *publp, void **privdp, int *privlp) { char *t; HKALG *fa; void *pubd; int publ; void *privd; int privl; char *comm; FILE *ef; asprintf(&t,"%s/%s",config_str("host-key-dir"),alg->hkfile); ef = fopen_null(); if (! load_key_pair(t,t,&pubd,&publ,&fa,&privd,&privl,&comm,0,ef)) { fclose(ef); return(0); } fclose(ef); free(comm); if ( (fa != alg) || !priv_unwrap(privd,privl,0,privdp,privlp,NO_PASSPHRASE) ) { free(pubd); bzero(privd,privl); free(privd); return(0); } *pubdp = pubd; *publp = publ; return(1); }