diff options
Diffstat (limited to 'cipher')
-rw-r--r-- | cipher/cipher.c | 6 | ||||
-rw-r--r-- | cipher/dsa.c | 12 | ||||
-rw-r--r-- | cipher/dynload.c | 8 | ||||
-rw-r--r-- | cipher/elgamal.c | 14 | ||||
-rw-r--r-- | cipher/md.c | 30 | ||||
-rw-r--r-- | cipher/primegen.c | 24 | ||||
-rw-r--r-- | cipher/random.c | 20 | ||||
-rw-r--r-- | cipher/random.h | 2 | ||||
-rw-r--r-- | cipher/rndegd.c | 2 | ||||
-rw-r--r-- | cipher/rndw32.c | 6 | ||||
-rw-r--r-- | cipher/rsa.c | 4 |
11 files changed, 64 insertions, 64 deletions
diff --git a/cipher/cipher.c b/cipher/cipher.c index 950f625cf..591ce208e 100644 --- a/cipher/cipher.c +++ b/cipher/cipher.c @@ -389,10 +389,10 @@ cipher_open( int algo, int mode, int secure ) /* ? perform selftest here and mark this with a flag in cipher_table ? */ - hd = secure ? m_alloc_secure_clear( sizeof *hd + hd = secure ? xmalloc_secure_clear( sizeof *hd + cipher_table[i].contextsize - sizeof(PROPERLY_ALIGNED_TYPE) ) - : m_alloc_clear( sizeof *hd + cipher_table[i].contextsize + : xmalloc_clear( sizeof *hd + cipher_table[i].contextsize - sizeof(PROPERLY_ALIGNED_TYPE) ); hd->algo = algo; hd->blocksize = cipher_table[i].blocksize; @@ -421,7 +421,7 @@ cipher_open( int algo, int mode, int secure ) void cipher_close( CIPHER_HANDLE c ) { - m_free(c); + xfree(c); } diff --git a/cipher/dsa.c b/cipher/dsa.c index 1fdb29ae4..967243e83 100644 --- a/cipher/dsa.c +++ b/cipher/dsa.c @@ -94,7 +94,7 @@ gen_k( MPI q ) progress('.'); if( !rndbuf || nbits < 32 ) { - m_free(rndbuf); + xfree(rndbuf); rndbuf = get_random_bits( nbits, 1, 1 ); } else { /* change only some of the higher bits */ @@ -103,7 +103,7 @@ gen_k( MPI q ) * maybe it is easier to do this directly in random.c */ char *pp = get_random_bits( 32, 1, 1 ); memcpy( rndbuf,pp, 4 ); - m_free(pp); + xfree(pp); } mpi_set_buffer( k, rndbuf, nbytes, 0 ); if( mpi_test_bit( k, nbits-1 ) ) @@ -125,7 +125,7 @@ gen_k( MPI q ) } break; /* okay */ } - m_free(rndbuf); + xfree(rndbuf); if( DBG_CIPHER ) progress('\n'); @@ -148,7 +148,7 @@ test_keys( DSA_secret_key *sk, unsigned qbits ) /*mpi_set_bytes( test, qbits, get_random_byte, 0 );*/ { char *p = get_random_bits( qbits, 0, 0 ); mpi_set_buffer( test, p, (qbits+7)/8, 0 ); - m_free(p); + xfree(p); } sign( out1_a, out1_b, test, sk ); @@ -219,12 +219,12 @@ generate( DSA_secret_key *sk, unsigned nbits, MPI **ret_factors ) else { /* change only some of the higher bits (= 2 bytes)*/ char *r = get_random_bits( 16, 2, 1 ); memcpy(rndbuf, r, 16/8 ); - m_free(r); + xfree(r); } mpi_set_buffer( x, rndbuf, (qbits+7)/8, 0 ); mpi_clear_highbit( x, qbits+1 ); } while( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, h )<0 ) ); - m_free(rndbuf); + xfree(rndbuf); mpi_free( e ); mpi_free( h ); diff --git a/cipher/dynload.c b/cipher/dynload.c index 3f0e2b720..05d82f623 100644 --- a/cipher/dynload.c +++ b/cipher/dynload.c @@ -65,12 +65,12 @@ register_cipher_extension( const char *mainpgm, const char *fname ) tmp = make_filename(fname, NULL); else tmp = make_filename(GNUPG_LIBDIR, fname, NULL); - el = m_alloc_clear( sizeof *el + strlen(tmp) ); + el = xmalloc_clear( sizeof *el + strlen(tmp) ); strcpy(el->name, tmp ); - m_free(tmp); + xfree(tmp); } else { - el = m_alloc_clear( sizeof *el + strlen(fname) ); + el = xmalloc_clear( sizeof *el + strlen(fname) ); strcpy(el->name, fname ); } /* check whether we have a class hint */ @@ -82,7 +82,7 @@ register_cipher_extension( const char *mainpgm, const char *fname ) for(r = extensions; r; r = r->next ) { if( !compare_filenames(r->name, el->name) ) { log_info("extension `%s' already registered\n", el->name ); - m_free(el); + xfree(el); return; } } diff --git a/cipher/elgamal.c b/cipher/elgamal.c index 95ff38ccc..3c37a283e 100644 --- a/cipher/elgamal.c +++ b/cipher/elgamal.c @@ -133,7 +133,7 @@ test_keys( ELG_secret_key *sk, unsigned nbits ) /*mpi_set_bytes( test, nbits, get_random_byte, 0 );*/ { char *p = get_random_bits( nbits, 0, 0 ); mpi_set_buffer( test, p, (nbits+7)/8, 0 ); - m_free(p); + xfree(p); } do_encrypt( out1_a, out1_b, test, &pk ); @@ -183,7 +183,7 @@ gen_k( MPI p, int small_k ) mpi_sub_ui( p_1, p, 1); for(;;) { if( !rndbuf || nbits < 32 ) { - m_free(rndbuf); + xfree(rndbuf); rndbuf = get_random_bits( nbits, 1, 1 ); } else { /* Change only some of the higher bits. */ @@ -194,7 +194,7 @@ gen_k( MPI p, int small_k ) */ char *pp = get_random_bits( 32, 1, 1 ); memcpy( rndbuf,pp, 4 ); - m_free(pp); + xfree(pp); } mpi_set_buffer( k, rndbuf, nbytes, 0 ); @@ -217,7 +217,7 @@ gen_k( MPI p, int small_k ) } } found: - m_free(rndbuf); + xfree(rndbuf); if( DBG_CIPHER ) progress('\n'); mpi_free(p_1); @@ -280,13 +280,13 @@ generate( ELG_secret_key *sk, unsigned int nbits, MPI **ret_factors ) progress('.'); if( rndbuf ) { /* change only some of the higher bits */ if( xbits < 16 ) {/* should never happen ... */ - m_free(rndbuf); + xfree(rndbuf); rndbuf = get_random_bits( xbits, 2, 1 ); } else { char *r = get_random_bits( 16, 2, 1 ); memcpy(rndbuf, r, 16/8 ); - m_free(r); + xfree(r); } } else @@ -294,7 +294,7 @@ generate( ELG_secret_key *sk, unsigned int nbits, MPI **ret_factors ) mpi_set_buffer( x, rndbuf, (xbits+7)/8, 0 ); mpi_clear_highbit( x, xbits+1 ); } while( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, p_min1 )<0 ) ); - m_free(rndbuf); + xfree(rndbuf); y = mpi_alloc(nbits/BITS_PER_MPI_LIMB); mpi_powm( y, g, x, p ); diff --git a/cipher/md.c b/cipher/md.c index 66a8b0540..7c23bc00e 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -62,14 +62,14 @@ new_list_item (int algo, { struct md_digest_list_s *r; - r = m_alloc_clear (sizeof *r ); + r = xmalloc_clear (sizeof *r ); r->algo = algo; r->name = (*get_info)( algo, &r->contextsize, &r->asnoid, &r->asnlen, &r->mdlen, &r->init, &r->write, &r->final, &r->read ); if (!r->name ) { - m_free(r); + xfree(r); r = NULL; } if (r) @@ -192,11 +192,11 @@ md_open( int algo, int secure ) if( secure ) { bufsize = 512 - sizeof( *hd ); - hd = m_alloc_secure_clear( sizeof *hd + bufsize ); + hd = xmalloc_secure_clear( sizeof *hd + bufsize ); } else { bufsize = 1024 - sizeof( *hd ); - hd = m_alloc_clear( sizeof *hd + bufsize ); + hd = xmalloc_clear( sizeof *hd + bufsize ); } hd->bufsize = bufsize+1; /* hd has already one byte allocated */ @@ -226,9 +226,9 @@ md_enable( MD_HANDLE h, int algo ) return; } /* and allocate a new list entry */ - ac = h->secure? m_alloc_secure( sizeof *ac + r->contextsize + ac = h->secure? xmalloc_secure( sizeof *ac + r->contextsize - sizeof(r->context) ) - : m_alloc( sizeof *ac + r->contextsize + : xmalloc( sizeof *ac + r->contextsize - sizeof(r->context) ); *ac = *r; ac->next = h->list; @@ -246,17 +246,17 @@ md_copy( MD_HANDLE a ) if( a->bufcount ) md_write( a, NULL, 0 ); - b = a->secure ? m_alloc_secure( sizeof *b + a->bufsize - 1 ) - : m_alloc( sizeof *b + a->bufsize - 1 ); + b = a->secure ? xmalloc_secure( sizeof *b + a->bufsize - 1 ) + : xmalloc( sizeof *b + a->bufsize - 1 ); memcpy( b, a, sizeof *a + a->bufsize - 1 ); b->list = NULL; b->debug = NULL; /* and now copy the complete list of algorithms */ /* I know that the copied list is reversed, but that doesn't matter */ for( ar=a->list; ar; ar = ar->next ) { - br = a->secure ? m_alloc_secure( sizeof *br + ar->contextsize + br = a->secure ? xmalloc_secure( sizeof *br + ar->contextsize - sizeof(ar->context) ) - : m_alloc( sizeof *br + ar->contextsize + : xmalloc( sizeof *br + ar->contextsize - sizeof(ar->context) ); memcpy( br, ar, sizeof(*br) + ar->contextsize - sizeof(ar->context) ); @@ -298,9 +298,9 @@ md_close(MD_HANDLE a) md_stop_debug(a); for(r=a->list; r; r = r2 ) { r2 = r->next; - m_free(r); + xfree(r); } - m_free(a); + xfree(a); } @@ -404,8 +404,8 @@ md_digest( MD_HANDLE a, int algo, byte *buffer, int buflen ) /* I don't want to change the interface, so I simply work on a copy * the context (extra overhead - should be fixed)*/ - context = a->secure ? m_alloc_secure( r->contextsize ) - : m_alloc( r->contextsize ); + context = a->secure ? xmalloc_secure( r->contextsize ) + : xmalloc( r->contextsize ); memcpy( context, r->context.c, r->contextsize ); (*r->final)( context ); digest = (*r->read)( context ); @@ -414,7 +414,7 @@ md_digest( MD_HANDLE a, int algo, byte *buffer, int buflen ) buflen = r->mdlen; memcpy( buffer, digest, buflen ); - m_free(context); + xfree(context); return buflen; } diff --git a/cipher/primegen.c b/cipher/primegen.c index 98d63696a..0662d39e0 100644 --- a/cipher/primegen.c +++ b/cipher/primegen.c @@ -137,7 +137,7 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, q_factor = mode==1? gen_prime( req_qbits, 0, 0 ) : NULL; /* allocate an array to hold the factors + 2 for later usage */ - factors = m_alloc_clear( (n+2) * sizeof *factors ); + factors = xmalloc_clear( (n+2) * sizeof *factors ); /* make a pool of 3n+5 primes (this is an arbitrary value) */ m = n*3+5; @@ -145,7 +145,7 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, m += 5; /* need some more for DSA */ if( m < 25 ) m = 25; - pool = m_alloc_clear( m * sizeof *pool ); + pool = xmalloc_clear( m * sizeof *pool ); /* permutate over the pool of primes */ count1=count2=0; @@ -158,7 +158,7 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, pool[i] = NULL; } /* init m_out_of_n() */ - perms = m_alloc_clear( m ); + perms = xmalloc_clear( m ); for(i=0; i < n; i++ ) { perms[i] = 1; pool[i] = gen_prime( fbits, 0, 0 ); @@ -174,7 +174,7 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, factors[j++] = pool[i]; } if( i == n ) { - m_free(perms); perms = NULL; + xfree(perms); perms = NULL; progress('!'); goto next_try; /* allocate new primes */ } @@ -231,7 +231,7 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, } if( ret_factors ) { /* caller wants the factors */ - *ret_factors = m_alloc_clear( (n+2) * sizeof **ret_factors); + *ret_factors = xmalloc_clear( (n+2) * sizeof **ret_factors); i = 0; if( mode == 1 ) { (*ret_factors)[i++] = mpi_copy( q_factor ); @@ -282,11 +282,11 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, if( !DBG_CIPHER ) progress('\n'); - m_free( factors ); /* (factors are shallow copies) */ + xfree( factors ); /* (factors are shallow copies) */ for(i=0; i < m; i++ ) mpi_free( pool[i] ); - m_free( pool ); - m_free(perms); + xfree( pool ); + xfree(perms); mpi_free(val_2); mpi_free(q); return prime; @@ -317,7 +317,7 @@ gen_prime( unsigned int nbits, int secret, int randomlevel ) for(i=0; small_prime_numbers[i]; i++ ) no_of_small_prime_numbers++; } - mods = m_alloc( no_of_small_prime_numbers * sizeof *mods ); + mods = xmalloc( no_of_small_prime_numbers * sizeof *mods ); /* make nbits fit into MPI implementation */ nlimbs = (nbits + BITS_PER_MPI_LIMB - 1) / BITS_PER_MPI_LIMB; val_2 = mpi_alloc_set_ui( 2 ); @@ -333,7 +333,7 @@ gen_prime( unsigned int nbits, int secret, int randomlevel ) /* generate a random number */ { char *p = get_random_bits( nbits, randomlevel, secret ); mpi_set_buffer( prime, p, (nbits+7)/8, 0 ); - m_free(p); + xfree(p); } /* Set high order bit to 1, set low order bit to 0. @@ -382,7 +382,7 @@ gen_prime( unsigned int nbits, int secret, int randomlevel ) mpi_free(result); mpi_free(pminus1); mpi_free(prime); - m_free(mods); + xfree(mods); return ptest; } } @@ -467,7 +467,7 @@ is_prime( MPI n, int steps, int *count ) p = get_random_bits( nbits, 0, 0 ); mpi_set_buffer( x, p, (nbits+7)/8, 0 ); - m_free(p); + xfree(p); /* Make sure that the number is smaller than the prime * and keep the randomness of the high bit. */ diff --git a/cipher/random.c b/cipher/random.c index 4dd8d54c7..1ae2e8065 100644 --- a/cipher/random.c +++ b/cipher/random.c @@ -200,10 +200,10 @@ initialize(void) /* The data buffer is allocated somewhat larger, so that * we can use this extra space (which is allocated in secure memory) * as a temporary hash buffer */ - rndpool = secure_alloc ? m_alloc_secure_clear(POOLSIZE+BLOCKLEN) - : m_alloc_clear(POOLSIZE+BLOCKLEN); - keypool = secure_alloc ? m_alloc_secure_clear(POOLSIZE+BLOCKLEN) - : m_alloc_clear(POOLSIZE+BLOCKLEN); + rndpool = secure_alloc ? xmalloc_secure_clear(POOLSIZE+BLOCKLEN) + : xmalloc_clear(POOLSIZE+BLOCKLEN); + keypool = secure_alloc ? xmalloc_secure_clear(POOLSIZE+BLOCKLEN) + : xmalloc_clear(POOLSIZE+BLOCKLEN); is_initialized = 1; } @@ -231,7 +231,7 @@ random_dump_stats() } void -secure_random_alloc() +secure_randoxmalloc() { secure_alloc = 1; } @@ -260,7 +260,7 @@ randomize_buffer( byte *buffer, size_t length, int level ) { char *p = get_random_bits( length*8, level, 1 ); memcpy( buffer, p, length ); - m_free(p); + xfree(p); } @@ -295,7 +295,7 @@ get_random_bits( size_t nbits, int level, int secure ) rndstats.ngetbytes2++; } - buf = secure && secure_alloc ? m_alloc_secure( nbytes ) : m_alloc( nbytes ); + buf = secure && secure_alloc ? xmalloc_secure( nbytes ) : xmalloc( nbytes ); for( p = buf; nbytes > 0; ) { size_t n = nbytes > POOLSIZE? POOLSIZE : nbytes; read_pool( p, n, level ); @@ -356,7 +356,7 @@ set_random_seed_file( const char *name ) { if( seed_file_name ) BUG(); - seed_file_name = m_strdup( name ); + seed_file_name = xstrdup( name ); } /**************** @@ -738,7 +738,7 @@ gather_faked( void (*add)(const void*, size_t, int), int requester, #endif } - p = buffer = m_alloc( length ); + p = buffer = xmalloc( length ); n = length; #ifdef HAVE_RAND while( n-- ) @@ -748,6 +748,6 @@ gather_faked( void (*add)(const void*, size_t, int), int requester, *p++ = ((unsigned)(1 + (int) (256.0*random()/(RAND_MAX+1.0)))-1); #endif add_randomness( buffer, length, requester ); - m_free(buffer); + xfree(buffer); return 0; /* okay */ } diff --git a/cipher/random.h b/cipher/random.h index 08d1e2ddd..9e8090ec7 100644 --- a/cipher/random.h +++ b/cipher/random.h @@ -25,7 +25,7 @@ /*-- random.c --*/ void random_dump_stats(void); -void secure_random_alloc(void); +void secure_randoxmalloc(void); void set_random_seed_file(const char *); void update_random_seed_file(void); int quick_random_gen( int onoff ); diff --git a/cipher/rndegd.c b/cipher/rndegd.c index f2e2a020a..fb997d283 100644 --- a/cipher/rndegd.c +++ b/cipher/rndegd.c @@ -140,7 +140,7 @@ rndegd_connect_socket (int nofail) close (fd); fd = -1; } - m_free(name); + xfree(name); if (fd != -1) egd_socket = fd; return fd; diff --git a/cipher/rndw32.c b/cipher/rndw32.c index b59ae6fbe..dc3c775c2 100644 --- a/cipher/rndw32.c +++ b/cipher/rndw32.c @@ -482,7 +482,7 @@ slow_gatherer_windowsNT( void (*add)(const void*, size_t, int), int requester ) * worst-case estimate which is usually nowhere near the actual amount * required. For example it may report that 128K of memory is required, * but only return 64K of data */ - { pPerfData = m_alloc (cbPerfData); + { pPerfData = xmalloc (cbPerfData); for (;;) { dwSize = cbPerfData; if ( debug_me ) @@ -499,14 +499,14 @@ slow_gatherer_windowsNT( void (*add)(const void*, size_t, int), int requester ) } else if (status == ERROR_MORE_DATA) { cbPerfData += PERFORMANCE_BUFFER_STEP; - pPerfData = m_realloc (pPerfData, cbPerfData); + pPerfData = xrealloc (pPerfData, cbPerfData); } else { g10_log_debug ( "rndw32: get performance data problem\n"); break; } } - m_free (pPerfData); + xfree (pPerfData); } /* Although this isn't documented in the Win32 API docs, it's necessary to explicitly close the HKEY_PERFORMANCE_DATA key after use (it's diff --git a/cipher/rsa.c b/cipher/rsa.c index f23f3fcaa..8b23326f2 100644 --- a/cipher/rsa.c +++ b/cipher/rsa.c @@ -70,7 +70,7 @@ test_keys( RSA_secret_key *sk, unsigned nbits ) pk.e = sk->e; { char *p = get_random_bits( nbits, 0, 0 ); mpi_set_buffer( test, p, (nbits+7)/8, 0 ); - m_free(p); + xfree(p); } public( out1, test, &pk ); @@ -355,7 +355,7 @@ rsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ) skey[5] = sk.u; /* make an empty list of factors */ if (retfactors) - *retfactors = m_alloc_clear( 1 * sizeof **retfactors ); + *retfactors = xmalloc_clear( 1 * sizeof **retfactors ); return 0; } |