Fri, 21 Jun 2013 14:20:33 +0530
Added autogeneration of GEnums using glib-mkenums to enums.c and enums.h
using template files enums.c.template and enums.h.template
|
34566
e0f887dee077
Split PurpleCipher into PurpleCipher and PurpleHash. Hashes will subclass PurpleHash.
Ankit Vani <a@nevitus.org>
parents:
34561
diff
changeset
|
1 | /* purple |
| 10684 | 2 | * |
| 15884 | 3 | * Purple is the legal property of its developers, whose names are too numerous |
| 10684 | 4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 5 | * source distribution. | |
| 6 | * | |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19832
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 10684 | 20 | */ |
| 21 | #include "internal.h" | |
| 22 | #include "cipher.h" | |
|
34558
2e1dc888240d
Refactored the libpurple core to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents:
34535
diff
changeset
|
23 | #include "debug.h" |
| 10684 | 24 | |
| 25 | /****************************************************************************** | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
26 | * Object Stuff |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
27 | *****************************************************************************/ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
28 | static void |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
29 | purple_cipher_class_init(PurpleCipherClass *klass) { |
|
34534
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
30 | klass->reset = NULL; |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
31 | klass->reset_state = NULL; |
|
34534
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
32 | klass->set_iv = NULL; |
|
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
33 | klass->append = NULL; |
|
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
34 | klass->digest = NULL; |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
35 | klass->get_digest_size = NULL; |
|
34534
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
36 | klass->encrypt = NULL; |
|
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
37 | klass->decrypt = NULL; |
|
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
38 | klass->set_salt = NULL; |
|
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
39 | klass->set_key = NULL; |
|
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
40 | klass->get_key_size = NULL; |
|
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
41 | klass->set_batch_mode = NULL; |
|
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
42 | klass->get_batch_mode = NULL; |
|
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
43 | klass->get_block_size = NULL; |
|
9aa25874424b
Initialized methods of PurpleCipher to NULL
Ankit Vani <a@nevitus.org>
parents:
34533
diff
changeset
|
44 | klass->get_name = NULL; |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
45 | } |
| 10684 | 46 | |
| 47 | /****************************************************************************** | |
| 15884 | 48 | * PurpleCipher API |
| 10684 | 49 | *****************************************************************************/ |
| 50 | const gchar * | |
| 15884 | 51 | purple_cipher_get_name(PurpleCipher *cipher) { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
52 | PurpleCipherClass *klass = NULL; |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
53 | |
| 10684 | 54 | g_return_val_if_fail(cipher, NULL); |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
55 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), NULL); |
| 10684 | 56 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
57 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
58 | g_return_val_if_fail(klass->get_name, NULL); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
59 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
60 | return klass->get_name(cipher); |
| 10684 | 61 | } |
| 62 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
63 | GType |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
64 | purple_cipher_get_type(void) { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
65 | static GType type = 0; |
| 10684 | 66 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
67 | if(type == 0) { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
68 | static const GTypeInfo info = { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
69 | sizeof(PurpleCipherClass), |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
70 | NULL, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
71 | NULL, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
72 | (GClassInitFunc)purple_cipher_class_init, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
73 | NULL, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
74 | NULL, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
75 | sizeof(PurpleCipher), |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
76 | 0, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
77 | NULL, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
78 | NULL |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
79 | }; |
| 10684 | 80 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
81 | type = g_type_register_static(G_TYPE_OBJECT, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
82 | "PurpleCipher", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
83 | &info, G_TYPE_FLAG_ABSTRACT); |
| 10684 | 84 | } |
| 85 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
86 | return type; |
| 10684 | 87 | } |
| 88 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
89 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
90 | * purple_cipher_reset: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
91 | * @cipher: The cipher to reset |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
92 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
93 | * Resets a cipher to it's default value |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
94 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
95 | * @note If you have set an IV you will have to set it after resetting |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
96 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
97 | void |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
98 | purple_cipher_reset(PurpleCipher *cipher) { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
99 | PurpleCipherClass *klass = NULL; |
| 10684 | 100 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
101 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
| 10684 | 102 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
103 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 104 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
105 | if(klass && klass->reset) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
106 | klass->reset(cipher); |
|
34560
d4caeb911491
Added a debug warning if a cipher's reset method was called and it isn't implemented
Ankit Vani <a@nevitus.org>
parents:
34558
diff
changeset
|
107 | else |
|
d4caeb911491
Added a debug warning if a cipher's reset method was called and it isn't implemented
Ankit Vani <a@nevitus.org>
parents:
34558
diff
changeset
|
108 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
d4caeb911491
Added a debug warning if a cipher's reset method was called and it isn't implemented
Ankit Vani <a@nevitus.org>
parents:
34558
diff
changeset
|
109 | "reset method\n", |
|
d4caeb911491
Added a debug warning if a cipher's reset method was called and it isn't implemented
Ankit Vani <a@nevitus.org>
parents:
34558
diff
changeset
|
110 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 111 | } |
| 112 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
113 | /** |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
114 | * Resets a cipher state to it's default value, but doesn't touch stateless |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
115 | * configuration. |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
116 | * |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
117 | * That means, IV and digest context will be wiped out, but keys, ops or salt |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
118 | * will remain untouched. |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
119 | */ |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
120 | void |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
121 | purple_cipher_reset_state(PurpleCipher *cipher) { |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
122 | PurpleCipherClass *klass = NULL; |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
123 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
124 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
125 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
126 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
127 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
128 | if(klass && klass->reset_state) |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
129 | klass->reset_state(cipher); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
130 | else |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
131 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
132 | "reset_state method\n", |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
133 | klass->get_name ? klass->get_name(cipher) : ""); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
134 | } |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
135 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
136 | /** |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
137 | * purple_cipher_set_iv: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
138 | * @cipher: The cipher to set the IV to |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
139 | * @iv: The initialization vector to set |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
140 | * @len: The len of the IV |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
141 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
142 | * @note This should only be called right after a cipher is created or reset |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
143 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
144 | * Sets the initialization vector for a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
145 | */ |
| 10684 | 146 | void |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
147 | purple_cipher_set_iv(PurpleCipher *cipher, guchar *iv, size_t len) |
| 10684 | 148 | { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
149 | PurpleCipherClass *klass = NULL; |
| 10684 | 150 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
151 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
152 | g_return_if_fail(iv); |
| 10684 | 153 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
154 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 155 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
156 | if(klass && klass->set_iv) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
157 | klass->set_iv(cipher, iv, len); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
158 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
159 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
160 | "set_iv method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
161 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 162 | } |
| 163 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
164 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
165 | * purple_cipher_append: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
166 | * @cipher: The cipher to append data to |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
167 | * @data: The data to append |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
168 | * @len: The length of the data |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
169 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
170 | * Appends data to the cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
171 | */ |
| 10684 | 172 | void |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
173 | purple_cipher_append(PurpleCipher *cipher, const guchar *data, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
174 | size_t len) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
175 | { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
176 | PurpleCipherClass *klass = NULL; |
|
33913
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
177 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
178 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
|
33913
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
179 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
180 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 181 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
182 | if(klass && klass->append) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
183 | klass->append(cipher, data, len); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
184 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
185 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
186 | "append method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
187 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 188 | } |
| 189 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
190 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
191 | * purple_cipher_digest: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
192 | * @cipher: The cipher to digest |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
193 | * @in_len: The length of the buffer |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
194 | * @digest: The return buffer for the digest |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
195 | * @out_len: The length of the returned value |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
196 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
197 | * Digests a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
198 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
199 | * Return Value: TRUE if the digest was successful, FALSE otherwise. |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
200 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
201 | gboolean |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
202 | purple_cipher_digest(PurpleCipher *cipher, guchar digest[], size_t len) |
| 10684 | 203 | { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
204 | PurpleCipherClass *klass = NULL; |
| 10684 | 205 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
206 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), FALSE); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
207 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
208 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 209 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
210 | if(klass && klass->digest) |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
211 | return klass->digest(cipher, digest, len); |
| 10684 | 212 | else |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
213 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
214 | "digest method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
215 | klass->get_name ? klass->get_name(cipher) : ""); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
216 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
217 | return FALSE; |
| 10684 | 218 | } |
| 219 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
220 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
221 | * purple_cipher_digest_to_str: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
222 | * @cipher: The cipher to get a digest from |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
223 | * @in_len: The length of the buffer |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
224 | * @digest_s: The return buffer for the string digest |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
225 | * @out_len: The length of the returned value |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
226 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
227 | * Converts a guchar digest into a hex string |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
228 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
229 | * Return Value: TRUE if the digest was successful, FALSE otherwise. |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
230 | */ |
| 10684 | 231 | gboolean |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
232 | purple_cipher_digest_to_str(PurpleCipher *cipher, gchar digest_s[], size_t len) |
| 10684 | 233 | { |
| 10687 | 234 | /* 8k is a bit excessive, will tweak later. */ |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11143
diff
changeset
|
235 | guchar digest[BUF_LEN * 4]; |
| 10684 | 236 | gint n = 0; |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
237 | size_t digest_size; |
| 10684 | 238 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
239 | g_return_val_if_fail(cipher, FALSE); |
| 10684 | 240 | g_return_val_if_fail(digest_s, FALSE); |
| 241 | ||
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
242 | digest_size = purple_cipher_get_digest_size(cipher); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
243 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
244 | g_return_val_if_fail(digest_size <= BUF_LEN * 4, FALSE); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
245 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
246 | if(!purple_cipher_digest(cipher, digest, sizeof(digest))) |
| 10684 | 247 | return FALSE; |
| 248 | ||
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
249 | /* Every digest byte occupies 2 chars + the NUL at the end. */ |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
250 | g_return_val_if_fail(digest_size * 2 + 1 <= len, FALSE); |
| 10684 | 251 | |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
252 | for(n = 0; n < digest_size; n++) |
| 10684 | 253 | sprintf(digest_s + (n * 2), "%02x", digest[n]); |
| 254 | ||
| 255 | digest_s[n * 2] = '\0'; | |
| 256 | ||
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
257 | return TRUE; |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
258 | } |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
259 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
260 | size_t |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
261 | purple_cipher_get_digest_size(PurpleCipher *cipher) |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
262 | { |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
263 | PurpleCipherClass *klass = NULL; |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
264 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
265 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), FALSE); |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
266 | |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
267 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
268 | |
|
34558
2e1dc888240d
Refactored the libpurple core to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents:
34535
diff
changeset
|
269 | if(klass && klass->get_digest_size) |
|
2e1dc888240d
Refactored the libpurple core to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents:
34535
diff
changeset
|
270 | return klass->get_digest_size(cipher); |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
271 | else |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
272 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
273 | "get_digest_size method\n", |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
274 | klass->get_name ? klass->get_name(cipher) : ""); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
275 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
276 | return FALSE; |
|
33909
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
277 | } |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
278 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
279 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
280 | * purple_cipher_encrypt: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
281 | * @cipher: The cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
282 | * @data: The data to encrypt |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
283 | * @len: The length of the data |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
284 | * @output: The output buffer |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
285 | * @outlen: The len of data that was outputed |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
286 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
287 | * Encrypts data using the cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
288 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
289 | * Return Value: A cipher specific status code |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
290 | */ |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
291 | ssize_t |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
292 | purple_cipher_encrypt(PurpleCipher *cipher, const guchar input[], |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
293 | size_t in_len, guchar output[], size_t out_size) |
|
33909
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
294 | { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
295 | PurpleCipherClass *klass = NULL; |
| 10684 | 296 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
297 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1); |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
298 | g_return_val_if_fail(input != NULL, -1); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
299 | g_return_val_if_fail(output != NULL, -1); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
300 | g_return_val_if_fail(out_size >= in_len, -1); |
| 10684 | 301 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
302 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 303 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
304 | if(klass && klass->encrypt) |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
305 | return klass->encrypt(cipher, input, in_len, output, out_size); |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
306 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
307 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
308 | "encrypt method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
309 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 310 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
311 | return -1; |
| 10684 | 312 | } |
| 313 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
314 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
315 | * purple_cipher_decrypt: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
316 | * @cipher: The cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
317 | * @data: The data to encrypt |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
318 | * @len: The length of the returned value |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
319 | * @output: The output buffer |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
320 | * @outlen: The len of data that was outputed |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
321 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
322 | * Decrypts data using the cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
323 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
324 | * Return Value: A cipher specific status code |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
325 | */ |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
326 | ssize_t |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
327 | purple_cipher_decrypt(PurpleCipher *cipher, const guchar input[], |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
328 | size_t in_len, guchar output[], size_t out_size) |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
329 | { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
330 | PurpleCipherClass *klass = NULL; |
| 10684 | 331 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
332 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1); |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
333 | g_return_val_if_fail(input != NULL, -1); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
334 | g_return_val_if_fail(output != NULL, -1); |
| 10684 | 335 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
336 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 337 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
338 | if(klass && klass->decrypt) |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
339 | return klass->decrypt(cipher, input, in_len, output, out_size); |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
340 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
341 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
342 | "decrypt method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
343 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 344 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
345 | return -1; |
| 10684 | 346 | } |
| 347 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
348 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
349 | * purple_cipher_set_salt: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
350 | * @cipher: The cipher whose salt to set |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
351 | * @salt: The salt |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
352 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
353 | * Sets the salt on a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
354 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
355 | void |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
356 | purple_cipher_set_salt(PurpleCipher *cipher, const guchar *salt, size_t len) { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
357 | PurpleCipherClass *klass = NULL; |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
358 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
359 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
360 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
361 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
362 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
363 | if(klass && klass->set_salt) |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
364 | klass->set_salt(cipher, salt, len); |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
365 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
366 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
367 | "set_salt method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
368 | klass->get_name ? klass->get_name(cipher) : ""); |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
369 | } |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
370 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
371 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
372 | * purple_cipher_set_key: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
373 | * @cipher: The cipher whose key to set |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
374 | * @key: The key |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
375 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
376 | * Sets the key on a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
377 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
378 | void |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
379 | purple_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len) { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
380 | PurpleCipherClass *klass = NULL; |
|
22025
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
381 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
382 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
383 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
384 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
22025
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
385 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
386 | if(klass && klass->set_key) |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
387 | klass->set_key(cipher, key, len); |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
388 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
389 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
390 | "set_key method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
391 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 392 | } |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
393 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
394 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
395 | * purple_cipher_get_key_size: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
396 | * @cipher: The cipher whose key size to get |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
397 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
398 | * Gets the key size for a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
399 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
400 | * Return Value: The size of the key |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
401 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
402 | size_t |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
403 | purple_cipher_get_key_size(PurpleCipher *cipher) { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
404 | PurpleCipherClass *klass = NULL; |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
405 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
406 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
407 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
408 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
409 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
410 | if(klass && klass->get_key_size) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
411 | return klass->get_key_size(cipher); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
412 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
413 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
414 | "get_key_size method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
415 | klass->get_name ? klass->get_name(cipher) : ""); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
416 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
417 | return -1; |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
418 | } |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
419 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
420 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
421 | * purple_cipher_set_batch_mode: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
422 | * @cipher: The cipher whose batch mode to set |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
423 | * @mode: The batch mode under which the cipher should operate |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
424 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
425 | * Sets the batch mode of a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
426 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
427 | void |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
428 | purple_cipher_set_batch_mode(PurpleCipher *cipher, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
429 | PurpleCipherBatchMode mode) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
430 | { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
431 | PurpleCipherClass *klass = NULL; |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
432 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
433 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
434 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
435 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
436 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
437 | if(klass && klass->set_batch_mode) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
438 | klass->set_batch_mode(cipher, mode); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
439 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
440 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
441 | "set_batch_mode method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
442 | klass->get_name ? klass->get_name(cipher) : ""); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
443 | } |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
444 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
445 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
446 | * purple_cipher_get_batch_mode: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
447 | * @cipher: The cipher whose batch mode to get |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
448 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
449 | * Gets the batch mode of a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
450 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
451 | * Return Value: The batch mode under which the cipher is operating |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
452 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
453 | PurpleCipherBatchMode |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
454 | purple_cipher_get_batch_mode(PurpleCipher *cipher) |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
455 | { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
456 | PurpleCipherClass *klass = NULL; |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
457 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
458 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
459 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
460 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
461 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
462 | if(klass && klass->get_batch_mode) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
463 | return klass->get_batch_mode(cipher); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
464 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
465 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
466 | "get_batch_mode method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
467 | klass->get_name ? klass->get_name(cipher) : ""); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
468 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
469 | return -1; |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
470 | } |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
471 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
472 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
473 | * purple_cipher_get_block_size: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
474 | * @cipher: The cipher whose block size to get |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
475 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
476 | * Gets the block size of a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
477 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
478 | * Return Value: The block size of the cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
479 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
480 | size_t |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
481 | purple_cipher_get_block_size(PurpleCipher *cipher) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
482 | { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
483 | PurpleCipherClass *klass = NULL; |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
484 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
485 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
486 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
487 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
488 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
489 | if(klass && klass->get_block_size) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
490 | return klass->get_block_size(cipher); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
491 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
492 | purple_debug_warning("cipher", "the %s cipher does not implement the " |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
493 | "get_block_size method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
494 | klass->get_name ? klass->get_name(cipher) : ""); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
495 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
496 | return -1; |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
497 | } |