media: Updated media patches README
[siplcs.git] / src / purple / purple-crypt.c
blobcc015ba451f508c6e0b6c5ce6d9730beefa6cfba
1 /**
2 * @file purple-crypt.c
4 * pidgin-sipe
6 * Copyright (C) 2010 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "glib.h"
24 #include "cipher.h"
26 #include "sipe-crypt.h"
28 void sipe_crypt_des(const guchar *key,
29 const guchar *plaintext, gsize plaintext_length,
30 guchar *encrypted_text)
32 gsize dummy;
33 PurpleCipherContext *context = purple_cipher_context_new_by_name("des", NULL);
34 purple_cipher_context_set_key(context, key);
35 purple_cipher_context_encrypt(context, plaintext, plaintext_length, encrypted_text, &dummy);
36 purple_cipher_context_destroy(context);
39 void sipe_crypt_rc4(const guchar *key, gsize key_length,
40 const guchar *plaintext, gsize plaintext_length,
41 guchar *encrypted_text)
43 gsize dummy;
44 PurpleCipherContext *context = purple_cipher_context_new_by_name("rc4", NULL);
45 purple_cipher_context_set_option(context, "key_len", (gpointer)key_length);
46 purple_cipher_context_set_key(context, key);
47 purple_cipher_context_encrypt(context, plaintext, plaintext_length, encrypted_text, &dummy);
48 purple_cipher_context_destroy(context);
51 /* Stream RC4 cipher for file transfer */
52 gpointer sipe_crypt_ft_start(const guchar *key)
54 PurpleCipherContext *context = purple_cipher_context_new_by_name("rc4", NULL);
55 /* only use first 16 characters of the key */
56 purple_cipher_context_set_option(context, "key_len", (gpointer)16);
57 purple_cipher_context_set_key(context, key);
58 return(context);
61 void sipe_crypt_ft_stream(gpointer context,
62 const guchar *in, gsize length,
63 guchar *out)
65 purple_cipher_context_encrypt(context, in, length, out, NULL);
68 void sipe_crypt_ft_destroy(gpointer context)
70 purple_cipher_context_destroy(context);
74 Local Variables:
75 mode: c
76 c-file-style: "bsd"
77 indent-tabs-mode: t
78 tab-width: 8
79 End: