summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2003-03-23 17:03:40 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2003-03-23 17:03:40 +0000
commit6b85104f36a1d1a0af18a0627cce13ff48516d2f (patch)
tree62c1d60ca3a8dca99beac7dbf14199b404843687
parent1eff1dd92bb79997fb81a8dc53da7c73c4308e98 (diff)
downloadgnutls-6b85104f36a1d1a0af18a0627cce13ff48516d2f.tar.gz
Some cleanups.
-rw-r--r--lib/x509/common.c91
-rw-r--r--lib/x509/common.h1
-rw-r--r--lib/x509/privkey_pkcs8.c6
-rw-r--r--lib/x509/xml.c5
4 files changed, 46 insertions, 57 deletions
diff --git a/lib/x509/common.c b/lib/x509/common.c
index b76fc49996..15191beb7a 100644
--- a/lib/x509/common.c
+++ b/lib/x509/common.c
@@ -30,47 +30,46 @@
#include <common.h>
typedef struct _oid2string {
- const char * OID;
- const char * DESC;
+ const char * oid;
const char * ldap_desc;
int choice;
int printable;
} oid2string;
-static const oid2string OID2STR[] = {
- {"2.5.4.6", "X520countryName", "C", 0, 1},
- {"2.5.4.12", "X520title", "T", 1, 1},
- {"2.5.4.10", "X520OrganizationName", "O", 1, 1},
- {"2.5.4.11", "X520OrganizationalUnitName", "OU", 1, 1},
- {"2.5.4.3", "X520CommonName", "CN", 1, 1},
- {"2.5.4.7", "X520LocalityName", "L", 1, 1},
- {"2.5.4.8", "X520StateOrProvinceName", "ST", 1, 1},
- {"2.5.4.5", "X520serialNumber", "serialNumber", 0, 1},
- {"2.5.4.20", "X520telephoneNumber", "telephoneNumber", 0, 1},
-
- {"0.9.2342.19200300.100.1.25", "dc", "DC", 0, 1}, /* FIXME: CHOICE? */
- {"0.9.2342.19200300.100.1.1", "uid", "UID", 0, 1}, /* FIXME: CHOICE? */
- {"1.2.840.113549.1.9.1", "Pkcs9email", "EMAIL", 0, 1},
- {"1.2.840.113549.1.9.7", "Pkcs9challengePassword", NULL, 1, 1},
- {PKIX1_RSA_OID, "rsaEncryption", NULL, 0, 0},
-
- {RSA_MD5_OID, "md5WithRSAEncryption", NULL, 0, 0},
- {RSA_SHA1_OID, "sha1WithRSAEncryption", NULL, 0, 0},
- {DSA_SHA1_OID, "id-dsa-with-sha1", NULL, 0, 0},
- {DSA_OID, "id-dsa", NULL, 0, 0},
- {NULL, NULL, NULL, 0, 0}
+static const oid2string _oid2str[] = {
+ {"2.5.4.6", "C", 0, 1},
+ {"2.5.4.12", "T", 1, 1},
+ {"2.5.4.10", "O", 1, 1},
+ {"2.5.4.11", "OU", 1, 1},
+ {"2.5.4.3", "CN", 1, 1},
+ {"2.5.4.7", "L", 1, 1},
+ {"2.5.4.8", "ST", 1, 1},
+ {"2.5.4.5", "serialNumber", 0, 1},
+ {"2.5.4.20", "telephoneNumber", 0, 1},
+
+ {"0.9.2342.19200300.100.1.25", "DC", 0, 1}, /* FIXME: CHOICE? */
+ {"0.9.2342.19200300.100.1.1", "UID", 0, 1}, /* FIXME: CHOICE? */
+ {"1.2.840.113549.1.9.1", "EMAIL", 0, 1},
+ {"1.2.840.113549.1.9.7", NULL, 1, 1},
+ {PKIX1_RSA_OID, NULL, 0, 0},
+
+ {RSA_MD5_OID, NULL, 0, 0},
+ {RSA_SHA1_OID, NULL, 0, 0},
+ {DSA_SHA1_OID, NULL, 0, 0},
+ {DSA_OID, NULL, 0, 0},
+ {NULL, NULL, 0, 0}
};
/* Returns 1 if the data defined by the OID are printable.
*/
-int _gnutls_x509_oid_data_printable( const char* OID) {
+int _gnutls_x509_oid_data_printable( const char* oid) {
int i = 0;
do {
- if ( strcmp(OID2STR[i].OID, OID)==0)
- return OID2STR[i].printable;
+ if ( strcmp(_oid2str[i].oid, oid)==0)
+ return _oid2str[i].printable;
i++;
- } while( OID2STR[i].OID != NULL);
+ } while( _oid2str[i].oid != NULL);
return 0;
}
@@ -78,38 +77,26 @@ int i = 0;
/* Returns 1 if the data defined by the OID are of a choice
* type.
*/
-int _gnutls_x509_oid_data_choice( const char* OID) {
+int _gnutls_x509_oid_data_choice( const char* oid) {
int i = 0;
do {
- if ( strcmp(OID2STR[i].OID, OID)==0)
- return OID2STR[i].choice;
+ if ( strcmp(_oid2str[i].oid, oid)==0)
+ return _oid2str[i].choice;
i++;
- } while( OID2STR[i].OID != NULL);
+ } while( _oid2str[i].oid != NULL);
return 0;
}
-const char* _gnutls_x509_oid2string( const char* OID) {
+const char* _gnutls_x509_oid2ldap_string( const char* oid) {
int i = 0;
do {
- if ( strcmp(OID2STR[i].OID, OID)==0)
- return OID2STR[i].DESC;
+ if ( strcmp(_oid2str[i].oid, oid)==0)
+ return _oid2str[i].ldap_desc;
i++;
- } while( OID2STR[i].OID != NULL);
-
- return NULL;
-}
-
-const char* _gnutls_x509_oid2ldap_string( const char* OID) {
-int i = 0;
-
- do {
- if ( strcmp(OID2STR[i].OID, OID)==0)
- return OID2STR[i].ldap_desc;
- i++;
- } while( OID2STR[i].OID != NULL);
+ } while( _oid2str[i].oid != NULL);
return NULL;
}
@@ -120,7 +107,7 @@ int i = 0;
* res may be null. This will just return the res_size, needed to
* hold the string.
*/
-int _gnutls_x509_oid_data2string( const char* OID, void* value,
+int _gnutls_x509_oid_data2string( const char* oid, void* value,
int value_size, char * res, int *res_size) {
int result;
@@ -137,13 +124,13 @@ ASN1_TYPE tmpasn = ASN1_TYPE_EMPTY;
res[0] = 0;
- if ( _gnutls_x509_oid_data_printable( OID) == 0) {
+ if ( _gnutls_x509_oid_data_printable( oid) == 0) {
gnutls_assert();
return GNUTLS_E_INTERNAL_ERROR;
}
- ANAME = _gnutls_x509_oid2string( OID);
- CHOICE = _gnutls_x509_oid_data_choice( OID);
+ ANAME = asn1_find_structure_from_oid( _gnutls_get_pkix(), oid);
+ CHOICE = _gnutls_x509_oid_data_choice( oid);
if (ANAME==NULL) {
gnutls_assert();
diff --git a/lib/x509/common.h b/lib/x509/common.h
index 6c484c7bd1..0661c4d153 100644
--- a/lib/x509/common.h
+++ b/lib/x509/common.h
@@ -20,7 +20,6 @@ time_t _gnutls_x509_generalTime2gtime(char *ttime);
int _gnutls_x509_oid_data2string( const char* OID, void* value,
int value_size, char * res, int *res_size);
-const char* _gnutls_x509_oid2string( const char* OID);
const char* _gnutls_x509_oid2ldap_string( const char* OID);
int _gnutls_x509_oid_data_choice( const char* OID);
diff --git a/lib/x509/privkey_pkcs8.c b/lib/x509/privkey_pkcs8.c
index 453c305f1e..a1b3182677 100644
--- a/lib/x509/privkey_pkcs8.c
+++ b/lib/x509/privkey_pkcs8.c
@@ -210,8 +210,8 @@ static int encode_to_private_key_info( gnutls_x509_privkey pkey, gnutls_datum* d
/* Converts a PKCS #8 private key info to
* a PKCS #8 EncryptedPrivateKeyInfo.
*/
-static ASN1_TYPE encode_to_pkcs8_key( gnutls_x509_privkey pkey,
- const gnutls_datum *raw_key, char* password, unsigned int flags)
+static ASN1_TYPE encode_to_pkcs8_key( const gnutls_datum *raw_key,
+ char* password, unsigned int flags)
{
int result;
gnutls_datum key = {NULL, 0};
@@ -319,7 +319,7 @@ gnutls_datum tmp;
}
- pkcs8_asn = encode_to_pkcs8_key( key, &tmp, password, flags);
+ pkcs8_asn = encode_to_pkcs8_key( &tmp, password, flags);
_gnutls_free_datum( &tmp);
if (pkcs8_asn == NULL) {
diff --git a/lib/x509/xml.c b/lib/x509/xml.c
index 0cb2945c39..d29add0b3a 100644
--- a/lib/x509/xml.c
+++ b/lib/x509/xml.c
@@ -41,6 +41,9 @@
#include <x509.h>
#include <common.h>
+const char* asn1_find_structure_from_oid(ASN1_TYPE definitions,
+ const char *oidValue);
+
static int _gnutls_x509_expand_extensions(ASN1_TYPE* rasn, const char *root);
static const void *find_default_value(ASN1_TYPE x)
@@ -151,7 +154,7 @@ static int normalize_name( ASN1_TYPE p, char* output, int output_size)
up->type & CONST_DEFINED_BY &&
type_field(up->left->type)==TYPE_OBJECT_ID) {
- tmp = _gnutls_x509_oid2string(up->left->value);
+ tmp = asn1_find_structure_from_oid( _gnutls_get_pkix(), up->left->value);
if ( tmp != NULL)
_gnutls_str_cpy( output, output_size, tmp);
else {