~ubuntu-branches/ubuntu/maverick/gnutls26/maverick-security

« back to all changes in this revision

Viewing changes to lib/x509/mpi.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2009-04-14 14:23:19 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090414142319-ok7xejzbqkofno1q
Tags: 2.6.5-1
* Sync sections in debian/control with override file. libgnutls26-dbg is
  section debug, guile-gnutls is section lisp.
* New upstream version. (Needed for Libtasn1-3 2.0)
* New patch 15_tasn1inpc.diff. Make sure libtasn1 is listed in Libs.private.
* Standards-Version: 3.8.1, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 * Returns 2 parameters (m,e).
38
38
 */
39
39
int
40
 
_gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params)
 
40
_gnutls_x509_read_rsa_params (opaque * der, int dersize, bigint_t * params)
41
41
{
42
42
  int result;
43
43
  ASN1_TYPE spk = ASN1_TYPE_EMPTY;
88
88
 * params[0-2]
89
89
 */
90
90
int
91
 
_gnutls_x509_read_dsa_params (opaque * der, int dersize, mpi_t * params)
 
91
_gnutls_x509_read_dsa_params (opaque * der, int dersize, bigint_t * params)
92
92
{
93
93
  int result;
94
94
  ASN1_TYPE spk = ASN1_TYPE_EMPTY;
154
154
 */
155
155
 
156
156
int
157
 
_gnutls_x509_read_der_int  (opaque * der, int dersize, mpi_t * out)
 
157
_gnutls_x509_read_der_int (opaque * der, int dersize, bigint_t * out)
158
158
{
159
159
  int result;
160
160
  ASN1_TYPE spk = ASN1_TYPE_EMPTY;
197
197
 * only sets params[3]
198
198
 */
199
199
int
200
 
_gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params)
 
200
_gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, bigint_t * params)
201
201
{
202
 
  return _gnutls_x509_read_der_int( der, dersize, &params[3]);
 
202
  return _gnutls_x509_read_der_int (der, dersize, &params[3]);
203
203
}
204
204
 
205
205
 
207
207
 */
208
208
int
209
209
_gnutls_x509_crt_get_mpis (gnutls_x509_crt_t cert,
210
 
                           mpi_t * params, int *params_size)
 
210
                           bigint_t * params, int *params_size)
211
211
{
212
212
  int result;
213
213
  int pk_algorithm;
219
219
 
220
220
  /* Read the algorithm's parameters
221
221
   */
222
 
  result = _gnutls_x509_read_value( cert->cert,
223
 
    "tbsCertificate.subjectPublicKeyInfo.subjectPublicKey", &tmp, 2);
 
222
  result = _gnutls_x509_read_value (cert->cert,
 
223
                                    "tbsCertificate.subjectPublicKeyInfo.subjectPublicKey",
 
224
                                    &tmp, 2);
224
225
 
225
226
  if (result < 0)
226
227
    {
237
238
      if (*params_size < RSA_PUBLIC_PARAMS)
238
239
        {
239
240
          gnutls_assert ();
240
 
          /* internal error. Increase the mpi_ts in params */
 
241
          /* internal error. Increase the bigint_ts in params */
241
242
          result = GNUTLS_E_INTERNAL_ERROR;
242
243
          goto error;
243
244
        }
244
245
 
245
 
      if ((result = _gnutls_x509_read_rsa_params (tmp.data, tmp.size, params)) < 0)
 
246
      if ((result =
 
247
           _gnutls_x509_read_rsa_params (tmp.data, tmp.size, params)) < 0)
246
248
        {
247
249
          gnutls_assert ();
248
250
          goto error;
260
262
      if (*params_size < DSA_PUBLIC_PARAMS)
261
263
        {
262
264
          gnutls_assert ();
263
 
          /* internal error. Increase the mpi_ts in params */
 
265
          /* internal error. Increase the bigint_ts in params */
264
266
          result = GNUTLS_E_INTERNAL_ERROR;
265
267
          goto error;
266
268
        }
267
269
 
268
 
      if ((result = _gnutls_x509_read_dsa_pubkey (tmp.data, tmp.size, params)) < 0)
 
270
      if ((result =
 
271
           _gnutls_x509_read_dsa_pubkey (tmp.data, tmp.size, params)) < 0)
269
272
        {
270
273
          gnutls_assert ();
271
274
          goto error;
273
276
 
274
277
      /* Now read the parameters
275
278
       */
276
 
      _gnutls_free_datum( &tmp);
 
279
      _gnutls_free_datum (&tmp);
277
280
 
278
281
      result = _gnutls_x509_read_value (cert->cert,
279
 
                                "tbsCertificate.subjectPublicKeyInfo.algorithm.parameters",
280
 
                                &tmp, 0);
 
282
                                        "tbsCertificate.subjectPublicKeyInfo.algorithm.parameters",
 
283
                                        &tmp, 0);
281
284
 
282
285
      /* FIXME: If the parameters are not included in the certificate
283
286
       * then the issuer's parameters should be used. This is not
290
293
          goto error;
291
294
        }
292
295
 
293
 
      if ((result = _gnutls_x509_read_dsa_params (tmp.data, tmp.size, params)) < 0)
 
296
      if ((result =
 
297
           _gnutls_x509_read_dsa_params (tmp.data, tmp.size, params)) < 0)
294
298
        {
295
299
          gnutls_assert ();
296
300
          goto error;
309
313
    }
310
314
 
311
315
  result = 0;
312
 
  
 
316
 
313
317
error:
314
 
  _gnutls_free_datum( &tmp);
 
318
  _gnutls_free_datum (&tmp);
315
319
  return result;
316
320
}
317
321
 
323
327
 * Allocates the space used to store the DER data.
324
328
 */
325
329
int
326
 
_gnutls_x509_write_rsa_params (mpi_t * params, int params_size,
 
330
_gnutls_x509_write_rsa_params (bigint_t * params, int params_size,
327
331
                               gnutls_datum_t * der)
328
332
{
329
333
  int result;
384
388
int
385
389
_gnutls_x509_write_sig_params (ASN1_TYPE dst, const char *dst_name,
386
390
                               gnutls_pk_algorithm_t pk_algorithm,
387
 
                               gnutls_digest_algorithm_t dig, mpi_t * params,
388
 
                               int params_size)
 
391
                               gnutls_digest_algorithm_t dig,
 
392
                               bigint_t * params, int params_size)
389
393
{
390
394
  gnutls_datum_t der;
391
395
  int result;
457
461
 * Allocates the space used to store the DER data.
458
462
 */
459
463
int
460
 
_gnutls_x509_write_dsa_params (mpi_t * params, int params_size,
 
464
_gnutls_x509_write_dsa_params (bigint_t * params, int params_size,
461
465
                               gnutls_datum_t * der)
462
466
{
463
467
  int result;
523
527
 * Allocates the space used to store the DER data.
524
528
 */
525
529
int
526
 
_gnutls_x509_write_dsa_public_key (mpi_t * params, int params_size,
 
530
_gnutls_x509_write_dsa_public_key (bigint_t * params, int params_size,
527
531
                                   gnutls_datum_t * der)
528
532
{
529
533
  int result;