~ubuntu-branches/ubuntu/quantal/gnutls26/quantal

« back to all changes in this revision

Viewing changes to lib/auth_srp_sb64.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-05-20 13:07:18 UTC
  • mfrom: (12.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110520130718-db41dybbanzfvlji
Tags: 2.10.5-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Fix build failure with --no-add-needed.
  - Build for multiarch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2008 Free Software Foundation
 
2
 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2008, 2010 Free Software
 
3
 * Foundation, Inc.
3
4
 *
4
5
 * Author: Nikos Mavrogiannopoulos
5
6
 *
6
 
 * This file is part of GNUTLS.
 
7
 * This file is part of GnuTLS.
7
8
 *
8
 
 * The GNUTLS library is free software; you can redistribute it and/or
 
9
 * The GnuTLS is free software; you can redistribute it and/or
9
10
 * modify it under the terms of the GNU Lesser General Public License
10
11
 * as published by the Free Software Foundation; either version 2.1 of
11
12
 * the License, or (at your option) any later version.
310
311
}
311
312
 
312
313
/**
313
 
  * gnutls_srp_base64_encode - Encode raw data using SRP-Base64
314
 
  * @data: contain the raw data
315
 
  * @result: the place where base64 data will be copied
316
 
  * @result_size: holds the size of the result
317
 
  *
318
 
  * This function will convert the given data to printable data, using
319
 
  * the base64 encoding, as used in the libsrp.  This is the encoding
320
 
  * used in SRP password files.  If the provided buffer is not long
321
 
  * enough GNUTLS_E_SHORT_MEMORY_BUFFER is returned.
322
 
  *
323
 
  * Warning!  This base64 encoding is not the "standard" encoding, so
324
 
  * do not use it for non-SRP purposes.
325
 
  *
326
 
  * Returns: %GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
327
 
  * long enough, or 0 on success.
328
 
  **/
 
314
 * gnutls_srp_base64_encode:
 
315
 * @data: contain the raw data
 
316
 * @result: the place where base64 data will be copied
 
317
 * @result_size: holds the size of the result
 
318
 *
 
319
 * This function will convert the given data to printable data, using
 
320
 * the base64 encoding, as used in the libsrp.  This is the encoding
 
321
 * used in SRP password files.  If the provided buffer is not long
 
322
 * enough GNUTLS_E_SHORT_MEMORY_BUFFER is returned.
 
323
 *
 
324
 * Warning!  This base64 encoding is not the "standard" encoding, so
 
325
 * do not use it for non-SRP purposes.
 
326
 *
 
327
 * Returns: %GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
 
328
 * long enough, or 0 on success.
 
329
 **/
329
330
int
330
331
gnutls_srp_base64_encode (const gnutls_datum_t * data, char *result,
331
332
                          size_t * result_size)
354
355
}
355
356
 
356
357
/**
357
 
  * gnutls_srp_base64_encode_alloc - encode raw data using SRP-Base64
358
 
  * @data: contains the raw data
359
 
  * @result: will hold the newly allocated encoded data
360
 
  *
361
 
  * This function will convert the given data to printable data, using
362
 
  * the base64 encoding.  This is the encoding used in SRP password
363
 
  * files.  This function will allocate the required memory to hold
364
 
  * the encoded data.
365
 
  *
366
 
  * You should use gnutls_free() to free the returned data.
367
 
  *
368
 
  * Warning!  This base64 encoding is not the "standard" encoding, so
369
 
  * do not use it for non-SRP purposes.
370
 
  *
371
 
  * Returns: 0 on success, or an error code.
372
 
  **/
 
358
 * gnutls_srp_base64_encode_alloc:
 
359
 * @data: contains the raw data
 
360
 * @result: will hold the newly allocated encoded data
 
361
 *
 
362
 * This function will convert the given data to printable data, using
 
363
 * the base64 encoding.  This is the encoding used in SRP password
 
364
 * files.  This function will allocate the required memory to hold
 
365
 * the encoded data.
 
366
 *
 
367
 * You should use gnutls_free() to free the returned data.
 
368
 *
 
369
 * Warning!  This base64 encoding is not the "standard" encoding, so
 
370
 * do not use it for non-SRP purposes.
 
371
 *
 
372
 * Returns: 0 on success, or an error code.
 
373
 **/
373
374
int
374
375
gnutls_srp_base64_encode_alloc (const gnutls_datum_t * data,
375
376
                                gnutls_datum_t * result)
396
397
}
397
398
 
398
399
/**
399
 
  * gnutls_srp_base64_decode - decode SRP-base64 encoded data
400
 
  * @b64_data: contain the encoded data
401
 
  * @result: the place where decoded data will be copied
402
 
  * @result_size: holds the size of the result
403
 
  *
404
 
  * This function will decode the given encoded data, using the base64
405
 
  * encoding found in libsrp.
406
 
  *
407
 
  * Note that b64_data should be null terminated.
408
 
  *
409
 
  * Warning!  This base64 encoding is not the "standard" encoding, so
410
 
  * do not use it for non-SRP purposes.
411
 
  *
412
 
  * Returns: %GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
413
 
  * long enough, or 0 on success.
414
 
  **/
 
400
 * gnutls_srp_base64_decode:
 
401
 * @b64_data: contain the encoded data
 
402
 * @result: the place where decoded data will be copied
 
403
 * @result_size: holds the size of the result
 
404
 *
 
405
 * This function will decode the given encoded data, using the base64
 
406
 * encoding found in libsrp.
 
407
 *
 
408
 * Note that @b64_data should be null terminated.
 
409
 *
 
410
 * Warning!  This base64 encoding is not the "standard" encoding, so
 
411
 * do not use it for non-SRP purposes.
 
412
 *
 
413
 * Returns: %GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
 
414
 * long enough, or 0 on success.
 
415
 **/
415
416
int
416
417
gnutls_srp_base64_decode (const gnutls_datum_t * b64_data, char *result,
417
418
                          size_t * result_size)
440
441
}
441
442
 
442
443
/**
443
 
  * gnutls_srp_base64_decode_alloc - decode SRP-base64 encoded data
444
 
  * @b64_data: contains the encoded data
445
 
  * @result: the place where decoded data lie
446
 
  *
447
 
  * This function will decode the given encoded data. The decoded data
448
 
  * will be allocated, and stored into result.  It will decode using
449
 
  * the base64 algorithm as used in libsrp.
450
 
  *
451
 
  * You should use gnutls_free() to free the returned data.
452
 
  *
453
 
  * Warning!  This base64 encoding is not the "standard" encoding, so
454
 
  * do not use it for non-SRP purposes.
455
 
  *
456
 
  * Returns: 0 on success, or an error code.
457
 
  **/
 
444
 * gnutls_srp_base64_decode_alloc:
 
445
 * @b64_data: contains the encoded data
 
446
 * @result: the place where decoded data lie
 
447
 *
 
448
 * This function will decode the given encoded data. The decoded data
 
449
 * will be allocated, and stored into result.  It will decode using
 
450
 * the base64 algorithm as used in libsrp.
 
451
 *
 
452
 * You should use gnutls_free() to free the returned data.
 
453
 *
 
454
 * Warning!  This base64 encoding is not the "standard" encoding, so
 
455
 * do not use it for non-SRP purposes.
 
456
 *
 
457
 * Returns: 0 on success, or an error code.
 
458
 **/
458
459
int
459
460
gnutls_srp_base64_decode_alloc (const gnutls_datum_t * b64_data,
460
461
                                gnutls_datum_t * result)