20
20
#ifndef __PRIVKEY_H__
21
21
#define __PRIVKEY_H__
25
typedef struct s_PrivKey {
29
unsigned char *pubkey_data;
30
size_t pubkey_datalen;
31
struct s_PrivKey *next;
32
struct s_PrivKey **tous;
23
#include "privkey-t.h"
36
24
#include "userstate.h"
38
26
/* Convert a 20-byte hash value to a 45-byte human-readable value */
39
void otrl_privkey_hash_to_human(char human[45], unsigned char hash[20]);
27
void otrl_privkey_hash_to_human(char human[45], const unsigned char hash[20]);
41
29
/* Calculate a human-readable hash of our DSA public key. Return it in
42
30
* the passed fingerprint buffer. Return NULL on error, or a pointer to
69
57
/* Fetch the private key from the given OtrlUserState associated with
70
58
* the given account */
71
PrivKey *otrl_privkey_find(OtrlUserState us, const char *accountname,
59
OtrlPrivKey *otrl_privkey_find(OtrlUserState us, const char *accountname,
72
60
const char *protocol);
74
62
/* Forget a private key */
75
void otrl_privkey_forget(PrivKey *privkey);
63
void otrl_privkey_forget(OtrlPrivKey *privkey);
77
65
/* Forget all private keys in a given OtrlUserState. */
78
66
void otrl_privkey_forget_all(OtrlUserState us);
68
/* Sign data using a private key. The data must be small enough to be
69
* signed (i.e. already hashed, if necessary). The signature will be
70
* returned in *sigp, which the caller must free(). Its length will be
71
* returned in *siglenp. */
72
gcry_error_t otrl_privkey_sign(unsigned char **sigp, size_t *siglenp,
73
OtrlPrivKey *privkey, const unsigned char *data, size_t len);
75
/* Verify a signature on data using a public key. The data must be
76
* small enough to be signed (i.e. already hashed, if necessary). */
77
gcry_error_t otrl_privkey_verify(const unsigned char *sigbuf, size_t siglen,
78
unsigned short pubkey_type, gcry_sexp_t pubs,
79
const unsigned char *data, size_t len);