~ubuntu-branches/ubuntu/karmic/gnupg2/karmic-security

« back to all changes in this revision

Viewing changes to mpi/g10m.c

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* g10m.c  -  Wrapper for MPI
2
 
 * Copyright (C) 1998 Free Software Foundation, Inc.
3
 
 *
4
 
 * This file is part of GnuPG.
5
 
 *
6
 
 * GnuPG is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * GnuPG is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19
 
 */
20
 
 
21
 
#include <config.h>
22
 
#include <stdio.h>
23
 
#include <stdlib.h>
24
 
#include "mpi.h"
25
 
#include "util.h"
26
 
 
27
 
/* FIXME: The modules should use functions from libgcrypt */
28
 
 
29
 
const char *g10m_revision_string(int dummy) { return "$Revision$"; }
30
 
 
31
 
MPI
32
 
g10m_new( unsigned nbits )
33
 
{
34
 
    return mpi_alloc( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB );
35
 
}
36
 
 
37
 
MPI
38
 
g10m_new_secure( unsigned nbits )
39
 
{
40
 
    return mpi_alloc_secure( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB );
41
 
}
42
 
 
43
 
void
44
 
g10m_release( MPI a )
45
 
{
46
 
    mpi_free(a);
47
 
}
48
 
 
49
 
void
50
 
g10m_resize( MPI a, unsigned nbits )
51
 
{
52
 
    mpi_resize( a, (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB );
53
 
}
54
 
 
55
 
MPI  g10m_copy( MPI a )            { return mpi_copy( a );   }
56
 
void g10m_swap( MPI a, MPI b)      { mpi_swap( a, b );       }
57
 
void g10m_set( MPI w, MPI u)       { mpi_set( w, u );        }
58
 
void g10m_set_ui( MPI w, ulong u ) { mpi_set_ui( w, u ); }
59
 
 
60
 
int  g10m_cmp( MPI u, MPI v )       { return mpi_cmp( u, v ); }
61
 
int  g10m_cmp_ui( MPI u, ulong v )  { return mpi_cmp_ui( u, v ); }
62
 
 
63
 
void g10m_add(MPI w, MPI u, MPI v)        { mpi_add( w, u, v ); }
64
 
void g10m_add_ui(MPI w, MPI u, ulong v )  { mpi_add_ui( w, u, v ); }
65
 
void g10m_sub( MPI w, MPI u, MPI v)       { mpi_sub( w, u, v ); }
66
 
void g10m_sub_ui(MPI w, MPI u, ulong v )  { mpi_sub_ui( w, u, v ); }
67
 
 
68
 
void g10m_mul( MPI w, MPI u, MPI v)          { mpi_mul( w, u, v ); }
69
 
void g10m_mulm( MPI w, MPI u, MPI v, MPI m)  { mpi_mulm( w, u, v, m ); }
70
 
void g10m_mul_2exp( MPI w, MPI u, ulong cnt) { mpi_mul_2exp( w, u, cnt ); }
71
 
void g10m_mul_ui(MPI w, MPI u, ulong v )     { mpi_mul_ui( w, u, v ); }
72
 
 
73
 
void g10m_fdiv_q( MPI q, MPI d, MPI r )      { mpi_fdiv_q( q, d, r ); }
74
 
 
75
 
void g10m_powm( MPI r, MPI b, MPI e, MPI m)  { mpi_powm( r, b, e, m );  }
76
 
 
77
 
int  g10m_gcd( MPI g, MPI a, MPI b )    { return mpi_gcd( g, a, b ); }
78
 
int  g10m_invm( MPI x, MPI u, MPI v )   { mpi_invm( x, u, v ); return 0; }
79
 
 
80
 
unsigned g10m_get_nbits( MPI a )   { return mpi_get_nbits( a ); }
81
 
 
82
 
unsigned
83
 
g10m_get_size( MPI a )
84
 
{
85
 
    return mpi_get_nlimbs( a ) * BITS_PER_MPI_LIMB;
86
 
}
87
 
 
88
 
 
89
 
void
90
 
g10m_set_buffer( MPI a, const char *buffer, unsigned nbytes, int sign )
91
 
{
92
 
    mpi_set_buffer( a, buffer, nbytes, sign );
93
 
}
94
 
 
95