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

« back to all changes in this revision

Viewing changes to src/dh.h

  • Committer: Bazaar Package Importer
  • Author(s): Thibaut VARENE
  • Date: 2006-01-02 19:52:18 UTC
  • mfrom: (2.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20060102195218-wb8803196y9mycx6
Tags: 3.0.0-2
Fix typo: "malformed messahes" (Closes: #345400)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    gcry_mpi_t priv, pub;
28
28
} DH_keypair;
29
29
 
 
30
/* Which half of the secure session id should be shown in bold? */
30
31
typedef enum {
31
 
    SESS_DIR_LOW,
32
 
    SESS_DIR_HIGH
33
 
} SessionDirection;
 
32
    OTRL_SESSIONID_FIRST_HALF_BOLD,
 
33
    OTRL_SESSIONID_SECOND_HALF_BOLD
 
34
} OtrlSessionIdHalf;
34
35
 
35
36
typedef struct {
36
 
    SessionDirection dir;
37
 
    unsigned char sessionid[20];
38
37
    unsigned char sendctr[16];
39
38
    unsigned char rcvctr[16];
40
39
    gcry_cipher_hd_t sendenc;
54
53
void otrl_dh_init(void);
55
54
 
56
55
/*
 
56
 * Initialize the fields of a DH keypair.
 
57
 */
 
58
void otrl_dh_keypair_init(DH_keypair *kp);
 
59
 
 
60
/*
 
61
 * Copy a DH_keypair.
 
62
 */
 
63
void otrl_dh_keypair_copy(DH_keypair *dst, const DH_keypair *src);
 
64
 
 
65
/*
57
66
 * Deallocate the contents of a DH_keypair (but not the DH_keypair
58
67
 * itself)
59
68
 */
68
77
 * Construct session keys from a DH keypair and someone else's public
69
78
 * key.
70
79
 */
71
 
gcry_error_t otrl_dh_session(DH_sesskeys *sess, DH_keypair *kp, gcry_mpi_t y);
 
80
gcry_error_t otrl_dh_session(DH_sesskeys *sess, const DH_keypair *kp,
 
81
        gcry_mpi_t y);
 
82
 
 
83
/*
 
84
 * Compute the secure session id, two encryption keys, and four MAC keys
 
85
 * given our DH key and their DH public key.
 
86
 */
 
87
gcry_error_t otrl_dh_compute_v2_auth_keys(const DH_keypair *our_dh,
 
88
        gcry_mpi_t their_pub, unsigned char *sessionid, size_t *sessionidlenp,
 
89
        gcry_cipher_hd_t *enc_c, gcry_cipher_hd_t *enc_cp,
 
90
        gcry_md_hd_t *mac_m1, gcry_md_hd_t *mac_m1p,
 
91
        gcry_md_hd_t *mac_m2, gcry_md_hd_t *mac_m2p);
 
92
 
 
93
/*
 
94
 * Compute the secure session id, given our DH key and their DH public
 
95
 * key.
 
96
 */
 
97
gcry_error_t otrl_dh_compute_v1_session_id(const DH_keypair *our_dh,
 
98
        gcry_mpi_t their_pub, unsigned char *sessionid, size_t *sessionidlenp,
 
99
        OtrlSessionIdHalf *halfp);
72
100
 
73
101
/*
74
102
 * Deallocate the contents of a DH_sesskeys (but not the DH_sesskeys
86
114
 
87
115
/* Compare two counter values (8 bytes each).  Return 0 if ctr1 == ctr2,
88
116
 * < 0 if ctr1 < ctr2 (as unsigned 64-bit values), > 0 if ctr1 > ctr2. */
89
 
int otrl_dh_cmpctr(unsigned char *ctr1, unsigned char *ctr2);
 
117
int otrl_dh_cmpctr(const unsigned char *ctr1, const unsigned char *ctr2);
90
118
 
91
119
#endif