libpurple/plugins/perl/common/Cipher.xs

Sun, 16 Jun 2013 05:59:31 +0530

author
Ankit Vani <a@nevitus.org>
date
Sun, 16 Jun 2013 05:59:31 +0530
branch
soc.2013.gobjectification
changeset 34567
ea5103f66b0e
parent 34552
d39fc37af80a
child 34606
bca53cda8ed5
permissions
-rw-r--r--

Refactor the codebase to use PurpleHash

11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
1 #include "module.h"
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
2
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
3 MODULE = Purple::Cipher PACKAGE = Purple::Cipher PREFIX = purple_cipher_
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
4 PROTOTYPES: ENABLE
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
5
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
6 BOOT:
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
7 {
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
8 HV *stash = gv_stashpv("Purple::Cipher::BatchMode", 1);
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
9
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
10 static const constiv *civ, const_iv[] = {
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
11 #define const_iv(name) {#name, (IV)PURPLE_CIPHER_BATCH_MODE_##name}
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
12 const_iv(ECB),
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
13 const_iv(CBC),
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
14 #undef const_iv
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
15 };
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
16
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
17 for (civ = const_iv + sizeof(const_iv) / sizeof(const_iv[0]); civ-- > const_iv; )
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
18 newCONSTSUB(stash, (char *)civ->name, newSViv(civ->iv));
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
19 }
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
20
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
21 const gchar *
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
22 purple_cipher_get_name(cipher)
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
23 Purple::Cipher cipher
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
24
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
25 gchar_own*
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
26 purple_http_digest_calculate_response(algorithm, method, digest_uri, qop, entity, nonce, nonce_count, client_nonce, session_key)
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
27 const gchar* algorithm
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
28 const gchar* method
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
29 const gchar* digest_uri
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
30 const gchar* qop
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
31 const gchar* entity
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
32 const gchar* nonce
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
33 const gchar* nonce_count
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
34 const gchar* client_nonce
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
35 const gchar* session_key
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
36
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
37 gchar_own*
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
38 purple_http_digest_calculate_session_key(algorithm, username, realm, password, nonce, client_nonce)
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
39 const gchar* algorithm
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
40 const gchar* username
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
41 const gchar* realm
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
42 const gchar* password
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
43 const gchar* nonce
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
44 const gchar* client_nonce
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
45
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
46 void
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
47 purple_cipher_reset(cipher)
15894
765ec644ac47 Perl fixes for s/gaim/purple/. This hasn't really been tested yet.
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
48 Purple::Cipher cipher
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
49
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
50 void
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
51 purple_cipher_set_iv(Purple::Cipher cipher, guchar *iv, size_t length(iv))
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
52 PROTOTYPE: $$
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
53
12777
68ba8956a3d7 [gaim-migrate @ 15124]
Etan Reisner <deryni@pidgin.im>
parents: 11290
diff changeset
54 void
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
55 purple_cipher_append(Purple::Cipher cipher, guchar *data, size_t length(data))
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
56 PROTOTYPE: $$
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
57
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
58 gboolean
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
59 purple_cipher_digest(cipher, digest)
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
60 Purple::Cipher cipher
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
61 SV *digest
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
62 PREINIT:
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
63 guchar *buff = NULL;
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
64 size_t digest_size;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
65 CODE:
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
66 digest_size = purple_cipher_get_digest_size(cipher);
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
67 SvUPGRADE(digest, SVt_PV);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
68 buff = (guchar *)SvGROW(digest, digest_size);
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
69 if (purple_cipher_digest(cipher, buff, digest_size)) {
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
70 SvCUR_set(digest, digest_size);
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
71 SvPOK_only(digest);
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
72 RETVAL = 1;
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
73 } else {
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
74 SvSetSV_nosteal(digest, &PL_sv_undef);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
75 RETVAL = 0;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
76 }
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
77 OUTPUT:
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
78 RETVAL
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
79
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
80 gboolean
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
81 purple_cipher_digest_to_str(cipher, digest_s)
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
82 Purple::Cipher cipher
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
83 SV *digest_s
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
84 PREINIT:
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
85 gchar *buff = NULL;
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
86 size_t digest_size, str_len;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
87 CODE:
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
88 digest_size = purple_cipher_get_digest_size(cipher);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
89 str_len = 2 * digest_size;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
90 SvUPGRADE(digest_s, SVt_PV);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
91 buff = SvGROW(digest_s, str_len + 1);
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
92 if (purple_cipher_digest_to_str(cipher, buff, str_len + 1)) {
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
93 SvCUR_set(digest_s, str_len);
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
94 SvPOK_only(digest_s);
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
95 RETVAL = 1;
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
96 } else {
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
97 SvSetSV_nosteal(digest_s, &PL_sv_undef);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
98 RETVAL = 0;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
99 }
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
100 OUTPUT:
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
101 RETVAL
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
102
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
103 gboolean
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
104 purple_cipher_encrypt(cipher, input, output)
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
105 Purple::Cipher cipher
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
106 SV *input
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
107 SV *output
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
108 PREINIT:
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
109 size_t input_len, output_len;
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
110 ssize_t ret;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
111 guchar *buff = NULL;
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
112 guchar *data = NULL;
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
113 CODE:
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
114 data = (guchar *)SvPV(input, input_len);
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
115 output_len = input_len + purple_cipher_get_block_size(cipher);
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
116 SvUPGRADE(output, SVt_PV);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
117 buff = (guchar *)SvGROW(output, output_len);
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
118 ret = purple_cipher_encrypt(cipher, data, input_len, buff, output_len);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
119 if (ret >= 0) {
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
120 RETVAL = 1;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
121 SvPOK_only(output);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
122 SvCUR_set(output, ret);
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
123 } else {
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
124 RETVAL = 0;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
125 SvSetSV_nosteal(output, &PL_sv_undef);
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
126 }
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
127 OUTPUT:
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
128 RETVAL
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
129
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
130 gboolean
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
131 purple_cipher_decrypt(cipher, input, output)
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
132 Purple::Cipher cipher
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
133 SV *input
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
134 SV *output
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
135 PREINIT:
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
136 size_t input_len, output_len;
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
137 ssize_t ret;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
138 guchar *buff = NULL;
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
139 guchar *data = NULL;
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
140 CODE:
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
141 data = (guchar *)SvPV(input, input_len);
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
142 output_len = input_len + purple_cipher_get_block_size(cipher);
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
143 SvUPGRADE(output, SVt_PV);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
144 buff = (guchar *)SvGROW(output, output_len);
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
145 ret = purple_cipher_decrypt(cipher, data, input_len, buff, output_len);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
146 if (ret >= 0) {
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
147 RETVAL = 1;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
148 SvPOK_only(output);
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
149 SvCUR_set(output, ret);
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
150 } else {
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
151 RETVAL = 0;
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
152 SvSetSV_nosteal(output, &PL_sv_undef);
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
153 }
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
154 OUTPUT:
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
155 RETVAL
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
156
12777
68ba8956a3d7 [gaim-migrate @ 15124]
Etan Reisner <deryni@pidgin.im>
parents: 11290
diff changeset
157 void
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
158 purple_cipher_set_salt(cipher, salt, len)
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
159 Purple::Cipher cipher
11183
be87fe695c93 [gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents: 11130
diff changeset
160 guchar *salt
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
161 size_t len
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
162
12777
68ba8956a3d7 [gaim-migrate @ 15124]
Etan Reisner <deryni@pidgin.im>
parents: 11290
diff changeset
163 void
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
164 purple_cipher_set_key(cipher, key, len)
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
165 Purple::Cipher cipher
11183
be87fe695c93 [gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents: 11130
diff changeset
166 guchar *key
33912
01e0d716a28e ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 27158
diff changeset
167 size_t len
11118
36db35a9da56 [gaim-migrate @ 13174]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
168
12777
68ba8956a3d7 [gaim-migrate @ 15124]
Etan Reisner <deryni@pidgin.im>
parents: 11290
diff changeset
169 size_t
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
170 purple_cipher_get_key_size(cipher)
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
171 Purple::Cipher cipher
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
172
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
173 Purple::Cipher::BatchMode
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
174 purple_cipher_get_batch_mode(cipher)
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
175 Purple::Cipher cipher
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
176
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
177 size_t
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
178 purple_cipher_get_block_size(cipher)
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
179 Purple::Cipher cipher
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
180
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
181 void
34552
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
182 purple_cipher_set_batch_mode(cipher, mode)
d39fc37af80a Refactored libpurple/plugins/perl/common to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 33912
diff changeset
183 Purple::Cipher cipher
23982
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
184 Purple::Cipher::BatchMode mode
204b6e71f403 Some Perl bindings fixes and additions from Zsombor Welker.
Daniel Atallah <datallah@pidgin.im>
parents: 15894
diff changeset
185

mercurial