~ubuntu-branches/ubuntu/trusty/gnutls26/trusty

« back to all changes in this revision

Viewing changes to lib/crypto.c

  • Committer: Package Import Robot
  • Author(s): Andreas Metzler
  • Date: 2011-10-01 15:28:13 UTC
  • mfrom: (12.1.20 sid)
  • Revision ID: package-import@ubuntu.com-20111001152813-yygm1c4cxonfxhzy
* New upstream version.
  + Allow CA importing of 0 certificates to succeed. Closes: #640639
* Add libp11-kit-dev to libgnutls-dev dependencies. (see #643811)
* [20_guiledocstring.diff] guile: Fix docstring extraction with CPP 4.5+.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <random.h>
32
32
#include <gnutls_cipher_int.h>
33
33
 
 
34
/* default values for priorities */
 
35
int crypto_mac_prio = INT_MAX;
 
36
int crypto_digest_prio = INT_MAX;
 
37
int crypto_cipher_prio = INT_MAX;
 
38
 
34
39
typedef struct algo_list
35
40
{
36
41
  int algorithm;
55
60
  while (cl && cl->alg_data)
56
61
    {
57
62
      if (cl->algorithm == algorithm)
58
 
        {
59
 
          if (cl->priority < priority)
60
 
            {
61
 
              gnutls_assert ();
62
 
              return GNUTLS_E_CRYPTO_ALREADY_REGISTERED;
63
 
            }
64
 
          else
65
 
            {
66
 
              /* the current has higher priority -> overwrite */
67
 
              cl->algorithm = algorithm;
68
 
              cl->priority = priority;
69
 
              cl->alg_data = s;
70
 
              return 0;
71
 
            }
72
 
        }
 
63
        {
 
64
          if (cl->priority < priority)
 
65
            {
 
66
              gnutls_assert ();
 
67
              return GNUTLS_E_CRYPTO_ALREADY_REGISTERED;
 
68
            }
 
69
          else
 
70
            {
 
71
              /* the current has higher priority -> overwrite */
 
72
              cl->algorithm = algorithm;
 
73
              cl->priority = priority;
 
74
              cl->alg_data = s;
 
75
              return 0;
 
76
            }
 
77
        }
73
78
      cl = cl->next;
74
79
      if (cl)
75
 
        last_cl = cl;
 
80
        last_cl = cl;
76
81
    }
77
82
 
78
83
  cl = gnutls_calloc (1, sizeof (cipher_list));
103
108
  while (cl && cl->alg_data)
104
109
    {
105
110
      if (cl->algorithm == algo)
106
 
        {
107
 
          return cl->alg_data;
108
 
        }
 
111
        {
 
112
          return cl->alg_data;
 
113
        }
109
114
      cl = cl->next;
110
115
    }
111
116
 
165
170
 **/
166
171
int
167
172
gnutls_crypto_single_cipher_register2 (gnutls_cipher_algorithm_t algorithm,
168
 
                                       int priority, int version,
169
 
                                       const gnutls_crypto_cipher_st * s)
 
173
                                       int priority, int version,
 
174
                                       const gnutls_crypto_cipher_st * s)
170
175
{
171
176
  if (version != GNUTLS_CRYPTO_API_VERSION)
172
177
    {
206
211
 **/
207
212
int
208
213
gnutls_crypto_rnd_register2 (int priority, int version,
209
 
                             const gnutls_crypto_rnd_st * s)
 
214
                             const gnutls_crypto_rnd_st * s)
210
215
{
211
216
  if (version != GNUTLS_CRYPTO_API_VERSION)
212
217
    {
247
252
 **/
248
253
int
249
254
gnutls_crypto_single_mac_register2 (gnutls_mac_algorithm_t algorithm,
250
 
                                    int priority, int version,
251
 
                                    const gnutls_crypto_mac_st * s)
 
255
                                    int priority, int version,
 
256
                                    const gnutls_crypto_mac_st * s)
252
257
{
253
258
  if (version != GNUTLS_CRYPTO_API_VERSION)
254
259
    {
289
294
 **/
290
295
int
291
296
gnutls_crypto_single_digest_register2 (gnutls_digest_algorithm_t algorithm,
292
 
                                       int priority, int version,
293
 
                                       const gnutls_crypto_digest_st * s)
 
297
                                       int priority, int version,
 
298
                                       const gnutls_crypto_digest_st * s)
294
299
{
295
300
  if (version != GNUTLS_CRYPTO_API_VERSION)
296
301
    {
333
338
 **/
334
339
int
335
340
gnutls_crypto_bigint_register2 (int priority, int version,
336
 
                                const gnutls_crypto_bigint_st * s)
 
341
                                const gnutls_crypto_bigint_st * s)
337
342
{
338
343
  if (version != GNUTLS_CRYPTO_API_VERSION)
339
344
    {
377
382
 **/
378
383
int
379
384
gnutls_crypto_pk_register2 (int priority, int version,
380
 
                            const gnutls_crypto_pk_st * s)
 
385
                            const gnutls_crypto_pk_st * s)
381
386
{
382
387
  if (version != GNUTLS_CRYPTO_API_VERSION)
383
388
    {
418
423
 **/
419
424
int
420
425
gnutls_crypto_cipher_register2 (int priority, int version,
421
 
                                const gnutls_crypto_cipher_st * s)
 
426
                                const gnutls_crypto_cipher_st * s)
422
427
{
423
428
  if (version != GNUTLS_CRYPTO_API_VERSION)
424
429
    {
459
464
 **/
460
465
int
461
466
gnutls_crypto_mac_register2 (int priority, int version,
462
 
                             const gnutls_crypto_mac_st * s)
 
467
                             const gnutls_crypto_mac_st * s)
463
468
{
464
469
  if (version != GNUTLS_CRYPTO_API_VERSION)
465
470
    {
500
505
 **/
501
506
int
502
507
gnutls_crypto_digest_register2 (int priority, int version,
503
 
                                const gnutls_crypto_digest_st * s)
 
508
                                const gnutls_crypto_digest_st * s)
504
509
{
505
510
  if (version != GNUTLS_CRYPTO_API_VERSION)
506
511
    {