static struct lsh_string * lsh_decode_key(struct lsh_string *contents) { struct simple_buffer buffer; enum lsh_atom type; struct verifier *v; simple_buffer_init(&buffer, STRING_LD(contents)); if (!parse_atom(&buffer, &type)) { werror("Invalid (binary) input data.\n"); return NULL; } switch (type) { case ATOM_SSH_DSS: { werror("Reading key of type ssh-dss...\n"); v = parse_ssh_dss_public(&buffer); if (!v) { werror("Invalid dsa key.\n"); return NULL; } break; } case ATOM_SSH_DSA_SHA256_LOCAL: { werror("Reading key of type ssh-dsa-sha256...\n"); v = parse_ssh_dsa_sha256_public(&buffer); if (!v) { werror("Invalid dsa-sha256 key.\n"); return NULL; } break; } case ATOM_SSH_RSA: { werror("Reading key of type ssh-rsa...\n"); v = parse_ssh_rsa_public(&buffer); if (!v) { werror("Invalid rsa key.\n"); return NULL; } break; } default: werror("Unknown key type."); return NULL; } return PUBLIC_SPKI_KEY(v, 1); }
struct sexp * spki_make_public_key(struct verifier *verifier) { return sexp_l(2, SA(PUBLIC_KEY), PUBLIC_SPKI_KEY(verifier), -1); }