Frameworks/libpurple.framework/Versions/0.6.2/Headers/cipher.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 1739 Frameworks/libpurple.framework/Versions/0.6.0/Headers/cipher.h@8b0daad9656c
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
Evan@653
     1
/**
Evan@653
     2
 * @file cipher.h Purple Cipher API
Evan@653
     3
 * @ingroup core
Evan@653
     4
 * @see @ref cipher-signals
Evan@653
     5
 */
Evan@653
     6
Evan@653
     7
/* purple
Evan@653
     8
 *
Evan@653
     9
 * Purple is the legal property of its developers, whose names are too numerous
Evan@653
    10
 * to list here.  Please refer to the COPYRIGHT file distributed with this
Evan@653
    11
 * source distribution.
Evan@653
    12
 *
Evan@653
    13
 * This program is free software; you can redistribute it and/or modify
Evan@653
    14
 * it under the terms of the GNU General Public License as published by
Evan@653
    15
 * the Free Software Foundation; either version 2 of the License, or
Evan@653
    16
 * (at your option) any later version.
Evan@653
    17
 *
Evan@653
    18
 * This program is distributed in the hope that it will be useful,
Evan@653
    19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Evan@653
    20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Evan@653
    21
 * GNU General Public License for more details.
Evan@653
    22
 *
Evan@653
    23
 * You should have received a copy of the GNU General Public License
Evan@653
    24
 * along with this program; if not, write to the Free Software
Evan@653
    25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
Evan@653
    26
 */
Evan@653
    27
#ifndef PURPLE_CIPHER_H
Evan@653
    28
#define PURPLE_CIPHER_H
Evan@653
    29
Evan@653
    30
#include <glib.h>
Evan@653
    31
Evan@653
    32
#define PURPLE_CIPHER(obj)			((PurpleCipher *)(obj))			/**< PurpleCipher typecast helper			*/
Evan@653
    33
#define PURPLE_CIPHER_OPS(obj)		((PurpleCipherOps *)(obj))		/**< PurpleCipherInfo typecase helper		*/
Evan@653
    34
#define PURPLE_CIPHER_CONTEXT(obj)	((PurpleCipherContext *)(obj))	/**< PurpleCipherContext typecast helper	*/
Evan@653
    35
Evan@653
    36
typedef struct _PurpleCipher			PurpleCipher;			/**< A handle to a PurpleCipher	*/
Evan@653
    37
typedef struct _PurpleCipherOps		PurpleCipherOps;		/**< Ops for a PurpleCipher		*/
Evan@653
    38
typedef struct _PurpleCipherContext	PurpleCipherContext;	/**< A context for a PurpleCipher	*/
Evan@653
    39
Evan@653
    40
/**
Evan@653
    41
 * Modes for batch encrypters
Evan@653
    42
 */
Evan@653
    43
typedef enum _PurpleCipherBatchMode {
Evan@653
    44
	PURPLE_CIPHER_BATCH_MODE_ECB,
Evan@653
    45
	PURPLE_CIPHER_BATCH_MODE_CBC
Evan@653
    46
} PurpleCipherBatchMode;
Evan@653
    47
Evan@653
    48
/**
Evan@653
    49
 * The operation flags for a cipher
Evan@653
    50
 */
Evan@653
    51
