-int get_public_key(const char *key_file, struct asymmetric_key **result)
-{
- int ret, ret2;
- void *map;
- size_t map_size;
- unsigned char *start, *end;
- gcry_sexp_t sexp;
- struct asymmetric_key *key;
-
- ret = mmap_full_file(key_file, O_RDONLY, &map, &map_size, NULL);
- if (ret < 0)
- return ret;
- ret = is_ssh_rsa_key(map, map_size);
- if (!ret) {
- para_munmap(map, map_size);
- return -E_SSH_PARSE;
- }
- start = map + ret;
- end = map + map_size;
- ret = -E_SSH_PARSE;
- if (start >= end)
- goto unmap;
- ret = get_ssh_public_key(start, end - start, &sexp);
- if (ret < 0)
- goto unmap;
- key = para_malloc(sizeof(*key));
- key->num_bytes = ret;
- key->sexp = sexp;
- *result = key;
-unmap:
- ret2 = para_munmap(map, map_size);
- if (ret >= 0 && ret2 < 0)
- ret = ret2;
- return ret;
-}
-
-void free_public_key(struct asymmetric_key *key)