Fri, 14 Jun 2013 12:11:09 +0530
GObjectified gchecksum.c as PurpleSHA1Cipher, PurpleSHA256Cipher and PurpleMD5Cipher
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
1 | /* |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
2 | * Original des taken from gpg |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
3 | * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
4 | * des.c - Triple-DES encryption/decryption Algorithm |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
5 | * Copyright (C) 1998 Free Software Foundation, Inc. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
6 | * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
7 | * Please see below for more legal information! |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
8 | * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
9 | * According to the definition of DES in FIPS PUB 46-2 from December 1993. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
10 | * For a description of triple encryption, see: |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
11 | * Bruce Schneier: Applied Cryptography. Second Edition. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
12 | * John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
13 | * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
14 | * Purple is the legal property of its developers, whose names are too numerous |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
15 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
16 | * source distribution. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
17 | * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
18 | * This program is free software; you can redistribute it and/or modify |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
19 | * it under the terms of the GNU General Public License as published by |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
20 | * the Free Software Foundation; either version 2 of the License, or |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
21 | * (at your option) any later version. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
22 | * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
23 | * This program is distributed in the hope that it will be useful, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
26 | * GNU General Public License for more details. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
27 | * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
28 | * You should have received a copy of the GNU General Public License |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
29 | * along with this program; if not, write to the Free Software |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
30 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
31 | */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
32 | #include "des3.h" |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
33 | #include "des.h" |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
34 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
35 | #include <string.h> |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
36 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
37 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
38 | * Structs |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
39 | *****************************************************************************/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
40 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
41 | #define PURPLE_DES3_CIPHER_GET_PRIVATE(obj) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
42 | (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_DES3_CIPHER, PurpleDES3CipherPrivate)) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
43 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
44 | typedef struct _PurpleDES3CipherPrivate PurpleDES3CipherPrivate; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
45 | struct _PurpleDES3CipherPrivate |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
46 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
47 | PurpleCipherBatchMode mode; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
48 | guchar iv[8]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
49 | /* First key for encryption */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
50 | PurpleCipher *key1; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
51 | /* Second key for decryption */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
52 | PurpleCipher *key2; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
53 | /* Third key for encryption */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
54 | PurpleCipher *key3; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
55 | }; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
56 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
57 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
58 | * Enums |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
59 | *****************************************************************************/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
60 | enum { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
61 | PROP_NONE, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
62 | PROP_BATCH_MODE, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
63 | PROP_IV, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
64 | PROP_KEY, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
65 | PROP_LAST, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
66 | }; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
67 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
68 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
69 | * Globals |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
70 | *****************************************************************************/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
71 | static GObjectClass *parent_class = NULL; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
72 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
73 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
74 | * Cipher Stuff |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
75 | *****************************************************************************/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
76 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
77 | static size_t |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
78 | purple_des3_cipher_get_key_size(PurpleCipher *cipher) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
79 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
80 | return 24; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
81 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
82 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
83 | /* |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
84 | * Fill a DES3 context with subkeys calculated from 3 64bit key. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
85 | * Does not check parity bits, but simply ignore them. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
86 | * Does not check for weak keys. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
87 | **/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
88 | static void |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
89 | purple_des3_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
90 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
91 | PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
92 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
93 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
94 | g_return_if_fail(len == 24); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
95 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
96 | purple_cipher_set_key(PURPLE_CIPHER(priv->key1), key + 0, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
97 | purple_des3_cipher_get_key_size(cipher)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
98 | purple_cipher_set_key(PURPLE_CIPHER(priv->key2), key + 8, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
99 | purple_des3_cipher_get_key_size(cipher)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
100 | purple_cipher_set_key(PURPLE_CIPHER(priv->key3), key + 16, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
101 | purple_des3_cipher_get_key_size(cipher)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
102 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
103 | g_object_notify(G_OBJECT(des3_cipher), "key"); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
104 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
105 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
106 | static ssize_t |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
107 | purple_des3_cipher_ecb_encrypt(PurpleDES3Cipher *des3_cipher, const guchar input[], |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
108 | size_t in_len, guchar output[], size_t out_size) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
109 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
110 | int offset = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
111 | int i = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
112 | int tmp; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
113 | guint8 buf[8] = {0,0,0,0,0,0,0,0}; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
114 | ssize_t out_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
115 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
116 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
117 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
118 | g_return_val_if_fail(out_size < in_len, -1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
119 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
120 | while (offset + 8 <= in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
121 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
122 | input + offset, output + offset, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
123 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
124 | output + offset, buf, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
125 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
126 | buf, output + offset, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
127 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
128 | offset += 8; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
129 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
130 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
131 | out_len = in_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
132 | if (offset < in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
133 | out_len += in_len - offset; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
134 | g_return_val_if_fail(out_size < out_len, -1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
135 | tmp = offset; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
136 | memset(buf, 0, 8); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
137 | while (tmp < in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
138 | buf[i++] = input[tmp]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
139 | tmp++; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
140 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
141 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
142 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
143 | buf, output + offset, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
144 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
145 | output + offset, buf, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
146 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
147 | buf, output + offset, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
148 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
149 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
150 | return out_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
151 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
152 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
153 | static ssize_t |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
154 | purple_des3_cipher_cbc_encrypt(PurpleDES3Cipher *des3_cipher, const guchar input[], |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
155 | size_t in_len, guchar output[], size_t out_size) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
156 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
157 | int offset = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
158 | int i = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
159 | int tmp; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
160 | guint8 buf[8]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
161 | ssize_t out_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
162 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
163 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
164 | memcpy(buf, priv->iv, 8); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
165 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
166 | g_return_val_if_fail(out_size < in_len, -1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
167 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
168 | while (offset + 8 <= in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
169 | for (i = 0; i < 8; i++) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
170 | buf[i] ^= input[offset + i]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
171 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
172 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
173 | buf, output + offset, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
174 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
175 | output + offset, buf, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
176 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
177 | buf, output + offset, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
178 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
179 | memcpy(buf, output+offset, 8); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
180 | offset += 8; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
181 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
182 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
183 | out_len = in_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
184 | if (offset < in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
185 | out_len += in_len - offset; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
186 | g_return_val_if_fail(out_size < out_len, -1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
187 | tmp = offset; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
188 | i = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
189 | while (tmp < in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
190 | buf[i++] ^= input[tmp]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
191 | tmp++; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
192 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
193 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
194 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
195 | buf, output + offset, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
196 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
197 | output + offset, buf, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
198 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
199 | buf, output + offset, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
200 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
201 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
202 | return out_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
203 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
204 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
205 | static ssize_t |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
206 | purple_des3_cipher_encrypt(PurpleCipher *cipher, const guchar input[], |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
207 | size_t in_len, guchar output[], size_t out_size) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
208 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
209 | PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
210 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
211 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
212 | if (priv->mode == PURPLE_CIPHER_BATCH_MODE_ECB) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
213 | return purple_des3_cipher_ecb_encrypt(des3_cipher, input, in_len, output, out_size); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
214 | } else if (priv->mode == PURPLE_CIPHER_BATCH_MODE_CBC) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
215 | return purple_des3_cipher_cbc_encrypt(des3_cipher, input, in_len, output, out_size); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
216 | } else { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
217 | g_return_val_if_reached(0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
218 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
219 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
220 | return 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
221 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
222 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
223 | static ssize_t |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
224 | purple_des3_cipher_ecb_decrypt(PurpleDES3Cipher *des3_cipher, const guchar input[], |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
225 | size_t in_len, guchar output[], size_t out_size) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
226 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
227 | int offset = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
228 | int i = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
229 | int tmp; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
230 | guint8 buf[8] = {0,0,0,0,0,0,0,0}; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
231 | ssize_t out_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
232 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
233 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
234 | g_return_val_if_fail(out_size < in_len, -1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
235 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
236 | while (offset + 8 <= in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
237 | /* NOTE: Apply key in reverse */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
238 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
239 | input + offset, output + offset, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
240 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
241 | output + offset, buf, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
242 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
243 | buf, output + offset, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
244 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
245 | offset += 8; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
246 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
247 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
248 | out_len = in_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
249 | if (offset < in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
250 | out_len += in_len - offset; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
251 | g_return_val_if_fail(out_size < out_len, -1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
252 | tmp = offset; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
253 | memset(buf, 0, 8); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
254 | while (tmp < in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
255 | buf[i++] = input[tmp]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
256 | tmp++; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
257 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
258 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
259 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
260 | buf, output + offset, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
261 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
262 | output + offset, buf, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
263 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
264 | buf, output + offset, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
265 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
266 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
267 | return out_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
268 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
269 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
270 | static ssize_t |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
271 | purple_des3_cipher_cbc_decrypt(PurpleDES3Cipher *des3_cipher, const guchar input[], |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
272 | size_t in_len, guchar output[], size_t out_size) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
273 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
274 | int offset = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
275 | int i = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
276 | int tmp; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
277 | guint8 buf[8] = {0,0,0,0,0,0,0,0}; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
278 | guint8 link[8]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
279 | ssize_t out_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
280 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
281 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
282 | g_return_val_if_fail(out_size < in_len, -1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
283 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
284 | memcpy(link, priv->iv, 8); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
285 | while (offset + 8 <= in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
286 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
287 | input + offset, output + offset, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
288 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
289 | output + offset, buf, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
290 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
291 | buf, output + offset, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
292 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
293 | for (i = 0; i < 8; i++) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
294 | output[offset + i] ^= link[i]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
295 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
296 | memcpy(link, input + offset, 8); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
297 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
298 | offset+=8; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
299 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
300 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
301 | out_len = in_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
302 | if(offset<in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
303 | out_len += in_len - offset; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
304 | g_return_val_if_fail(out_size < out_len, -1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
305 | tmp = offset; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
306 | memset(buf, 0, 8); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
307 | i = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
308 | while(tmp<in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
309 | buf[i++] = input[tmp]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
310 | tmp++; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
311 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
312 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
313 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
314 | buf, output + offset, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
315 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
316 | output + offset, buf, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
317 | purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
318 | buf, output + offset, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
319 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
320 | for (i = 0; i < 8; i++) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
321 | output[offset + i] ^= link[i]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
322 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
323 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
324 | return out_len; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
325 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
326 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
327 | static ssize_t |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
328 | purple_des3_cipher_decrypt(PurpleCipher *cipher, const guchar input[], |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
329 | size_t in_len, guchar output[], size_t out_size) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
330 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
331 | PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
332 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
333 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
334 | if (priv->mode == PURPLE_CIPHER_BATCH_MODE_ECB) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
335 | return purple_des3_cipher_ecb_decrypt(des3_cipher, input, in_len, output, out_size); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
336 | } else if (priv->mode == PURPLE_CIPHER_BATCH_MODE_CBC) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
337 | return purple_des3_cipher_cbc_decrypt(des3_cipher, input, in_len, output, out_size); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
338 | } else { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
339 | g_return_val_if_reached(0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
340 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
341 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
342 | return 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
343 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
344 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
345 | static void |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
346 | purple_des3_cipher_set_batch_mode(PurpleCipher *cipher, PurpleCipherBatchMode mode) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
347 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
348 | PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
349 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
350 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
351 | priv->mode = mode; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
352 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
353 | g_object_notify(G_OBJECT(des3_cipher), "batchMode"); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
354 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
355 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
356 | static PurpleCipherBatchMode |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
357 | purple_des3_cipher_get_batch_mode(PurpleCipher *cipher) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
358 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
359 | PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
360 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
361 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
362 | return priv->mode; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
363 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
364 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
365 | static void |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
366 | purple_des3_cipher_set_iv(PurpleCipher *cipher, guchar *iv, size_t len) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
367 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
368 | PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
369 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
370 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
371 | g_return_if_fail(len == 8); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
372 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
373 | memcpy(priv->iv, iv, len); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
374 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
375 | g_object_notify(G_OBJECT(des3_cipher), "iv"); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
376 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
377 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
378 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
379 | * Object Stuff |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
380 | *****************************************************************************/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
381 | static void |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
382 | purple_des3_cipher_get_property(GObject *obj, guint param_id, GValue *value, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
383 | GParamSpec *pspec) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
384 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
385 | PurpleCipher *cipher = PURPLE_CIPHER(obj); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
386 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
387 | switch(param_id) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
388 | case PROP_BATCH_MODE: |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
389 | g_value_set_enum(value, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
390 | purple_cipher_get_batch_mode(cipher)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
391 | break; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
392 | default: |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
393 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
394 | break; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
395 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
396 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
397 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
398 | static void |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
399 | purple_des3_cipher_set_property(GObject *obj, guint param_id, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
400 | const GValue *value, GParamSpec *pspec) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
401 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
402 | PurpleCipher *cipher = PURPLE_CIPHER(obj); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
403 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
404 | switch(param_id) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
405 | case PROP_BATCH_MODE: |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
406 | purple_cipher_set_batch_mode(cipher, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
407 | g_value_get_enum(value)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
408 | break; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
409 | case PROP_IV: |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
410 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
411 | guchar *iv = (guchar *)g_value_get_string(value); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
412 | purple_cipher_set_iv(cipher, iv, strlen((gchar*)iv)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
413 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
414 | break; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
415 | case PROP_KEY: |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
416 | purple_cipher_set_key(cipher, (guchar *)g_value_get_string(value), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
417 | purple_des3_cipher_get_key_size(cipher)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
418 | break; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
419 | default: |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
420 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
421 | break; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
422 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
423 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
424 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
425 | static void |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
426 | purple_des3_cipher_finalize(GObject *obj) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
427 | { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
428 | PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(obj); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
429 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
430 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
431 | g_object_unref(G_OBJECT(priv->key1)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
432 | g_object_unref(G_OBJECT(priv->key2)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
433 | g_object_unref(G_OBJECT(priv->key3)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
434 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
435 | memset(priv->iv, 0, sizeof(priv->iv)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
436 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
437 | parent_class->finalize(obj); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
438 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
439 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
440 | static void |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
441 | purple_des3_cipher_class_init(PurpleDES3CipherClass *klass) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
442 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
443 | PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
444 | GParamSpec *pspec; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
445 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
446 | parent_class = g_type_class_peek_parent(klass); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
447 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
448 | obj_class->finalize = purple_des3_cipher_finalize; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
449 | obj_class->get_property = purple_des3_cipher_get_property; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
450 | obj_class->set_property = purple_des3_cipher_set_property; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
451 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
452 | cipher_class->set_iv = purple_des3_cipher_set_iv; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
453 | cipher_class->encrypt = purple_des3_cipher_encrypt; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
454 | cipher_class->decrypt = purple_des3_cipher_decrypt; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
455 | cipher_class->set_key = purple_des3_cipher_set_key; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
456 | cipher_class->set_batch_mode = purple_des3_cipher_set_batch_mode; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
457 | cipher_class->get_batch_mode = purple_des3_cipher_get_batch_mode; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
458 | cipher_class->get_key_size = purple_des3_cipher_get_key_size; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
459 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
460 | pspec = g_param_spec_enum("batchMode", "batchMode", "batchMode", |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
461 | PURPLE_TYPE_CIPHER_BATCH_MODE, 0, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
462 | G_PARAM_READWRITE); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
463 | g_object_class_install_property(obj_class, PROP_BATCH_MODE, pspec); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
464 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
465 | pspec = g_param_spec_string("iv", "iv", "iv", NULL, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
466 | G_PARAM_WRITABLE); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
467 | g_object_class_install_property(obj_class, PROP_IV, pspec); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
468 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
469 | pspec = g_param_spec_string("key", "key", "key", NULL, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
470 | G_PARAM_WRITABLE); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
471 | g_object_class_install_property(obj_class, PROP_KEY, pspec); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
472 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
473 | g_type_class_add_private(klass, sizeof(PurpleDES3CipherPrivate)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
474 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
475 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
476 | static void |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
477 | purple_des3_cipher_init(PurpleCipher *cipher) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
478 | PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
479 | PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
480 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
481 | priv->key1 = purple_des_cipher_new(); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
482 | priv->key2 = purple_des_cipher_new(); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
483 | priv->key3 = purple_des_cipher_new(); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
484 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
485 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
486 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
487 | * API |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
488 | *****************************************************************************/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
489 | GType |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
490 | purple_des3_cipher_get_gtype(void) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
491 | static GType type = 0; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
492 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
493 | if(type == 0) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
494 | static const GTypeInfo info = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
495 | sizeof(PurpleDES3CipherClass), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
496 | NULL, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
497 | NULL, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
498 | (GClassInitFunc)purple_des3_cipher_class_init, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
499 | NULL, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
500 | NULL, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
501 | sizeof(PurpleDES3Cipher), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
502 | 0, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
503 | (GInstanceInitFunc)purple_des3_cipher_init, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
504 | NULL |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
505 | }; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
506 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
507 | type = g_type_register_static(PURPLE_TYPE_CIPHER, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
508 | "PurpleDES3Cipher", |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
509 | &info, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
510 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
511 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
512 | return type; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
513 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
514 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
515 | PurpleCipher * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
516 | purple_des3_cipher_new(void) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
517 | return g_object_new(PURPLE_TYPE_DES3_CIPHER, NULL); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
diff
changeset
|
518 | } |