summaryrefslogtreecommitdiff
path: root/libextra
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2002-05-22 19:29:37 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2002-05-22 19:29:37 +0000
commita5c46d2bda51cec16ede2fa50a82c6fac0c0d0be (patch)
tree78029cd3f3a3eb324a1b7429660cb2bdfa76381d /libextra
parent2e6a260117b619d308a723fb4a9d652cea267e3b (diff)
downloadgnutls-a5c46d2bda51cec16ede2fa50a82c6fac0c0d0be.tar.gz
Applied Jeff Johnson's patch which fixes type problems in 64 bit machines. Removed the default allocation handlers, and made the libc's functions to be defaults. Added function which sets the memory allocation functions to be used.
Diffstat (limited to 'libextra')
-rw-r--r--libextra/auth_srp.c5
-rw-r--r--libextra/auth_srp_passwd.c24
-rw-r--r--libextra/crypt_bcrypt.c13
-rw-r--r--libextra/crypt_srpsha1.c11
-rw-r--r--libextra/gnutls_openpgp.c12
-rw-r--r--libextra/gnutls_srp.c8
6 files changed, 41 insertions, 32 deletions
diff --git a/libextra/auth_srp.c b/libextra/auth_srp.c
index 89b7b36fcb..1dbb3649f9 100644
--- a/libextra/auth_srp.c
+++ b/libextra/auth_srp.c
@@ -300,7 +300,7 @@ int proc_srp_server_hello(GNUTLS_STATE state, const opaque * data, int data_size
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;
@@ -370,10 +370,11 @@ int proc_srp_server_hello(GNUTLS_STATE state, const opaque * data, int data_size
/* 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();
diff --git a/libextra/auth_srp_passwd.c b/libextra/auth_srp_passwd.c
index 83b961b135..078719468a 100644
--- a/libextra/auth_srp_passwd.c
+++ b/libextra/auth_srp_passwd.c
@@ -44,6 +44,7 @@ int len;
opaque *verifier;
int verifier_size;
int indx;
+size_t xx;
p = rindex( str, ':'); /* we have index */
if (p==NULL) {
@@ -112,11 +113,12 @@ int indx;
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);
@@ -141,7 +143,8 @@ static int pwd_put_values2( GNUTLS_SRP_PWD_ENTRY *entry, char *str, int str_size
char * p;
int len;
opaque * tmp;
-int tmp_size;
+int ret;
+size_t tmp_size;
p = rindex( str, ':'); /* we have g */
if (p==NULL) {
@@ -155,13 +158,15 @@ int tmp_size;
/* 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;
@@ -182,14 +187,15 @@ int tmp_size;
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);
@@ -385,7 +391,7 @@ int _gnutls_srp_generate_prime(opaque ** ret_g, opaque ** ret_n, int bits)
{
GNUTLS_MPI prime, g;
- int siz;
+ size_t siz;
char *tmp;
if ( _gnutls_dh_generate_prime(&g, &prime, bits) < 0) {
diff --git a/libextra/crypt_bcrypt.c b/libextra/crypt_bcrypt.c
index e01bbca978..73cf342b01 100644
--- a/libextra/crypt_bcrypt.c
+++ b/libextra/crypt_bcrypt.c
@@ -602,13 +602,14 @@ static const char magic[] = "$2$";
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;
@@ -636,11 +637,11 @@ char *crypt_bcrypt(const char* username, const char *passwd, const char *salt, G
}
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();
diff --git a/libextra/crypt_srpsha1.c b/libextra/crypt_srpsha1.c
index aa7c64e6d1..cfeda1ca57 100644
--- a/libextra/crypt_srpsha1.c
+++ b/libextra/crypt_srpsha1.c
@@ -35,7 +35,7 @@ static const char magic[] = "";
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;
@@ -43,7 +43,8 @@ char *crypt_srpsha1(const char *username, const char *passwd,
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 */
@@ -69,11 +70,11 @@ char *crypt_srpsha1(const char *username, const char *passwd,
}
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) {
diff --git a/libextra/gnutls_openpgp.c b/libextra/gnutls_openpgp.c
index 88f56238e1..cbb8311ba2 100644
--- a/libextra/gnutls_openpgp.c
+++ b/libextra/gnutls_openpgp.c
@@ -46,7 +46,7 @@ typedef struct {
int type;
int armored;
size_t size;
- byte *data;
+ uint8 *data;
} keybox_blob;
typedef enum {
@@ -67,9 +67,9 @@ release_mpi_array( GNUTLS_MPI *arr, size_t n )
}
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;
@@ -193,7 +193,7 @@ static byte*
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;
@@ -1216,7 +1216,7 @@ int
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;
@@ -1256,7 +1256,7 @@ int
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)
diff --git a/libextra/gnutls_srp.c b/libextra/gnutls_srp.c
index 850726f474..6e638018d1 100644
--- a/libextra/gnutls_srp.c
+++ b/libextra/gnutls_srp.c
@@ -39,14 +39,14 @@
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) {
@@ -124,7 +124,7 @@ GNUTLS_MPI _gnutls_calc_srp_B(GNUTLS_MPI * ret_b, GNUTLS_MPI g, GNUTLS_MPI n, GN
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;