version 1.8, 2019/11/13 07:53:10 |
version 1.9, 2020/10/19 22:49:23 |
|
|
#include "sshkey.h" |
#include "sshkey.h" |
#include "sshkey-xmss.h" |
#include "sshkey-xmss.h" |
#include "atomicio.h" |
#include "atomicio.h" |
|
#include "log.h" |
|
|
#include "xmss_fast.h" |
#include "xmss_fast.h" |
|
|
|
|
int sshkey_xmss_init_enc_key(struct sshkey *, const char *); |
int sshkey_xmss_init_enc_key(struct sshkey *, const char *); |
void sshkey_xmss_free_bds(struct sshkey *); |
void sshkey_xmss_free_bds(struct sshkey *); |
int sshkey_xmss_get_state_from_file(struct sshkey *, const char *, |
int sshkey_xmss_get_state_from_file(struct sshkey *, const char *, |
int *, sshkey_printfn *); |
int *, int); |
int sshkey_xmss_encrypt_state(const struct sshkey *, struct sshbuf *, |
int sshkey_xmss_encrypt_state(const struct sshkey *, struct sshbuf *, |
struct sshbuf **); |
struct sshbuf **); |
int sshkey_xmss_decrypt_state(const struct sshkey *, struct sshbuf *, |
int sshkey_xmss_decrypt_state(const struct sshkey *, struct sshbuf *, |
|
|
int sshkey_xmss_serialize_enc_key(const struct sshkey *, struct sshbuf *); |
int sshkey_xmss_serialize_enc_key(const struct sshkey *, struct sshbuf *); |
int sshkey_xmss_deserialize_enc_key(struct sshkey *, struct sshbuf *); |
int sshkey_xmss_deserialize_enc_key(struct sshkey *, struct sshbuf *); |
|
|
#define PRINT(s...) do { if (pr) pr(s); } while (0) |
#define PRINT(...) do { if (printerror) sshlog(__FILE__, __func__, __LINE__, \ |
|
0, SYSLOG_LEVEL_ERROR, __VA_ARGS__); } while (0) |
|
|
int |
int |
sshkey_xmss_init(struct sshkey *key, const char *name) |
sshkey_xmss_init(struct sshkey *key, const char *name) |
|
|
|
|
int |
int |
sshkey_xmss_get_state_from_file(struct sshkey *k, const char *filename, |
sshkey_xmss_get_state_from_file(struct sshkey *k, const char *filename, |
int *have_file, sshkey_printfn *pr) |
int *have_file, int printerror) |
{ |
{ |
struct sshbuf *b = NULL, *enc = NULL; |
struct sshbuf *b = NULL, *enc = NULL; |
int ret = SSH_ERR_SYSTEM_ERROR, r, fd = -1; |
int ret = SSH_ERR_SYSTEM_ERROR, r, fd = -1; |
|
|
} |
} |
|
|
int |
int |
sshkey_xmss_get_state(const struct sshkey *k, sshkey_printfn *pr) |
sshkey_xmss_get_state(const struct sshkey *k, int printerror) |
{ |
{ |
struct ssh_xmss_state *state = k->xmss_state; |
struct ssh_xmss_state *state = k->xmss_state; |
u_int32_t idx = 0; |
u_int32_t idx = 0; |
|
|
} |
} |
/* XXX no longer const */ |
/* XXX no longer const */ |
if ((r = sshkey_xmss_get_state_from_file((struct sshkey *)k, |
if ((r = sshkey_xmss_get_state_from_file((struct sshkey *)k, |
statefile, &have_state, pr)) != 0) { |
statefile, &have_state, printerror)) != 0) { |
if ((r = sshkey_xmss_get_state_from_file((struct sshkey *)k, |
if ((r = sshkey_xmss_get_state_from_file((struct sshkey *)k, |
ostatefile, &have_ostate, pr)) == 0) { |
ostatefile, &have_ostate, printerror)) == 0) { |
state->allow_update = 1; |
state->allow_update = 1; |
r = sshkey_xmss_forward_state(k, 1); |
r = sshkey_xmss_forward_state(k, 1); |
state->idx = PEEK_U32(k->xmss_sk); |
state->idx = PEEK_U32(k->xmss_sk); |
|
|
} |
} |
|
|
int |
int |
sshkey_xmss_update_state(const struct sshkey *k, sshkey_printfn *pr) |
sshkey_xmss_update_state(const struct sshkey *k, int printerror) |
{ |
{ |
struct ssh_xmss_state *state = k->xmss_state; |
struct ssh_xmss_state *state = k->xmss_state; |
struct sshbuf *b = NULL, *enc = NULL; |
struct sshbuf *b = NULL, *enc = NULL; |