sxt: key API becomes more printable;

master
Alexander Vdolainen 8 years ago
parent f1d7b2ae53
commit b97b9047c1

@ -67,55 +67,76 @@ typedef struct sxtsignature_type {
/* API */ /* API */
/* allocate a key */ /* allocate a key */
sxtkey_t *sxt_key_alloc(void); sxtkey_t *sxtkey_alloc(void);
/* burn i.e. zero all stuff within key structure to be /* burn i.e. zero all stuff within key structure to be
* hidden in core dump * hidden in core dump
*/ */
void sxt_key_burn(sxtkey_t *); void sxtkey_burn(sxtkey_t *);
/* free sxt key structure */ /* free sxt key structure */
void sxt_key_free(sxtkey_t *); void sxtkey_free(sxtkey_t *);
/* generate a keypair, depends on type and optional parameter given /* generate a keypair, depends on type and optional parameter given
* the last one leaved for stable API, current ed25519 keys doesn't * the last one leaved for stable API, current ed25519 keys doesn't
* need them * need them
*/ */
int sxt_key_generate(sxtkey_t *, int , int ); int sxtkey_generate(sxtkey_t *, int , int );
/* generic functions useful to deal with keys */ /* generic functions useful to deal with keys */
/* get 8bit ID from key name */ /* get 8bit ID from key name */
uint8_t sxt_key_type_fname(const char *); uint8_t sxtkey_type_fname(const char *);
/* get cstring name from type of the key */ /* get cstring name from type of the key */
const char *sxt_key_name(int); const char *sxtkey_name(int);
/* return 0 if key isn't public, 1 otherwise */ /* return 0 if key isn't public, 1 otherwise */
int sxt_key_public(const sxtkey_t *); int sxtkey_public(const sxtkey_t *);
/* return 0 if key isn't private, 1 otherwise */ /* return 0 if key isn't private, 1 otherwise */
int sxt_key_private(const sxtkey_t *); int sxtkey_private(const sxtkey_t *);
/* duplication/convertion API */ /* duplication/convertion API */
/* will duplicate a key depends on it's kind */ /* will duplicate a key depends on it's kind */
int sxt_key_dup(const sxtkey_t *, sxtkey_t **); int sxtkey_dup(const sxtkey_t *, sxtkey_t **);
/* will duplicate public key, if key was private or pair - it becomes public */ /* will duplicate public key, if key was private or pair - it becomes public */
int sxt_key_dup_public(const sxtkey_t *, sxtkey_t **); int sxtkey_dup_public(const sxtkey_t *, sxtkey_t **);
/* will duplicate private key, if key public error will returns */ /* will duplicate private key, if key public error will returns */
int sxt_key_dup_private(const sxtkey_t *, sxtkey_t **); int sxtkey_dup_private(const sxtkey_t *, sxtkey_t **);
/* import key API */ /* import key API */
/* import a private key, /* import a private key,
* the most parameters the same as for export * the most parameters the same as for export
*/ */
int sxt_key_import_priv_file(const char *file, const char *passkey, int sxtkey_import_priv_file(const char *file, const char *passkey,
int (*ask_passkey)(char *pkbuf, size_t length, int confirm, void *priv), int (*ask_passkey)(char *pkbuf, size_t length, int confirm, void *priv),
void *priv, sxtkey_t **ik); void *priv, sxtkey_t **ik);
/* import a public key from a given file */ /* import a public key from a given file */
int sxt_key_import_public_file(const char *file, sxtkey_t **ik); int sxtkey_import_public_file(const char *file, sxtkey_t **ik);
/* some useful functions to import keys */
/* import public key from base64 blob, ctrl_hash is a hash
* for control of decoding
*/
int sxtkey_pubkey_import_fbase64blob(const char *b64b, uint8_t keytype,
uint64_t ctrl_hash, sxtkey_t **ik);
/* import a private key from base64 blob
* with passkey related pointers (required in case of encrypted key,
* SXT_EAUTH will returned if no passed or passkey invalid)
*/
int sxtkey_privkey_import_fbase64blob(const char *b64pk, uint8_t keytype,
int (*ask_passkey)(char *pkbuf, size_t length,
int confirm, void *priv),
void *priv, sxtkey_t **ik);
int sxtkey_privkey_import_rdbuf(sxtrdb_t *buf, uint8_t keytype,
int (*ask_passkey)(char *pkbuf, size_t length,
int confirm, void *priv),
void *priv, sxtkey_t **ik);
/* export key API */ /* export key API */
/** this function will pack the private key to sxt key container and /** this function will pack the private key to sxt key container and
@ -133,17 +154,17 @@ int sxt_key_import_public_file(const char *file, sxtkey_t **ik);
* @@priv - some custom pointer to the some custom data * @@priv - some custom pointer to the some custom data
* @priv - the data coming to ask_passkey function * @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 sxtkey_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), int (*ask_passkey)(char *pkbuf, size_t length, int confirm, void *priv),
void *priv); void *priv);
/* export a public key to a given file */ /* export a public key to a given file */
int sxt_key_export_public_file(const sxtkey_t *key, const char *file); int sxtkey_export_public_file(const sxtkey_t *key, const char *file);
/* key custom hash ops */ /* key custom hash ops */
/* assign a 64bit hash, 0 mean there are no hash */ /* assign a 64bit hash, 0 mean there are no hash */
int sxt_key_assign_hash(sxtkey_t *, uint64_t); int sxtkey_assign_hash(sxtkey_t *, uint64_t);
/* get a 64bit hash from a key */ /* get a 64bit hash from a key */
uint64_t sxt_key_hash(const sxtkey_t *); uint64_t sxtkey_hash(const sxtkey_t *);
#endif /* __SXT_SXTKEY_H__ */ #endif /* __SXT_SXTKEY_H__ */

Loading…
Cancel
Save