Sun, 11 Aug 2013 21:19:33 +0530
Better wording for ABI mismatch error
|
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 | /****************************************************************************** | |
| 15884 | 26 | * PurpleCipher API |
| 10684 | 27 | *****************************************************************************/ |
| 28 | const gchar * | |
| 15884 | 29 | purple_cipher_get_name(PurpleCipher *cipher) { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
30 | PurpleCipherClass *klass = NULL; |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
31 | |
| 10684 | 32 | g_return_val_if_fail(cipher, NULL); |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
33 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), NULL); |
| 10684 | 34 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
35 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
36 | g_return_val_if_fail(klass->get_name, NULL); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
37 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
38 | return klass->get_name(cipher); |
| 10684 | 39 | } |
| 40 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
41 | GType |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
42 | purple_cipher_get_type(void) { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
43 | static GType type = 0; |
| 10684 | 44 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
45 | if(type == 0) { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
46 | static const GTypeInfo info = { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
47 | sizeof(PurpleCipherClass), |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
48 | NULL, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
49 | NULL, |
|
34650
fcc35d976057
Removed unnecessary class init for PurpleCipher
Ankit Vani <a@nevitus.org>
parents:
34597
diff
changeset
|
50 | NULL, |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
51 | NULL, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
52 | NULL, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
53 | sizeof(PurpleCipher), |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
54 | 0, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
55 | NULL, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
56 | NULL |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
57 | }; |
| 10684 | 58 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
59 | type = g_type_register_static(G_TYPE_OBJECT, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
60 | "PurpleCipher", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
61 | &info, G_TYPE_FLAG_ABSTRACT); |
| 10684 | 62 | } |
| 63 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
64 | return type; |
| 10684 | 65 | } |
| 66 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
67 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
68 | * purple_cipher_reset: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
69 | * @cipher: The cipher to reset |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
70 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
71 | * Resets a cipher to it's default value |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
72 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
73 | * @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
|
74 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
75 | void |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
76 | purple_cipher_reset(PurpleCipher *cipher) { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
77 | PurpleCipherClass *klass = NULL; |
| 10684 | 78 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
79 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
| 10684 | 80 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
81 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 82 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
83 | if(klass && klass->reset) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
84 | 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
|
85 | 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
|
86 | 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
|
87 | "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
|
88 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 89 | } |
| 90 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
91 | /** |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
92 | * 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
|
93 | * configuration. |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
94 | * |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
95 | * 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
|
96 | * will remain untouched. |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
97 | */ |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
98 | void |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
99 | 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
|
100 | PurpleCipherClass *klass = NULL; |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
101 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
102 | 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
|
103 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
104 | 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
|
105 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
106 | if(klass && klass->reset_state) |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
107 | klass->reset_state(cipher); |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
108 | else |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
109 | 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
|
110 | "reset_state method\n", |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
111 | 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
|
112 | } |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
113 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
114 | /** |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
115 | * purple_cipher_set_iv: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
116 | * @cipher: The cipher to set the IV to |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
117 | * @iv: The initialization vector to set |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
118 | * @len: The len of the IV |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
119 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
120 | * @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
|
121 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
122 | * Sets the initialization vector for a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
123 | */ |
| 10684 | 124 | void |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
125 | purple_cipher_set_iv(PurpleCipher *cipher, guchar *iv, size_t len) |
| 10684 | 126 | { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
127 | PurpleCipherClass *klass = NULL; |
| 10684 | 128 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
129 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
130 | g_return_if_fail(iv); |
| 10684 | 131 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
132 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 133 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
134 | if(klass && klass->set_iv) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
135 | klass->set_iv(cipher, iv, len); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
136 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
137 | 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
|
138 | "set_iv method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
139 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 140 | } |
| 141 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
142 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
143 | * purple_cipher_append: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
144 | * @cipher: The cipher to append data to |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
145 | * @data: The data to append |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
146 | * @len: The length of the data |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
147 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
148 | * Appends data to the cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
149 | */ |
| 10684 | 150 | void |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
151 | purple_cipher_append(PurpleCipher *cipher, const guchar *data, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
152 | size_t len) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
153 | { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
154 | PurpleCipherClass *klass = NULL; |
|
33913
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
155 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
156 | 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
|
157 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
158 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 159 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
160 | if(klass && klass->append) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
161 | klass->append(cipher, data, len); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
162 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
163 | 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
|
164 | "append method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
165 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 166 | } |
| 167 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
168 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
169 | * purple_cipher_digest: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
170 | * @cipher: The cipher to digest |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
171 | * @in_len: The length of the buffer |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
172 | * @digest: The return buffer for the digest |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
173 | * @out_len: The length of the returned value |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
174 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
175 | * Digests a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
176 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
177 | * Return Value: TRUE if the digest was successful, FALSE otherwise. |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
178 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
179 | gboolean |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
180 | purple_cipher_digest(PurpleCipher *cipher, guchar digest[], size_t len) |
| 10684 | 181 | { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
182 | PurpleCipherClass *klass = NULL; |
| 10684 | 183 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
184 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), FALSE); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
185 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
186 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 187 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
188 | if(klass && klass->digest) |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
189 | return klass->digest(cipher, digest, len); |
| 10684 | 190 | else |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
191 | 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
|
192 | "digest method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
193 | klass->get_name ? klass->get_name(cipher) : ""); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
194 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
195 | return FALSE; |
| 10684 | 196 | } |
| 197 | ||
|
34533
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 | * purple_cipher_digest_to_str: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
200 | * @cipher: The cipher to get a digest from |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
201 | * @in_len: The length of the buffer |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
202 | * @digest_s: The return buffer for the string digest |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
203 | * @out_len: The length of the returned value |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
204 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
205 | * Converts a guchar digest into a hex string |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
206 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
207 | * Return Value: TRUE if the digest was successful, FALSE otherwise. |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
208 | */ |
| 10684 | 209 | gboolean |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
210 | purple_cipher_digest_to_str(PurpleCipher *cipher, gchar digest_s[], size_t len) |
| 10684 | 211 | { |
| 10687 | 212 | /* 8k is a bit excessive, will tweak later. */ |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
11143
diff
changeset
|
213 | guchar digest[BUF_LEN * 4]; |
| 10684 | 214 | gint n = 0; |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
215 | size_t digest_size; |
| 10684 | 216 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
217 | g_return_val_if_fail(cipher, FALSE); |
| 10684 | 218 | g_return_val_if_fail(digest_s, FALSE); |
| 219 | ||
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
220 | 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
|
221 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
222 | 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
|
223 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
224 | if(!purple_cipher_digest(cipher, digest, sizeof(digest))) |
| 10684 | 225 | return FALSE; |
| 226 | ||
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
227 | /* 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
|
228 | g_return_val_if_fail(digest_size * 2 + 1 <= len, FALSE); |
| 10684 | 229 | |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
230 | for(n = 0; n < digest_size; n++) |
| 10684 | 231 | sprintf(digest_s + (n * 2), "%02x", digest[n]); |
| 232 | ||
| 233 | digest_s[n * 2] = '\0'; | |
| 234 | ||
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
235 | return TRUE; |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
236 | } |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
237 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
238 | size_t |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
239 | 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
|
240 | { |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
241 | PurpleCipherClass *klass = NULL; |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
242 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
243 | 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
|
244 | |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
245 | 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
|
246 | |
|
34558
2e1dc888240d
Refactored the libpurple core to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents:
34535
diff
changeset
|
247 | 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
|
248 | 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
|
249 | else |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
250 | 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
|
251 | "get_digest_size method\n", |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
252 | 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
|
253 | |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
254 | return FALSE; |
|
33909
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
255 | } |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
256 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
257 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
258 | * purple_cipher_encrypt: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
259 | * @cipher: The cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
260 | * @data: The data to encrypt |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
261 | * @len: The length of the data |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
262 | * @output: The output buffer |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
263 | * @outlen: The len of data that was outputed |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
264 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
265 | * Encrypts data using the cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
266 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
267 | * Return Value: A cipher specific status code |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
268 | */ |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
269 | ssize_t |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
270 | 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
|
271 | 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
|
272 | { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
273 | PurpleCipherClass *klass = NULL; |
| 10684 | 274 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
275 | 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
|
276 | 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
|
277 | 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
|
278 | g_return_val_if_fail(out_size >= in_len, -1); |
| 10684 | 279 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
280 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 281 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
282 | if(klass && klass->encrypt) |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
283 | 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
|
284 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
285 | 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
|
286 | "encrypt method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
287 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 288 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
289 | return -1; |
| 10684 | 290 | } |
| 291 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
292 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
293 | * purple_cipher_decrypt: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
294 | * @cipher: The cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
295 | * @data: The data to encrypt |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
296 | * @len: The length of the returned value |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
297 | * @output: The output buffer |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
298 | * @outlen: The len of data that was outputed |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
299 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
300 | * Decrypts data using the cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
301 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
302 | * Return Value: A cipher specific status code |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
303 | */ |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
304 | ssize_t |
|
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
305 | 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
|
306 | 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
|
307 | { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
308 | PurpleCipherClass *klass = NULL; |
| 10684 | 309 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
310 | 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
|
311 | 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
|
312 | g_return_val_if_fail(output != NULL, -1); |
| 10684 | 313 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
314 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
| 10684 | 315 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
316 | if(klass && klass->decrypt) |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
317 | 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
|
318 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
319 | 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
|
320 | "decrypt method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
321 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 322 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
323 | return -1; |
| 10684 | 324 | } |
| 325 | ||
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
326 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
327 | * purple_cipher_set_salt: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
328 | * @cipher: The cipher whose salt to set |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
329 | * @salt: The salt |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
330 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
331 | * Sets the salt on a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
332 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
333 | void |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
334 | 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
|
335 | PurpleCipherClass *klass = NULL; |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
336 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
337 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
338 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
339 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
340 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
341 | 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
|
342 | klass->set_salt(cipher, salt, len); |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
343 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
344 | 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
|
345 | "set_salt method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
346 | klass->get_name ? klass->get_name(cipher) : ""); |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
347 | } |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
348 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
349 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
350 | * purple_cipher_set_key: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
351 | * @cipher: The cipher whose key to set |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
352 | * @key: The key |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
353 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
354 | * Sets the key on a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
355 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
356 | void |
|
34535
f8fd1c60c22a
Merged PurpleCipher structure with the one in default branch
Ankit Vani <a@nevitus.org>
parents:
34534
diff
changeset
|
357 | 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
|
358 | PurpleCipherClass *klass = NULL; |
|
22025
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
359 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
360 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
361 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
362 | 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
|
363 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
364 | 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
|
365 | klass->set_key(cipher, key, len); |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
366 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
367 | 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
|
368 | "set_key method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
369 | klass->get_name ? klass->get_name(cipher) : ""); |
| 10684 | 370 | } |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
371 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
372 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
373 | * purple_cipher_get_key_size: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
374 | * @cipher: The cipher whose key size to get |
|
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 | * Gets the key size for 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 | * Return Value: The size of the key |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
379 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
380 | size_t |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
381 | purple_cipher_get_key_size(PurpleCipher *cipher) { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
382 | PurpleCipherClass *klass = NULL; |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
383 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
384 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
385 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
386 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
387 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
388 | if(klass && klass->get_key_size) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
389 | return klass->get_key_size(cipher); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
390 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
391 | 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
|
392 | "get_key_size method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
393 | klass->get_name ? klass->get_name(cipher) : ""); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
394 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
395 | return -1; |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
396 | } |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
397 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
398 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
399 | * purple_cipher_set_batch_mode: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
400 | * @cipher: The cipher whose batch mode to set |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
401 | * @mode: The batch mode under which the cipher should operate |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
402 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
403 | * Sets the batch mode of a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
404 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
405 | void |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
406 | purple_cipher_set_batch_mode(PurpleCipher *cipher, |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
407 | PurpleCipherBatchMode mode) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
408 | { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
409 | PurpleCipherClass *klass = NULL; |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
410 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
411 | g_return_if_fail(PURPLE_IS_CIPHER(cipher)); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
412 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
413 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
414 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
415 | if(klass && klass->set_batch_mode) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
416 | klass->set_batch_mode(cipher, mode); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
417 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
418 | 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
|
419 | "set_batch_mode method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
420 | klass->get_name ? klass->get_name(cipher) : ""); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
421 | } |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
422 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
423 | /** |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
424 | * purple_cipher_get_batch_mode: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
425 | * @cipher: The cipher whose batch mode to get |
|
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 | * Gets the batch mode of a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
428 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
429 | * 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
|
430 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
431 | PurpleCipherBatchMode |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
432 | purple_cipher_get_batch_mode(PurpleCipher *cipher) |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
433 | { |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
434 | PurpleCipherClass *klass = NULL; |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
435 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
436 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
437 | |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
438 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
439 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
440 | if(klass && klass->get_batch_mode) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
441 | return klass->get_batch_mode(cipher); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
442 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
443 | 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
|
444 | "get_batch_mode method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
445 | klass->get_name ? klass->get_name(cipher) : ""); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
446 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
447 | return -1; |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
448 | } |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
449 | |
|
34533
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 | * purple_cipher_get_block_size: |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
452 | * @cipher: The cipher whose block size to get |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
453 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
454 | * Gets the block size of a cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
455 | * |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
456 | * Return Value: The block size of the cipher |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
457 | */ |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
458 | size_t |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
459 | purple_cipher_get_block_size(PurpleCipher *cipher) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
460 | { |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
461 | PurpleCipherClass *klass = NULL; |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
462 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
463 | g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
464 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
465 | klass = PURPLE_CIPHER_GET_CLASS(cipher); |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
466 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
467 | if(klass && klass->get_block_size) |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
468 | return klass->get_block_size(cipher); |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
469 | else |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
470 | 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
|
471 | "get_block_size method\n", |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
472 | klass->get_name ? klass->get_name(cipher) : ""); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
11677
diff
changeset
|
473 | |
|
34533
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
474 | return -1; |
|
74b179b1e8ef
GObjectify the PurpleCipher structure
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
475 | } |