aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/libotr/libotr-3.2.0/toolkit/otr_mackey.c
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/toolkit/otr_mackey.c
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/toolkit/otr_mackey.c')
-rwxr-xr-xlinden/indra/libotr/libotr-3.2.0/toolkit/otr_mackey.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/linden/indra/libotr/libotr-3.2.0/toolkit/otr_mackey.c b/linden/indra/libotr/libotr-3.2.0/toolkit/otr_mackey.c
new file mode 100755
index 0000000..214d59b
--- /dev/null
+++ b/linden/indra/libotr/libotr-3.2.0/toolkit/otr_mackey.c
@@ -0,0 +1,65 @@
1/*
2 * Off-the-Record Messaging Toolkit
3 * Copyright (C) 2004-2008 Ian Goldberg, Chris Alexander, Nikita Borisov
4 * <otr@cypherpunks.ca>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
9 *
10 * This program 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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20/* system headers */
21#include <stdio.h>
22#include <stdlib.h>
23
24/* toolkit headers */
25#include "parse.h"
26#include "sesskeys.h"
27
28static void usage(const char *progname)
29{
30 fprintf(stderr, "Usage: %s aeskey\n"
31"Calculate and display the MAC key derived from a given AES key.\n",
32 progname);
33 exit(1);
34}
35
36int main(int argc, char **argv)
37{
38 unsigned char *argbuf;
39 size_t argbuflen;
40 unsigned char mackey[20];
41
42 if (argc != 2) {
43 usage(argv[0]);
44 }
45
46 argv_to_buf(&argbuf, &argbuflen, argv[1]);
47 /* AES keys are 128 bits long, so check for that */
48 if (!argbuf) {
49 usage(argv[0]);
50 }
51
52 if (argbuflen != 16) {
53 fprintf(stderr, "The AES key must be 32 hex chars long.\n");
54 usage(argv[0]);
55 }
56
57 sesskeys_make_mac(mackey, argbuf);
58
59 dump_data(stdout, "AES key", argbuf, 16);
60 dump_data(stdout, "MAC key", mackey, 20);
61
62 free(argbuf);
63 fflush(stdout);
64 return 0;
65}