RSApub* readpublickey(Biobuf *b, char **sp) { char *s; RSApub *key; key = rsapuballoc(); if(key == nil) return nil; for(;;){ if((s = Brdstr(b, '\n', 1)) == nil){ rsapubfree(key); return nil; } if(s[0]=='#'){ free(s); continue; } if(parsepubkey(s, key, sp, 10)==0 || parsepubkey(s, key, sp, 16)==0) return key; fprint(2, "warning: skipping line '%s'; cannot parse\n", s); free(s); } }
static void* rsa_str2pk(char *str, char **strp) { RSApub *rsa; char *p; rsa = rsapuballoc(); rsa->n = base64tobig(str, &p); rsa->ek = base64tobig(p, &p); if(strp) *strp = p; return rsa; }