aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/libotr/libotr-3.2.0/src/dh.h
diff options
context:
space:
mode:
authorJay Threeth2011-04-04 11:48:26 -0700
committerJay Threeth2011-04-04 11:48:26 -0700
commit3c9cc506f741b980565ff5b3b001cd8b6ee36b12 (patch)
treecb862c57b3d5f74177cde3bd962a53fc377166f6 /linden/indra/libotr/libotr-3.2.0/src/dh.h
parentbuild fixes, might build on linux now (diff)
downloadmeta-impy-3c9cc506f741b980565ff5b3b001cd8b6ee36b12.zip
meta-impy-3c9cc506f741b980565ff5b3b001cd8b6ee36b12.tar.gz
meta-impy-3c9cc506f741b980565ff5b3b001cd8b6ee36b12.tar.bz2
meta-impy-3c9cc506f741b980565ff5b3b001cd8b6ee36b12.tar.xz
add source to libraries, and cruft for building under windows
Diffstat (limited to 'linden/indra/libotr/libotr-3.2.0/src/dh.h')
-rwxr-xr-xlinden/indra/libotr/libotr-3.2.0/src/dh.h119
1 files changed, 119 insertions, 0 deletions
diff --git a/linden/indra/libotr/libotr-3.2.0/src/dh.h b/linden/indra/libotr/libotr-3.2.0/src/dh.h
new file mode 100755
index 0000000..d68328f
--- /dev/null
+++ b/linden/indra/libotr/libotr-3.2.0/src/dh.h
@@ -0,0 +1,119 @@
1/*
2 * Off-the-Record Messaging library
3 * Copyright (C) 2004-2008 Ian Goldberg, Chris Alexander, Nikita Borisov
4 * <otr@cypherpunks.ca>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of version 2.1 of the GNU Lesser General
8 * Public License as published by the Free Software Foundation.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef __DH_H__
21#define __DH_H__
22
23#define DH1536_GROUP_ID 5
24
25typedef struct {
26 unsigned int groupid;
27 gcry_mpi_t priv, pub;
28} DH_keypair;
29
30/* Which half of the secure session id should be shown in bold? */
31typedef enum {
32 OTRL_SESSIONID_FIRST_HALF_BOLD,
33 OTRL_SESSIONID_SECOND_HALF_BOLD
34} OtrlSessionIdHalf;
35
36typedef struct {
37 unsigned char sendctr[16];
38 unsigned char rcvctr[16];
39 gcry_cipher_hd_t sendenc;
40 gcry_cipher_hd_t rcvenc;
41 gcry_md_hd_t sendmac;
42 unsigned char sendmackey[20];
43 int sendmacused;
44 gcry_md_hd_t rcvmac;
45 unsigned char rcvmackey[20];
46 int rcvmacused;
47} DH_sesskeys;
48
49/*
50 * Call this once, at plugin load time. It sets up the modulus and
51 * generator MPIs.
52 */
53void otrl_dh_init(void);
54
55/*
56 * Initialize the fields of a DH keypair.
57 */
58void otrl_dh_keypair_init(DH_keypair *kp);
59
60/*
61 * Copy a DH_keypair.
62 */
63void otrl_dh_keypair_copy(DH_keypair *dst, const DH_keypair *src);
64
65/*
66 * Deallocate the contents of a DH_keypair (but not the DH_keypair
67 * itself)
68 */
69void otrl_dh_keypair_free(DH_keypair *kp);
70
71/*
72 * Generate a DH keypair for a specified group.
73 */
74gcry_error_t otrl_dh_gen_keypair(unsigned int groupid, DH_keypair *kp);
75
76/*
77 * Construct session keys from a DH keypair and someone else's public
78 * key.
79 */
80gcry_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 */
87gcry_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 */
97gcry_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);
100
101/*
102 * Deallocate the contents of a DH_sesskeys (but not the DH_sesskeys
103 * itself)
104 */
105void otrl_dh_session_free(DH_sesskeys *sess);
106
107/*
108 * Blank out the contents of a DH_sesskeys (without releasing it)
109 */
110void otrl_dh_session_blank(DH_sesskeys *sess);
111
112/* Increment the top half of a counter block */
113void otrl_dh_incctr(unsigned char *ctr);
114
115/* Compare two counter values (8 bytes each). Return 0 if ctr1 == ctr2,
116 * < 0 if ctr1 < ctr2 (as unsigned 64-bit values), > 0 if ctr1 > ctr2. */
117int otrl_dh_cmpctr(const unsigned char *ctr1, const unsigned char *ctr2);
118
119#endif