typedef enum _PurpleCipherCaps {
Evan@653
    52
	PURPLE_CIPHER_CAPS_SET_OPT          = 1 << 1,   /**< Set option flag	*/
Evan@653
    53
	PURPLE_CIPHER_CAPS_GET_OPT          = 1 << 2,   /**< Get option flag	*/
Evan@653
    54
	PURPLE_CIPHER_CAPS_INIT             = 1 << 3,   /**< Init flag			*/
Evan@653
    55
	PURPLE_CIPHER_CAPS_RESET            = 1 << 4,   /**< Reset flag			*/
Evan@653
    56
	PURPLE_CIPHER_CAPS_UNINIT           = 1 << 5,   /**< Uninit flag		*/
Evan@653
    57
	PURPLE_CIPHER_CAPS_SET_IV           = 1 << 6,   /**< Set IV flag		*/
Evan@653
    58
	PURPLE_CIPHER_CAPS_APPEND           = 1 << 7,   /**< Append flag		*/
Evan@653
    59
	PURPLE_CIPHER_CAPS_DIGEST           = 1 << 8,   /**< Digest flag		*/
Evan@653
    60
	PURPLE_CIPHER_CAPS_ENCRYPT          = 1 << 9,   /**< Encrypt flag		*/
Evan@653
    61
	PURPLE_CIPHER_CAPS_DECRYPT          = 1 << 10,  /**< Decrypt flag		*/
Evan@653
    62
	PURPLE_CIPHER_CAPS_SET_SALT         = 1 << 11,  /**< Set salt flag		*/
Evan@653
    63
	PURPLE_CIPHER_CAPS_GET_SALT_SIZE    = 1 << 12,  /**< Get salt size flag	*/
Evan@653
    64
	PURPLE_CIPHER_CAPS_SET_KEY          = 1 << 13,  /**< Set key flag		*/
Evan@653
    65
	PURPLE_CIPHER_CAPS_GET_KEY_SIZE     = 1 << 14,  /**< Get key size flag	*/
Evan@653
    66
	PURPLE_CIPHER_CAPS_SET_BATCH_MODE   = 1 << 15,  /**< Set batch mode flag */
Evan@653
    67
	PURPLE_CIPHER_CAPS_GET_BATCH_MODE   = 1 << 16,  /**< Get batch mode flag */
Evan@653
    68
	PURPLE_CIPHER_CAPS_GET_BLOCK_SIZE   = 1 << 17,  /**< The get block size flag */
Evan@653
    69
	PURPLE_CIPHER_CAPS_SET_KEY_WITH_LEN = 1 << 18,  /**< The set key with length flag */
Evan@653
    70
	PURPLE_CIPHER_CAPS_UNKNOWN          = 1 << 19   /**< Unknown			*/
Evan@653
    71
} PurpleCipherCaps;
Evan@653
    72
Evan@653
    73
/**
Evan@653
    74
 * The operations of a cipher.  Every cipher must implement one of these.
Evan@653
    75
 */
Evan@653
    76
struct _PurpleCipherOps {
Evan@653
    77
	/** The set option function	*/
Evan@653
    78
	void (*set_option)(PurpleCipherContext *context, const gchar *name, void *value);
Evan@653
    79
Evan@653
    80
	/** The get option function */
Evan@653
    81
	void *(*get_option)(PurpleCipherContext *context, const gchar *name);
Evan@653
    82
Evan@653
    83
	/** The init function */
Evan@653
    84
	void (*init)(PurpleCipherContext *context, void *extra);
Evan@653
    85
Evan@653
    86
	/** The reset function */
Evan@653
    87
	void (*reset)(PurpleCipherContext *context, void *extra);
Evan@653
    88
Evan@653
    89
	/** The uninit function */
Evan@653
    90
	void (*uninit)(PurpleCipherContext *context);
Evan@653
    91
Evan@653
    92
	/** The set initialization vector function */
Evan@653
    93
	void (*set_iv)(PurpleCipherContext *context, guchar *iv, size_t len);
Evan@653
    94
Evan@653
    95
	/** The append data function */
Evan@653
    96
	void (*append)(PurpleCipherContext *context, const guchar *data, size_t len);
Evan@653
    97
Evan@653
    98
	/** The digest function */
Evan@653
    99
	gboolean (*digest)(PurpleCipherContext *context, size_t in_len, guchar digest[], size_t *out_len);
Evan@653
   100
Evan@653
   101
	/** The encrypt function */
Evan@653
   102
	int (*encrypt)(PurpleCipherContext *context, const guchar data[], size_t len, guchar output[], size_t *outlen);
Evan@653
   103
Evan@653
   104
	/** The decrypt function */
Evan@653
   105
	int (*decrypt)(PurpleCipherContext *context, const guchar data[], size_t len, guchar output[], size_t *outlen);
Evan@653
   106
Evan@653
   107
	/** The set salt function */
Evan@653
   108
	void (*set_salt)(PurpleCipherContext *context, guchar *salt);
Evan@653
   109
Evan@653
   110
	/** The get salt size function */
Evan@653
   111
	size_t (*get_salt_size)(PurpleCipherContext *context);
Evan@653
   112
Evan@653
   113
	/** The set key function */
Evan@653
   114
	void (*set_key)(PurpleCipherContext *context, const guchar *key);
Evan@653
   115
Evan@653
   116
	/** The get key size function */
Evan@653
   117
	size_t (*get_key_size)(PurpleCipherContext *context);
Evan@653
   118
Evan@653
   119
	/** The set batch mode function */
Evan@653
   120
	void (*set_batch_mode)(PurpleCipherContext *context, PurpleCipherBatchMode mode);
Evan@653
   121
Evan@653
   122
	/** The get batch mode function */
Evan@653
   123
	PurpleCipherBatchMode (*get_batch_mode)(PurpleCipherContext *context);
Evan@653
   124
Evan@653
   125
	/** The get block size function */
Evan@653
   126
	size_t (*get_block_size)(PurpleCipherContext *context);
Evan@653
   127
Evan@653
   128
	/** The set key with length function */
Evan@653
   129
	void (*set_key_with_len)(PurpleCipherContext *context, const guchar *key, size_t len);
Evan@653
   130
};
Evan@653
   131
