Fri, 31 Jan 2014 18:14:33 +0530
Initial replacements for gtk-doc style comments
| 34182 | 1 | /* |
| 2 | * purple | |
| 3 | * | |
| 4 | * Purple is the legal property of its developers, whose names are too numerous | |
| 5 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | |
| 21 | * | |
| 22 | * Written by Tomek Wasilczyk <tomkiewicz@cpw.pidgin.im> | |
| 23 | */ | |
| 24 | ||
|
35026
fde23518e1e5
Moved PurpleHash to cipher.[ch]
Ankit Vani <a@nevitus.org>
parents:
35020
diff
changeset
|
25 | #include "internal.h" |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
26 | #include "glibcompat.h" |
|
35026
fde23518e1e5
Moved PurpleHash to cipher.[ch]
Ankit Vani <a@nevitus.org>
parents:
35020
diff
changeset
|
27 | |
|
34566
e0f887dee077
Split PurpleCipher into PurpleCipher and PurpleHash. Hashes will subclass PurpleHash.
Ankit Vani <a@nevitus.org>
parents:
34547
diff
changeset
|
28 | #include "aescipher.h" |
| 34182 | 29 | #include "debug.h" |
|
34644
368d270dc0c3
Included enums.h in AES, DES and DES3 cipher to use the PURPLE_TYPE_BATCH_MODE GType for batch_mode property
Ankit Vani <a@nevitus.org>
parents:
34566
diff
changeset
|
30 | #include "enums.h" |
| 34182 | 31 | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
32 | #include <string.h> |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
33 | |
| 34182 | 34 | #if defined(HAVE_GNUTLS) |
| 35 | # define PURPLE_AES_USE_GNUTLS 1 | |
| 36 | # include <gnutls/gnutls.h> | |
| 37 | # include <gnutls/crypto.h> | |
| 38 | #elif defined(HAVE_NSS) | |
| 39 | # define PURPLE_AES_USE_NSS 1 | |
| 40 | # include <nss.h> | |
| 41 | # include <pk11pub.h> | |
| 42 | # include <prerror.h> | |
| 43 | #else | |
| 44 | # error "No GnuTLS or NSS support" | |
| 45 | #endif | |
| 46 | ||
| 47 | /* 128bit */ | |
| 48 | #define PURPLE_AES_BLOCK_SIZE 16 | |
| 49 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
50 | /****************************************************************************** |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
51 | * Structs |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
52 | *****************************************************************************/ |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
53 | #define PURPLE_AES_CIPHER_GET_PRIVATE(obj) \ |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
54 | (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_AES_CIPHER, PurpleAESCipherPrivate)) |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
55 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
56 | typedef struct { |
| 34182 | 57 | guchar iv[PURPLE_AES_BLOCK_SIZE]; |
| 58 | guchar key[32]; | |
| 59 | guint key_size; | |
| 60 | gboolean failure; | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
61 | } PurpleAESCipherPrivate; |
| 34182 | 62 | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
63 | /****************************************************************************** |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
64 | * Enums |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
65 | *****************************************************************************/ |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
66 | enum { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
67 | PROP_NONE, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
68 | PROP_BATCH_MODE, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
69 | PROP_IV, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
70 | PROP_KEY, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
71 | PROP_LAST, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
72 | }; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
73 | |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
74 | /******************************************************************************* |
|
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
75 | * Globals |
|
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
76 | ******************************************************************************/ |
|
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
77 | static GParamSpec *properties[PROP_LAST]; |
|
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
78 | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
79 | /****************************************************************************** |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
80 | * Cipher Stuff |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
81 | *****************************************************************************/ |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
82 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
83 | typedef gboolean (*purple_aes_cipher_crypt_func)( |
| 34182 | 84 | const guchar *input, guchar *output, size_t len, |
| 85 | guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size); | |
| 86 | ||
| 87 | static void | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
88 | purple_aes_cipher_reset(PurpleCipher *cipher) |
| 34182 | 89 | { |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
90 | PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher); |
| 34182 | 91 | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
92 | g_return_if_fail(priv != NULL); |
| 34182 | 93 | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
94 | memset(priv->iv, 0, sizeof(priv->iv)); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
95 | memset(priv->key, 0, sizeof(priv->key)); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
96 | priv->key_size = 32; /* 256bit */ |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
97 | priv->failure = FALSE; |
| 34182 | 98 | } |
| 99 | ||
| 100 | static void | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
101 | purple_aes_cipher_set_iv(PurpleCipher *cipher, guchar *iv, size_t len) |
| 34182 | 102 | { |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
103 | PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher); |
| 34182 | 104 | |
| 105 | if ((len > 0 && iv == NULL) || | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
106 | (len != 0 && len != sizeof(priv->iv))) { |
| 34182 | 107 | purple_debug_error("cipher-aes", "invalid IV length\n"); |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
108 | priv->failure = TRUE; |
| 34182 | 109 | return; |
| 110 | } | |
| 111 | ||
| 112 | if (len == 0) | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
113 | memset(priv->iv, 0, sizeof(priv->iv)); |
| 34182 | 114 | else |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
115 | memcpy(priv->iv, iv, len); |
|
35065
2fe1b3f20c3c
Added a few missing G_PARAM_STATIC_STRINGS and g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35062
diff
changeset
|
116 | |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
117 | g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_IV]); |
| 34182 | 118 | } |
| 119 | ||
| 120 | static void | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
121 | purple_aes_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len) |
| 34182 | 122 | { |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
123 | PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher); |
| 34182 | 124 | |
| 125 | if ((len > 0 && key == NULL) || | |
| 126 | (len != 0 && len != 16 && len != 24 && len != 32)) { | |
| 127 | purple_debug_error("cipher-aes", "invalid key length\n"); | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
128 | priv->failure = TRUE; |
| 34182 | 129 | return; |
| 130 | } | |
| 131 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
132 | priv->key_size = len; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
133 | memset(priv->key, 0, sizeof(priv->key)); |
| 34182 | 134 | if (len > 0) |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
135 | memcpy(priv->key, key, len); |
|
35065
2fe1b3f20c3c
Added a few missing G_PARAM_STATIC_STRINGS and g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35062
diff
changeset
|
136 | |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
137 | g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_KEY]); |
| 34182 | 138 | } |
| 139 | ||
| 140 | static guchar * | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
141 | purple_aes_cipher_pad_pkcs7(const guchar input[], size_t in_len, size_t *out_len) |
| 34182 | 142 | { |
| 143 | int padding_len, total_len; | |
| 144 | guchar *padded; | |
| 145 | ||
| 146 | g_return_val_if_fail(input != NULL, NULL); | |
| 147 | g_return_val_if_fail(out_len != NULL, NULL); | |
| 148 | ||
| 149 | padding_len = PURPLE_AES_BLOCK_SIZE - (in_len % PURPLE_AES_BLOCK_SIZE); | |
| 150 | total_len = in_len + padding_len; | |
| 151 | g_assert((total_len % PURPLE_AES_BLOCK_SIZE) == 0); | |
| 152 | ||
| 153 | padded = g_new(guchar, total_len); | |
| 154 | *out_len = total_len; | |
| 155 | ||
| 156 | memcpy(padded, input, in_len); | |
| 157 | memset(padded + in_len, padding_len, padding_len); | |
| 158 | ||
| 159 | return padded; | |
| 160 | } | |
| 161 | ||
| 162 | static ssize_t | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
163 | purple_aes_cipher_unpad_pkcs7(guchar input[], size_t in_len) |
| 34182 | 164 | { |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34275
diff
changeset
|
165 | guchar padding_len, i; |
| 34182 | 166 | size_t out_len; |
| 167 | ||
| 168 | g_return_val_if_fail(input != NULL, -1); | |
| 169 | g_return_val_if_fail(in_len > 0, -1); | |
| 170 | ||
| 171 | padding_len = input[in_len - 1]; | |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34275
diff
changeset
|
172 | if (padding_len == 0 || padding_len > PURPLE_AES_BLOCK_SIZE || |
| 34182 | 173 | padding_len > in_len) { |
| 174 | purple_debug_warning("cipher-aes", | |
|
34275
a6ddc53d1c84
Fix minor printf format warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34250
diff
changeset
|
175 | "Invalid padding length: %d (total %" G_GSIZE_FORMAT ") - " |
| 34182 | 176 | "most probably, the key was invalid\n", |
| 177 | padding_len, in_len); | |
| 178 | return -1; | |
| 179 | } | |
| 180 | ||
| 181 | out_len = in_len - padding_len; | |
| 182 | for (i = 0; i < padding_len; i++) { | |
| 183 | if (input[out_len + i] != padding_len) { | |
| 184 | purple_debug_warning("cipher-aes", | |
| 185 | "Padding doesn't match at pos %d (found %02x, " | |
| 186 | "expected %02x) - " | |
| 187 | "most probably, the key was invalid\n", | |
| 188 | i, input[out_len + i], padding_len); | |
| 189 | return -1; | |
| 190 | } | |
| 191 | } | |
| 192 | ||
| 193 | memset(input + out_len, 0, padding_len); | |
| 194 | return out_len; | |
| 195 | } | |
| 196 | ||
| 197 | #ifdef PURPLE_AES_USE_GNUTLS | |
| 198 | ||
| 199 | static gnutls_cipher_hd_t | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
200 | purple_aes_cipher_gnutls_crypt_init(guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], |
| 34182 | 201 | guint key_size) |
| 202 | { | |
| 203 | gnutls_cipher_hd_t handle; | |
| 204 | gnutls_cipher_algorithm_t algorithm; | |
| 205 | gnutls_datum_t key_info, iv_info; | |
| 206 | int ret; | |
| 207 | ||
| 208 | if (key_size == 16) | |
| 209 | algorithm = GNUTLS_CIPHER_AES_128_CBC; | |
| 210 | else if (key_size == 24) | |
| 211 | algorithm = GNUTLS_CIPHER_AES_192_CBC; | |
| 212 | else if (key_size == 32) | |
| 213 | algorithm = GNUTLS_CIPHER_AES_256_CBC; | |
| 214 | else | |
| 215 | g_return_val_if_reached(NULL); | |
| 216 | ||
| 217 | key_info.data = key; | |
| 218 | key_info.size = key_size; | |
| 219 | ||
| 220 | iv_info.data = iv; | |
| 221 | iv_info.size = PURPLE_AES_BLOCK_SIZE; | |
| 222 | ||
| 223 | ret = gnutls_cipher_init(&handle, algorithm, &key_info, &iv_info); | |
| 224 | if (ret != 0) { | |
| 225 | purple_debug_error("cipher-aes", | |
| 226 | "gnutls_cipher_init failed: %d\n", ret); | |
| 227 | return NULL; | |
| 228 | } | |
| 229 | ||
| 230 | return handle; | |
| 231 | } | |
| 232 | ||
| 233 | static gboolean | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
234 | purple_aes_cipher_gnutls_encrypt(const guchar *input, guchar *output, size_t len, |
| 34182 | 235 | guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size) |
| 236 | { | |
| 237 | gnutls_cipher_hd_t handle; | |
| 238 | int ret; | |
| 239 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
240 | handle = purple_aes_cipher_gnutls_crypt_init(iv, key, key_size); |
| 34182 | 241 | if (handle == NULL) |
| 242 | return FALSE; | |
| 243 | ||
| 34758 | 244 | ret = gnutls_cipher_encrypt2(handle, (guchar *)input, len, output, len); |
| 34182 | 245 | gnutls_cipher_deinit(handle); |
| 246 | ||
| 247 | if (ret != 0) { | |
| 248 | purple_debug_error("cipher-aes", | |
| 249 | "gnutls_cipher_encrypt2 failed: %d\n", ret); | |
| 250 | return FALSE; | |
| 251 | } | |
| 252 | ||
| 253 | return TRUE; | |
| 254 | } | |
| 255 | ||
| 256 | static gboolean | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
257 | purple_aes_cipher_gnutls_decrypt(const guchar *input, guchar *output, size_t len, |
| 34182 | 258 | guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size) |
| 259 | { | |
| 260 | gnutls_cipher_hd_t handle; | |
| 261 | int ret; | |
| 262 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
263 | handle = purple_aes_cipher_gnutls_crypt_init(iv, key, key_size); |
| 34182 | 264 | if (handle == NULL) |
| 265 | return FALSE; | |
| 266 | ||
| 267 | ret = gnutls_cipher_decrypt2(handle, input, len, output, len); | |
| 268 | gnutls_cipher_deinit(handle); | |
| 269 | ||
| 270 | if (ret != 0) { | |
| 271 | purple_debug_error("cipher-aes", | |
| 272 | "gnutls_cipher_decrypt2 failed: %d\n", ret); | |
| 273 | return FALSE; | |
| 274 | } | |
| 275 | ||
| 276 | return TRUE; | |
| 277 | } | |
| 278 | ||
|
34250
1625de486023
Fix pre-processing directives to consistently only inclde code that will be used.
Daniel Atallah <datallah@pidgin.im>
parents:
34248
diff
changeset
|
279 | #elif defined(PURPLE_AES_USE_NSS) |
| 34182 | 280 | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
281 | typedef struct { |
| 34182 | 282 | PK11SlotInfo *slot; |
| 283 | PK11SymKey *sym_key; | |
| 284 | SECItem *sec_param; | |
| 285 | PK11Context *enc_context; | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
286 | } PurpleAESCipherNSSContext; |
| 34182 | 287 | |
| 288 | static void | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
289 | purple_aes_cipher_nss_cleanup(PurpleAESCipherNSSContext *context) |
| 34182 | 290 | { |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
291 | g_return_if_fail(context != NULL); |
| 34182 | 292 | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
293 | if (context->enc_context != NULL) |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
294 | PK11_DestroyContext(context->enc_context, TRUE); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
295 | if (context->sec_param != NULL) |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
296 | SECITEM_FreeItem(context->sec_param, TRUE); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
297 | if (context->sym_key != NULL) |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
298 | PK11_FreeSymKey(context->sym_key); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
299 | if (context->slot != NULL) |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
300 | PK11_FreeSlot(context->slot); |
| 34182 | 301 | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
302 | memset(context, 0, sizeof(PurpleAESCipherNSSContext)); |
| 34182 | 303 | } |
| 304 | ||
| 305 | static gboolean | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
306 | purple_aes_cipher_nss_crypt(const guchar *input, guchar *output, size_t len, |
| 34182 | 307 | guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size, |
| 308 | CK_ATTRIBUTE_TYPE operation) | |
| 309 | { | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
310 | PurpleAESCipherNSSContext context; |
| 34182 | 311 | CK_MECHANISM_TYPE cipher_mech = CKM_AES_CBC; |
| 312 | SECItem key_item, iv_item; | |
| 313 | SECStatus ret; | |
| 35028 | 314 | int outlen = 0; |
| 34182 | 315 | unsigned int outlen_tmp = 0; |
| 316 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
317 | memset(&context, 0, sizeof(PurpleAESCipherNSSContext)); |
| 34182 | 318 | |
| 319 | if (NSS_NoDB_Init(NULL) != SECSuccess) { | |
| 320 | purple_debug_error("cipher-aes", | |
| 321 | "NSS_NoDB_Init failed: %d\n", PR_GetError()); | |
| 322 | return FALSE; | |
| 323 | } | |
| 324 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
325 | context.slot = PK11_GetBestSlot(cipher_mech, NULL); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
326 | if (context.slot == NULL) { |
| 34182 | 327 | purple_debug_error("cipher-aes", |
| 328 | "PK11_GetBestSlot failed: %d\n", PR_GetError()); | |
| 329 | return FALSE; | |
| 330 | } | |
| 331 | ||
| 332 | key_item.type = siBuffer; | |
| 333 | key_item.data = key; | |
| 334 | key_item.len = key_size; | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
335 | context.sym_key = PK11_ImportSymKey(context.slot, cipher_mech, |
| 34182 | 336 | PK11_OriginUnwrap, CKA_ENCRYPT, &key_item, NULL); |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
337 | if (context.sym_key == NULL) { |
| 34182 | 338 | purple_debug_error("cipher-aes", |
| 339 | "PK11_ImportSymKey failed: %d\n", PR_GetError()); | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
340 | purple_aes_cipher_nss_cleanup(&context); |
| 34182 | 341 | return FALSE; |
| 342 | } | |
| 343 | ||
| 344 | iv_item.type = siBuffer; | |
| 345 | iv_item.data = iv; | |
| 346 | iv_item.len = PURPLE_AES_BLOCK_SIZE; | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
347 | context.sec_param = PK11_ParamFromIV(cipher_mech, &iv_item); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
348 | if (context.sec_param == NULL) { |
| 34182 | 349 | purple_debug_error("cipher-aes", |
| 350 | "PK11_ParamFromIV failed: %d\n", PR_GetError()); | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
351 | purple_aes_cipher_nss_cleanup(&context); |
| 34182 | 352 | return FALSE; |
| 353 | } | |
| 354 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
355 | context.enc_context = PK11_CreateContextBySymKey(cipher_mech, operation, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
356 | context.sym_key, context.sec_param); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
357 | if (context.enc_context == NULL) { |
| 34182 | 358 | purple_debug_error("cipher-aes", |
| 359 | "PK11_CreateContextBySymKey failed: %d\n", | |
| 360 | PR_GetError()); | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
361 | purple_aes_cipher_nss_cleanup(&context); |
| 34182 | 362 | return FALSE; |
| 363 | } | |
| 364 | ||
|
35190
5986ee34c476
libpurple: Fix build and warnings with glib 2.24
Ankit Vani <a@nevitus.org>
parents:
35084
diff
changeset
|
365 | ret = PK11_CipherOp(context.enc_context, output, &outlen, len, |
|
5986ee34c476
libpurple: Fix build and warnings with glib 2.24
Ankit Vani <a@nevitus.org>
parents:
35084
diff
changeset
|
366 | (guchar *)input, len); |
| 34182 | 367 | if (ret != SECSuccess) { |
| 368 | purple_debug_error("cipher-aes", | |
| 369 | "PK11_CipherOp failed: %d\n", PR_GetError()); | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
370 | purple_aes_cipher_nss_cleanup(&context); |
| 34182 | 371 | return FALSE; |
| 372 | } | |
| 373 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
374 | ret = PK11_DigestFinal(context.enc_context, output + outlen, &outlen_tmp, |
| 34182 | 375 | len - outlen); |
| 376 | if (ret != SECSuccess) { | |
| 377 | purple_debug_error("cipher-aes", | |
| 378 | "PK11_DigestFinal failed: %d\n", PR_GetError()); | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
379 | purple_aes_cipher_nss_cleanup(&context); |
| 34182 | 380 | return FALSE; |
| 381 | } | |
| 382 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
383 | purple_aes_cipher_nss_cleanup(&context); |
| 34182 | 384 | |
| 385 | outlen += outlen_tmp; | |
| 35029 | 386 | if (outlen != (int)len) { |
| 34182 | 387 | purple_debug_error("cipher-aes", |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
388 | "resulting length doesn't match: %d (expected: %lu)\n", |
| 34182 | 389 | outlen, len); |
| 390 | return FALSE; | |
| 391 | } | |
| 392 | ||
| 393 | return TRUE; | |
| 394 | } | |
| 395 | ||
| 396 | static gboolean | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
397 | purple_aes_cipher_nss_encrypt(const guchar *input, guchar *output, size_t len, |
| 34182 | 398 | guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size) |
| 399 | { | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
400 | return purple_aes_cipher_nss_crypt(input, output, len, iv, key, key_size, |
| 34182 | 401 | CKA_ENCRYPT); |
| 402 | } | |
| 403 | ||
| 404 | static gboolean | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
405 | purple_aes_cipher_nss_decrypt(const guchar *input, guchar *output, size_t len, |
| 34182 | 406 | guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size) |
| 407 | { | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
408 | return purple_aes_cipher_nss_crypt(input, output, len, iv, key, key_size, |
| 34182 | 409 | CKA_DECRYPT); |
| 410 | } | |
| 411 | ||
| 412 | #endif /* PURPLE_AES_USE_NSS */ | |
| 413 | ||
| 414 | static ssize_t | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
415 | purple_aes_cipher_encrypt(PurpleCipher *cipher, const guchar input[], |
| 34182 | 416 | size_t in_len, guchar output[], size_t out_size) |
| 417 | { | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
418 | PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
419 | purple_aes_cipher_crypt_func encrypt_func; |
| 34182 | 420 | guchar *input_padded; |
| 421 | size_t out_len = 0; | |
| 422 | gboolean succ; | |
| 423 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
424 | if (priv->failure) |
| 34182 | 425 | return -1; |
| 426 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
427 | input_padded = purple_aes_cipher_pad_pkcs7(input, in_len, &out_len); |
| 34182 | 428 | |
| 429 | if (out_len > out_size) { | |
| 430 | purple_debug_error("cipher-aes", "Output buffer too small\n"); | |
| 431 | memset(input_padded, 0, out_len); | |
| 432 | g_free(input_padded); | |
| 433 | return -1; | |
| 434 | } | |
| 435 | ||
| 436 | #if defined(PURPLE_AES_USE_GNUTLS) | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
437 | encrypt_func = purple_aes_cipher_gnutls_encrypt; |
| 34182 | 438 | #elif defined(PURPLE_AES_USE_NSS) |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
439 | encrypt_func = purple_aes_cipher_nss_encrypt; |
| 34182 | 440 | #else |
| 441 | # error "No matching encrypt_func" | |
| 442 | #endif | |
| 443 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
444 | succ = encrypt_func(input_padded, output, out_len, priv->iv, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
445 | priv->key, priv->key_size); |
| 34182 | 446 | |
| 447 | memset(input_padded, 0, out_len); | |
| 448 | g_free(input_padded); | |
| 449 | ||
| 450 | if (!succ) { | |
| 451 | memset(output, 0, out_len); | |
| 452 | return -1; | |
| 453 | } | |
| 454 | ||
| 455 | return out_len; | |
| 456 | } | |
| 457 | ||
| 458 | static ssize_t | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
459 | purple_aes_cipher_decrypt(PurpleCipher *cipher, const guchar input[], |
| 34182 | 460 | size_t in_len, guchar output[], size_t out_size) |
| 461 | { | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
462 | PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
463 | purple_aes_cipher_crypt_func decrypt_func; |
| 34182 | 464 | gboolean succ; |
| 465 | ssize_t out_len; | |
| 466 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
467 | if (priv->failure) |
| 34182 | 468 | return -1; |
| 469 | ||
| 470 | if (in_len > out_size) { | |
| 471 | purple_debug_error("cipher-aes", "Output buffer too small\n"); | |
| 472 | return -1; | |
| 473 | } | |
| 474 | ||
| 475 | if ((in_len % PURPLE_AES_BLOCK_SIZE) != 0 || in_len == 0) { | |
| 476 | purple_debug_error("cipher-aes", "Malformed data\n"); | |
| 477 | return -1; | |
| 478 | } | |
| 479 | ||
| 480 | #if defined(PURPLE_AES_USE_GNUTLS) | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
481 | decrypt_func = purple_aes_cipher_gnutls_decrypt; |
| 34182 | 482 | #elif defined(PURPLE_AES_USE_NSS) |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
483 | decrypt_func = purple_aes_cipher_nss_decrypt; |
| 34182 | 484 | #else |
| 485 | # error "No matching encrypt_func" | |
| 486 | #endif | |
| 487 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
488 | succ = decrypt_func(input, output, in_len, priv->iv, priv->key, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
489 | priv->key_size); |
| 34182 | 490 | |
| 491 | if (!succ) { | |
| 492 | memset(output, 0, in_len); | |
| 493 | return -1; | |
| 494 | } | |
| 495 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
496 | out_len = purple_aes_cipher_unpad_pkcs7(output, in_len); |
| 34182 | 497 | if (out_len < 0) { |
| 498 | memset(output, 0, in_len); | |
| 499 | return -1; | |
| 500 | } | |
| 501 | ||
| 502 | return out_len; | |
| 503 | } | |
| 504 | ||
| 505 | static size_t | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
506 | purple_aes_cipher_get_key_size(PurpleCipher *cipher) |
| 34182 | 507 | { |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
508 | PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher); |
| 34182 | 509 | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
510 | return priv->key_size; |
| 34182 | 511 | } |
| 512 | ||
| 513 | static void | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
514 | purple_aes_cipher_set_batch_mode(PurpleCipher *cipher, |
| 34182 | 515 | PurpleCipherBatchMode mode) |
| 516 | { | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
517 | PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher); |
| 34182 | 518 | |
|
35062
2aee8634c912
ciphers: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents:
35029
diff
changeset
|
519 | if (mode != PURPLE_CIPHER_BATCH_MODE_CBC) { |
|
2aee8634c912
ciphers: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents:
35029
diff
changeset
|
520 | purple_debug_error("cipher-aes", "unsupported batch mode\n"); |
|
2aee8634c912
ciphers: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents:
35029
diff
changeset
|
521 | priv->failure = TRUE; |
|
2aee8634c912
ciphers: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents:
35029
diff
changeset
|
522 | } |
| 34182 | 523 | |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
524 | g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_BATCH_MODE]); |
| 34182 | 525 | } |
| 526 | ||
| 527 | static PurpleCipherBatchMode | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
528 | purple_aes_cipher_get_batch_mode(PurpleCipher *cipher) |
| 34182 | 529 | { |
| 530 | return PURPLE_CIPHER_BATCH_MODE_CBC; | |
| 531 | } | |
| 532 | ||
| 533 | static size_t | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
534 | purple_aes_cipher_get_block_size(PurpleCipher *cipher) |
| 34182 | 535 | { |
| 536 | return PURPLE_AES_BLOCK_SIZE; | |
| 537 | } | |
| 538 | ||
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
539 | /****************************************************************************** |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
540 | * Object Stuff |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
541 | *****************************************************************************/ |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
542 | static void |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
543 | purple_aes_cipher_get_property(GObject *obj, guint param_id, GValue *value, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
544 | GParamSpec *pspec) |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
545 | { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
546 | PurpleCipher *cipher = PURPLE_CIPHER(obj); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
547 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
548 | switch(param_id) { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
549 | case PROP_BATCH_MODE: |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
550 | g_value_set_enum(value, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
551 | purple_cipher_get_batch_mode(cipher)); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
552 | break; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
553 | default: |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
554 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
555 | break; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
556 | } |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
557 | } |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
558 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
559 | static void |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
560 | purple_aes_cipher_set_property(GObject *obj, guint param_id, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
561 | const GValue *value, GParamSpec *pspec) |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
562 | { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
563 | PurpleCipher *cipher = PURPLE_CIPHER(obj); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
564 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
565 | switch(param_id) { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
566 | case PROP_BATCH_MODE: |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
567 | purple_cipher_set_batch_mode(cipher, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
568 | g_value_get_enum(value)); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
569 | break; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
570 | case PROP_IV: |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
571 | { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
572 | guchar *iv = (guchar *)g_value_get_string(value); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
573 | purple_cipher_set_iv(cipher, iv, strlen((gchar*)iv)); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
574 | } |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
575 | break; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
576 | case PROP_KEY: |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
577 | purple_cipher_set_key(cipher, (guchar *)g_value_get_string(value), |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
578 | purple_aes_cipher_get_key_size(cipher)); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
579 | break; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
580 | default: |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
581 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
582 | break; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
583 | } |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
584 | } |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
585 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
586 | static void |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
587 | purple_aes_cipher_class_init(PurpleAESCipherClass *klass) { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
588 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
589 | PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
590 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
591 | obj_class->get_property = purple_aes_cipher_get_property; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
592 | obj_class->set_property = purple_aes_cipher_set_property; |
| 34182 | 593 | |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
594 | cipher_class->reset = purple_aes_cipher_reset; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
595 | cipher_class->set_iv = purple_aes_cipher_set_iv; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
596 | cipher_class->encrypt = purple_aes_cipher_encrypt; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
597 | cipher_class->decrypt = purple_aes_cipher_decrypt; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
598 | cipher_class->set_key = purple_aes_cipher_set_key; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
599 | cipher_class->get_key_size = purple_aes_cipher_get_key_size; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
600 | cipher_class->set_batch_mode = purple_aes_cipher_set_batch_mode; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
601 | cipher_class->get_batch_mode = purple_aes_cipher_get_batch_mode; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
602 | cipher_class->get_block_size = purple_aes_cipher_get_block_size; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
603 | |
|
35084
07cd7f1767c7
ciphers: use g_object_class_install_properties instead of repeated g_object_class_install_property
Ankit Vani <a@nevitus.org>
parents:
35077
diff
changeset
|
604 | g_type_class_add_private(klass, sizeof(PurpleAESCipherPrivate)); |
|
07cd7f1767c7
ciphers: use g_object_class_install_properties instead of repeated g_object_class_install_property
Ankit Vani <a@nevitus.org>
parents:
35077
diff
changeset
|
605 | |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
606 | properties[PROP_BATCH_MODE] = g_param_spec_enum("batch-mode", "batch-mode", |
|
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
607 | "batch-mode", PURPLE_TYPE_CIPHER_BATCH_MODE, 0, |
|
35062
2aee8634c912
ciphers: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents:
35029
diff
changeset
|
608 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
609 | |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
610 | properties[PROP_IV] = g_param_spec_string("iv", "iv", "iv", NULL, |
|
35062
2aee8634c912
ciphers: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents:
35029
diff
changeset
|
611 | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS); |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
612 | |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
613 | properties[PROP_KEY] = g_param_spec_string("key", "key", "key", NULL, |
|
35062
2aee8634c912
ciphers: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents:
35029
diff
changeset
|
614 | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS); |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
615 | |
|
35084
07cd7f1767c7
ciphers: use g_object_class_install_properties instead of repeated g_object_class_install_property
Ankit Vani <a@nevitus.org>
parents:
35077
diff
changeset
|
616 | g_object_class_install_properties(obj_class, PROP_LAST, properties); |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
617 | } |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
618 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
619 | static void |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
620 | purple_aes_cipher_init(PurpleCipher *cipher) { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
621 | purple_cipher_reset(cipher); |
| 34182 | 622 | } |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
623 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
624 | /****************************************************************************** |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
625 | * API |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
626 | *****************************************************************************/ |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
627 | GType |
|
35020
0ab63ada3cf2
Changed *_get_gtype to *_get_type for ciphers and hashes so gtk-doc can find them
Ankit Vani <a@nevitus.org>
parents:
35014
diff
changeset
|
628 | purple_aes_cipher_get_type(void) { |
|
34546
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
629 | static GType type = 0; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
630 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
631 | if(type == 0) { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
632 | static const GTypeInfo info = { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
633 | sizeof(PurpleAESCipherClass), |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
634 | NULL, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
635 | NULL, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
636 | (GClassInitFunc)purple_aes_cipher_class_init, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
637 | NULL, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
638 | NULL, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
639 | sizeof(PurpleAESCipher), |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
640 | 0, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
641 | (GInstanceInitFunc)purple_aes_cipher_init, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
642 | NULL |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
643 | }; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
644 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
645 | type = g_type_register_static(PURPLE_TYPE_CIPHER, |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
646 | "PurpleAESCipher", |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
647 | &info, 0); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
648 | } |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
649 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
650 | return type; |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
651 | } |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
652 | |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
653 | PurpleCipher * |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
654 | purple_aes_cipher_new(void) { |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
655 | return g_object_new(PURPLE_TYPE_AES_CIPHER, NULL); |
|
5c2f894fe4d6
GObjectified the AES cipher as PurpleAESCipher
Ankit Vani <a@nevitus.org>
parents:
34182
diff
changeset
|
656 | } |