+Version 1.1.10
+- Added gnutls_sign_algorithm_get_name() and gnutls_pk_algorithm_get_name()
+
Version 1.1.9 (14/04/2004)
- Added support for authority key identifier and the extended key usage
X.509 extension fields. The certtoool was updated to support them.
in order to avoid having people working on the same thing.
Current list:
+* Verify added CRLs
* Document the format for the supported DN attributes.
* Add support for Certificate Extensions Profile for Qualified
Certificates (rfc3039)
/* Beware here we do not check for errors.
*/
- if ( gnutls_x509_crt_get_expiration( cert) < time(0)) {
+ if ( gnutls_x509_crt_get_expiration_time( cert) < time(0)) {
printf("The certificate has expired\n");
return;
}
GNUTLS_PK_UNKNOWN = 0xff
} gnutls_pk_algorithm;
+const char *gnutls_pk_algorithm_get_name( gnutls_pk_algorithm algorithm);
+
typedef enum gnutls_sign_algorithm { GNUTLS_SIGN_RSA_SHA = 1, GNUTLS_SIGN_DSA_SHA,
GNUTLS_SIGN_RSA_MD5, GNUTLS_SIGN_RSA_MD2,
GNUTLS_SIGN_UNKNOWN = 0xff
} gnutls_sign_algorithm;
+const char *gnutls_sign_algorithm_get_name( gnutls_sign_algorithm algorithm);
+
/* If you want to change this, then also change the
* define in gnutls_int.h, and recompile.
*/
return ret;
}
+
+/* signature algorithms;
+ */
+struct gnutls_sign_entry {
+ const char *name;
+ gnutls_sign_algorithm id;
+};
+typedef struct gnutls_sign_entry gnutls_sign_entry;
+
+static const gnutls_sign_entry sign_algorithms[] = {
+ {"RSA-SHA", GNUTLS_SIGN_RSA_SHA},
+ {"DSA-SHA", GNUTLS_SIGN_DSA_SHA},
+ {"RSA-MD5", GNUTLS_SIGN_RSA_MD5},
+ {"RSA-MD2", GNUTLS_SIGN_RSA_MD2},
+ {0, 0}
+};
+
+#define GNUTLS_SIGN_LOOP(b) \
+ const gnutls_sign_entry *p; \
+ for(p = sign_algorithms; p->name != NULL; p++) { b ; }
+
+#define GNUTLS_SIGN_ALG_LOOP(a) \
+ GNUTLS_SIGN_LOOP( if(p->id == algorithm) { a; break; } )
+
+
+
+/**
+ * gnutls_sign_algorithm_get_name - Returns a string with the name of the specified sign algorithm
+ * @algorithm: is a sign algorithm
+ *
+ * Returns a string that contains the name
+ * of the specified sign algorithm or NULL.
+ **/
+const char *gnutls_sign_algorithm_get_name( gnutls_sign_algorithm algorithm)
+{
+ const char *ret = NULL;
+
+ /* avoid prefix */
+ GNUTLS_SIGN_ALG_LOOP(ret =
+ p->name);
+
+ return ret;
+}
+
+/* pk algorithms;
+ */
+struct gnutls_pk_entry {
+ const char *name;
+ gnutls_pk_algorithm id;
+};
+typedef struct gnutls_pk_entry gnutls_pk_entry;
+
+static const gnutls_pk_entry pk_algorithms[] = {
+ {"RSA", GNUTLS_PK_RSA},
+ {"DSA", GNUTLS_PK_DSA},
+ {0, 0}
+};
+
+#define GNUTLS_PK_LOOP(b) \
+ const gnutls_pk_entry *p; \
+ for(p = sign_algorithms; p->name != NULL; p++) { b ; }
+
+#define GNUTLS_PK_ALG_LOOP(a) \
+ GNUTLS_PK_LOOP( if(p->id == algorithm) { a; break; } )
+
+
+
+/**
+ * gnutls_pk_algorithm_get_name - Returns a string with the name of the specified public key algorithm
+ * @algorithm: is a pk algorithm
+ *
+ * Returns a string that contains the name
+ * of the specified public key algorithm or NULL.
+ **/
+const char *gnutls_pk_algorithm_get_name( gnutls_pk_algorithm algorithm)
+{
+ const char *ret = NULL;
+
+ /* avoid prefix */
+ GNUTLS_PK_ALG_LOOP(ret =
+ p->name);
+
+ return ret;
+}
static int in_cert_format;
static int out_cert_format;
+#define UNKNOWN "Unknown"
+
/* non interactive operation if set
*/
int batch;
}
-const char* get_pk_algorithm( gnutls_pk_algorithm a)
-{
- switch (a) {
- case GNUTLS_PK_RSA:
- return "RSA";
- case GNUTLS_PK_DSA:
- return "DSA";
- break;
- default:
- return "UNKNOWN";
- }
-}
-
-const char* get_sign_algorithm( gnutls_sign_algorithm a)
-{
- switch (a) {
- case GNUTLS_SIGN_RSA_SHA:
- return "RSA-SHA";
- case GNUTLS_SIGN_RSA_MD5:
- return "RSA-MD5";
- case GNUTLS_SIGN_RSA_MD2:
- return "RSA-MD2";
- case GNUTLS_SIGN_DSA_SHA:
- return "DSA-SHA";
- break;
- default:
- return "UNKNOWN";
- }
-}
-
/* OIDs that are handled by the gnutls' functions.
*/
static inline int known_oid( const char* oid)
fprintf(out, "Signature Algorithm: ");
ret = gnutls_x509_crt_get_signature_algorithm(crt);
- cprint = get_sign_algorithm( ret);
+ cprint = gnutls_sign_algorithm_get_name( ret);
+ if (cprint == NULL) cprint = UNKNOWN;
fprintf(out, "%s\n", cprint);
}
ret = gnutls_x509_crt_get_pk_algorithm(crt, NULL);
fprintf(out, "\tPublic Key Algorithm: ");
- cprint = get_pk_algorithm( ret);
+ cprint = gnutls_pk_algorithm_get_name( ret);
+ if (cprint == NULL) cprint = UNKNOWN;
fprintf(out, "%s\n", cprint);
fprintf(out, "Signature Algorithm: ");
ret = gnutls_x509_crl_get_signature_algorithm(crl);
- cprint = get_sign_algorithm( ret);
+ cprint = gnutls_sign_algorithm_get_name( ret);
+ if (cprint == NULL) cprint = UNKNOWN;
fprintf(out, "%s\n", cprint);
}
ret = gnutls_x509_privkey_get_pk_algorithm(key);
fprintf(outfile, "\tPublic Key Algorithm: ");
- cprint = get_pk_algorithm( ret);
+ cprint = gnutls_pk_algorithm_get_name( ret);
+ if (cprint == NULL) cprint = UNKNOWN;
fprintf(outfile, "%s\n", cprint);
-/* File generated by GAA 1.6.5
+/* File generated by GAA 1.6.6
*/
#define GAA_NO_WIN32
#line 1 "crypt.gaa"
#endif
#endif
-void* gaa_malloc( size_t size) {
+static void* gaa_malloc( size_t size) {
void* ret;
ret = malloc(size);
if (ret==NULL) {
return ret;
}
-void __gaa_helpsingle(char short_name, char *name,
+static void __gaa_helpsingle(char short_name, char *name,
char *arg_desc, char *opt_help)
{
int col1, col3, col4, tabsize = 3, curr;
void gaa_help(void);
- int gaa_file(char *name, gaainfo *gaaval);
+ int gaa_file(const char *name, gaainfo *gaaval);
#ifdef __cplusplus
}
return x; \
}
-char *gaa_current_option;
-int gaa_error = 0;
+static char *gaa_current_option;
+static int gaa_error = 0;
/* Generated by gaa */
}
-char **GAAargv;
-int GAAargc;
-char *gaa_arg_used;
-int gaa_processing_file = 0;
-int inited = 0;
+static char **GAAargv;
+static int GAAargc;
+static char *gaa_arg_used;
+static int gaa_processing_file = 0;
+static int inited = 0;
-int gaa_getint(char *arg)
+static int gaa_getint(char *arg)
{
int tmp;
char a;
return tmp;
}
-char gaa_getchar(char *arg)
+static char gaa_getchar(char *arg)
{
if(strlen(arg) != 1)
{
return arg[0];
}
-char* gaa_getstr(char *arg)
+static char* gaa_getstr(char *arg)
{
return arg;
}
-float gaa_getfloat(char *arg)
+static float gaa_getfloat(char *arg)
{
float tmp;
char a;
};
#line 349 "gaa.skel"
-int gaa_is_an_argument(char *str)
+static int gaa_is_an_argument(char *str)
{
#ifdef GAA_WIN32
if(str[0] == '/' && str[1] != 0)
return GAA_MULTIPLE_OPTION;
}
-int gaa_get_option_num(char *str, int status)
+static int gaa_get_option_num(char *str, int status)
{
switch(status)
{
return GAA_ERROR_NOMATCH;
}
-int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
+static int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
{
int OK = 0;
int gaa_last_non_option;
typedef struct gaastrnode gaa_str_node;
-int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc)
+static int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc)
{
int pos_ini;
int a;
- char ca;
int i = 0, len = 0, newline = 0;
if(argc == 1) {
fseek(file,pos_ini, SEEK_SET);
do
{
- if(fscanf(file, "%c", &ca) != 1)
- {
+ a = fgetc( file);
+
+ if (a == EOF) {
i+=2;
break;
}
- a = ca;
tmp_str->str[i] = a;
i++;
}
return -1;
}
-int gaa_file(char *name, gaainfo *gaaval)
+int gaa_file(const char *name, gaainfo *gaaval)
{
gaa_str_node *first_str, **tmp_str, *tmp_str2;
int rval, i;
void gaa_help(void);
- int gaa_file(char *name, gaainfo *gaaval);
+ int gaa_file(const char *name, gaainfo *gaaval);
#ifdef __cplusplus
}