From 116aa2b6bfe993ccc6e7c96fdd53674e657aee4c Mon Sep 17 00:00:00 2001 From: Alexander Vdolainen Date: Sun, 26 Jun 2016 02:51:36 +0300 Subject: [PATCH] sxt: added key export API description, some misc functions added as well; --- include/sxt/sxtkey.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/sxt/sxtkey.h b/include/sxt/sxtkey.h index 1170c81..29b2184 100644 --- a/include/sxt/sxtkey.h +++ b/include/sxt/sxtkey.h @@ -81,8 +81,39 @@ void sxt_key_free(sxtkey_t *); */ int sxt_key_generate(sxtkey_t *, int , int ); +/* generic functions useful to deal with keys */ +/* get 8bit ID from key name */ +uint8_t sxt_key_type_fname(const char *); + +/* return 0 if key isn't public, 1 otherwise */ +int sxt_key_public(const sxtkey_t *); +/* return 0 if key isn't private, 1 otherwise */ +int sxt_key_private(const sxtkey_t *); + +/* export key API */ +/** this function will pack the private key to sxt key container and + * write it to the file. + * @key - private key + * @file - file name to write + * NOTE: the following parameters required in case if you want to encrypt the key + * with passkey (password) + * @passkey - plaintext passkey + * or + * @ask_passkey with: + * @@pkbuf - passkey buffer (allocated) + * @@length - length of pkbuf + * @@confirm - if not nil - function should force passkey confirmation + * @@priv - some custom pointer to the some custom data + * @priv - the data coming to ask_passkey function + */ +int sxt_key_export_priv_file(const sxtkey_t *key, const char *file, const char *passkey, + int (*ask_passkey)(char *pkbuf, size_t length, int confirm, void *priv), + void *priv); + /* key custom hash ops */ +/* assign a 64bit hash, 0 mean there are no hash */ int sxt_key_assign_hash(sxtkey_t *, uint64_t); +/* get a 64bit hash from a key */ uint64_t sxt_key_hash(const sxtkey_t *); #endif /* __SXT_SXTKEY_H__ */