~ubuntu-branches/ubuntu/oneiric/libotr/oneiric-security

« back to all changes in this revision

Viewing changes to src/privkey.h

  • Committer: Bazaar Package Importer
  • Author(s): Thibaut VARENE
  • Date: 2005-11-19 00:08:41 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20051119000841-xvh66l22yco8u2m4
Tags: 3.0.0-1
* New upstream release (closes: #337851)
* Support for OTR protocol version 2

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef __PRIVKEY_H__
21
21
#define __PRIVKEY_H__
22
22
 
23
 
#include <gcrypt.h>
24
 
 
25
 
typedef struct s_PrivKey {
26
 
    char *accountname;
27
 
    char *protocol;
28
 
    gcry_sexp_t privkey;
29
 
    unsigned char *pubkey_data;
30
 
    size_t pubkey_datalen;
31
 
    struct s_PrivKey *next;
32
 
    struct s_PrivKey **tous;
33
 
} PrivKey;
34
 
 
35
 
#include "context.h"
 
23
#include "privkey-t.h"
36
24
#include "userstate.h"
37
25
 
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]);
40
28
 
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
68
56
 
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);
73
61
 
74
62
/* Forget a private key */
75
 
void otrl_privkey_forget(PrivKey *privkey);
 
63
void otrl_privkey_forget(OtrlPrivKey *privkey);
76
64
 
77
65
/* Forget all private keys in a given OtrlUserState. */
78
66
void otrl_privkey_forget_all(OtrlUserState us);
79
67
 
 
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);
 
74
 
 
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);
 
80
 
80
81
#endif