summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2002-01-02 15:55:58 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2002-01-02 15:55:58 +0000
commit9316fec4f5573e446d69579dc4faf6c741ddbc6f (patch)
tree9abfe0e4c95823e94751f31c126de1af529d8259
parent39e5de8077dd56137ff4388b3c0f8075981f9e56 (diff)
downloadgnutls-9316fec4f5573e446d69579dc4faf6c741ddbc6f.tar.gz
cleanups
-rw-r--r--lib/crypt_srpsha1.c4
-rw-r--r--lib/gnutls.h.in.in2
-rw-r--r--lib/gnutls_auth.c2
-rw-r--r--lib/gnutls_global.c2
-rw-r--r--lib/gnutls_handshake.c4
-rw-r--r--lib/gnutls_hash_int.c28
-rw-r--r--lib/gnutls_int.h7
-rw-r--r--lib/gnutls_sig.c8
-rw-r--r--lib/gnutls_srp.c6
-rw-r--r--lib/gnutls_ui.c1
-rw-r--r--lib/x509_sig_check.c14
11 files changed, 39 insertions, 39 deletions
diff --git a/lib/crypt_srpsha1.c b/lib/crypt_srpsha1.c
index f32319187e..a0ddc5f1fb 100644
--- a/lib/crypt_srpsha1.c
+++ b/lib/crypt_srpsha1.c
@@ -44,7 +44,7 @@ char *crypt_srpsha1(const char *username, const char *passwd,
passwd_len = strlen(passwd); /* we do not want the null */
- h1 = gnutls_hash_init(GNUTLS_DIG_SHA);
+ h1 = gnutls_hash_init(GNUTLS_MAC_SHA);
gnutls_hash(h1, (char *) username, strlen(username));
gnutls_hash(h1, ":", 1);
gnutls_hash(h1, (char *) passwd, passwd_len);
@@ -73,7 +73,7 @@ char *crypt_srpsha1(const char *username, const char *passwd,
return NULL;
}
- h1 = gnutls_hash_init(GNUTLS_DIG_SHA);
+ h1 = gnutls_hash_init(GNUTLS_MAC_SHA);
gnutls_hash(h1, csalt, rsalt_size);
gnutls_free(csalt);
diff --git a/lib/gnutls.h.in.in b/lib/gnutls.h.in.in
index 1dafb8b0d9..15094f620f 100644
--- a/lib/gnutls.h.in.in
+++ b/lib/gnutls.h.in.in
@@ -38,7 +38,7 @@ typedef enum GNUTLS_CredType { GNUTLS_X509PKI=1, GNUTLS_ANON, GNUTLS_SRP } GNUTL
#define CredType GNUTLS_CredType
typedef enum GNUTLS_MACAlgorithm { GNUTLS_MAC_NULL=1, GNUTLS_MAC_MD5, GNUTLS_MAC_SHA } GNUTLS_MACAlgorithm;
-typedef enum GNUTLS_DigestAlgorithm { GNUTLS_DIG_MD5=1, GNUTLS_DIG_SHA } GNUTLS_DigestAlgorithm;
+typedef enum GNUTLS_DigestAlgorithm { GNUTLS_DIG_NULL=1, GNUTLS_DIG_MD5, GNUTLS_DIG_SHA } GNUTLS_DigestAlgorithm;
typedef enum GNUTLS_CompressionMethod { GNUTLS_COMP_NULL=1, GNUTLS_COMP_ZLIB } GNUTLS_CompressionMethod;
typedef enum GNUTLS_ConnectionEnd { GNUTLS_SERVER=1, GNUTLS_CLIENT } GNUTLS_ConnectionEnd;
typedef enum GNUTLS_AlertLevel { GNUTLS_AL_WARNING=1, GNUTLS_AL_FATAL } GNUTLS_AlertLevel;
diff --git a/lib/gnutls_auth.c b/lib/gnutls_auth.c
index f2004dc0fa..e2be2b9b4e 100644
--- a/lib/gnutls_auth.c
+++ b/lib/gnutls_auth.c
@@ -211,7 +211,7 @@ void _gnutls_free_auth_info( GNUTLS_STATE state) {
if (info==NULL) break;
for (i=0;i<info->ncerts;i++) {
- gnutls_free( info->raw_certificate_list[0].data);
+ gnutls_free_datum( &info->raw_certificate_list[i]);
}
gnutls_free( info->raw_certificate_list);
diff --git a/lib/gnutls_global.c b/lib/gnutls_global.c
index 5eb9f865c2..2037bf7dde 100644
--- a/lib/gnutls_global.c
+++ b/lib/gnutls_global.c
@@ -132,7 +132,7 @@ int gnutls_global_init( void)
void gnutls_global_deinit( void) {
_gnutls_init--;
-
+
if (_gnutls_init==0) {
asn1_delete_structure( PKCS1_ASN);
asn1_delete_structure( PKIX1_ASN);
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c
index 267c5092ee..627ce1d27a 100644
--- a/lib/gnutls_handshake.c
+++ b/lib/gnutls_handshake.c
@@ -184,13 +184,13 @@ int _gnutls_finished(GNUTLS_STATE state, int type, int skip, void *ret)
opaque concat[36];
opaque *mesg, *data;
- td = gnutls_hash_init(GNUTLS_DIG_MD5);
+ td = gnutls_hash_init(GNUTLS_MAC_MD5);
if (td == GNUTLS_HASH_FAILED) {
gnutls_assert();
return GNUTLS_E_HASH_FAILED;
}
- td2 = gnutls_hash_init(GNUTLS_DIG_SHA);
+ td2 = gnutls_hash_init(GNUTLS_MAC_SHA);
if (td2 == GNUTLS_HASH_FAILED) {
gnutls_assert();
gnutls_hash_deinit(td2, tmp);
diff --git a/lib/gnutls_hash_int.c b/lib/gnutls_hash_int.c
index 8e06869196..86fc32d13a 100644
--- a/lib/gnutls_hash_int.c
+++ b/lib/gnutls_hash_int.c
@@ -27,12 +27,12 @@
* the gcrypt library that this can be easily changed.
*/
-GNUTLS_HASH_HANDLE gnutls_hash_init(DigestAlgorithm algorithm)
+GNUTLS_HASH_HANDLE gnutls_hash_init(MACAlgorithm algorithm)
{
GNUTLS_MAC_HANDLE ret;
switch (algorithm) {
- case GNUTLS_DIG_SHA:
+ case GNUTLS_MAC_SHA:
ret = gnutls_malloc(sizeof(GNUTLS_MAC_HANDLE_INT));
if (ret==NULL) return GNUTLS_HASH_FAILED;
#ifdef USE_MHASH
@@ -46,7 +46,7 @@ GNUTLS_HASH_HANDLE gnutls_hash_init(DigestAlgorithm algorithm)
}
break;
- case GNUTLS_DIG_MD5:
+ case GNUTLS_MAC_MD5:
ret = gnutls_malloc(sizeof(GNUTLS_MAC_HANDLE_INT));
if (ret==NULL) return GNUTLS_HASH_FAILED;
#ifdef USE_MHASH
@@ -69,19 +69,19 @@ GNUTLS_HASH_HANDLE gnutls_hash_init(DigestAlgorithm algorithm)
return ret;
}
-int gnutls_hash_get_algo_len(DigestAlgorithm algorithm)
+int gnutls_hash_get_algo_len(MACAlgorithm algorithm)
{
int ret;
switch (algorithm) {
- case GNUTLS_DIG_SHA:
+ case GNUTLS_MAC_SHA:
#ifdef USE_MHASH
ret = mhash_get_block_size(MHASH_SHA1);
#else
ret = gcry_md_get_algo_dlen(GCRY_MD_SHA1);
#endif
break;
- case GNUTLS_DIG_MD5:
+ case GNUTLS_MAC_MD5:
#ifdef USE_MHASH
ret = mhash_get_block_size(MHASH_MD5);
#else
@@ -263,8 +263,8 @@ GNUTLS_MAC_HANDLE gnutls_mac_init_ssl3(MACAlgorithm algorithm, void *key,
if (padsize>0) {
memset(ipad, 0x36, padsize);
}
- ret = gnutls_hash_init(algorithm);
- if (ret!=GNUTLS_MAC_FAILED) {
+ ret = gnutls_hash_init( algorithm);
+ if (ret!=GNUTLS_HASH_FAILED) {
ret->key = key;
ret->keysize = keylen;
@@ -280,8 +280,8 @@ GNUTLS_MAC_HANDLE gnutls_mac_init_ssl3_handshake(MACAlgorithm algorithm, void *k
{
GNUTLS_MAC_HANDLE ret;
- ret = gnutls_hash_init(algorithm);
- if (ret!=GNUTLS_MAC_FAILED) {
+ ret = gnutls_hash_init( algorithm);
+ if (ret!=GNUTLS_HASH_FAILED) {
ret->key = key;
ret->keysize = keylen;
}
@@ -311,7 +311,7 @@ void gnutls_mac_deinit_ssl3(GNUTLS_MAC_HANDLE handle, void* digest)
memset(opad, 0x5C, padsize);
}
- td = gnutls_hash_init(handle->algorithm);
+ td = gnutls_hash_init( handle->algorithm);
if (td!=GNUTLS_MAC_FAILED) {
if (handle->keysize > 0) gnutls_hash(td, handle->key, handle->keysize);
@@ -349,8 +349,8 @@ void gnutls_mac_deinit_ssl3_handshake(GNUTLS_MAC_HANDLE handle, void* digest)
memset(ipad, 0x36, padsize);
}
- td = gnutls_hash_init(handle->algorithm);
- if (td!=GNUTLS_MAC_FAILED) {
+ td = gnutls_hash_init( handle->algorithm);
+ if (td!=GNUTLS_HASH_FAILED) {
if (handle->keysize > 0) gnutls_hash(td, handle->key, handle->keysize);
gnutls_hash(td, opad, padsize);
@@ -373,7 +373,7 @@ static int ssl3_sha(int i, char *secret, int secret_len, char *random,
int j;
char text1[26];
- GNUTLS_MAC_HANDLE td;
+ GNUTLS_HASH_HANDLE td;
for (j = 0; j < i + 1; j++) {
text1[j] = 65 + i; /* A==65 */
diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h
index 131a381ff0..00fba1dc2a 100644
--- a/lib/gnutls_int.h
+++ b/lib/gnutls_int.h
@@ -30,10 +30,10 @@
#define HARD_DEBUG
#define WRITE_DEBUG
#define READ_DEBUG
+#define RECORD_DEBUG*/
#define HANDSHAKE_DEBUG // Prints some information on handshake
-#define RECORD_DEBUG
#define DEBUG
-*/
+
/* It might be a good idea to replace int with void*
* here.
@@ -147,9 +147,8 @@ typedef enum Extensions { GNUTLS_EXTENSION_DNSNAME=0, GNUTLS_EXTENSION_MAX_RECOR
typedef enum KXAlgorithm { GNUTLS_KX_X509PKI_RSA=1, GNUTLS_KX_X509PKI_DHE_DSS, GNUTLS_KX_X509PKI_DHE_RSA, GNUTLS_KX_ANON_DH, GNUTLS_KX_SRP } KXAlgorithm;
typedef enum CredType { GNUTLS_X509PKI=1, GNUTLS_ANON, GNUTLS_SRP } CredType;
typedef enum CipherType { CIPHER_STREAM, CIPHER_BLOCK } CipherType;
-typedef enum MACAlgorithm { GNUTLS_MAC_NULL=1, GNUTLS_MAC_MD5, GNUTLS_MAC_SHA } MACAlgorithm;
-typedef enum DigestAlgorithm { GNUTLS_DIG_MD5=1, GNUTLS_DIG_SHA } DigestAlgorithm;
typedef enum CompressionMethod { GNUTLS_COMP_NULL=1, GNUTLS_COMP_ZLIB } CompressionMethod;
+typedef enum MACAlgorithm { GNUTLS_MAC_NULL=1, GNUTLS_MAC_MD5, GNUTLS_MAC_SHA } MACAlgorithm;
typedef enum ValidSession { VALID_TRUE, VALID_FALSE } ValidSession;
typedef enum ResumableSession { RESUME_TRUE, RESUME_FALSE } ResumableSession;
diff --git a/lib/gnutls_sig.c b/lib/gnutls_sig.c
index 6c0dec4350..51830ae4e7 100644
--- a/lib/gnutls_sig.c
+++ b/lib/gnutls_sig.c
@@ -121,7 +121,7 @@ GNUTLS_HASH_HANDLE td;
switch(pkey->pk_algorithm) {
case GNUTLS_PK_RSA:
- td = gnutls_hash_init( GNUTLS_DIG_MD5);
+ td = gnutls_hash_init( GNUTLS_MAC_MD5);
if (td==NULL) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
@@ -129,7 +129,7 @@ GNUTLS_HASH_HANDLE td;
gnutls_hash( td, data->data, data->size);
gnutls_hash_deinit( td, digest);
- td = gnutls_hash_init( GNUTLS_DIG_SHA);
+ td = gnutls_hash_init( GNUTLS_MAC_SHA);
if (td==NULL) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
@@ -183,7 +183,7 @@ int _gnutls_pkcs1_rsa_verify_sig( gnutls_cert *cert, const gnutls_datum *data, g
switch(cert->subject_pk_algorithm) {
case GNUTLS_PK_RSA:
- td = gnutls_hash_init( GNUTLS_DIG_MD5);
+ td = gnutls_hash_init( GNUTLS_MAC_MD5);
if (td==NULL) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
@@ -191,7 +191,7 @@ int _gnutls_pkcs1_rsa_verify_sig( gnutls_cert *cert, const gnutls_datum *data, g
gnutls_hash( td, data->data, data->size);
gnutls_hash_deinit( td, digest);
- td = gnutls_hash_init( GNUTLS_DIG_SHA);
+ td = gnutls_hash_init( GNUTLS_MAC_SHA);
if (td==NULL) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
diff --git a/lib/gnutls_srp.c b/lib/gnutls_srp.c
index f8e5c0a426..78de212de8 100644
--- a/lib/gnutls_srp.c
+++ b/lib/gnutls_srp.c
@@ -133,7 +133,7 @@ MPI _gnutls_calc_srp_u(MPI B)
_gnutls_mpi_print( b_holder, &b_size, B);
- td = gnutls_hash_init(GNUTLS_DIG_SHA);
+ td = gnutls_hash_init(GNUTLS_MAC_SHA);
if (td==NULL) {
gnutls_free(b_holder);
gnutls_assert();
@@ -231,7 +231,7 @@ int _gnutls_calc_srp_sha(char *username, char *password, opaque * salt,
*size = 20;
- td = gnutls_hash_init(GNUTLS_DIG_SHA);
+ td = gnutls_hash_init(GNUTLS_MAC_SHA);
if (td==NULL) {
return GNUTLS_E_MEMORY_ERROR;
}
@@ -241,7 +241,7 @@ int _gnutls_calc_srp_sha(char *username, char *password, opaque * salt,
gnutls_hash_deinit(td, res);
- td = gnutls_hash_init(GNUTLS_DIG_SHA);
+ td = gnutls_hash_init(GNUTLS_MAC_SHA);
if (td==NULL) {
return GNUTLS_E_MEMORY_ERROR;
}
diff --git a/lib/gnutls_ui.c b/lib/gnutls_ui.c
index 3a7bc7ce68..222d957ef6 100644
--- a/lib/gnutls_ui.c
+++ b/lib/gnutls_ui.c
@@ -171,6 +171,7 @@ int gnutls_x509pki_get_certificate_request_status(GNUTLS_STATE state)
}
+typedef MACAlgorithm DigestAlgorithm;
/**
* gnutls_fingerprint - This function calculates the fingerprint of the given data
* @algo: is a digest algorithm
diff --git a/lib/x509_sig_check.c b/lib/x509_sig_check.c
index 39c28a0e9a..d7620724e3 100644
--- a/lib/x509_sig_check.c
+++ b/lib/x509_sig_check.c
@@ -74,7 +74,7 @@ int start, end;
/* we use DER here -- FIXME: use BER
*/
-static int _gnutls_get_ber_digest_info( const gnutls_datum *info, DigestAlgorithm *hash, opaque* digest, int *digest_size) {
+static int _gnutls_get_ber_digest_info( const gnutls_datum *info, MACAlgorithm *hash, opaque* digest, int *digest_size) {
node_asn* dinfo;
int result;
opaque str[1024];
@@ -104,10 +104,10 @@ int len;
*hash = -1;
if ( strcmp(str, "1 2 840 113549 2 5")==0) { /* MD5 */
- *hash = GNUTLS_DIG_MD5;
+ *hash = GNUTLS_MAC_MD5;
} else
if ( strcmp(str, "1 3 14 3 2 26")==0) { /* SHA1 ID */
- *hash = GNUTLS_DIG_SHA;
+ *hash = GNUTLS_MAC_SHA;
}
if (*hash==-1) {
@@ -139,7 +139,7 @@ int len;
int
_pkcs1_rsa_verify_sig( gnutls_datum* signature, gnutls_datum* text, MPI e, MPI m)
{
- DigestAlgorithm hash;
+ MACAlgorithm hash;
int ret;
opaque digest[MAX_HASH_SIZE], md[MAX_HASH_SIZE];
int digest_size;
@@ -265,7 +265,7 @@ int result;
return 0;
}
-int _pkcs1_rsa_generate_sig( DigestAlgorithm hash_algo, gnutls_private_key *pkey, const gnutls_datum *data, gnutls_datum *signature) {
+int _pkcs1_rsa_generate_sig( MACAlgorithm hash_algo, gnutls_private_key *pkey, const gnutls_datum *data, gnutls_datum *signature) {
int ret;
GNUTLS_HASH_HANDLE hd;
opaque digest[MAX_HASH_SIZE];
@@ -273,9 +273,9 @@ int _pkcs1_rsa_generate_sig( DigestAlgorithm hash_algo, gnutls_private_key *pkey
int digest_size = gnutls_hash_get_algo_len( hash_algo);
gnutls_datum der;
- if (hash_algo==GNUTLS_DIG_MD5)
+ if (hash_algo==GNUTLS_MAC_MD5)
strcpy(OID, "1 2 840 113549 2 5");
- else if (hash_algo==GNUTLS_DIG_SHA)
+ else if (hash_algo==GNUTLS_MAC_SHA)
strcpy(OID, "1 3 14 3 2 26");
else {
gnutls_assert();