version 1.10, 2022/10/28 00:41:17 |
version 1.11, 2022/10/28 00:41:52 |
|
|
|
|
static int |
static int |
ssh_xmss_serialize_public(const struct sshkey *key, struct sshbuf *b, |
ssh_xmss_serialize_public(const struct sshkey *key, struct sshbuf *b, |
const char *typename, enum sshkey_serialize_rep opts) |
enum sshkey_serialize_rep opts) |
{ |
{ |
int r; |
int r; |
|
|
if (key->xmss_name == NULL || key->xmss_pk == NULL || |
if (key->xmss_name == NULL || key->xmss_pk == NULL || |
sshkey_xmss_pklen(key) == 0) |
sshkey_xmss_pklen(key) == 0) |
return SSH_ERR_INVALID_ARGUMENT; |
return SSH_ERR_INVALID_ARGUMENT; |
if ((r = sshbuf_put_cstring(b, typename)) != 0 || |
if ((r = sshbuf_put_cstring(b, key->xmss_name)) != 0 || |
(r = sshbuf_put_cstring(b, key->xmss_name)) != 0 || |
|
(r = sshbuf_put_string(b, key->xmss_pk, |
(r = sshbuf_put_string(b, key->xmss_pk, |
sshkey_xmss_pklen(key))) != 0 || |
sshkey_xmss_pklen(key))) != 0 || |
(r = sshkey_xmss_serialize_pk_info(key, b, opts)) != 0) |
(r = sshkey_xmss_serialize_pk_info(key, b, opts)) != 0) |
|
|
return 0; |
return 0; |
} |
} |
|
|
|
static int |
|
ssh_xmss_deserialize_public(const char *ktype, struct sshbuf *b, |
|
struct sshkey *key) |
|
{ |
|
size_t len = 0; |
|
char *xmss_name = NULL; |
|
u_char *pk = NULL; |
|
int ret = SSH_ERR_INTERNAL_ERROR; |
|
|
|
if ((ret = sshbuf_get_cstring(b, &xmss_name, NULL)) != 0) |
|
goto out; |
|
if ((ret = sshkey_xmss_init(key, xmss_name)) != 0) |
|
goto out; |
|
if ((ret = sshbuf_get_string(b, &pk, &len)) != 0) |
|
goto out; |
|
if (len == 0 || len != sshkey_xmss_pklen(key)) { |
|
ret = SSH_ERR_INVALID_FORMAT; |
|
goto out; |
|
} |
|
key->xmss_pk = pk; |
|
pk = NULL; |
|
if (!sshkey_is_cert(key) && |
|
(ret = sshkey_xmss_deserialize_pk_info(key, b)) != 0) |
|
goto out; |
|
/* success */ |
|
ret = 0; |
|
out: |
|
free(xmss_name); |
|
freezero(pk, len); |
|
return ret; |
|
} |
|
|
int |
int |
ssh_xmss_sign(const struct sshkey *key, u_char **sigp, size_t *lenp, |
ssh_xmss_sign(const struct sshkey *key, u_char **sigp, size_t *lenp, |
const u_char *data, size_t datalen, u_int compat) |
const u_char *data, size_t datalen, u_int compat) |
|
|
/* .cleanup = */ ssh_xmss_cleanup, |
/* .cleanup = */ ssh_xmss_cleanup, |
/* .equal = */ ssh_xmss_equal, |
/* .equal = */ ssh_xmss_equal, |
/* .ssh_serialize_public = */ ssh_xmss_serialize_public, |
/* .ssh_serialize_public = */ ssh_xmss_serialize_public, |
|
/* .ssh_deserialize_public = */ ssh_xmss_deserialize_public, |
/* .generate = */ sshkey_xmss_generate_private_key, |
/* .generate = */ sshkey_xmss_generate_private_key, |
/* .copy_public = */ ssh_xmss_copy_public, |
/* .copy_public = */ ssh_xmss_copy_public, |
}; |
}; |