Sat, 18 May 2013 19:22:47 +0200
win32: globally define _WIN32_WINNT macro, tune config, move gtkconv themes
| 10684 | 1 | /** |
| 15884 | 2 | * @file cipher.h Purple Cipher API |
| 10684 | 3 | * @ingroup core |
|
20889
3d0ef192f98c
All the links to libpurple signal pages were in the comment containing the
Will Thompson <resiak@pidgin.im>
parents:
20147
diff
changeset
|
4 | * @see @ref cipher-signals |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
7 | /* purple |
| 10684 | 8 | * |
| 15884 | 9 | * Purple is the legal property of its developers, whose names are too numerous |
| 10684 | 10 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 11 | * source distribution. | |
| 12 | * | |
| 13 | * This program is free software; you can redistribute it and/or modify | |
| 14 | * it under the terms of the GNU General Public License as published by | |
| 15 | * the Free Software Foundation; either version 2 of the License, or | |
| 16 | * (at your option) any later version. | |
| 17 | * | |
| 18 | * This program is distributed in the hope that it will be useful, | |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 21 | * GNU General Public License for more details. | |
| 22 | * | |
| 23 | * You should have received a copy of the GNU General Public License | |
| 24 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18412
diff
changeset
|
25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 10684 | 26 | */ |
| 15884 | 27 | #ifndef PURPLE_CIPHER_H |
| 28 | #define PURPLE_CIPHER_H | |
| 10684 | 29 | |
| 30 | #include <glib.h> | |
|
31428
f392265bbe2d
included string.h in cipher.h since almost all of the ciphers use it.
Gary Kramlich <grim@reaperworld.com>
parents:
31421
diff
changeset
|
31 | #include <string.h> |
| 10684 | 32 | |
| 15884 | 33 | #define PURPLE_CIPHER(obj) ((PurpleCipher *)(obj)) /**< PurpleCipher typecast helper */ |
| 34 | #define PURPLE_CIPHER_OPS(obj) ((PurpleCipherOps *)(obj)) /**< PurpleCipherInfo typecase helper */ | |
| 35 | #define PURPLE_CIPHER_CONTEXT(obj) ((PurpleCipherContext *)(obj)) /**< PurpleCipherContext typecast helper */ | |
| 10684 | 36 | |
| 15884 | 37 | typedef struct _PurpleCipher PurpleCipher; /**< A handle to a PurpleCipher */ |
| 38 | typedef struct _PurpleCipherOps PurpleCipherOps; /**< Ops for a PurpleCipher */ | |
| 39 | typedef struct _PurpleCipherContext PurpleCipherContext; /**< A context for a PurpleCipher */ | |
| 10684 | 40 | |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
41 | /** |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
42 | * Modes for batch encrypters |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
43 | */ |
|
32206
a2c62b07ae5a
Please correct me if I'm wrong, but I don't think we gain anything
Mark Doliner <markdoliner@pidgin.im>
parents:
31430
diff
changeset
|
44 | typedef enum { |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
45 | PURPLE_CIPHER_BATCH_MODE_ECB, |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
46 | PURPLE_CIPHER_BATCH_MODE_CBC |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
47 | } PurpleCipherBatchMode; |
| 10684 | 48 | |
| 49 | /** | |
| 50 | * The operation flags for a cipher | |
| 51 | */ | |
|
32206
a2c62b07ae5a
Please correct me if I'm wrong, but I don't think we gain anything
Mark Doliner <markdoliner@pidgin.im>
parents:
31430
diff
changeset
|
52 | typedef enum { |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
53 | PURPLE_CIPHER_CAPS_SET_OPT = 1 << 1, /**< Set option flag */ |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
54 | PURPLE_CIPHER_CAPS_GET_OPT = 1 << 2, /**< Get option flag */ |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
55 | PURPLE_CIPHER_CAPS_INIT = 1 << 3, /**< Init flag */ |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
56 | PURPLE_CIPHER_CAPS_RESET = 1 << 4, /**< Reset flag */ |
|
33913
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
57 | PURPLE_CIPHER_CAPS_RESET_STATE = 1 << 5, /**< Reset state flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
58 | PURPLE_CIPHER_CAPS_UNINIT = 1 << 6, /**< Uninit flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
59 | PURPLE_CIPHER_CAPS_SET_IV = 1 << 7, /**< Set IV flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
60 | PURPLE_CIPHER_CAPS_APPEND = 1 << 8, /**< Append flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
61 | PURPLE_CIPHER_CAPS_DIGEST = 1 << 9, /**< Digest flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
62 | PURPLE_CIPHER_CAPS_GET_DIGEST_SIZE = 1 << 10, /**< The get digest size flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
63 | PURPLE_CIPHER_CAPS_ENCRYPT = 1 << 11, /**< Encrypt flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
64 | PURPLE_CIPHER_CAPS_DECRYPT = 1 << 12, /**< Decrypt flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
65 | PURPLE_CIPHER_CAPS_SET_SALT = 1 << 13, /**< Set salt flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
66 | PURPLE_CIPHER_CAPS_GET_SALT_SIZE = 1 << 14, /**< Get salt size flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
67 | PURPLE_CIPHER_CAPS_SET_KEY = 1 << 15, /**< Set key flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
68 | PURPLE_CIPHER_CAPS_GET_KEY_SIZE = 1 << 16, /**< Get key size flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
69 | PURPLE_CIPHER_CAPS_SET_BATCH_MODE = 1 << 17, /**< Set batch mode flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
70 | PURPLE_CIPHER_CAPS_GET_BATCH_MODE = 1 << 18, /**< Get batch mode flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
71 | PURPLE_CIPHER_CAPS_GET_BLOCK_SIZE = 1 << 19, /**< The get block size flag */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
72 | PURPLE_CIPHER_CAPS_UNKNOWN = 1 << 20 /**< Unknown */ |
| 15884 | 73 | } PurpleCipherCaps; |
| 10684 | 74 | |
| 75 | /** | |
| 76 | * The operations of a cipher. Every cipher must implement one of these. | |
| 77 | */ | |
| 15884 | 78 | struct _PurpleCipherOps { |
| 10684 | 79 | /** The set option function */ |
| 15884 | 80 | void (*set_option)(PurpleCipherContext *context, const gchar *name, void *value); |
| 10684 | 81 | |
| 82 | /** The get option function */ | |
| 15884 | 83 | void *(*get_option)(PurpleCipherContext *context, const gchar *name); |
| 10684 | 84 | |
| 85 | /** The init function */ | |
| 15884 | 86 | void (*init)(PurpleCipherContext *context, void *extra); |
| 10684 | 87 | |
| 88 | /** The reset function */ | |
| 15884 | 89 | void (*reset)(PurpleCipherContext *context, void *extra); |
| 10684 | 90 | |
|
33913
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
91 | /** The reset state function */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
92 | void (*reset_state)(PurpleCipherContext *context, void *extra); |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
93 | |
| 10684 | 94 | /** The uninit function */ |
| 15884 | 95 | void (*uninit)(PurpleCipherContext *context); |
| 10684 | 96 | |
| 97 | /** The set initialization vector function */ | |
| 15884 | 98 | void (*set_iv)(PurpleCipherContext *context, guchar *iv, size_t len); |
| 10684 | 99 | |
| 100 | /** The append data function */ | |
| 15884 | 101 | void (*append)(PurpleCipherContext *context, const guchar *data, size_t len); |
| 10684 | 102 | |
| 103 | /** The digest function */ | |
|
33909
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
104 | gboolean (*digest)(PurpleCipherContext *context, guchar digest[], size_t len); |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
105 | |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
106 | /** The get digest size function */ |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
107 | size_t (*get_digest_size)(PurpleCipherContext *context); |
| 10684 | 108 | |
| 109 | /** The encrypt function */ | |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
110 | ssize_t (*encrypt)(PurpleCipherContext *context, const guchar input[], size_t in_len, guchar output[], size_t out_size); |
| 10684 | 111 | |
| 112 | /** The decrypt function */ | |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
113 | ssize_t (*decrypt)(PurpleCipherContext *context, const guchar input[], size_t in_len, guchar output[], size_t out_size); |
| 10684 | 114 | |
| 115 | /** The set salt function */ | |
|
33915
5bc654243432
ciphers cleanup: set_salt - add const
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33913
diff
changeset
|
116 | void (*set_salt)(PurpleCipherContext *context, const guchar *salt, size_t len); |
| 10684 | 117 | |
| 118 | /** The get salt size function */ | |
| 15884 | 119 | size_t (*get_salt_size)(PurpleCipherContext *context); |
| 10684 | 120 | |
| 121 | /** The set key function */ | |
|
33908
78b42fd69e02
ciphers cleanup: passing keys with length by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32206
diff
changeset
|
122 | void (*set_key)(PurpleCipherContext *context, const guchar *key, size_t len); |
|
16743
1ce5ffe12e2a
Initial addition of padding for ui_ops and other class-like structs
Gary Kramlich <grim@reaperworld.com>
parents:
15884
diff
changeset
|
123 | |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
124 | /** The get key size function */ |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
125 | size_t (*get_key_size)(PurpleCipherContext *context); |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
126 | |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
127 | /** The set batch mode function */ |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
128 | void (*set_batch_mode)(PurpleCipherContext *context, PurpleCipherBatchMode mode); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
129 | |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
130 | /** The get batch mode function */ |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
131 | PurpleCipherBatchMode (*get_batch_mode)(PurpleCipherContext *context); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
132 | |
|
22025
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
133 | /** The get block size function */ |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
134 | size_t (*get_block_size)(PurpleCipherContext *context); |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
135 | |
|
33908
78b42fd69e02
ciphers cleanup: passing keys with length by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32206
diff
changeset
|
136 | void (*_purple_reserved1)(void); |
|
78b42fd69e02
ciphers cleanup: passing keys with length by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32206
diff
changeset
|
137 | void (*_purple_reserved2)(void); |
|
78b42fd69e02
ciphers cleanup: passing keys with length by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32206
diff
changeset
|
138 | void (*_purple_reserved3)(void); |
|
78b42fd69e02
ciphers cleanup: passing keys with length by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32206
diff
changeset
|
139 | void (*_purple_reserved4)(void); |
| 10684 | 140 | }; |
| 141 | ||
|
31421
713fb035d563
Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
25888
diff
changeset
|
142 | G_BEGIN_DECLS |
| 10684 | 143 | |
| 144 | /*****************************************************************************/ | |
| 15884 | 145 | /** @name PurpleCipher API */ |
| 10684 | 146 | /*****************************************************************************/ |
| 147 | /*@{*/ | |
| 148 | ||
| 149 | /** | |
| 150 | * Gets a cipher's name | |
| 151 | * | |
| 152 | * @param cipher The cipher handle | |
| 153 | * | |
| 154 | * @return The cipher's name | |
| 155 | */ | |
| 15884 | 156 | const gchar *purple_cipher_get_name(PurpleCipher *cipher); |
| 10684 | 157 | |
| 158 | /** | |
| 159 | * Gets a cipher's capabilities | |
| 160 | * | |
| 161 | * @param cipher The cipher handle | |
| 162 | * | |
| 163 | * @return The cipher's info | |
| 164 | */ | |
| 15884 | 165 | guint purple_cipher_get_capabilities(PurpleCipher *cipher); |
| 10684 | 166 | |
| 167 | /** | |
| 168 | * Gets a digest from a cipher | |
| 169 | * | |
| 10687 | 170 | * @param name The cipher's name |
| 171 | * @param data The data to hash | |
| 172 | * @param data_len The length of the data | |
| 173 | * @param digest The returned digest | |
|
33909
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
174 | * @param out_size The size of digest buffer |
| 10687 | 175 | * |
|
33912
01e0d716a28e
ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33911
diff
changeset
|
176 | * @return The count of bytes written, or -1 if failed |
| 10684 | 177 | */ |
|
33912
01e0d716a28e
ciphers cleanup: fix perl compilation; better purple_cipher_digest_region
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33911
diff
changeset
|
178 | ssize_t purple_cipher_digest_region(const gchar *name, const guchar *data, size_t data_len, guchar digest[], size_t out_size); |
| 10684 | 179 | |
| 180 | /*@}*/ | |
| 181 | /******************************************************************************/ | |
| 15884 | 182 | /** @name PurpleCiphers API */ |
| 10684 | 183 | /******************************************************************************/ |
| 184 | /*@{*/ | |
| 185 | ||
| 186 | /** | |
| 187 | * Finds a cipher by it's name | |
| 188 | * | |
| 189 | * @param name The name of the cipher to find | |
| 190 | * | |
| 191 | * @return The cipher handle or @c NULL | |
| 192 | */ | |
| 15884 | 193 | PurpleCipher *purple_ciphers_find_cipher(const gchar *name); |
| 10684 | 194 | |
| 195 | /** | |
| 196 | * Registers a cipher as a usable cipher | |
| 197 | * | |
| 198 | * @param name The name of the new cipher | |
| 199 | * @param ops The cipher ops to register | |
| 200 | * | |
| 201 | * @return The handle to the new cipher or @c NULL if it failed | |
| 202 | */ | |
| 15884 | 203 | PurpleCipher *purple_ciphers_register_cipher(const gchar *name, PurpleCipherOps *ops); |
| 10684 | 204 | |
| 205 | /** | |
| 206 | * Unregisters a cipher | |
| 207 | * | |
| 208 | * @param cipher The cipher handle to unregister | |
| 209 | * | |
| 210 | * @return Whether or not the cipher was successfully unloaded | |
| 211 | */ | |
| 15884 | 212 | gboolean purple_ciphers_unregister_cipher(PurpleCipher *cipher); |
| 10684 | 213 | |
| 214 | /** | |
| 215 | * Gets the list of ciphers | |
| 216 | * | |
| 217 | * @return The list of available ciphers | |
| 218 | * @note This list should not be modified, it is owned by the cipher core | |
| 219 | */ | |
| 15884 | 220 | GList *purple_ciphers_get_ciphers(void); |
| 10684 | 221 | |
| 222 | /*@}*/ | |
| 223 | /******************************************************************************/ | |
| 15884 | 224 | /** @name PurpleCipher Subsystem API */ |
| 10684 | 225 | /******************************************************************************/ |
| 226 | /*@{*/ | |
| 227 | ||
| 228 | /** | |
| 229 | * Gets the handle to the cipher subsystem | |
| 230 | * | |
| 231 | * @return The handle to the cipher subsystem | |
| 232 | */ | |
| 15884 | 233 | gpointer purple_ciphers_get_handle(void); |
| 10684 | 234 | |
| 235 | /** | |
| 236 | * Initializes the cipher core | |
| 237 | */ | |
| 15884 | 238 | void purple_ciphers_init(void); |
| 10684 | 239 | |
| 240 | /** | |
| 241 | * Uninitializes the cipher core | |
| 242 | */ | |
| 15884 | 243 | void purple_ciphers_uninit(void); |
| 10684 | 244 | |
| 245 | /*@}*/ | |
| 246 | /******************************************************************************/ | |
| 15884 | 247 | /** @name PurpleCipherContext API */ |
| 10684 | 248 | /******************************************************************************/ |
| 249 | /*@{*/ | |
| 250 | ||
| 251 | /** | |
| 252 | * Sets the value an option on a cipher context | |
| 253 | * | |
| 254 | * @param context The cipher context | |
| 255 | * @param name The name of the option | |
| 256 | * @param value The value to set | |
| 257 | */ | |
| 15884 | 258 | void purple_cipher_context_set_option(PurpleCipherContext *context, const gchar *name, gpointer value); |
| 10684 | 259 | |
| 260 | /** | |
| 261 | * Gets the vale of an option on a cipher context | |
| 262 | * | |
| 263 | * @param context The cipher context | |
| 264 | * @param name The name of the option | |
| 265 | * @return The value of the option | |
| 266 | */ | |
| 15884 | 267 | gpointer purple_cipher_context_get_option(PurpleCipherContext *context, const gchar *name); |
| 10684 | 268 | |
| 269 | /** | |
| 270 | * Creates a new cipher context and initializes it | |
| 271 | * | |
| 272 | * @param cipher The cipher to use | |
| 273 | * @param extra Extra data for the specific cipher | |
| 274 | * | |
| 275 | * @return The new cipher context | |
| 276 | */ | |
| 15884 | 277 | PurpleCipherContext *purple_cipher_context_new(PurpleCipher *cipher, void *extra); |
| 10684 | 278 | |
| 279 | /** | |
| 280 | * Creates a new cipher context by the cipher name and initializes it | |
| 281 | * | |
| 282 | * @param name The cipher's name | |
| 283 | * @param extra Extra data for the specific cipher | |
| 284 | * | |
| 285 | * @return The new cipher context | |
| 286 | */ | |
| 15884 | 287 | PurpleCipherContext *purple_cipher_context_new_by_name(const gchar *name, void *extra); |
| 10684 | 288 | |
| 289 | /** | |
| 290 | * Resets a cipher context to it's default value | |
| 291 | * @note If you have set an IV you will have to set it after resetting | |
| 292 | * | |
| 293 | * @param context The context to reset | |
| 294 | * @param extra Extra data for the specific cipher | |
| 295 | */ | |
| 15884 | 296 | void purple_cipher_context_reset(PurpleCipherContext *context, gpointer extra); |
| 10684 | 297 | |
| 298 | /** | |
|
33913
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
299 | * Resets a cipher state to it's default value, but doesn't touch stateless |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
300 | * configuration. |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
301 | * |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
302 | * That means, IV and digest context will be wiped out, but keys, ops or salt |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
303 | * will remain untouched. |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
304 | * |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
305 | * @param context The context to reset |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
306 | * @param extra Extra data for the specific cipher |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
307 | */ |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
308 | void purple_cipher_context_reset_state(PurpleCipherContext *context, gpointer extra); |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
309 | |
|
9effc94565d8
ciphers cleanup: add reset state callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33912
diff
changeset
|
310 | /** |
| 10684 | 311 | * Destorys a cipher context and deinitializes it |
| 312 | * | |
| 313 | * @param context The cipher context to destory | |
| 314 | */ | |
| 15884 | 315 | void purple_cipher_context_destroy(PurpleCipherContext *context); |
| 10684 | 316 | |
| 317 | /** | |
| 318 | * Sets the initialization vector for a context | |
| 319 | * @note This should only be called right after a cipher context is created or reset | |
| 320 | * | |
| 321 | * @param context The context to set the IV to | |
| 322 | * @param iv The initialization vector to set | |
| 323 | * @param len The len of the IV | |
| 324 | */ | |
| 15884 | 325 | void purple_cipher_context_set_iv(PurpleCipherContext *context, guchar *iv, size_t len); |
| 10684 | 326 | |
| 327 | /** | |
| 328 | * Appends data to the context | |
| 329 | * | |
| 330 | * @param context The context to append data to | |
| 331 | * @param data The data to append | |
| 332 | * @param len The length of the data | |
| 333 | */ | |
| 15884 | 334 | void purple_cipher_context_append(PurpleCipherContext *context, const guchar *data, size_t len); |
| 10684 | 335 | |
| 336 | /** | |
| 337 | * Digests a context | |
| 338 | * | |
| 339 | * @param context The context to digest | |
| 340 | * @param digest The return buffer for the digest | |
|
33909
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
341 | * @param len The length of the buffer |
| 10684 | 342 | */ |
|
33909
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
343 | gboolean purple_cipher_context_digest(PurpleCipherContext *context, guchar digest[], size_t len); |
| 10684 | 344 | |
| 345 | /** | |
|
11183
be87fe695c93
[gaim-migrate @ 13295]
Mark Doliner <markdoliner@pidgin.im>
parents:
10687
diff
changeset
|
346 | * Converts a guchar digest into a hex string |
| 10684 | 347 | * |
| 348 | * @param context The context to get a digest from | |
| 349 | * @param digest_s The return buffer for the string digest | |
|
33909
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
350 | * @param len The length of the buffer |
| 10684 | 351 | */ |
|
33909
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
352 | gboolean purple_cipher_context_digest_to_str(PurpleCipherContext *context, gchar digest_s[], size_t len); |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
353 | |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
354 | /** |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
355 | * Gets the digest size of a context |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
356 | * |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
357 | * @param context The context whose digest size to get |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
358 | * |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
359 | * @return The digest size of the context |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
360 | */ |
|
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
361 | size_t purple_cipher_context_get_digest_size(PurpleCipherContext *context); |
| 10684 | 362 | |
| 363 | /** | |
| 364 | * Encrypts data using the context | |
| 365 | * | |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
366 | * @param context The context |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
367 | * @param input The data to encrypt |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
368 | * @param in_len The length of the data |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
369 | * @param output The output buffer |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
370 | * @param out_size The size of the output buffer |
| 10684 | 371 | * |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
372 | * @return A length of data that was outputed or -1, if failed |
| 10684 | 373 | */ |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
374 | ssize_t purple_cipher_context_encrypt(PurpleCipherContext *context, const guchar input[], size_t in_len, guchar output[], size_t out_size); |
| 10684 | 375 | |
| 376 | /** | |
| 377 | * Decrypts data using the context | |
| 378 | * | |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
379 | * @param context The context |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
380 | * @param input The data to encrypt |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
381 | * @param in_len The length of the returned value |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
382 | * @param output The output buffer |
|
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
383 | * @param out_size The size of the output buffer |
| 10684 | 384 | * |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
385 | * @return A length of data that was outputed or -1, if failed |
| 10684 | 386 | */ |
|
33911
a924aacd5a37
ciphers cleanup: encryption and decryption lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33910
diff
changeset
|
387 | ssize_t purple_cipher_context_decrypt(PurpleCipherContext *context, const guchar input[], size_t in_len, guchar output[], size_t out_size); |
| 10684 | 388 | |
| 389 | /** | |
| 390 | * Sets the salt on a context | |
| 391 | * | |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
392 | * @param context The context whose salt to set |
| 10684 | 393 | * @param salt The salt |
|
33909
773899cbd05a
ciphers cleanup: salt and digest lengths
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33908
diff
changeset
|
394 | * @param len The length of the salt |
| 10684 | 395 | */ |
|
33915
5bc654243432
ciphers cleanup: set_salt - add const
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33913
diff
changeset
|
396 | void purple_cipher_context_set_salt(PurpleCipherContext *context, const guchar *salt, size_t len); |
| 10684 | 397 | |
| 398 | /** | |
| 399 | * Gets the size of the salt if the cipher supports it | |
| 400 | * | |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
401 | * @param context The context whose salt size to get |
| 10684 | 402 | * |
| 403 | * @return The size of the salt | |
| 404 | */ | |
| 15884 | 405 | size_t purple_cipher_context_get_salt_size(PurpleCipherContext *context); |
| 10684 | 406 | |
| 407 | /** | |
| 408 | * Sets the key on a context | |
| 409 | * | |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
410 | * @param context The context whose key to set |
| 10684 | 411 | * @param key The key |
|
33908
78b42fd69e02
ciphers cleanup: passing keys with length by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32206
diff
changeset
|
412 | * @param len The size of the key |
| 10684 | 413 | */ |
|
33908
78b42fd69e02
ciphers cleanup: passing keys with length by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32206
diff
changeset
|
414 | void purple_cipher_context_set_key(PurpleCipherContext *context, const guchar *key, size_t len); |
| 10684 | 415 | |
| 416 | /** | |
|
33910
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
417 | * Gets the size of the key if the cipher supports it |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
418 | * |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
419 | * @param context The context whose key size to get |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
420 | * |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
421 | * @return The size of the key |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
422 | */ |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
423 | size_t purple_cipher_context_get_key_size(PurpleCipherContext *context); |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
424 | |
|
5749f2724b12
ciphers cleanup: get key size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33909
diff
changeset
|
425 | /** |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
426 | * Sets the batch mode of a context |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
427 | * |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
428 | * @param context The context whose batch mode to set |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
429 | * @param mode The batch mode under which the cipher should operate |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
430 | * |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
431 | */ |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
432 | void purple_cipher_context_set_batch_mode(PurpleCipherContext *context, PurpleCipherBatchMode mode); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
433 | |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
434 | /** |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
435 | * Gets the batch mode of a context |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
436 | * |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
437 | * @param context The context whose batch mode to get |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
438 | * |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
439 | * @return The batch mode under which the cipher is operating |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
440 | */ |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
441 | PurpleCipherBatchMode purple_cipher_context_get_batch_mode(PurpleCipherContext *context); |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
442 | |
|
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
443 | /** |
|
22025
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
444 | * Gets the block size of a context |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
445 | * |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
446 | * @param context The context whose block size to get |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
447 | * |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
448 | * @return The block size of the context |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
449 | */ |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
450 | size_t purple_cipher_context_get_block_size(PurpleCipherContext *context); |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
451 | |
|
23756775175d
HMAC digest support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22024
diff
changeset
|
452 | /** |
| 10684 | 453 | * Sets the cipher data for a context |
| 454 | * | |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
455 | * @param context The context whose cipher data to set |
| 10684 | 456 | * @param data The cipher data to set |
| 457 | */ | |
| 15884 | 458 | void purple_cipher_context_set_data(PurpleCipherContext *context, gpointer data); |
| 10684 | 459 | |
| 460 | /** | |
| 461 | * Gets the cipher data for a context | |
| 462 | * | |
|
22024
3fd5e4fff1be
Triple DES cipher support from Elliott Sales de Andrade
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
20889
diff
changeset
|
463 | * @param context The context whose cipher data to get |
| 10684 | 464 | * |
| 465 | * @return The cipher data | |
| 466 | */ | |
| 15884 | 467 | gpointer purple_cipher_context_get_data(PurpleCipherContext *context); |
| 10684 | 468 | |
|
12388
3a25d96abdaf
[gaim-migrate @ 14694]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
469 | /*@}*/ |
|
3a25d96abdaf
[gaim-migrate @ 14694]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
470 | /*****************************************************************************/ |
| 15884 | 471 | /** @name Purple Cipher HTTP Digest Helper Functions */ |
|
12388
3a25d96abdaf
[gaim-migrate @ 14694]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
472 | /*****************************************************************************/ |
|
3a25d96abdaf
[gaim-migrate @ 14694]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
473 | /*@{*/ |
|
3a25d96abdaf
[gaim-migrate @ 14694]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
474 | |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
475 | /** |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
476 | * Calculates a session key for HTTP Digest authentation |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
477 | * |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
478 | * See RFC 2617 for more information. |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
479 | * |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
480 | * @param algorithm The hash algorithm to use |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
481 | * @param username The username provided by the user |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
482 | * @param realm The authentication realm provided by the server |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
483 | * @param password The password provided by the user |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
484 | * @param nonce The nonce provided by the server |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
485 | * @param client_nonce The nonce provided by the client |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
486 | * |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
487 | * @return The session key, or @c NULL if an error occurred. |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
488 | */ |
| 15884 | 489 | gchar *purple_cipher_http_digest_calculate_session_key( |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
490 | const gchar *algorithm, const gchar *username, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
491 | const gchar *realm, const gchar *password, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
492 | const gchar *nonce, const gchar *client_nonce); |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
493 | |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
494 | /** Calculate a response for HTTP Digest authentication |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
495 | * |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
496 | * See RFC 2617 for more information. |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
497 | * |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
498 | * @param algorithm The hash algorithm to use |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
499 | * @param method The HTTP method in use |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
500 | * @param digest_uri The URI from the initial request |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
501 | * @param qop The "quality of protection" |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
502 | * @param entity The entity body |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
503 | * @param nonce The nonce provided by the server |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
504 | * @param nonce_count The nonce count |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
505 | * @param client_nonce The nonce provided by the client |
| 15884 | 506 | * @param session_key The session key from purple_cipher_http_digest_calculate_session_key() |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
507 | * |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
508 | * @return The hashed response, or @c NULL if an error occurred. |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
509 | */ |
| 15884 | 510 | gchar *purple_cipher_http_digest_calculate_response( |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
511 | const gchar *algorithm, const gchar *method, |
|
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
512 | const gchar *digest_uri, const gchar *qop, |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
513 | const gchar *entity, const gchar *nonce, |
|
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
514 | const gchar *nonce_count, const gchar *client_nonce, |
|
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12388
diff
changeset
|
515 | const gchar *session_key); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
516 | |
| 10684 | 517 | /*@}*/ |
|
31421
713fb035d563
Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
25888
diff
changeset
|
518 | |
|
713fb035d563
Created a new branch to break the ciphers out to their own files. Also I've now exposed purple_g_checksum_* if we're on glib >= 2.16.0
Gary Kramlich <grim@reaperworld.com>
parents:
25888
diff
changeset
|
519 | G_END_DECLS |
| 10684 | 520 | |
| 15884 | 521 | #endif /* PURPLE_CIPHER_H */ |