Evan@653
   132
#ifdef __cplusplus
Evan@653
   133
extern "C" {
Evan@653
   134
#endif /* __cplusplus */
Evan@653
   135
Evan@653
   136
/*****************************************************************************/
Evan@653
   137
/** @name PurpleCipher API													 */
Evan@653
   138
/*****************************************************************************/
Evan@653
   139
/*@{*/
Evan@653
   140
Evan@653
   141
/**
Evan@653
   142
 * Gets a cipher's name
Evan@653
   143
 *
Evan@653
   144
 * @param cipher The cipher handle
Evan@653
   145
 *
Evan@653
   146
 * @return The cipher's name
Evan@653
   147
 */
Evan@653
   148
const gchar *purple_cipher_get_name(PurpleCipher *cipher);
Evan@653
   149
Evan@653
   150
/**
Evan@653
   151
 * Gets a cipher's capabilities
Evan@653
   152
 *
Evan@653
   153
 * @param cipher The cipher handle
Evan@653
   154
 *
Evan@653
   155
 * @return The cipher's info
Evan@653
   156
 */
Evan@653
   157
guint purple_cipher_get_capabilities(PurpleCipher *cipher);
Evan@653
   158
Evan@653
   159
/**
Evan@653
   160
 * Gets a digest from a cipher
Evan@653
   161
 *
Evan@653
   162
 * @param name     The cipher's name
Evan@653
   163
 * @param data     The data to hash
Evan@653
   164
 * @param data_len The length of the data
Evan@653
   165
 * @param in_len   The length of the buffer
Evan@653
   166
 * @param digest   The returned digest
Evan@653
   167
 * @param out_len  The length written
Evan@653
   168
 *
Evan@653
   169
 * @return @c TRUE if successful, @c FALSE otherwise
Evan@653
   170
 */
Evan@653
   171
gboolean purple_cipher_digest_region(const gchar *name, const guchar *data, size_t data_len, size_t in_len, guchar digest[], size_t *out_len);
Evan@653
   172
Evan@653
   173
/*@}*/
Evan@653
   174
/******************************************************************************/
Evan@653
   175
/** @name PurpleCiphers API													  */
Evan@653
   176
/******************************************************************************/
Evan@653
   177
/*@{*/
Evan@653
   178
Evan@653
   179
/**
Evan@653
   180
 * Finds a cipher by it's name
Evan@653
   181
 *
Evan@653
   182
 * @param name The name of the cipher to find
Evan@653
   183
 *
Evan@653
   184
 * @return The cipher handle or @c NULL
Evan@653
   185
 */
Evan@653
   186
PurpleCipher *purple_ciphers_find_cipher(const gchar *name);
Evan@653
   187
Evan@653
   188
/**
Evan@653
   189
 * Registers a cipher as a usable cipher
Evan@653
   190
 *
Evan@653
   191
 * @param name The name of the new cipher
Evan@653
   192
 * @param ops  The cipher ops to register
Evan@653
   193
 *
Evan@653
   194
 * @return The handle to the new cipher or @c NULL if it failed
Evan@653
   195
 */
Evan@653
   196
PurpleCipher *purple_ciphers_register_cipher(const gchar *name, PurpleCipherOps *ops);
Evan@653
   197
Evan@653
   198
/**
Evan@653
   199
 * Unregisters a cipher
Evan@653
   200
 *
Evan@653
   201
 * @param cipher The cipher handle to unregister
Evan@653
   202
 *
Evan@653
   203
 * @return Whether or not the cipher was successfully unloaded
Evan@653
   204
 */
Evan@653
   205
gboolean purple_ciphers_unregister_cipher(PurpleCipher *cipher);
Evan@653
   206
Evan@653
   207
/**
Evan@653
   208
 * Gets the list of ciphers
Evan@653
   209
 *
Evan@653
   210
 * @return The list of available ciphers
Evan@653
   211
 * @note This list should not be modified, it is owned by the cipher core
Evan@653
   212
 */
Evan@653
   213
GList *purple_ciphers_get_ciphers(void);
Evan@653
   214
Evan@653
   215
/*@}*/
Evan@653
   216
/******************************************************************************/
Evan@653
   217
/** @name PurpleCipher Subsystem API											  */
Evan@653
   218
/******************************************************************************/
Evan@653
   219
/*@{*/
Evan@653
   220
Evan@653
   221
/**
Evan@653
   222
 * Gets the handle to the cipher subsystem
Evan@653
   223
 *
Evan@653
   224
 * @return The handle to the cipher subsystem
Evan@653
   225
 */
Evan@653
   226
gpointer purple_ciphers_get_handle(void);
Evan@653
   227
Evan@653
   228
/**
Evan@653
   229
 * Initializes the cipher core
Evan@653
   230
 */
Evan@653
   231
void purple_ciphers_init(void);
Evan@653
   232
Evan@653
   233
/**
Evan@653
   234
 * Uninitializes the cipher core
Evan@653
   235
 */
Evan@653
   236
void purple_ciphers_uninit(void);
Evan@653
   237
Evan@653
   238
/*@}*/
Evan@653
   239
/******************************************************************************/
Evan@653
   240
/** @name PurpleCipherContext API												  */
Evan@653
   241
/******************************************************************************/
Evan@653
   242
/*@{*/
Evan@653
   243
Evan@653
   244
/**
Evan@653
   245
 * Sets the value an option on a cipher context
Evan@653
   246
 *
Evan@653
   247
 * @param context The cipher context
Evan@653
   248
 * @param name    The name of the option
Evan@653
   249
 * @param value   The value to set
Evan@653
   250
 */
Evan@653
   251
void purple_cipher_context_set_option(PurpleCipherContext *context, const gchar *name, gpointer value);
Evan@653
   252
Evan@653
   253
/**
Evan@653
   254
 * Gets the vale of an option on a cipher context
Evan@653
   255
 *
Evan@653
   256
 * @param context The cipher context
Evan@653
   257
 * @param name    The name of the option
Evan@653
   258
 * @return The value of the option
Evan@653
   259
 */
Evan@653
   260
gpointer purple_cipher_context_get_option(PurpleCipherContext *context, const gchar *name);
Evan@653
   261
Evan@653
   262
/**
Evan@653
   263
 * Creates a new cipher context and initializes it
Evan@653
   264
 *
Evan@653
   265
 * @param cipher The cipher to use
Evan@653
   266
 * @param extra  Extra data for the specific cipher
Evan@653
   267
 *
Evan@653
   268
 * @return The new cipher context
Evan@653
   269
 */
Evan@653
   270
PurpleCipherContext *purple_cipher_context_new(PurpleCipher *cipher, void *extra);
Evan@653
   271
Evan@653
   272
/**
Evan@653
   273
 * Creates a new cipher context by the cipher name and initializes it
Evan@653
   274
 *
Evan@653
   275
 * @param name  The cipher's name
Evan@653
   276
 * @param extra Extra data for the specific cipher
Evan@653
   277
 *
Evan@653
   278
 * @return The new cipher context
Evan@653
   279
 */
Evan@653
   280
PurpleCipherContext *purple_cipher_context_new_by_name(const gchar *name, void *extra);
Evan@653
   281
Evan@653
   282
/**
Evan@653
   283
 * Resets a cipher context to it's default value
Evan@653
   284
 * @note If you have set an IV you will have to set it after resetting
Evan@653
   285
 *
Evan@653
   286
 * @param context The context to reset
Evan@653
   287
 * @param extra   Extra data for the specific cipher
Evan@653
   288
 */
Evan@653
   289
void purple_cipher_context_reset(PurpleCipherContext *context, gpointer extra);
Evan@653
   290
Evan@653
   291
/**
Evan@653
   292
 * Destorys a cipher context and deinitializes it
Evan@653
   293
 *
Evan@653
   294
 * @param context The cipher context to destory
Evan@653
   295
 */
Evan@653
   296
void purple_cipher_context_destroy(PurpleCipherContext *context);
Evan@653
   297
Evan@653
   298
/**
Evan@653
   299
 * Sets the initialization vector for a context
Evan@653
   300
 * @note This should only be called right after a cipher context is created or reset
Evan@653
   301
 *
Evan@653
   302
 * @param context The context to set the IV to
Evan@653
   303
 * @param iv      The initialization vector to set
Evan@653
   304
 * @param len     The len of the IV
Evan@653
   305
 */
Evan@653
   306
void purple_cipher_context_set_iv(PurpleCipherContext *context, guchar *iv, size_t len);
Evan@653
   307
Evan@653
   308
/**
Evan@653
   309
 * Appends data to the context
Evan@653
   310
 *
Evan@653
   311
 * @param context The context to append data to
Evan@653
   312
 * @param data    The data to append
Evan@653
   313
 * @param len     The length of the data
Evan@653
   314
 */
Evan@653
   315
void purple_cipher_context_append(PurpleCipherContext *context, const guchar *data, size_t len);
Evan@653
   316
Evan@653
   317
/**
Evan@653
   318
 * Digests a context
Evan@653
   319
 *
Evan@653
   320
 * @param context The context to digest
Evan@653
   321
 * @param in_len  The length of the buffer
Evan@653
   322
 * @param digest  The return buffer for the digest
Evan@653
   323
 * @param out_len The length of the returned value
Evan@653
   324
 */
Evan@653
   325
gboolean purple_cipher_context_digest(PurpleCipherContext *context, size_t in_len, guchar digest[], size_t *out_len);
Evan@653
   326
Evan@653
   327
/**
Evan@653
   328
 * Converts a guchar digest into a hex string
Evan@653
   329
 *
Evan@653
   330
 * @param context  The context to get a digest from
Evan@653
   331
 * @param in_len   The length of the buffer
Evan@653
   332
 * @param digest_s The return buffer for the string digest
Evan@653
   333
 * @param out_len  The length of the returned value
Evan@653
   334
 */
Evan@653
   335
gboolean purple_cipher_context_digest_to_str(PurpleCipherContext *context, size_t in_len, gchar digest_s[], size_t *out_len);
Evan@653
   336
Evan@653
   337
/**
Evan@653
   338
 * Encrypts data using the context
Evan@653
   339
 *
Evan@653
   340
 * @param context The context
Evan@653
   341
 * @param data    The data to encrypt
Evan@653
   342
 * @param len     The length of the data
Evan@653
   343
 * @param output  The output buffer
Evan@653
   344
 * @param outlen  The len of data that was outputed
Evan@653
   345
 *
Evan@653
   346
 * @return A cipher specific status code
Evan@653
   347
 */
Evan@653
   348
gint purple_cipher_context_encrypt(PurpleCipherContext *context, const guchar data[], size_t len, guchar output[], size_t *outlen);
Evan@653
   349
Evan@653
   350
/**
Evan@653
   351
 * Decrypts data using the context
Evan@653
   352
 *
Evan@653
   353
 * @param context The context
Evan@653
   354
 * @param data    The data to encrypt
Evan@653
   355
 * @param len     The length of the returned value
Evan@653
   356
 * @param output  The output buffer
Evan@653
   357
 * @param outlen  The len of data that was outputed
Evan@653
   358
 *
Evan@653
   359
 * @return A cipher specific status code
Evan@653
   360
 */
Evan@653
   361
gint purple_cipher_context_decrypt(PurpleCipherContext *context, const guchar data[], size_t len, guchar output[], size_t *outlen);
Evan@653
   362
Evan@653
   363
/**
Evan@653
   364
 * Sets the salt on a context
Evan@653
   365
 *
Evan@653
   366
 * @param context The context whose salt to set
Evan@653
   367
 * @param salt    The salt
Evan@653
   368
 */
Evan@653
   369
void purple_cipher_context_set_salt(PurpleCipherContext *context, guchar *salt);
Evan@653
   370
Evan@653
   371
/**
Evan@653
   372
 * Gets the size of the salt if the cipher supports it
Evan@653
   373
 *
Evan@653
   374
 * @param context The context whose salt size to get
Evan@653
   375
 *
Evan@653
   376
 * @return The size of the salt
Evan@653
   377
 */
Evan@653
   378
size_t purple_cipher_context_get_salt_size(PurpleCipherContext *context);
Evan@653
   379
Evan@653
   380
/**
Evan@653
   381
 * Sets the key on a context
Evan@653
   382
 *
Evan@653
   383
 * @param context The context whose key to set
Evan@653
   384
 * @param key     The key
Evan@653
   385
 */
Evan@653
   386
void purple_cipher_context_set_key(PurpleCipherContext *context, const guchar *key);
Evan@653
   387
Evan@653
   388
/**
Evan@653
   389
 * Gets the key size for a context
Evan@653
   390
 *
Evan@653
   391
 * @param context The context whose key size to get
Evan@653
   392
 *
Evan@653
   393
 * @return The size of the key
Evan@653
   394
 */
Evan@653
   395
size_t purple_cipher_context_get_key_size(PurpleCipherContext *context);
Evan@653
   396
Evan@653
   397
/**
Evan@653
   398
 * Sets the batch mode of a context
Evan@653
   399
 *
Evan@653
   400
 * @param context The context whose batch mode to set
Evan@653
   401
 * @param mode    The batch mode under which the cipher should operate
Evan@653
   402
 *
Evan@653
   403
 */
Evan@653
   404
void purple_cipher_context_set_batch_mode(PurpleCipherContext *context, PurpleCipherBatchMode mode);
Evan@653
   405
Evan@653
   406
/**
Evan@653
   407
 * Gets the batch mode of a context
Evan@653
   408
 *
Evan@653
   409
 * @param context The context whose batch mode to get
Evan@653
   410
 *
Evan@653
   411
 * @return The batch mode under which the cipher is operating
Evan@653
   412
 */
Evan@653
   413
PurpleCipherBatchMode purple_cipher_context_get_batch_mode(PurpleCipherContext *context);
Evan@653
   414
Evan@653
   415
/**
Evan@653
   416
 * Gets the block size of a context
Evan@653
   417
 *
Evan@653
   418
 * @param context The context whose block size to get
Evan@653
   419
 *
Evan@653
   420
 * @return The block size of the context
Evan@653
   421
 */
Evan@653
   422
size_t purple_cipher_context_get_block_size(PurpleCipherContext *context);
Evan@653
   423
Evan@653
   424
/**
Evan@1427
   425
 * Sets the key with a given length on a context
Evan@653
   426
 *
Evan@653
   427
 * @param context The context whose key to set
Evan@653
   428
 * @param key     The key
Evan@653
   429
 * @param len     The length of the key
Evan@653
   430
 *
Evan@653
   431
 */
Evan@653
   432
void purple_cipher_context_set_key_with_len(PurpleCipherContext *context, const guchar *key, size_t len);
Evan@653
   433
Evan@653
   434
/**
Evan@653
   435
 * Sets the cipher data for a context
Evan@653
   436
 *
Evan@653
   437
 * @param context The context whose cipher data to set
Evan@653
   438
 * @param data    The cipher data to set
Evan@653
   439
 */
Evan@653
   440
void purple_cipher_context_set_data(PurpleCipherContext *context, gpointer data);
Evan@653
   441
Evan@653
   442
/**
Evan@653
   443
 * Gets the cipher data for a context
Evan@653
   444
 *
Evan@653
   445
 * @param context The context whose cipher data to get
Evan@653
   446
 *
Evan@653
   447
 * @return The cipher data
Evan@653
   448
 */
Evan@653
   449
gpointer purple_cipher_context_get_data(PurpleCipherContext *context);
Evan@653
   450
Evan@653
   451
/*@}*/
Evan@653
   452
/*****************************************************************************/
Evan@653
   453
/** @name Purple Cipher HTTP Digest Helper Functions							 */
Evan@653
   454
/*****************************************************************************/
Evan@653
   455
/*@{*/
Evan@653
   456
Evan@653
   457
/**
Evan@653
   458
 * Calculates a session key for HTTP Digest authentation
Evan@653
   459
 *
Evan@653
   460
 * See RFC 2617 for more information.
Evan@653
   461
 *
Evan@653
   462
 * @param algorithm    The hash algorithm to use
Evan@653
   463
 * @param username     The username provided by the user
Evan@653
   464
 * @param realm        The authentication realm provided by the server
Evan@653
   465
 * @param password     The password provided by the user
Evan@653
   466
 * @param nonce        The nonce provided by the server
Evan@653
   467
 * @param client_nonce The nonce provided by the client
Evan@653
   468
 *
Evan@653
   469
 * @return The session key, or @c NULL if an error occurred.
Evan@653
   470
 */
Evan@653
   471
gchar *purple_cipher_http_digest_calculate_session_key(
Evan@653
   472
		const gchar *algorithm, const gchar *username,
Evan@653
   473
		const gchar *realm, const gchar *password,
Evan@653
   474
		const gchar *nonce, const gchar *client_nonce);
Evan@653
   475
Evan@653
   476
/** Calculate a response for HTTP Digest authentication
Evan@653
   477
 *
Evan@653
   478
 * See RFC 2617 for more information.
Evan@653
   479
 *
Evan@653
   480
 * @param algorithm         The hash algorithm to use
Evan@653
   481
 * @param method            The HTTP method in use
Evan@653
   482
 * @param digest_uri        The URI from the initial request
Evan@653
   483
 * @param qop               The "quality of protection"
Evan@653
   484
 * @param entity            The entity body
Evan@653
   485
 * @param nonce             The nonce provided by the server
Evan@653
   486
 * @param nonce_count       The nonce count
Evan@653
   487
 * @param client_nonce      The nonce provided by the client
Evan@653
   488
 * @param session_key       The session key from purple_cipher_http_digest_calculate_session_key()
Evan@653
   489
 *
Evan@653
   490
 * @return The hashed response, or @c NULL if an error occurred.
Evan@653
   491
 */
Evan@653
   492
gchar *purple_cipher_http_digest_calculate_response(
Evan@653
   493
		const gchar *algorithm, const gchar *method,
Evan@653
   494
		const gchar *digest_uri, const gchar *qop,
Evan@653
   495
		const gchar *entity, const gchar *nonce,
Evan@653
   496
		const gchar *nonce_count, const gchar *client_nonce,
Evan@653
   497
		const gchar *session_key);
Evan@653
   498
Evan@653
   499
/*@}*/
Evan@653
   500
Evan@653
   501
#ifdef __cplusplus
Evan@653
   502
}
Evan@653
   503
#endif /* __cplusplus */
Evan@653
   504
Evan@653
   505
#endif /* PURPLE_CIPHER_H */