Mon, 03 Feb 2014 22:40:31 +0530
Swap @title and @short_description roles
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Original des taken from gpg |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
4 | * des.c - DES encryption/decryption Algorithm |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * Copyright (C) 1998 Free Software Foundation, Inc. |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * Please see below for more legal information! |
|
35094
47964e26263e
Assorted whitespace fixes.
Mark Doliner <mark@kingant.net>
parents:
35084
diff
changeset
|
8 | * |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * According to the definition of DES in FIPS PUB 46-2 from December 1993. |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * For a description of triple encryption, see: |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * Bruce Schneier: Applied Cryptography. Second Edition. |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff. |
|
35094
47964e26263e
Assorted whitespace fixes.
Mark Doliner <mark@kingant.net>
parents:
35084
diff
changeset
|
13 | * |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
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:
33944
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:
33944
diff
changeset
|
16 | * source distribution. |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * This program is free software; you can redistribute it and/or modify |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * it under the terms of the GNU General Public License as published by |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | * the Free Software Foundation; either version 2 of the License, or |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | * (at your option) any later version. |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | * |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | * This program is distributed in the hope that it will be useful, |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | * GNU General Public License for more details. |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | * |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | * You should have received a copy of the GNU General Public License |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | * along with this program; if not, write to the Free Software |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | */ |
|
35026
fde23518e1e5
Moved PurpleHash to cipher.[ch]
Ankit Vani <a@nevitus.org>
parents:
35014
diff
changeset
|
32 | #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
|
33 | #include "glibcompat.h" |
|
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
34 | |
|
34566
e0f887dee077
Split PurpleCipher into PurpleCipher and PurpleHash. Hashes will subclass PurpleHash.
Ankit Vani <a@nevitus.org>
parents:
34563
diff
changeset
|
35 | #include "descipher.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:
34619
diff
changeset
|
36 | #include "enums.h" |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
37 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
38 | #include <string.h> |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | /****************************************************************************** |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
41 | * Structs |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | *****************************************************************************/ |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
43 | #define PURPLE_DES_CIPHER_GET_PRIVATE(obj) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
44 | (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_DES_CIPHER, PurpleDESCipherPrivate)) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
45 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
46 | typedef struct { |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | guint32 encrypt_subkeys[32]; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | guint32 decrypt_subkeys[32]; |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
49 | } PurpleDESCipherPrivate; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
51 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
52 | * Enums |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
53 | *****************************************************************************/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
54 | enum { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
55 | PROP_NONE, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
56 | PROP_KEY, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
57 | PROP_LAST, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
58 | }; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
59 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
60 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
61 | * Globals |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
62 | *****************************************************************************/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
63 | static GObjectClass *parent_class = NULL; |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
64 | static GParamSpec *properties[PROP_LAST]; |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
65 | |
|
35094
47964e26263e
Assorted whitespace fixes.
Mark Doliner <mark@kingant.net>
parents:
35084
diff
changeset
|
66 | /* |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | * The s-box values are permuted according to the 'primitive function P' |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | */ |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
69 | static guint32 sbox1[64] = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
70 | 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
71 | 0x00000002, 0x00008000, 0x00000200, 0x00808200, 0x00808202, 0x00000200, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
72 | 0x00800202, 0x00808002, 0x00800000, 0x00000002, 0x00000202, 0x00800200, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
73 | 0x00800200, 0x00008200, 0x00008200, 0x00808000, 0x00808000, 0x00800202, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
74 | 0x00008002, 0x00800002, 0x00800002, 0x00008002, 0x00000000, 0x00000202, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
75 | 0x00008202, 0x00800000, 0x00008000, 0x00808202, 0x00000002, 0x00808000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
76 | 0x00808200, 0x00800000, 0x00800000, 0x00000200, 0x00808002, 0x00008000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
77 | 0x00008200, 0x00800002, 0x00000200, 0x00000002, 0x00800202, 0x00008202, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
78 | 0x00808202, 0x00008002, 0x00808000, 0x00800202, 0x00800002, 0x00000202, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
79 | 0x00008202, 0x00808200, 0x00000202, 0x00800200, 0x00800200, 0x00000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
80 | 0x00008002, 0x00008200, 0x00000000, 0x00808002 |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
83 | static guint32 sbox2[64] = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
84 | 0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
85 | 0x40080010, 0x40004010, 0x40000010, 0x40084010, 0x40084000, 0x40000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
86 | 0x40004000, 0x00080000, 0x00000010, 0x40080010, 0x00084000, 0x00080010, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
87 | 0x40004010, 0x00000000, 0x40000000, 0x00004000, 0x00084010, 0x40080000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
88 | 0x00080010, 0x40000010, 0x00000000, 0x00084000, 0x00004010, 0x40084000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
89 | 0x40080000, 0x00004010, 0x00000000, 0x00084010, 0x40080010, 0x00080000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
90 | 0x40004010, 0x40080000, 0x40084000, 0x00004000, 0x40080000, 0x40004000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
91 | 0x00000010, 0x40084010, 0x00084010, 0x00000010, 0x00004000, 0x40000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
92 | 0x00004010, 0x40084000, 0x00080000, 0x40000010, 0x00080010, 0x40004010, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
93 | 0x40000010, 0x00080010, 0x00084000, 0x00000000, 0x40004000, 0x00004010, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
94 | 0x40000000, 0x40080010, 0x40084010, 0x00084000 |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
97 | static guint32 sbox3[64] = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
98 | 0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
99 | 0x00010104, 0x04000100, 0x00010004, 0x04000004, 0x04000004, 0x00010000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
100 | 0x04010104, 0x00010004, 0x04010000, 0x00000104, 0x04000000, 0x00000004, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
101 | 0x04010100, 0x00000100, 0x00010100, 0x04010000, 0x04010004, 0x00010104, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
102 | 0x04000104, 0x00010100, 0x00010000, 0x04000104, 0x00000004, 0x04010104, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
103 | 0x00000100, 0x04000000, 0x04010100, 0x04000000, 0x00010004, 0x00000104, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
104 | 0x00010000, 0x04010100, 0x04000100, 0x00000000, 0x00000100, 0x00010004, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
105 | 0x04010104, 0x04000100, 0x04000004, 0x00000100, 0x00000000, 0x04010004, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
106 | 0x04000104, 0x00010000, 0x04000000, 0x04010104, 0x00000004, 0x00010104, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
107 | 0x00010100, 0x04000004, 0x04010000, 0x04000104, 0x00000104, 0x04010000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
108 | 0x00010104, 0x00000004, 0x04010004, 0x00010100 |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
111 | static guint32 sbox4[64] = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
112 | 0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
113 | 0x80400000, 0x80001000, 0x00000000, 0x00401000, 0x00401000, 0x80401040, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
114 | 0x80000040, 0x00000000, 0x00400040, 0x80400000, 0x80000000, 0x00001000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
115 | 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x80001000, 0x00001040, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
116 | 0x80400040, 0x80000000, 0x00001040, 0x00400040, 0x00001000, 0x00401040, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
117 | 0x80401040, 0x80000040, 0x00400040, 0x80400000, 0x00401000, 0x80401040, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
118 | 0x80000040, 0x00000000, 0x00000000, 0x00401000, 0x00001040, 0x00400040, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
119 | 0x80400040, 0x80000000, 0x80401000, 0x80001040, 0x80001040, 0x00000040, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
120 | 0x80401040, 0x80000040, 0x80000000, 0x00001000, 0x80400000, 0x80001000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
121 | 0x00401040, 0x80400040, 0x80001000, 0x00001040, 0x00400000, 0x80401000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
122 | 0x00000040, 0x00400000, 0x00001000, 0x00401040 |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
125 | static guint32 sbox5[64] = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
126 | 0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
127 | 0x20000000, 0x01040000, 0x20040080, 0x00040000, 0x01000080, 0x20040080, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
128 | 0x21000080, 0x21040000, 0x00040080, 0x20000000, 0x01000000, 0x20040000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
129 | 0x20040000, 0x00000000, 0x20000080, 0x21040080, 0x21040080, 0x01000080, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
130 | 0x21040000, 0x20000080, 0x00000000, 0x21000000, 0x01040080, 0x01000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
131 | 0x21000000, 0x00040080, 0x00040000, 0x21000080, 0x00000080, 0x01000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
132 | 0x20000000, 0x01040000, 0x21000080, 0x20040080, 0x01000080, 0x20000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
133 | 0x21040000, 0x01040080, 0x20040080, 0x00000080, 0x01000000, 0x21040000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
134 | 0x21040080, 0x00040080, 0x21000000, 0x21040080, 0x01040000, 0x00000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
135 | 0x20040000, 0x21000000, 0x00040080, 0x01000080, 0x20000080, 0x00040000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
136 | 0x00000000, 0x20040000, 0x01040080, 0x20000080 |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
139 | static guint32 sbox6[64] = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
140 | 0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
141 | 0x10202008, 0x00200000, 0x10002000, 0x00202008, 0x00200000, 0x10000008, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
142 | 0x00200008, 0x10002000, 0x10000000, 0x00002008, 0x00000000, 0x00200008, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
143 | 0x10002008, 0x00002000, 0x00202000, 0x10002008, 0x00000008, 0x10200008, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
144 | 0x10200008, 0x00000000, 0x00202008, 0x10202000, 0x00002008, 0x00202000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
145 | 0x10202000, 0x10000000, 0x10002000, 0x00000008, 0x10200008, 0x00202000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
146 | 0x10202008, 0x00200000, 0x00002008, 0x10000008, 0x00200000, 0x10002000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
147 | 0x10000000, 0x00002008, 0x10000008, 0x10202008, 0x00202000, 0x10200000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
148 | 0x00202008, 0x10202000, 0x00000000, 0x10200008, 0x00000008, 0x00002000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
149 | 0x10200000, 0x00202008, 0x00002000, 0x00200008, 0x10002008, 0x00000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
150 | 0x10202000, 0x10000000, 0x00200008, 0x10002008 |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
153 | static guint32 sbox7[64] = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
154 | 0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
155 | 0x00100401, 0x02100400, 0x02100401, 0x00100000, 0x00000000, 0x02000001, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
156 | 0x00000001, 0x02000000, 0x02100001, 0x00000401, 0x02000400, 0x00100401, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
157 | 0x00100001, 0x02000400, 0x02000001, 0x02100000, 0x02100400, 0x00100001, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
158 | 0x02100000, 0x00000400, 0x00000401, 0x02100401, 0x00100400, 0x00000001, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
159 | 0x02000000, 0x00100400, 0x02000000, 0x00100400, 0x00100000, 0x02000401, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
160 | 0x02000401, 0x02100001, 0x02100001, 0x00000001, 0x00100001, 0x02000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
161 | 0x02000400, 0x00100000, 0x02100400, 0x00000401, 0x00100401, 0x02100400, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
162 | 0x00000401, 0x02000001, 0x02100401, 0x02100000, 0x00100400, 0x00000000, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
163 | 0x00000001, 0x02100401, 0x00000000, 0x00100401, 0x02100000, 0x00000400, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
164 | 0x02000001, 0x02000400, 0x00000400, 0x00100001 |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
167 | static guint32 sbox8[64] = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
168 | 0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
169 | 0x00000020, 0x08000000, 0x00020020, 0x08020000, 0x08020820, 0x00020800, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
170 | 0x08020800, 0x00020820, 0x00000800, 0x00000020, 0x08020000, 0x08000020, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
171 | 0x08000800, 0x00000820, 0x00020800, 0x00020020, 0x08020020, 0x08020800, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
172 | 0x00000820, 0x00000000, 0x00000000, 0x08020020, 0x08000020, 0x08000800, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
173 | 0x00020820, 0x00020000, 0x00020820, 0x00020000, 0x08020800, 0x00000800, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
174 | 0x00000020, 0x08020020, 0x00000800, 0x00020820, 0x08000800, 0x00000020, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
175 | 0x08000020, 0x08020000, 0x08020020, 0x08000000, 0x00020000, 0x08000820, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
176 | 0x00000000, 0x08020820, 0x00020020, 0x08000020, 0x08020000, 0x08000800, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
177 | 0x08000820, 0x00000000, 0x08020820, 0x00020800, 0x00020800, 0x00000820, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
178 | 0x00000820, 0x00020020, 0x08000000, 0x08020800 |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | /* |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
182 | * These two tables are part of the 'permuted choice 1' function. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
183 | * In this implementation several speed improvements are done. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
184 | */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
185 | static guint32 leftkey_swap[16] = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
186 | 0x00000000, 0x00000001, 0x00000100, 0x00000101, 0x00010000, 0x00010001, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
187 | 0x00010100, 0x00010101, 0x01000000, 0x01000001, 0x01000100, 0x01000101, |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | 0x01010000, 0x01010001, 0x01010100, 0x01010101 |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
191 | static guint32 rightkey_swap[16] = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
192 | 0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00000100, 0x01000100, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
193 | 0x00010100, 0x01010100, 0x00000001, 0x01000001, 0x00010001, 0x01010001, |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | 0x00000101, 0x01000101, 0x00010101, 0x01010101, |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | /* |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | * Numbers of left shifts per round for encryption subkey schedule |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | * To calculate the decryption key scheduling we just reverse the |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | * ordering of the subkeys so we can omit the table for decryption |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | * subkey schedule. |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | */ |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
203 | static guint8 encrypt_rotate_tab[16] = { |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | }; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
207 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
208 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
209 | * Helpers |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
210 | *****************************************************************************/ |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | /* |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
212 | * Macro to swap bits across two words |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
213 | */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
214 | #define DO_PERMUTATION(a, temp, b, offset, mask) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
215 | temp = ((a>>offset) ^ b) & mask; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
216 | b ^= temp; \ |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | a ^= temp<<offset; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | /* |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
220 | * This performs the 'initial permutation' for the data to be encrypted or |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
221 | * decrypted |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
222 | */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
223 | #define INITIAL_PERMUTATION(left, temp, right) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
224 | DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
225 | DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
226 | DO_PERMUTATION(right, temp, left, 2, 0x33333333) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
227 | DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \ |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | DO_PERMUTATION(left, temp, right, 1, 0x55555555) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | /* |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | * The 'inverse initial permutation' |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
232 | */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
233 | #define FINAL_PERMUTATION(left, temp, right) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
234 | DO_PERMUTATION(left, temp, right, 1, 0x55555555) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
235 | DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
236 | DO_PERMUTATION(right, temp, left, 2, 0x33333333) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
237 | DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \ |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | /* |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | * A full DES round including 'expansion function', 'sbox substitution' |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | * and 'primitive function P' but without swapping the left and right word. |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
243 | */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
244 | #define DES_ROUND(from, to, work, subkey) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
245 | work = ((from<<1) | (from>>31)) ^ *subkey++; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
246 | to ^= sbox8[ work & 0x3f ]; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
247 | to ^= sbox6[ (work>>8) & 0x3f ]; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
248 | to ^= sbox4[ (work>>16) & 0x3f ]; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
249 | to ^= sbox2[ (work>>24) & 0x3f ]; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
250 | work = ((from>>3) | (from<<29)) ^ *subkey++; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
251 | to ^= sbox7[ work & 0x3f ]; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
252 | to ^= sbox5[ (work>>8) & 0x3f ]; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
253 | to ^= sbox3[ (work>>16) & 0x3f ]; \ |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | to ^= sbox1[ (work>>24) & 0x3f ]; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | /* |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | * Macros to convert 8 bytes from/to 32bit words |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
259 | */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
260 | #define READ_64BIT_DATA(data, left, right) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
261 | left = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; \ |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | right = (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7]; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
264 | #define WRITE_64BIT_DATA(data, left, right) \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
265 | data[0] = (left >> 24) &0xff; data[1] = (left >> 16) &0xff; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
266 | data[2] = (left >> 8) &0xff; data[3] = left &0xff; \ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
267 | data[4] = (right >> 24) &0xff; data[5] = (right >> 16) &0xff; \ |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | data[6] = (right >> 8) &0xff; data[7] = right &0xff; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
270 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
271 | * Cipher Stuff |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
272 | *****************************************************************************/ |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | /* |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | * des_key_schedule(): Calculate 16 subkeys pairs (even/odd) for |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | * 16 encryption rounds. |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | * To calculate subkeys for decryption the caller |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | * have to reorder the generated subkeys. |
|
35094
47964e26263e
Assorted whitespace fixes.
Mark Doliner <mark@kingant.net>
parents:
35084
diff
changeset
|
278 | * |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | * rawkey: 8 Bytes of key data |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | * subkey: Array of at least 32 guint32s. Will be filled |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | * with calculated subkeys. |
|
35094
47964e26263e
Assorted whitespace fixes.
Mark Doliner <mark@kingant.net>
parents:
35084
diff
changeset
|
282 | * |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
283 | */ |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | static void |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
285 | purple_des_cipher_key_schedule(const guint8 * rawkey, guint32 * subkey) { |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | guint32 left, right, work; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | int round; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | READ_64BIT_DATA (rawkey, left, right) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | DO_PERMUTATION (right, work, left, 4, 0x0f0f0f0f) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | DO_PERMUTATION (right, work, left, 0, 0x10101010) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
294 | left = (leftkey_swap[(left >> 0) & 0xf] << 3) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
295 | | (leftkey_swap[(left >> 8) & 0xf] << 2) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
296 | | (leftkey_swap[(left >> 16) & 0xf] << 1) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
297 | | (leftkey_swap[(left >> 24) & 0xf] ) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
298 | | (leftkey_swap[(left >> 5) & 0xf] << 7) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
299 | | (leftkey_swap[(left >> 13) & 0xf] << 6) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
300 | | (leftkey_swap[(left >> 21) & 0xf] << 5) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
301 | | (leftkey_swap[(left >> 29) & 0xf] << 4); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | left &= 0x0fffffff; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
304 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
305 | right = (rightkey_swap[(right >> 1) & 0xf] << 3) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
306 | | (rightkey_swap[(right >> 9) & 0xf] << 2) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
307 | | (rightkey_swap[(right >> 17) & 0xf] << 1) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
308 | | (rightkey_swap[(right >> 25) & 0xf] ) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
309 | | (rightkey_swap[(right >> 4) & 0xf] << 7) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
310 | | (rightkey_swap[(right >> 12) & 0xf] << 6) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
311 | | (rightkey_swap[(right >> 20) & 0xf] << 5) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
312 | | (rightkey_swap[(right >> 28) & 0xf] << 4); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | right &= 0x0fffffff; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
316 | for (round = 0; round < 16; ++round) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
317 | left = ((left << encrypt_rotate_tab[round]) | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
318 | (left >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
319 | right = ((right << encrypt_rotate_tab[round]) | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
320 | (right >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
322 | *subkey++ = ((left << 4) & 0x24000000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
323 | | ((left << 28) & 0x10000000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
324 | | ((left << 14) & 0x08000000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
325 | | ((left << 18) & 0x02080000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
326 | | ((left << 6) & 0x01000000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
327 | | ((left << 9) & 0x00200000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
328 | | ((left >> 1) & 0x00100000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
329 | | ((left << 10) & 0x00040000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
330 | | ((left << 2) & 0x00020000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
331 | | ((left >> 10) & 0x00010000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
332 | | ((right >> 13) & 0x00002000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
333 | | ((right >> 4) & 0x00001000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
334 | | ((right << 6) & 0x00000800) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
335 | | ((right >> 1) & 0x00000400) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
336 | | ((right >> 14) & 0x00000200) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
337 | | (right & 0x00000100) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
338 | | ((right >> 5) & 0x00000020) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
339 | | ((right >> 10) & 0x00000010) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
340 | | ((right >> 3) & 0x00000008) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
341 | | ((right >> 18) & 0x00000004) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
342 | | ((right >> 26) & 0x00000002) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
343 | | ((right >> 24) & 0x00000001); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
345 | *subkey++ = ((left << 15) & 0x20000000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
346 | | ((left << 17) & 0x10000000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
347 | | ((left << 10) & 0x08000000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
348 | | ((left << 22) & 0x04000000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
349 | | ((left >> 2) & 0x02000000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
350 | | ((left << 1) & 0x01000000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
351 | | ((left << 16) & 0x00200000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
352 | | ((left << 11) & 0x00100000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
353 | | ((left << 3) & 0x00080000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
354 | | ((left >> 6) & 0x00040000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
355 | | ((left << 15) & 0x00020000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
356 | | ((left >> 4) & 0x00010000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
357 | | ((right >> 2) & 0x00002000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
358 | | ((right << 8) & 0x00001000) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
359 | | ((right >> 14) & 0x00000808) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
360 | | ((right >> 9) & 0x00000400) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
361 | | ((right) & 0x00000200) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
362 | | ((right << 7) & 0x00000100) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
363 | | ((right >> 7) & 0x00000020) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
364 | | ((right >> 3) & 0x00000011) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
365 | | ((right << 2) & 0x00000004) |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
366 | | ((right >> 21) & 0x00000002); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
367 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | /* |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
371 | * Fill a DES context with subkeys calculated from a 64bit key. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
372 | * Does not check parity bits, but simply ignore them. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
373 | * Does not check for weak keys. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
374 | */ |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
375 | static void |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
376 | purple_des_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:
33944
diff
changeset
|
377 | PurpleDESCipher *des_cipher = PURPLE_DES_CIPHER(cipher); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
378 | PurpleDESCipherPrivate *priv = PURPLE_DES_CIPHER_GET_PRIVATE(des_cipher); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
379 | int i; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
381 | g_return_if_fail(len == 8); |
|
33908
78b42fd69e02
ciphers cleanup: passing keys with length by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33881
diff
changeset
|
382 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
383 | purple_des_cipher_key_schedule(key, priv->encrypt_subkeys); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
384 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
385 | for(i = 0; i < 32; i += 2) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
386 | priv->decrypt_subkeys[i] = priv->encrypt_subkeys[30 - i]; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
387 | priv->decrypt_subkeys[i + 1] = priv->encrypt_subkeys[31 - i]; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | } |
|
35065
2fe1b3f20c3c
Added a few missing G_PARAM_STATIC_STRINGS and g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35062
diff
changeset
|
389 | |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
390 | g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_KEY]); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
391 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
392 | |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
393 | static size_t |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
394 | purple_des_cipher_get_key_size(PurpleCipher *cipher) |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
395 | { |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
396 | return 8; |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
397 | } |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
398 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
399 | /* |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
400 | * Electronic Codebook Mode DES encryption/decryption of data according to |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
401 | * 'mode'. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
402 | */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
403 | int |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
404 | purple_des_cipher_ecb_crypt(PurpleDESCipher *des_cipher, const guint8 * from, guint8 * to, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
405 | int mode) |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
406 | { |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
407 | guint32 left, right, work; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
408 | guint32 *keys; |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
409 | PurpleDESCipherPrivate *priv = PURPLE_DES_CIPHER_GET_PRIVATE(des_cipher); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
410 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
411 | keys = mode ? priv->decrypt_subkeys : |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
412 | priv->encrypt_subkeys; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
413 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
414 | READ_64BIT_DATA (from, left, right) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
415 | INITIAL_PERMUTATION (left, work, right) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
416 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
417 | DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
418 | DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
419 | DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
420 | DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
421 | DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
422 | DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
423 | DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
424 | DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
425 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
426 | FINAL_PERMUTATION (right, work, left) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
427 | WRITE_64BIT_DATA (to, right, left) |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
428 | |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
429 | return 0; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
430 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
431 | |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
432 | static ssize_t |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
433 | purple_des_cipher_encrypt(PurpleCipher *cipher, const guchar input[], |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
434 | size_t in_len, guchar output[], size_t out_size) |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
435 | { |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
436 | PurpleDESCipher *des_cipher = PURPLE_DES_CIPHER(cipher); |
| 34889 | 437 | |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34222
diff
changeset
|
438 | gsize offset = 0; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
439 | int i = 0; |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34222
diff
changeset
|
440 | gsize tmp; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
441 | guint8 buf[8] = {0,0,0,0,0,0,0,0}; |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34222
diff
changeset
|
442 | gsize out_len; |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
443 | |
|
34215
717a428718a6
ciphers: Fix DES sanity checking - this makes MSN work again
Daniel Atallah <datallah@pidgin.im>
parents:
33944
diff
changeset
|
444 | g_return_val_if_fail(out_size >= in_len, -1); |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
445 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
446 | while(offset + 8 <= in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
447 | purple_des_cipher_ecb_crypt(des_cipher, input + offset, output + offset, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
448 | offset += 8; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
449 | } |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
450 | |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
451 | out_len = in_len; |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
452 | |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
453 | if(offset<in_len) { |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34222
diff
changeset
|
454 | g_return_val_if_fail(in_len >= offset, -1); |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
455 | out_len += in_len - offset; |
|
34215
717a428718a6
ciphers: Fix DES sanity checking - this makes MSN work again
Daniel Atallah <datallah@pidgin.im>
parents:
33944
diff
changeset
|
456 | g_return_val_if_fail(out_size >= out_len, -1); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
457 | tmp = offset; |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
458 | while(tmp<in_len) { |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
459 | buf[i++] = input[tmp]; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
460 | tmp++; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
461 | } |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
462 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
463 | purple_des_cipher_ecb_crypt(des_cipher, buf, output + offset, 0); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
464 | } |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
465 | |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
466 | return out_len; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
467 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
468 | |
|
33944
1ca572ed7563
Fix some minor type warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33914
diff
changeset
|
469 | static ssize_t |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
470 | purple_des_cipher_decrypt(PurpleCipher *cipher, const guchar input[], |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
471 | size_t in_len, guchar output[], size_t out_size) |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
472 | { |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
473 | PurpleDESCipher *des_cipher = PURPLE_DES_CIPHER(cipher); |
| 34889 | 474 | |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34222
diff
changeset
|
475 | gsize offset = 0; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
476 | int i = 0; |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34222
diff
changeset
|
477 | gsize tmp; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
478 | guint8 buf[8] = {0,0,0,0,0,0,0,0}; |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34222
diff
changeset
|
479 | gsize out_len; |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
480 | |
|
34215
717a428718a6
ciphers: Fix DES sanity checking - this makes MSN work again
Daniel Atallah <datallah@pidgin.im>
parents:
33944
diff
changeset
|
481 | g_return_val_if_fail(out_size >= in_len, -1); |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
482 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
483 | while(offset + 8 <= in_len) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
484 | purple_des_cipher_ecb_crypt(des_cipher, input + offset, output + offset, 1); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
485 | offset += 8; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
486 | } |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
487 | |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
488 | out_len = in_len; |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
489 | if(offset<in_len) { |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34222
diff
changeset
|
490 | g_return_val_if_fail(in_len >= offset, -1); |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
491 | out_len += in_len - offset; |
|
34215
717a428718a6
ciphers: Fix DES sanity checking - this makes MSN work again
Daniel Atallah <datallah@pidgin.im>
parents:
33944
diff
changeset
|
492 | g_return_val_if_fail(out_size >= out_len, -1); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
493 | tmp = offset; |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
494 | while(tmp<in_len) { |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
495 | buf[i++] = input[tmp]; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
496 | tmp++; |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
497 | } |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
498 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
499 | purple_des_cipher_ecb_crypt(des_cipher, buf, output + offset, 1); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
500 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
501 | |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
502 | return out_len; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
503 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
504 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
505 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
506 | * Object Stuff |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
507 | *****************************************************************************/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
508 | static void |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
509 | purple_des_cipher_set_property(GObject *obj, guint param_id, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
510 | const GValue *value, GParamSpec *pspec) |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
511 | { |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
512 | PurpleCipher *cipher = PURPLE_CIPHER(obj); |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
513 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
514 | switch(param_id) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
515 | case PROP_KEY: |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
516 | 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:
33944
diff
changeset
|
517 | purple_des_cipher_get_key_size(cipher)); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
518 | break; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
519 | default: |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
520 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
521 | break; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
522 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
523 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
524 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
525 | static void |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
526 | purple_des_cipher_class_init(PurpleDESCipherClass *klass) |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
527 | { |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
528 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
529 | PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
530 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
531 | parent_class = g_type_class_peek_parent(klass); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
532 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
533 | obj_class->set_property = purple_des_cipher_set_property; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
534 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
535 | cipher_class->encrypt = purple_des_cipher_encrypt; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
536 | cipher_class->decrypt = purple_des_cipher_decrypt; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
537 | cipher_class->set_key = purple_des_cipher_set_key; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
538 | cipher_class->get_key_size = purple_des_cipher_get_key_size; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
539 | |
|
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
|
540 | g_type_class_add_private(klass, sizeof(PurpleDESCipherPrivate)); |
|
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
|
541 | |
|
35077
0a120b204362
ciphers: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
542 | 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:
35026
diff
changeset
|
543 | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
544 | |
|
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
|
545 | g_object_class_install_properties(obj_class, PROP_LAST, properties); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
546 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
547 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
548 | /****************************************************************************** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
549 | * API |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
550 | *****************************************************************************/ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
551 | GType |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
552 | purple_des_cipher_get_type(void) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
553 | static GType type = 0; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
554 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
555 | if(type == 0) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
556 | static const GTypeInfo info = { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
557 | .class_size = sizeof(PurpleDESCipherClass), |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
558 | .class_init = (GClassInitFunc)purple_des_cipher_class_init, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
559 | .instance_size = sizeof(PurpleDESCipher), |
|
34548
18cc6efb5194
Added reset at every cipher's initialization
Ankit Vani <a@nevitus.org>
parents:
34547
diff
changeset
|
560 | .instance_init = (GInstanceInitFunc)purple_cipher_reset, |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
561 | }; |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
562 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
563 | type = g_type_register_static(PURPLE_TYPE_CIPHER, |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
564 | "PurpleDESCipher", |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
565 | &info, 0); |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
566 | } |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
567 | |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
568 | return type; |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
569 | } |
|
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
570 | |
|
34537
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
571 | /** |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
572 | * purple_des_cipher_new: |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
573 | * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
574 | * Creates a new #PurpleCipher instance which implements the DES block cipher. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
575 | * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
576 | * Return Value: The new DES implementation of #PurpleCipher. |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
577 | */ |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
578 | PurpleCipher * |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
579 | purple_des_cipher_new(void) { |
|
fb40b0460a36
GObjectify the DES and Triple-DES ciphers
Ankit Vani <a@nevitus.org>
parents:
33944
diff
changeset
|
580 | return g_object_new(PURPLE_TYPE_DES_CIPHER, NULL); |
|
31427
898d3736ee40
broke des and des3 out to ciphers/des.c
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
581 | } |