+Version 0.4.3
+- The gnutls-extra library now compiles fine, if the opencdk library is
+ not present.
+- Several bug fixes.
+- Added gnutls_global_set_mem_func() function, to set the memory allocation
+ functions, if other than the defaults are to be used.
+- The default memory allocation functions are now the ones in libc.
+
Version 0.4.2 (21/05/2002)
- Separated ASN.1 structures parser documentation and TLS library
documentation.
Marc Huber <Marc.Huber@web.de>
Guillaume Morin <guillaume@morinfr.org>
Andrew McDonald <andrew@mcdonald.org.uk>
+Jeff Johnson <jbj@redhat.com>
#undef LT_AGE
#undef USE_DMALLOC
#undef USE_EFENCE
-#undef USE_LIBCALLOC
#undef USE_GCRYPT
#undef GNUTLS_VERSION
if test x$opt_maintainer_mode = xyes; then
- CFLAGS="${CFLAGS} -O0 -ggdb3 -Wall -Wpointer-arith -Wstrict-prototypes" # -Werror
+ CFLAGS="${CFLAGS} -ggdb3 -Wall -Wpointer-arith -Wstrict-prototypes" # -Werror
else
- CFLAGS="${CFLAGS} -O2 -fexpensive-optimizations -fomit-frame-pointer"
+ CFLAGS="${CFLAGS} -O2 -finline-functions -fexpensive-optimizations -fomit-frame-pointer"
fi
if test x$opt_dmalloc_mode = xyes; then
AC_CHECK_LIB( dmalloc, main)
AC_DEFINE(USE_DMALLOC)
- AC_DEFINE(USE_LIBCALLOC)
else
if test x$opt_efence_mode = xyes; then
AC_CHECK_LIB( efence, main)
AC_DEFINE(USE_EFENCE)
- AC_DEFINE(USE_LIBCALLOC)
fi
fi
if test $ac_cv_c_compiler_gnu != no; then
if test x$opt_profiler_mode = xyes; then
- CFLAGS="${CFLAGS} -O0 `fc-config --cflags`"
+ CFLAGS="${CFLAGS} `fc-config --cflags`"
AC_CHECK_PROG(FC_OK, fc-config, yes, no)
if test x$FC_OK = xyes; then
LIBS="$LIBS `fc-config --libs`"
if (indx == -1 && state->gnutls_internals.client_cert_callback != NULL && cred->ncerts > 0) { /* use a callback to get certificate */
gnutls_datum *my_certs = NULL;
gnutls_datum *issuers_dn = NULL;
- int count;
int issuers_dn_len = 0;
opaque* dataptr = data;
int dataptr_size = data_size;
data += 2;
- issuers_dn[count].data = data;
- issuers_dn[count].size = size;
+ issuers_dn[i].data = data;
+ issuers_dn[i].size = size;
data += size;
int gnutls_global_init(void);
void gnutls_global_deinit(void);
+void gnutls_global_set_mem_func(
+ void *(*gnutls_alloc_func)(size_t), void* (*gnutls_secure_alloc_func)(size_t),
+ int (*gnutls_is_secure_func)(const void*), void *(*gnutls_realloc_func)(void *, size_t),
+ void (*gnutls_free_func)(void*));
+
+typedef void (*GNUTLS_LOG_FUNC)( const char*);
+void gnutls_global_set_log_func( GNUTLS_LOG_FUNC log_func);
+
int gnutls_dh_params_set( GNUTLS_DH_PARAMS, gnutls_datum prime, gnutls_datum generator, int bits);
int gnutls_dh_params_init( GNUTLS_DH_PARAMS*);
void gnutls_dh_params_deinit( GNUTLS_DH_PARAMS);
void gnutls_transport_set_lowat( GNUTLS_STATE state, int num);
-typedef void (*GNUTLS_LOG_FUNC)( const char*);
void gnutls_transport_set_push_func( GNUTLS_STATE, GNUTLS_PUSH_FUNC push_func);
void gnutls_transport_set_pull_func( GNUTLS_STATE, GNUTLS_PULL_FUNC pull_func);
_gnutls_version_is_supported(GNUTLS_STATE state,
const GNUTLS_Version version)
{
-int ret;
+int ret=0;
GNUTLS_VERSION_ALG_LOOP(ret = p->supported);
if (ret == 0) return 0;
* of a server.
**/
int gnutls_cred_set( GNUTLS_STATE state, GNUTLS_CredType type, void* cred) {
- AUTH_CRED * ccred, *pcred;
+ AUTH_CRED * ccred=NULL, *pcred=NULL;
int exists=0;
if (state->gnutls_key->cred==NULL) { /* begining of the list */
pcred = ccred;
ccred = ccred->next;
}
-
+ /* After this, pcred is not null.
+ */
+
if (exists==0) { /* new entry */
pcred->next = gnutls_malloc(sizeof(AUTH_CRED));
if (pcred->next == NULL) return GNUTLS_E_MEMORY_ERROR;
* to passive eavesdropers.
*/
if ( gnutls_auth_get_type( state) != state->gnutls_key->auth_info_type) {
- state->gnutls_key->auth_info = gnutls_realloc_fast(
+ state->gnutls_key->auth_info = gnutls_realloc(
state->gnutls_key->auth_info, size);
if (state->gnutls_key->auth_info == NULL) {
gnutls_assert();
memmove(state->gnutls_internals.application_data_buffer.data,
&state->gnutls_internals.application_data_buffer.data[length],
state->gnutls_internals.application_data_buffer.size);
+
/* this does not fail */
state->gnutls_internals.application_data_buffer.data =
- gnutls_realloc_fast(state->gnutls_internals.application_data_buffer.data,
+ gnutls_realloc(state->gnutls_internals.application_data_buffer.data,
state->gnutls_internals.application_data_buffer.size);
break;
/* does not fail */
state->gnutls_internals.handshake_data_buffer.data =
- gnutls_realloc_fast(state->gnutls_internals.handshake_data_buffer.data,
+ gnutls_realloc(state->gnutls_internals.handshake_data_buffer.data,
state->gnutls_internals.handshake_data_buffer.size);
break;
default:
int min, buf_pos;
char *buf;
int recvlowat = RCVLOWAT;
- int recvdata;
+ int recvdata, alloc_size;
*iptr = state->gnutls_internals.record_recv_buffer.data;
/* Allocate the data required to store the new packet.
*/
- state->gnutls_internals.record_recv_buffer.data = gnutls_realloc_fast(
- state->gnutls_internals.record_recv_buffer.data, recvdata+state->gnutls_internals.record_recv_buffer.size);
- if ( state->gnutls_internals.record_recv_buffer.data==NULL) {
+
+ alloc_size = recvdata+state->gnutls_internals.record_recv_buffer.size;
+ state->gnutls_internals.record_recv_buffer.data = gnutls_realloc(
+ state->gnutls_internals.record_recv_buffer.data, alloc_size);
+ if ( state->gnutls_internals.record_recv_buffer.data==NULL && alloc_size > 0) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
}
}
- buffer->data = gnutls_realloc_fast( buffer->data, data_size);
+ buffer->data = gnutls_realloc( buffer->data, data_size);
buffer->size = data_size;
- if (buffer->data == NULL) {
+ if (buffer->data == NULL && data_size > 0) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
}
if (dsize > 0 && (i==GNUTLS_E_INTERRUPTED || i==GNUTLS_E_AGAIN)) {
gnutls_assert();
- state->gnutls_internals.handshake_recv_buffer.data = gnutls_realloc_fast(
+ state->gnutls_internals.handshake_recv_buffer.data = gnutls_realloc(
state->gnutls_internals.handshake_recv_buffer.data, dsize);
- if (state->gnutls_internals.handshake_recv_buffer.data==NULL) {
+ if (state->gnutls_internals.handshake_recv_buffer.data==NULL && dsize > 0) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
}
if (ret<0) {
gnutls_assert();
- gnutls_secure_free(key_block);
+ gnutls_free(key_block);
return ret;
}
pos = 0;
if (hash_size > 0) {
if (gnutls_sset_datum( &state->cipher_specs.client_write_mac_secret, &key_block[pos], hash_size) < 0 ) {
- gnutls_secure_free(key_block);
+ gnutls_free(key_block);
return GNUTLS_E_MEMORY_ERROR;
}
pos+=hash_size;
if (gnutls_sset_datum( &state->cipher_specs.server_write_mac_secret, &key_block[pos], hash_size) < 0 ) {
- gnutls_secure_free(key_block);
+ gnutls_free(key_block);
return GNUTLS_E_MEMORY_ERROR;
}
pos+=hash_size;
if (key_size > 0) {
if (gnutls_sset_datum( &state->cipher_specs.client_write_key, &key_block[pos], key_size) < 0 ) {
- gnutls_secure_free(key_block);
+ gnutls_free(key_block);
return GNUTLS_E_MEMORY_ERROR;
}
pos+=key_size;
if (gnutls_sset_datum( &state->cipher_specs.server_write_key, &key_block[pos], key_size) < 0 ) {
- gnutls_secure_free(key_block);
+ gnutls_free(key_block);
return GNUTLS_E_MEMORY_ERROR;
}
pos+=key_size;
}
if (IV_size > 0) {
if (gnutls_sset_datum( &state->cipher_specs.client_write_IV, &key_block[pos], IV_size) < 0 ) {
- gnutls_secure_free(key_block);
+ gnutls_free(key_block);
return GNUTLS_E_MEMORY_ERROR;
}
pos+=IV_size;
if (gnutls_sset_datum( &state->cipher_specs.server_write_IV, &key_block[pos], IV_size) < 0 ) {
- gnutls_secure_free(key_block);
+ gnutls_free(key_block);
return GNUTLS_E_MEMORY_ERROR;
}
pos+=IV_size;
}
- gnutls_secure_free(key_block);
+ gnutls_free(key_block);
state->cipher_specs.generated_keys = 1;
void gnutls_sfree_datum( gnutls_datum* dat) {
if (dat->data!=NULL && dat->size!=0)
- gnutls_secure_free( dat->data);
+ gnutls_free( dat->data);
dat->data = NULL;
dat->size = 0;
*/
int _gnutls_dh_calc_mpis(void)
{
- int i, n;
+ int i;
+ size_t n;
if (_gnutls_dh_default_params == NULL) {
gnutls_assert();
gnutls_datum generator, int bits)
{
GNUTLS_MPI tmp_prime, tmp_g;
- int siz = 0, i = 0;
- GNUTLS_DH_PARAMS sprime;
+ int i = 0;
+ GNUTLS_DH_PARAMS sprime=NULL;
+ size_t siz = 0;
if (check_bits(bits) < 0) {
gnutls_assert();
break;
}
} while (dh_params[++i].bits != 0);
+ /* sprime is not null, because of the check_bits()
+ * above.
+ */
siz = prime.size;
if (_gnutls_mpi_scan(&tmp_prime, prime.data, &siz)) {
{
GNUTLS_MPI tmp_prime, tmp_g;
- int siz;
+ size_t siz;
if (check_bits(bits) < 0) {
gnutls_assert();
#endif
}
+extern void* (*gnutls_secure_malloc)(size_t);
+extern void* (*gnutls_malloc)(size_t);
+extern void (*gnutls_free)(void*);
+extern int (*_gnutls_is_secure_memory)(const void*);
+extern void* (*gnutls_realloc)(void*, size_t);
+
+int _gnutls_is_secure_mem_null( const void*);
+
+/**
+ * gnutls_global_set_mem_func - This function sets the memory allocation functions
+ * @alloc_func: it's the default memory allocation function. Like malloc().
+ * @secure_alloc_func: This is the memory allocation function that will be used for sensitive data.
+ * @is_secure_func: a function that returns 0 if the memory given is not secure. May be NULL.
+ * @realloc_func: A realloc function
+ * @free_func: The function that frees allocated data.
+ *
+ * This is the function were you set the memory allocation functions gnutls
+ * is going to use. By default the libc's allocation functions (malloc(), free()),
+ * are used by gnutls, to allocate both sensitive and not sensitive data.
+ * This function is provided to set the memory allocation functions to
+ * something other than the defaults (ie the gcrypt allocation functions).
+ *
+ * This function must be called before gnutls_global_init() is called.
+ *
+ **/
+void gnutls_global_set_mem_func(
+ void *(*gnutls_alloc_func)(size_t), void* (*gnutls_secure_alloc_func)(size_t),
+ int (*gnutls_is_secure_func)(const void*), void *(*gnutls_realloc_func)(void *, size_t),
+ void (*gnutls_free_func)(void*))
+{
+ gnutls_secure_malloc = gnutls_secure_alloc_func;
+ gnutls_malloc = gnutls_alloc_func;
+ gnutls_realloc = gnutls_realloc_func;
+ gnutls_free = gnutls_free_func;
+
+ if (gnutls_is_secure_func==NULL)
+ _gnutls_is_secure_memory = gnutls_is_secure_func;
+ else
+ _gnutls_is_secure_memory = _gnutls_is_secure_mem_null;
+
+ return;
+}
+
static int _gnutls_init = 0;
/**
if (_gnutls_init!=1) {
return 0;
}
-
+
if (gcry_control( GCRYCTL_ANY_INITIALIZATION_P) == 0) {
/* for gcrypt in order to be able to allocate memory */
gcry_set_allocation_handler(gnutls_malloc, gnutls_secure_malloc, _gnutls_is_secure_memory, gnutls_realloc, gnutls_free);
gnutls_assert();
return result;
}
+
return 0;
}
int _gnutls_send_finished(GNUTLS_STATE state, int again)
{
uint8 data[36];
- int ret;
+ int ret=0;
int data_size = 0;
#include <gnutls_errors.h>
#include <gnutls_num.h>
-#ifdef USE_LIBCALLOC
+void* (*gnutls_secure_malloc)(size_t) = malloc;
+void* (*gnutls_malloc)(size_t) = malloc;
+void (*gnutls_free)(void*) = free;
-int _gnutls_is_secure_memory(const void *ign)
-{
- return 0;
-}
-
-#else
-
-/* #define MALLOC_DEBUG */
-# define EXTRA_SIZE sizeof(size_t)+1
-
-int _gnutls_is_secure_memory(const svoid * mem)
-{
- if (mem==NULL) return 0;
- return *((opaque *) mem - 1);
-}
+int _gnutls_is_secure_mem_null( const void* ign) { return 0; }
-void *gnutls_malloc(size_t size)
-{
- opaque *ret;
- if (size == 0)
- return NULL;
+int (*_gnutls_is_secure_memory)(const void*) = _gnutls_is_secure_mem_null;
+void* (*gnutls_realloc)(void*, size_t) = realloc;
- ret = malloc(size + EXTRA_SIZE);
- if (ret == NULL)
- return ret;
-
- *((int *) ret) = size;
- ret[sizeof(size_t)] = 0; /* not secure */
-
- ret += EXTRA_SIZE;
-
-#ifdef MALLOC_DEBUG
- _gnutls_log("Allocated: %x with %d bytes\n", ret,
- _gnutls_malloc_ptr_size(ret));
-#endif
-
- return ret;
-
-}
void *gnutls_calloc(size_t nmemb, size_t size)
{
return ret;
}
-size_t _gnutls_malloc_ptr_size(void *_ptr)
-{
- opaque *ptr = _ptr;
-
- if (_ptr == NULL)
- return 0;
-
- return *((int *) ((opaque *) ptr - sizeof(size_t) - 1));
-}
-
-void *gnutls_realloc(void *_ptr, size_t size)
-{
- opaque *ret;
- opaque* ptr = _ptr;
-
- if (ptr!=NULL)
- ptr -= EXTRA_SIZE;
-
- ret = realloc(ptr, size + EXTRA_SIZE);
- if (ret == NULL)
- return ret;
-
- *((int *) ret) = size;
- ret[sizeof(size_t)] = 0; /* not secure */
-
- ret += EXTRA_SIZE;
-
- return ret;
-}
-
-/* This realloc only returns a new pointer if you
- * request more data than the data into the pointer.
- */
-void *gnutls_realloc_fast(void *ptr, size_t size)
-{
-
- if (ptr != NULL && size <= _gnutls_malloc_ptr_size(ptr)) {
- /* do nothing, just return the pointer.
- * It's much faster.
- */
- return ptr;
- }
- return gnutls_realloc(ptr, size);
-}
-
-inline
-static void _gnutls_free(void *_ptr)
-{
-opaque *ptr = _ptr;
-
-
- ptr -= EXTRA_SIZE;
-
-#ifdef MALLOC_DEBUG
- _gnutls_log("Freed: %x with %d bytes\n", _ptr,
- _gnutls_malloc_ptr_size(_ptr));
-#endif
- free(ptr);
-}
-
-void gnutls_free(void *_ptr)
-{
- if (_ptr == NULL)
- return;
-
- if ( _gnutls_is_secure_memory( _ptr) != 0) {
- return gnutls_secure_free( _ptr);
- } else {
- _gnutls_free( _ptr);
- }
-}
-
-
-
-svoid *gnutls_secure_malloc(size_t size)
-{
- opaque *ret;
- ret = gnutls_malloc(size);
- if (ret == NULL)
- return ret;
-
- *((opaque *) ret - 1) = 1; /* secure mem */
-
- return ret;
-
-}
-
svoid *gnutls_secure_calloc(size_t nmemb, size_t size)
{
svoid *ret;
return ret;
}
-size_t _gnutls_secure_ptr_size(svoid * ptr)
-{
- return _gnutls_malloc_ptr_size(ptr);
-}
-
-svoid *gnutls_secure_realloc(svoid * ptr, size_t size)
-{
- svoid *ret;
- if (ptr != NULL && size <= _gnutls_secure_ptr_size(ptr)) {
- /* do not do realloc.
- * return the previous pointer.
- */
- return ptr;
- }
- ret = gnutls_secure_malloc(size);
- if (ret == NULL)
- return ret;
-
- if (ptr != NULL) {
- memcpy(ret, ptr, GMIN(_gnutls_secure_ptr_size(ptr), size));
- gnutls_secure_free(ptr);
- }
-
- return ret;
-}
-
-void gnutls_secure_free(svoid * ptr)
-{
-opaque* _ptr = ptr;
-
- memset(ptr, 0, _gnutls_secure_ptr_size(ptr));
- *((opaque *) _ptr - 1) = 0; /* not secure mem */
-
- _gnutls_free(ptr);
-}
-
char *gnutls_strdup(const char *s)
{
int size = strlen(s);
return ret;
}
-#endif /* USE_LIBCALLOC */
# include <dmalloc.h>
#endif
-typedef void svoid; /* for functions that allocate using gnutls_secure_free */
+typedef void svoid; /* for functions that allocate using gnutls_secure_malloc */
/* Use gnutls_afree() when calling alloca, or
* memory leaks may occur in systems which do not
# define gnutls_afree gnutls_free
#endif /* HAVE_ALLOCA */
-#ifdef USE_LIBCALLOC
-# define gnutls_malloc malloc
-# define gnutls_realloc realloc
-# define gnutls_realloc_fast(x, y) (y==0?x:realloc(x, y))
-# define gnutls_free free
-# define gnutls_calloc calloc
-# define gnutls_secure_malloc malloc
-# define gnutls_secure_realloc realloc
-# define gnutls_secure_free free
-# define gnutls_secure_calloc calloc
-# define gnutls_strdup strdup
-int _gnutls_is_secure_memory(const void*);
+void* (*gnutls_secure_malloc)(size_t);
+void* (*gnutls_malloc)(size_t);
+void (*gnutls_free)(void*);
+int (*_gnutls_is_secure_memory)(const void*);
+void* (*gnutls_realloc)(void*, size_t);
-#else
-
-svoid* gnutls_secure_malloc( size_t size);
svoid* gnutls_secure_calloc( size_t nmemb, size_t size);
-size_t _gnutls_secure_ptr_size( svoid* ptr);
-svoid* gnutls_secure_realloc( svoid* ptr, size_t size);
-void gnutls_secure_free( svoid* ptr);
-int _gnutls_is_secure_memory(const svoid* mem);
-
-void* gnutls_malloc( size_t size);
void* gnutls_calloc( size_t nmemb, size_t size);
-size_t _gnutls_malloc_ptr_size( void* ptr);
-void* gnutls_realloc( void* ptr, size_t size);
-void* gnutls_realloc_fast( void* ptr, size_t size);
-void gnutls_free( void* ptr);
-char* gnutls_strdup( const char* s);
-#endif
+char* gnutls_strdup( const char* s);
#endif /* GNUTLS_MEM_H */
int params_len,
int btype)
{
- int k, psize, i, ret, pad;
+ int i, ret, pad;
GNUTLS_MPI m, res;
opaque *edata, *ps;
-
+ size_t k, psize;
k = _gnutls_mpi_get_nbits(params[0]) / 8;
gnutls_datum ciphertext, GNUTLS_MPI* params, int params_len,
int btype)
{
- int k, esize, i, ret;
+ int k, i, ret;
GNUTLS_MPI c, res;
opaque *edata;
+ size_t esize;
k = _gnutls_mpi_get_nbits(params[0]) / 8;
esize = ciphertext.size;
node_asn* sig;
int result;
opaque str[MAX_PARAMETER_SIZE];
-int len = sizeof(str);
-int tot_len = 0;
+size_t len = sizeof(str);
+size_t tot_len = 0;
if ((result=asn1_create_structure( _gnutls_get_gnutls_asn(), "GNUTLS.DSASignatureValue",
&sig, "sig"))!=ASN_OK) {
GNUTLS_MPI * params, int params_len)
{
GNUTLS_MPI rs[2], mdata;
- int k, ret;
+ int ret;
+ size_t k;
k = hash->size;
if (k!=20) { /* SHA only */
{
opaque ttime[MAX_TIME];
char name[1024];
- time_t ctime;
+ time_t ctime = (time_t)-1;
int len, result;
_gnutls_str_cpy(name, sizeof(name), root);
gnutls_datum tmp;
int ret, count;
+ ptr = input_cert;
+ siz = input_cert_size;
+
if (strstr( input_cert, "-----BEGIN PKCS7")!=NULL) {
siz2 = _gnutls_fbase64_decode(ptr, siz, &b64);
return ret;
}
-
- ptr = input_cert;
- siz = input_cert_size;
i = *ncerts + 1;
count = 0;
gnutls_assert();
return -1;
}
- data_size -= (int)rdata-(int)data;
+ data_size -= (unsigned long int)rdata-(unsigned long int)data;
if (data_size < 4 + strlen(bottom)) {
gnutls_assert();
return -1;
}
data_size -= strlen(ENDSTR);
- data_size -= (int)kdata-(int)rdata;
+ data_size -= (unsigned long int)kdata-(unsigned long int)rdata;
rdata = kdata + strlen(ENDSTR);
}
/* position of kdata is before the ----END--- footer
*/
- rdata_size = (int)kdata-(int)rdata;
+ rdata_size = (unsigned long int)kdata-(unsigned long int)rdata;
if (rdata_size < 4) {
gnutls_assert();
const uint8 *data_g;
const uint8 *data_s;
uint8 pwd_algo;
- int i, ret;
+ int i, xx, ret;
opaque hd[SRP_MAX_HASH_SIZE];
char *username;
char *password;
/* generate x = SHA(s | SHA(U | ":" | p))
* (or the equivalent using bcrypt)
*/
- if ( ( ret =_gnutls_calc_srp_x( username, password, (opaque*)data_s, n_s, pwd_algo, &_n_g, hd)) < 0) {
+ if ( ( ret =_gnutls_calc_srp_x( username, password, (opaque*)data_s, n_s, pwd_algo, &xx, hd)) < 0) {
gnutls_assert();
return ret;
}
+ _n_g = xx;
if (_gnutls_mpi_scan(&state->gnutls_key->x, hd, &_n_g) != 0 || state->gnutls_key->x==NULL) {
gnutls_assert();
opaque *verifier;
int verifier_size;
int indx;
+size_t xx;
p = rindex( str, ':'); /* we have index */
if (p==NULL) {
return GNUTLS_E_PARSING_ERROR;
}
- if (_gnutls_mpi_scan(&entry->v, verifier, &verifier_size) || entry->v == NULL) {
+ if (_gnutls_mpi_scan(&entry->v, verifier, &xx)) {
gnutls_assert();
gnutls_free( entry->salt);
return GNUTLS_E_MPI_SCAN_FAILED;
}
+ verifier_size = xx;
gnutls_free( verifier);
char * p;
int len;
opaque * tmp;
-int tmp_size;
+int ret;
+size_t tmp_size;
p = rindex( str, ':'); /* we have g */
if (p==NULL) {
/* read the generator */
len = strlen(p);
if (p[len-1]=='\n' || p[len-1]==' ') len--;
- tmp_size = _gnutls_sbase64_decode( p, len, &tmp);
+ ret = _gnutls_sbase64_decode( p, len, &tmp);
- if (tmp_size < 0) {
+ if (ret < 0) {
gnutls_assert();
return GNUTLS_E_PARSING_ERROR;
}
- if (_gnutls_mpi_scan(&entry->g, tmp, &tmp_size) || entry->g==NULL) {
+
+ tmp_size = ret;
+ if (_gnutls_mpi_scan(&entry->g, tmp, &tmp_size)) {
gnutls_assert();
gnutls_free(tmp);
return GNUTLS_E_MPI_SCAN_FAILED;
p++;
len = strlen(p);
- tmp_size = _gnutls_sbase64_decode( p, len, &tmp);
+ ret = _gnutls_sbase64_decode( p, len, &tmp);
- if (tmp_size < 0) {
+ if (ret < 0) {
gnutls_assert();
_gnutls_mpi_release(&entry->g);
return GNUTLS_E_PARSING_ERROR;
}
- if (_gnutls_mpi_scan(&entry->n, tmp, &tmp_size) || entry->n==NULL) {
+ tmp_size = ret;
+ if (_gnutls_mpi_scan(&entry->n, tmp, &tmp_size)) {
gnutls_assert();
gnutls_free(tmp);
_gnutls_mpi_release(&entry->g);
{
GNUTLS_MPI prime, g;
- int siz;
+ size_t siz;
char *tmp;
if ( _gnutls_dh_generate_prime(&g, &prime, bits) < 0) {
char *crypt_bcrypt(const char* username, const char *passwd, const char *salt, GNUTLS_MPI g, GNUTLS_MPI n)
{
- unsigned char *sp;
+ unsigned char *sp, *spe;
blf_ctx *ctx;
unsigned char text[24];
uint8 *csalt;
uint8 *rtext;
uint8 cost;
- int i, salt_size = strlen(salt), len;
+ int i, salt_size = strlen(salt);
+ size_t len;
unsigned char *local_salt, *v;
int passwd_len, vsize, tmpsize;
opaque *tmp;
}
sp++;
- len = (int)rindex(sp, ':');
- if (len==0) { /* no ':' was found */
+ spe = rindex(sp, ':');
+ if (spe == NULL) { /* no ':' was found */
len = strlen(sp);
- } else
- len -= (int) sp;
+ } else
+ len = (unsigned long int)spe - (unsigned long int)sp;
if (_gnutls_sbase64_decode(sp, len, &csalt) < 0) {
gnutls_assert();
char *crypt_srpsha1(const char *username, const char *passwd,
const char *salt, GNUTLS_MPI g, GNUTLS_MPI n)
{
- unsigned char *sp, r1[MAX_HASH_SIZE];
+ unsigned char *sp, *spe, r1[MAX_HASH_SIZE];
int salt_size = strlen(salt);
unsigned char *local_salt, *v;
int passwd_len;
int vsize, hash_len = _gnutls_hash_get_algo_len(GNUTLS_MAC_SHA);
opaque *tmp;
uint8 *rtext, *csalt;
- int rsalt_size, len, tmpsize;
+ int rsalt_size, tmpsize;
+ size_t len;
passwd_len = strlen(passwd); /* we do not want the null */
}
sp++;
- len = (int)rindex(sp, ':');
- if (len==0) { /* parse error */
+ spe = rindex(sp, ':');
+ if (spe==NULL) { /* parse error */
len = strlen(sp);
} else
- len -= (int)sp;
+ len = (unsigned long int)spe - (unsigned long int)sp;
rsalt_size = _gnutls_sbase64_decode(sp, len, &csalt);
if (rsalt_size < 0) {
int type;
int armored;
size_t size;
- byte *data;
+ uint8 *data;
} keybox_blob;
typedef enum {
}
static u32
-buffer_to_u32( const byte *buffer )
+buffer_to_u32( const uint8 *buffer )
{
- const byte *p = buffer;
+ const uint8 *p = buffer;
if ( !p )
return 0;
kbx_data_to_keyring( int type, int enc, const char *data,
size_t size, size_t *r_size )
{
- byte *p = NULL;
+ uint8 *p = NULL;
if ( !data )
return NULL;
gnutls_openpgp_add_keyring_file(gnutls_datum *keyring, const char *name)
{
CDK_IOBUF inp = NULL;
- byte *blob;
+ uint8 *blob;
size_t nbytes;
int enc = 0;
int rc = 0;
gnutls_openpgp_add_keyring_mem(gnutls_datum *keyring,
const char *data, size_t len)
{
- byte *blob;
+ uint8 *blob;
size_t nbytes = 0;
if (!keyring || !data || !len)
int _gnutls_srp_gx(opaque * text, int textsize, opaque ** result, GNUTLS_MPI g,
GNUTLS_MPI prime)
{
-
GNUTLS_MPI x, e;
- int result_size;
+ size_t result_size;
- if (_gnutls_mpi_scan(&x, text, &textsize)) {
+ if (_gnutls_mpi_scan(&x, text, &result_size)) {
gnutls_assert();
return GNUTLS_E_MPI_SCAN_FAILED;
}
+ textsize = result_size;
e = _gnutls_mpi_alloc_like(prime);
if (e==NULL) {
GNUTLS_MPI _gnutls_calc_srp_u(GNUTLS_MPI B)
{
- int b_size;
+ size_t b_size;
opaque *b_holder, hd[MAX_HASH_SIZE];
GNUTLS_HASH_HANDLE td;
uint32 u;
int cert_list_size = 0;
char digest[20];
char serial[40];
- int digest_size = sizeof(digest), i;
+ size_t digest_size = sizeof(digest);
+ int i;
int serial_size = sizeof(serial);
char printable[120];
char *print;