summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/x509/by_dir.c418
-rw-r--r--lib/libcrypto/x509/by_file.c272
-rw-r--r--lib/libcrypto/x509/x_all.c749
3 files changed, 739 insertions, 700 deletions
diff --git a/lib/libcrypto/x509/by_dir.c b/lib/libcrypto/x509/by_dir.c
index f9d55c4e6d7..b5512895a18 100644
--- a/lib/libcrypto/x509/by_dir.c
+++ b/lib/libcrypto/x509/by_dir.c
@@ -73,37 +73,34 @@
#include <openssl/x509.h>
-typedef struct lookup_dir_hashes_st
- {
+typedef struct lookup_dir_hashes_st {
unsigned long hash;
int suffix;
- } BY_DIR_HASH;
+} BY_DIR_HASH;
-typedef struct lookup_dir_entry_st
- {
+typedef struct lookup_dir_entry_st {
char *dir;
int dir_type;
STACK_OF(BY_DIR_HASH) *hashes;
- } BY_DIR_ENTRY;
+} BY_DIR_ENTRY;
-typedef struct lookup_dir_st
- {
+typedef struct lookup_dir_st {
BUF_MEM *buffer;
STACK_OF(BY_DIR_ENTRY) *dirs;
- } BY_DIR;
+} BY_DIR;
DECLARE_STACK_OF(BY_DIR_HASH)
DECLARE_STACK_OF(BY_DIR_ENTRY)
static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
- char **ret);
+ char **ret);
static int new_dir(X509_LOOKUP *lu);
static void free_dir(X509_LOOKUP *lu);
-static int add_cert_dir(BY_DIR *ctx,const char *dir,int type);
-static int get_cert_by_subject(X509_LOOKUP *xl,int type,X509_NAME *name,
- X509_OBJECT *ret);
-X509_LOOKUP_METHOD x509_dir_lookup=
- {
+static int add_cert_dir(BY_DIR *ctx, const char *dir, int type);
+static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
+ X509_OBJECT *ret);
+
+X509_LOOKUP_METHOD x509_dir_lookup = {
"Load certs from files in a directory",
new_dir, /* new */
free_dir, /* free */
@@ -114,254 +111,237 @@ X509_LOOKUP_METHOD x509_dir_lookup=
NULL, /* get_by_issuer_serial */
NULL, /* get_by_fingerprint */
NULL, /* get_by_alias */
- };
-
-X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void)
- {
- return(&x509_dir_lookup);
- }
-
-static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
- char **retp)
- {
- int ret=0;
+};
+
+X509_LOOKUP_METHOD
+*X509_LOOKUP_hash_dir(void)
+{
+ return (&x509_dir_lookup);
+}
+
+static int
+dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
+ char **retp)
+{
+ int ret = 0;
BY_DIR *ld;
char *dir = NULL;
- ld=(BY_DIR *)ctx->method_data;
+ ld = (BY_DIR *)ctx->method_data;
- switch (cmd)
- {
+ switch (cmd) {
case X509_L_ADD_DIR:
- if (argl == X509_FILETYPE_DEFAULT)
- {
- dir=(char *)getenv(X509_get_default_cert_dir_env());
+ if (argl == X509_FILETYPE_DEFAULT) {
+ dir = (char *)getenv(X509_get_default_cert_dir_env());
if (dir)
- ret=add_cert_dir(ld,dir,X509_FILETYPE_PEM);
+ ret = add_cert_dir(ld, dir, X509_FILETYPE_PEM);
else
- ret=add_cert_dir(ld,X509_get_default_cert_dir(),
- X509_FILETYPE_PEM);
- if (!ret)
- {
- X509err(X509_F_DIR_CTRL,X509_R_LOADING_CERT_DIR);
- }
+ ret = add_cert_dir(ld, X509_get_default_cert_dir(),
+ X509_FILETYPE_PEM);
+ if (!ret) {
+ X509err(X509_F_DIR_CTRL, X509_R_LOADING_CERT_DIR);
}
- else
- ret=add_cert_dir(ld,argp,(int)argl);
+ } else
+ ret = add_cert_dir(ld, argp,(int)argl);
break;
- }
- return(ret);
}
+ return (ret);
+}
-static int new_dir(X509_LOOKUP *lu)
- {
+static int
+new_dir(X509_LOOKUP *lu)
+{
BY_DIR *a;
- if ((a=(BY_DIR *)OPENSSL_malloc(sizeof(BY_DIR))) == NULL)
- return(0);
- if ((a->buffer=BUF_MEM_new()) == NULL)
- {
+ if ((a = (BY_DIR *)OPENSSL_malloc(sizeof(BY_DIR))) == NULL)
+ return (0);
+ if ((a->buffer = BUF_MEM_new()) == NULL) {
OPENSSL_free(a);
- return(0);
- }
- a->dirs=NULL;
- lu->method_data=(char *)a;
- return(1);
+ return (0);
}
-
-static void by_dir_hash_free(BY_DIR_HASH *hash)
- {
+ a->dirs = NULL;
+ lu->method_data = (char *)a;
+ return (1);
+}
+
+static void
+by_dir_hash_free(BY_DIR_HASH *hash)
+{
OPENSSL_free(hash);
- }
+}
-static int by_dir_hash_cmp(const BY_DIR_HASH * const *a,
- const BY_DIR_HASH * const *b)
- {
+static int
+by_dir_hash_cmp(const BY_DIR_HASH * const *a,
+ const BY_DIR_HASH * const *b)
+{
if ((*a)->hash > (*b)->hash)
return 1;
if ((*a)->hash < (*b)->hash)
return -1;
return 0;
- }
+}
-static void by_dir_entry_free(BY_DIR_ENTRY *ent)
- {
+static void
+by_dir_entry_free(BY_DIR_ENTRY *ent)
+{
if (ent->dir)
OPENSSL_free(ent->dir);
if (ent->hashes)
sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
OPENSSL_free(ent);
- }
+}
-static void free_dir(X509_LOOKUP *lu)
- {
+static void
+free_dir(X509_LOOKUP *lu)
+{
BY_DIR *a;
- a=(BY_DIR *)lu->method_data;
+ a = (BY_DIR *)lu->method_data;
if (a->dirs != NULL)
sk_BY_DIR_ENTRY_pop_free(a->dirs, by_dir_entry_free);
if (a->buffer != NULL)
BUF_MEM_free(a->buffer);
OPENSSL_free(a);
+}
+
+static int
+add_cert_dir(BY_DIR *ctx, const char *dir, int type)
+{
+ int j, len;
+ const char *s, *ss, *p;
+
+ if (dir == NULL || !*dir) {
+ X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY);
+ return 0;
}
-static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
- {
- int j,len;
- const char *s,*ss,*p;
-
- if (dir == NULL || !*dir)
- {
- X509err(X509_F_ADD_CERT_DIR,X509_R_INVALID_DIRECTORY);
- return 0;
- }
-
- s=dir;
- p=s;
- do
- {
- if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0'))
- {
+ s = dir;
+ p = s;
+ do {
+ if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0')) {
BY_DIR_ENTRY *ent;
- ss=s;
- s=p+1;
- len=(int)(p-ss);
- if (len == 0) continue;
- for (j=0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++)
- {
+ ss = s;
+ s = p + 1;
+ len = (int)(p - ss);
+ if (len == 0)
+ continue;
+ for (j = 0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) {
ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j);
if (strlen(ent->dir) == (size_t)len &&
- strncmp(ent->dir,ss,(unsigned int)len) == 0)
+ strncmp(ent->dir, ss,
+ (unsigned int)len) == 0)
break;
- }
+ }
if (j < sk_BY_DIR_ENTRY_num(ctx->dirs))
continue;
- if (ctx->dirs == NULL)
- {
+ if (ctx->dirs == NULL) {
ctx->dirs = sk_BY_DIR_ENTRY_new_null();
- if (!ctx->dirs)
- {
- X509err(X509_F_ADD_CERT_DIR,ERR_R_MALLOC_FAILURE);
+ if (!ctx->dirs) {
+ X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);
return 0;
- }
}
+ }
ent = OPENSSL_malloc(sizeof(BY_DIR_ENTRY));
if (!ent)
return 0;
ent->dir_type = type;
ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
- ent->dir = OPENSSL_malloc((unsigned int)len+1);
- if (!ent->dir || !ent->hashes)
- {
+ ent->dir = OPENSSL_malloc((unsigned int)len + 1);
+ if (!ent->dir || !ent->hashes) {
by_dir_entry_free(ent);
return 0;
- }
- strncpy(ent->dir,ss,(unsigned int)len);
+ }
+ strncpy(ent->dir, ss,(unsigned int)len);
ent->dir[len] = '\0';
- if (!sk_BY_DIR_ENTRY_push(ctx->dirs, ent))
- {
+ if (!sk_BY_DIR_ENTRY_push(ctx->dirs, ent)) {
by_dir_entry_free(ent);
return 0;
- }
}
- } while (*p++ != '\0');
+ }
+ } while (*p++ != '\0');
return 1;
- }
+}
-static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
- X509_OBJECT *ret)
- {
+static int
+get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
+ X509_OBJECT *ret)
+{
BY_DIR *ctx;
union {
struct {
X509 st_x509;
X509_CINF st_x509_cinf;
- } x509;
+ } x509;
struct {
X509_CRL st_crl;
X509_CRL_INFO st_crl_info;
- } crl;
- } data;
- int ok=0;
- int i,j,k;
+ } crl;
+ } data;
+ int ok = 0;
+ int i, j, k;
unsigned long h;
- BUF_MEM *b=NULL;
- X509_OBJECT stmp,*tmp;
+ BUF_MEM *b = NULL;
+ X509_OBJECT stmp, *tmp;
const char *postfix="";
- if (name == NULL) return(0);
+ if (name == NULL)
+ return (0);
- stmp.type=type;
- if (type == X509_LU_X509)
- {
- data.x509.st_x509.cert_info= &data.x509.st_x509_cinf;
- data.x509.st_x509_cinf.subject=name;
- stmp.data.x509= &data.x509.st_x509;
+ stmp.type = type;
+ if (type == X509_LU_X509) {
+ data.x509.st_x509.cert_info = &data.x509.st_x509_cinf;
+ data.x509.st_x509_cinf.subject = name;
+ stmp.data.x509 = &data.x509.st_x509;
postfix="";
- }
- else if (type == X509_LU_CRL)
- {
- data.crl.st_crl.crl= &data.crl.st_crl_info;
- data.crl.st_crl_info.issuer=name;
- stmp.data.crl= &data.crl.st_crl;
+ } else if (type == X509_LU_CRL) {
+ data.crl.st_crl.crl = &data.crl.st_crl_info;
+ data.crl.st_crl_info.issuer = name;
+ stmp.data.crl = &data.crl.st_crl;
postfix="r";
- }
- else
- {
- X509err(X509_F_GET_CERT_BY_SUBJECT,X509_R_WRONG_LOOKUP_TYPE);
+ } else {
+ X509err(X509_F_GET_CERT_BY_SUBJECT, X509_R_WRONG_LOOKUP_TYPE);
goto finish;
- }
+ }
- if ((b=BUF_MEM_new()) == NULL)
- {
- X509err(X509_F_GET_CERT_BY_SUBJECT,ERR_R_BUF_LIB);
+ if ((b = BUF_MEM_new()) == NULL) {
+ X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_BUF_LIB);
goto finish;
- }
-
- ctx=(BY_DIR *)xl->method_data;
+ }
+
+ ctx = (BY_DIR *)xl->method_data;
- h=X509_NAME_hash(name);
- for (i=0; i < sk_BY_DIR_ENTRY_num(ctx->dirs); i++)
- {
+ h = X509_NAME_hash(name);
+ for (i = 0; i < sk_BY_DIR_ENTRY_num(ctx->dirs); i++) {
BY_DIR_ENTRY *ent;
int idx;
BY_DIR_HASH htmp, *hent;
ent = sk_BY_DIR_ENTRY_value(ctx->dirs, i);
- j=strlen(ent->dir)+1+8+6+1+1;
- if (!BUF_MEM_grow(b,j))
- {
- X509err(X509_F_GET_CERT_BY_SUBJECT,ERR_R_MALLOC_FAILURE);
+ j = strlen(ent->dir) + 1 + 8 + 6 + 1 + 1;
+ if (!BUF_MEM_grow(b, j)) {
+ X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE);
goto finish;
- }
- if (type == X509_LU_CRL && ent->hashes)
- {
+ }
+ if (type == X509_LU_CRL && ent->hashes) {
htmp.hash = h;
CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE);
idx = sk_BY_DIR_HASH_find(ent->hashes, &htmp);
- if (idx >= 0)
- {
+ if (idx >= 0) {
hent = sk_BY_DIR_HASH_value(ent->hashes, idx);
k = hent->suffix;
- }
- else
- {
+ } else {
hent = NULL;
- k=0;
- }
- CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE);
+ k = 0;
}
- else
- {
+ CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE);
+ } else {
k = 0;
hent = NULL;
- }
- for (;;)
- {
+ }
+ for (;;) {
char c = '/';
#ifdef OPENSSL_SYS_VMS
- c = ent->dir[strlen(ent->dir)-1];
- if (c != ':' && c != '>' && c != ']')
- {
+ c = ent->dir[strlen(ent->dir) - 1];
+ if (c != ':' && c != '>' && c != ']') {
/* If no separator is present, we assume the
directory specifier is a logical name, and
add a colon. We really should use better
@@ -369,112 +349,100 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
but this will do for now...
-- Richard Levitte */
c = ':';
- }
- else
- {
+ } else {
c = '\0';
- }
+ }
#endif
- if (c == '\0')
- {
+ if (c == '\0') {
/* This is special. When c == '\0', no
directory separator should be added. */
- (void) snprintf(b->data,b->max,
- "%s%08lx.%s%d",ent->dir,h,
- postfix,k);
- }
- else
- {
- (void) snprintf(b->data,b->max,
- "%s%c%08lx.%s%d",ent->dir,c,h,
- postfix,k);
- }
+ (void) snprintf(b->data, b->max,
+ "%s%08lx.%s%d", ent->dir, h,
+ postfix, k);
+ } else {
+ (void) snprintf(b->data, b->max,
+ "%s%c%08lx.%s%d", ent->dir, c, h,
+ postfix, k);
+ }
#ifndef OPENSSL_NO_POSIX_IO
#ifdef _WIN32
#define stat _stat
#endif
{
- struct stat st;
- if (stat(b->data,&st) < 0)
- break;
+ struct stat st;
+ if (stat(b->data, &st) < 0)
+ break;
}
#endif
/* found one. */
- if (type == X509_LU_X509)
- {
- if ((X509_load_cert_file(xl,b->data,
+ if (type == X509_LU_X509) {
+ if ((X509_load_cert_file(xl, b->data,
ent->dir_type)) == 0)
- break;
- }
- else if (type == X509_LU_CRL)
- {
- if ((X509_load_crl_file(xl,b->data,
+ break;
+ } else if (type == X509_LU_CRL) {
+ if ((X509_load_crl_file(xl, b->data,
ent->dir_type)) == 0)
- break;
- }
+ break;
+ }
/* else case will caught higher up */
k++;
- }
+ }
/* we have added it to the cache so now pull
* it out again */
CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
- j = sk_X509_OBJECT_find(xl->store_ctx->objs,&stmp);
- if(j != -1) tmp=sk_X509_OBJECT_value(xl->store_ctx->objs,j);
- else tmp = NULL;
+ j = sk_X509_OBJECT_find(xl->store_ctx->objs, &stmp);
+ if (j != -1)
+ tmp = sk_X509_OBJECT_value(xl->store_ctx->objs, j);
+ else tmp = NULL;
CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
/* If a CRL, update the last file suffix added for this */
- if (type == X509_LU_CRL)
- {
+ if (type == X509_LU_CRL) {
CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
/* Look for entry again in case another thread added
* an entry first.
*/
- if (!hent)
- {
+ if (!hent) {
htmp.hash = h;
idx = sk_BY_DIR_HASH_find(ent->hashes, &htmp);
if (idx >= 0)
- hent =
- sk_BY_DIR_HASH_value(ent->hashes, idx);
- }
- if (!hent)
- {
+ hent = sk_BY_DIR_HASH_value(
+ ent->hashes, idx);
+ }
+ if (!hent) {
hent = OPENSSL_malloc(sizeof(BY_DIR_HASH));
hent->hash = h;
hent->suffix = k;
- if (!sk_BY_DIR_HASH_push(ent->hashes, hent))
- {
+ if (!sk_BY_DIR_HASH_push(ent->hashes, hent)) {
CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
OPENSSL_free(hent);
ok = 0;
goto finish;
- }
}
- else if (hent->suffix < k)
+ } else if (hent->suffix < k)
hent->suffix = k;
CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
- }
+ }
- if (tmp != NULL)
- {
- ok=1;
- ret->type=tmp->type;
- memcpy(&ret->data,&tmp->data,sizeof(ret->data));
+ if (tmp != NULL) {
+ ok = 1;
+ ret->type = tmp->type;
+ memcpy(&ret->data, &tmp->data, sizeof(ret->data));
/* If we were going to up the reference count,
* we would need to do it on a perl 'type'
* basis */
/* CRYPTO_add(&tmp->data.x509->references,1,
CRYPTO_LOCK_X509);*/
goto finish;
- }
}
-finish:
- if (b != NULL) BUF_MEM_free(b);
- return(ok);
}
+finish:
+ if (b != NULL)
+ BUF_MEM_free(b);
+ return (ok);
+}
diff --git a/lib/libcrypto/x509/by_file.c b/lib/libcrypto/x509/by_file.c
index 57b08ee0945..474d13bf0ec 100644
--- a/lib/libcrypto/x509/by_file.c
+++ b/lib/libcrypto/x509/by_file.c
@@ -69,9 +69,9 @@
#ifndef OPENSSL_NO_STDIO
static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
- long argl, char **ret);
-X509_LOOKUP_METHOD x509_file_lookup=
- {
+ long argl, char **ret);
+
+X509_LOOKUP_METHOD x509_file_lookup = {
"Load file into cache",
NULL, /* new */
NULL, /* free */
@@ -82,211 +82,199 @@ X509_LOOKUP_METHOD x509_file_lookup=
NULL, /* get_by_issuer_serial */
NULL, /* get_by_fingerprint */
NULL, /* get_by_alias */
- };
+};
-X509_LOOKUP_METHOD *X509_LOOKUP_file(void)
- {
- return(&x509_file_lookup);
- }
+X509_LOOKUP_METHOD
+*X509_LOOKUP_file(void)
+{
+ return (&x509_file_lookup);
+}
-static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
- char **ret)
- {
- int ok=0;
+static int
+by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
+ char **ret)
+{
+ int ok = 0;
char *file;
- switch (cmd)
- {
+ switch (cmd) {
case X509_L_FILE_LOAD:
- if (argl == X509_FILETYPE_DEFAULT)
- {
+ if (argl == X509_FILETYPE_DEFAULT) {
file = (char *)getenv(X509_get_default_cert_file_env());
if (file)
- ok = (X509_load_cert_crl_file(ctx,file,
- X509_FILETYPE_PEM) != 0);
-
+ ok = (X509_load_cert_crl_file(ctx, file,
+ X509_FILETYPE_PEM) != 0);
else
- ok = (X509_load_cert_crl_file(ctx,X509_get_default_cert_file(),
- X509_FILETYPE_PEM) != 0);
+ ok = (X509_load_cert_crl_file(ctx,
+ X509_get_default_cert_file(),
+ X509_FILETYPE_PEM) != 0);
- if (!ok)
- {
- X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS);
- }
+ if (!ok) {
+ X509err(X509_F_BY_FILE_CTRL,
+ X509_R_LOADING_DEFAULTS);
}
- else
- {
- if(argl == X509_FILETYPE_PEM)
- ok = (X509_load_cert_crl_file(ctx,argp,
- X509_FILETYPE_PEM) != 0);
+ } else {
+ if (argl == X509_FILETYPE_PEM)
+ ok = (X509_load_cert_crl_file(ctx, argp,
+ X509_FILETYPE_PEM) != 0);
else
- ok = (X509_load_cert_file(ctx,argp,(int)argl) != 0);
- }
- break;
+ ok = (X509_load_cert_file(ctx,
+ argp,(int)argl) != 0);
}
- return(ok);
+ break;
}
+ return (ok);
+}
-int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type)
- {
- int ret=0;
- BIO *in=NULL;
- int i,count=0;
- X509 *x=NULL;
+int
+X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type)
+{
+ int ret = 0;
+ BIO *in = NULL;
+ int i, count = 0;
+ X509 *x = NULL;
- if (file == NULL) return(1);
- in=BIO_new(BIO_s_file_internal());
+ if (file == NULL)
+ return (1);
+ in = BIO_new(BIO_s_file_internal());
- if ((in == NULL) || (BIO_read_filename(in,file) <= 0))
- {
- X509err(X509_F_X509_LOAD_CERT_FILE,ERR_R_SYS_LIB);
+ if ((in == NULL) || (BIO_read_filename(in, file) <= 0)) {
+ X509err(X509_F_X509_LOAD_CERT_FILE, ERR_R_SYS_LIB);
goto err;
- }
+ }
- if (type == X509_FILETYPE_PEM)
- {
- for (;;)
- {
- x=PEM_read_bio_X509_AUX(in,NULL,NULL,NULL);
- if (x == NULL)
- {
+ if (type == X509_FILETYPE_PEM) {
+ for (;;) {
+ x = PEM_read_bio_X509_AUX(in, NULL, NULL, NULL);
+ if (x == NULL) {
if ((ERR_GET_REASON(ERR_peek_last_error()) ==
- PEM_R_NO_START_LINE) && (count > 0))
- {
+ PEM_R_NO_START_LINE) && (count > 0)) {
ERR_clear_error();
break;
- }
- else
- {
+ } else {
X509err(X509_F_X509_LOAD_CERT_FILE,
- ERR_R_PEM_LIB);
+ ERR_R_PEM_LIB);
goto err;
- }
}
- i=X509_STORE_add_cert(ctx->store_ctx,x);
- if (!i) goto err;
+ }
+ i = X509_STORE_add_cert(ctx->store_ctx, x);
+ if (!i)
+ goto err;
count++;
X509_free(x);
- x=NULL;
- }
- ret=count;
+ x = NULL;
}
- else if (type == X509_FILETYPE_ASN1)
- {
- x=d2i_X509_bio(in,NULL);
- if (x == NULL)
- {
- X509err(X509_F_X509_LOAD_CERT_FILE,ERR_R_ASN1_LIB);
+ ret = count;
+ } else if (type == X509_FILETYPE_ASN1) {
+ x = d2i_X509_bio(in, NULL);
+ if (x == NULL) {
+ X509err(X509_F_X509_LOAD_CERT_FILE, ERR_R_ASN1_LIB);
goto err;
- }
- i=X509_STORE_add_cert(ctx->store_ctx,x);
- if (!i) goto err;
- ret=i;
}
- else
- {
- X509err(X509_F_X509_LOAD_CERT_FILE,X509_R_BAD_X509_FILETYPE);
+ i = X509_STORE_add_cert(ctx->store_ctx, x);
+ if (!i)
+ goto err;
+ ret = i;
+ } else {
+ X509err(X509_F_X509_LOAD_CERT_FILE, X509_R_BAD_X509_FILETYPE);
goto err;
- }
-err:
- if (x != NULL) X509_free(x);
- if (in != NULL) BIO_free(in);
- return(ret);
}
+err:
+ if (x != NULL)
+ X509_free(x);
+ if (in != NULL)
+ BIO_free(in);
+ return (ret);
+}
-int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type)
- {
- int ret=0;
- BIO *in=NULL;
- int i,count=0;
- X509_CRL *x=NULL;
+int
+X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type)
+{
+ int ret = 0;
+ BIO *in = NULL;
+ int i, count = 0;
+ X509_CRL *x = NULL;
- if (file == NULL) return(1);
- in=BIO_new(BIO_s_file_internal());
+ if (file == NULL)
+ return (1);
+ in = BIO_new(BIO_s_file_internal());
- if ((in == NULL) || (BIO_read_filename(in,file) <= 0))
- {
- X509err(X509_F_X509_LOAD_CRL_FILE,ERR_R_SYS_LIB);
+ if ((in == NULL) || (BIO_read_filename(in, file) <= 0)) {
+ X509err(X509_F_X509_LOAD_CRL_FILE, ERR_R_SYS_LIB);
goto err;
- }
+ }
- if (type == X509_FILETYPE_PEM)
- {
- for (;;)
- {
- x=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL);
- if (x == NULL)
- {
+ if (type == X509_FILETYPE_PEM) {
+ for (;;) {
+ x = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
+ if (x == NULL) {
if ((ERR_GET_REASON(ERR_peek_last_error()) ==
- PEM_R_NO_START_LINE) && (count > 0))
- {
+ PEM_R_NO_START_LINE) && (count > 0)) {
ERR_clear_error();
break;
- }
- else
- {
+ } else {
X509err(X509_F_X509_LOAD_CRL_FILE,
- ERR_R_PEM_LIB);
+ ERR_R_PEM_LIB);
goto err;
- }
}
- i=X509_STORE_add_crl(ctx->store_ctx,x);
- if (!i) goto err;
+ }
+ i = X509_STORE_add_crl(ctx->store_ctx, x);
+ if (!i)
+ goto err;
count++;
X509_CRL_free(x);
- x=NULL;
- }
- ret=count;
+ x = NULL;
}
- else if (type == X509_FILETYPE_ASN1)
- {
- x=d2i_X509_CRL_bio(in,NULL);
- if (x == NULL)
- {
- X509err(X509_F_X509_LOAD_CRL_FILE,ERR_R_ASN1_LIB);
+ ret = count;
+ } else if (type == X509_FILETYPE_ASN1) {
+ x = d2i_X509_CRL_bio(in, NULL);
+ if (x == NULL) {
+ X509err(X509_F_X509_LOAD_CRL_FILE, ERR_R_ASN1_LIB);
goto err;
- }
- i=X509_STORE_add_crl(ctx->store_ctx,x);
- if (!i) goto err;
- ret=i;
}
- else
- {
- X509err(X509_F_X509_LOAD_CRL_FILE,X509_R_BAD_X509_FILETYPE);
+ i = X509_STORE_add_crl(ctx->store_ctx, x);
+ if (!i)
+ goto err;
+ ret = i;
+ } else {
+ X509err(X509_F_X509_LOAD_CRL_FILE, X509_R_BAD_X509_FILETYPE);
goto err;
- }
-err:
- if (x != NULL) X509_CRL_free(x);
- if (in != NULL) BIO_free(in);
- return(ret);
}
+err:
+ if (x != NULL)
+ X509_CRL_free(x);
+ if (in != NULL)
+ BIO_free(in);
+ return (ret);
+}
-int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)
+int
+X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)
{
STACK_OF(X509_INFO) *inf;
X509_INFO *itmp;
BIO *in;
int i, count = 0;
- if(type != X509_FILETYPE_PEM)
+ if (type != X509_FILETYPE_PEM)
return X509_load_cert_file(ctx, file, type);
in = BIO_new_file(file, "r");
- if(!in) {
- X509err(X509_F_X509_LOAD_CERT_CRL_FILE,ERR_R_SYS_LIB);
+ if (!in) {
+ X509err(X509_F_X509_LOAD_CERT_CRL_FILE, ERR_R_SYS_LIB);
return 0;
}
inf = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL);
BIO_free(in);
- if(!inf) {
- X509err(X509_F_X509_LOAD_CERT_CRL_FILE,ERR_R_PEM_LIB);
+ if (!inf) {
+ X509err(X509_F_X509_LOAD_CERT_CRL_FILE, ERR_R_PEM_LIB);
return 0;
}
- for(i = 0; i < sk_X509_INFO_num(inf); i++) {
+ for (i = 0; i < sk_X509_INFO_num(inf); i++) {
itmp = sk_X509_INFO_value(inf, i);
- if(itmp->x509) {
+ if (itmp->x509) {
X509_STORE_add_cert(ctx->store_ctx, itmp->x509);
count++;
}
- if(itmp->crl) {
+ if (itmp->crl) {
X509_STORE_add_crl(ctx->store_ctx, itmp->crl);
count++;
}
@@ -295,6 +283,4 @@ int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)
return count;
}
-
#endif /* OPENSSL_NO_STDIO */
-
diff --git a/lib/libcrypto/x509/x_all.c b/lib/libcrypto/x509/x_all.c
index e06602d65ab..59099f026f8 100644
--- a/lib/libcrypto/x509/x_all.c
+++ b/lib/libcrypto/x509/x_all.c
@@ -70,468 +70,553 @@
#include <openssl/dsa.h>
#endif
-int X509_verify(X509 *a, EVP_PKEY *r)
- {
- return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF),a->sig_alg,
- a->signature,a->cert_info,r));
- }
-
-int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r)
- {
+int
+X509_verify(X509 *a, EVP_PKEY *r)
+{
+ return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF), a->sig_alg,
+ a->signature, a->cert_info, r));
+}
+
+int
+X509_REQ_verify(X509_REQ *a, EVP_PKEY *r)
+{
return( ASN1_item_verify(ASN1_ITEM_rptr(X509_REQ_INFO),
- a->sig_alg,a->signature,a->req_info,r));
- }
+ a->sig_alg, a->signature, a->req_info, r));
+}
-int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r)
- {
+int
+NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r)
+{
return(ASN1_item_verify(ASN1_ITEM_rptr(NETSCAPE_SPKAC),
- a->sig_algor,a->signature,a->spkac,r));
- }
+ a->sig_algor, a->signature, a->spkac, r));
+}
-int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
- {
+int
+X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
+{
x->cert_info->enc.modified = 1;
- return(ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF), x->cert_info->signature,
- x->sig_alg, x->signature, x->cert_info,pkey,md));
- }
+ return (ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF),
+ x->cert_info->signature, x->sig_alg, x->signature,
+ x->cert_info, pkey, md));
+}
-int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx)
- {
+int
+X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx)
+{
x->cert_info->enc.modified = 1;
return ASN1_item_sign_ctx(ASN1_ITEM_rptr(X509_CINF),
- x->cert_info->signature,
- x->sig_alg, x->signature, x->cert_info, ctx);
- }
-
-int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md)
- {
- return(ASN1_item_sign(ASN1_ITEM_rptr(X509_REQ_INFO),x->sig_alg, NULL,
- x->signature, x->req_info,pkey,md));
- }
-
-int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx)
- {
+ x->cert_info->signature, x->sig_alg, x->signature,
+ x->cert_info, ctx);
+}
+
+int
+X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md)
+{
+ return (ASN1_item_sign(ASN1_ITEM_rptr(X509_REQ_INFO),
+ x->sig_alg, NULL, x->signature, x->req_info, pkey, md));
+}
+
+int
+X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx)
+{
return ASN1_item_sign_ctx(ASN1_ITEM_rptr(X509_REQ_INFO),
- x->sig_alg, NULL, x->signature, x->req_info, ctx);
- }
+ x->sig_alg, NULL, x->signature, x->req_info, ctx);
+}
-int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md)
- {
+int
+X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md)
+{
x->crl->enc.modified = 1;
- return(ASN1_item_sign(ASN1_ITEM_rptr(X509_CRL_INFO),x->crl->sig_alg,
- x->sig_alg, x->signature, x->crl,pkey,md));
- }
+ return(ASN1_item_sign(ASN1_ITEM_rptr(X509_CRL_INFO), x->crl->sig_alg,
+ x->sig_alg, x->signature, x->crl, pkey, md));
+}
-int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx)
- {
+int
+X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx)
+{
x->crl->enc.modified = 1;
return ASN1_item_sign_ctx(ASN1_ITEM_rptr(X509_CRL_INFO),
- x->crl->sig_alg, x->sig_alg, x->signature, x->crl, ctx);
- }
+ x->crl->sig_alg, x->sig_alg, x->signature, x->crl, ctx);
+}
-int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md)
- {
- return(ASN1_item_sign(ASN1_ITEM_rptr(NETSCAPE_SPKAC), x->sig_algor,NULL,
- x->signature, x->spkac,pkey,md));
- }
+int
+NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md)
+{
+ return (ASN1_item_sign(ASN1_ITEM_rptr(NETSCAPE_SPKAC),
+ x->sig_algor, NULL, x->signature, x->spkac, pkey, md));
+}
#ifndef OPENSSL_NO_FP_API
-X509 *d2i_X509_fp(FILE *fp, X509 **x509)
- {
+X509
+*d2i_X509_fp(FILE *fp, X509 **x509)
+{
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509), fp, x509);
- }
+}
-int i2d_X509_fp(FILE *fp, X509 *x509)
- {
+int
+i2d_X509_fp(FILE *fp, X509 *x509)
+{
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509), fp, x509);
- }
+}
#endif
-X509 *d2i_X509_bio(BIO *bp, X509 **x509)
- {
+X509
+*d2i_X509_bio(BIO *bp, X509 **x509)
+{
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509), bp, x509);
- }
+}
-int i2d_X509_bio(BIO *bp, X509 *x509)
- {
+int
+i2d_X509_bio(BIO *bp, X509 *x509)
+{
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509), bp, x509);
- }
+}
#ifndef OPENSSL_NO_FP_API
-X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl)
- {
+X509_CRL
+*d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl)
+{
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509_CRL), fp, crl);
- }
+}
-int i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl)
- {
+int
+i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl)
+{
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509_CRL), fp, crl);
- }
+}
#endif
-X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl)
- {
+X509_CRL
+*d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl)
+{
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509_CRL), bp, crl);
- }
+}
-int i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl)
- {
+int
+i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl)
+{
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509_CRL), bp, crl);
- }
+}
#ifndef OPENSSL_NO_FP_API
-PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7)
- {
+PKCS7
+*d2i_PKCS7_fp(FILE *fp, PKCS7 **p7)
+{
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(PKCS7), fp, p7);
- }
+}
-int i2d_PKCS7_fp(FILE *fp, PKCS7 *p7)
- {
+int
+i2d_PKCS7_fp(FILE *fp, PKCS7 *p7)
+{
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(PKCS7), fp, p7);
- }
+}
#endif
-PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7)
- {
+PKCS7
+*d2i_PKCS7_bio(BIO *bp, PKCS7 **p7)
+{
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(PKCS7), bp, p7);
- }
+}
-int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7)
- {
+int
+i2d_PKCS7_bio(BIO *bp, PKCS7 *p7)
+{
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(PKCS7), bp, p7);
- }
+}
#ifndef OPENSSL_NO_FP_API
-X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req)
- {
+X509_REQ
+*d2i_X509_REQ_fp(FILE *fp, X509_REQ **req)
+{
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509_REQ), fp, req);
- }
+}
-int i2d_X509_REQ_fp(FILE *fp, X509_REQ *req)
- {
+int
+i2d_X509_REQ_fp(FILE *fp, X509_REQ *req)
+{
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509_REQ), fp, req);
- }
+}
#endif
-X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req)
- {
+X509_REQ
+*d2i_X509_REQ_bio(BIO *bp, X509_REQ **req)
+{
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509_REQ), bp, req);
- }
+}
-int i2d_X509_REQ_bio(BIO *bp, X509_REQ *req)
- {
+int
+i2d_X509_REQ_bio(BIO *bp, X509_REQ *req)
+{
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509_REQ), bp, req);
- }
+}
#ifndef OPENSSL_NO_RSA
#ifndef OPENSSL_NO_FP_API
-RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa)
- {
+RSA
+*d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa)
+{
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(RSAPrivateKey), fp, rsa);
- }
+}
-int i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa)
- {
+int
+i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa)
+{
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(RSAPrivateKey), fp, rsa);
- }
+}
-RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa)
- {
+RSA
+*d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa)
+{
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(RSAPublicKey), fp, rsa);
- }
+}
-RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa)
- {
- return ASN1_d2i_fp((void *(*)(void))
- RSA_new,(D2I_OF(void))d2i_RSA_PUBKEY, fp,
- (void **)rsa);
- }
+RSA
+*d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa)
+{
+ return ASN1_d2i_fp((void *(*)(void))RSA_new,
+ (D2I_OF(void))d2i_RSA_PUBKEY, fp, (void **)rsa);
+}
-int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa)
- {
+int
+i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa)
+{
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(RSAPublicKey), fp, rsa);
- }
+}
-int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa)
- {
- return ASN1_i2d_fp((I2D_OF(void))i2d_RSA_PUBKEY,fp,rsa);
- }
+int
+i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa)
+{
+ return ASN1_i2d_fp((I2D_OF(void))i2d_RSA_PUBKEY, fp, rsa);
+}
#endif
-RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa)
- {
+RSA
+*d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa)
+{
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(RSAPrivateKey), bp, rsa);
- }
+}
-int i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa)
- {
+int
+i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa)
+{
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(RSAPrivateKey), bp, rsa);
- }
+}
-RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa)
- {
+RSA
+*d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa)
+{
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(RSAPublicKey), bp, rsa);
- }
+}
-RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa)
- {
- return ASN1_d2i_bio_of(RSA,RSA_new,d2i_RSA_PUBKEY,bp,rsa);
- }
+RSA
+*d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa)
+{
+ return ASN1_d2i_bio_of(RSA, RSA_new, d2i_RSA_PUBKEY, bp, rsa);
+}
-int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa)
- {
+int
+i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa)
+{
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(RSAPublicKey), bp, rsa);
- }
+}
-int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa)
- {
- return ASN1_i2d_bio_of(RSA,i2d_RSA_PUBKEY,bp,rsa);
- }
+int
+i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa)
+{
+ return ASN1_i2d_bio_of(RSA, i2d_RSA_PUBKEY, bp, rsa);
+}
#endif
#ifndef OPENSSL_NO_DSA
#ifndef OPENSSL_NO_FP_API
-DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa)
- {
- return ASN1_d2i_fp_of(DSA,DSA_new,d2i_DSAPrivateKey,fp,dsa);
- }
-
-int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa)
- {
- return ASN1_i2d_fp_of_const(DSA,i2d_DSAPrivateKey,fp,dsa);
- }
-
-DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa)
- {
- return ASN1_d2i_fp_of(DSA,DSA_new,d2i_DSA_PUBKEY,fp,dsa);
- }
-
-int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa)
- {
- return ASN1_i2d_fp_of(DSA,i2d_DSA_PUBKEY,fp,dsa);
- }
+DSA
+*d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa)
+{
+ return ASN1_d2i_fp_of(DSA, DSA_new, d2i_DSAPrivateKey, fp, dsa);
+}
+
+int
+i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa)
+{
+ return ASN1_i2d_fp_of_const(DSA, i2d_DSAPrivateKey, fp, dsa);
+}
+
+DSA
+*d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa)
+{
+ return ASN1_d2i_fp_of(DSA, DSA_new, d2i_DSA_PUBKEY, fp, dsa);
+}
+
+int
+i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa)
+{
+ return ASN1_i2d_fp_of(DSA, i2d_DSA_PUBKEY, fp, dsa);
+}
#endif
-DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa)
- {
- return ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAPrivateKey,bp,dsa
-);
- }
+DSA
+*d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa)
+{
+ return ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSAPrivateKey, bp, dsa);
+}
-int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa)
- {
- return ASN1_i2d_bio_of_const(DSA,i2d_DSAPrivateKey,bp,dsa);
- }
+int
+i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa)
+{
+ return ASN1_i2d_bio_of_const(DSA, i2d_DSAPrivateKey, bp, dsa);
+}
-DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa)
- {
- return ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSA_PUBKEY,bp,dsa);
- }
+DSA
+*d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa)
+{
+ return ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSA_PUBKEY, bp, dsa);
+}
-int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa)
- {
- return ASN1_i2d_bio_of(DSA,i2d_DSA_PUBKEY,bp,dsa);
- }
+int
+i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa)
+{
+ return ASN1_i2d_bio_of(DSA, i2d_DSA_PUBKEY, bp, dsa);
+}
#endif
#ifndef OPENSSL_NO_EC
#ifndef OPENSSL_NO_FP_API
-EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey)
- {
- return ASN1_d2i_fp_of(EC_KEY,EC_KEY_new,d2i_EC_PUBKEY,fp,eckey);
- }
-
-int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey)
- {
- return ASN1_i2d_fp_of(EC_KEY,i2d_EC_PUBKEY,fp,eckey);
- }
-
-EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey)
- {
- return ASN1_d2i_fp_of(EC_KEY,EC_KEY_new,d2i_ECPrivateKey,fp,eckey);
- }
-
-int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey)
- {
- return ASN1_i2d_fp_of(EC_KEY,i2d_ECPrivateKey,fp,eckey);
- }
+EC_KEY
+*d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey)
+{
+ return ASN1_d2i_fp_of(EC_KEY, EC_KEY_new, d2i_EC_PUBKEY, fp, eckey);
+}
+
+int
+i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey)
+{
+ return ASN1_i2d_fp_of(EC_KEY, i2d_EC_PUBKEY, fp, eckey);
+}
+
+EC_KEY
+*d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey)
+{
+ return ASN1_d2i_fp_of(EC_KEY, EC_KEY_new, d2i_ECPrivateKey, fp, eckey);
+}
+
+int
+i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey)
+{
+ return ASN1_i2d_fp_of(EC_KEY, i2d_ECPrivateKey, fp, eckey);
+}
#endif
-EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey)
- {
- return ASN1_d2i_bio_of(EC_KEY,EC_KEY_new,d2i_EC_PUBKEY,bp,eckey);
- }
-
-int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *ecdsa)
- {
- return ASN1_i2d_bio_of(EC_KEY,i2d_EC_PUBKEY,bp,ecdsa);
- }
-
-EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey)
- {
- return ASN1_d2i_bio_of(EC_KEY,EC_KEY_new,d2i_ECPrivateKey,bp,eckey);
- }
-
-int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey)
- {
- return ASN1_i2d_bio_of(EC_KEY,i2d_ECPrivateKey,bp,eckey);
- }
+EC_KEY
+*d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey)
+{
+ return ASN1_d2i_bio_of(EC_KEY, EC_KEY_new, d2i_EC_PUBKEY, bp, eckey);
+}
+
+int
+i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *ecdsa)
+{
+ return ASN1_i2d_bio_of(EC_KEY, i2d_EC_PUBKEY, bp, ecdsa);
+}
+
+EC_KEY
+*d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey)
+{
+ return ASN1_d2i_bio_of(EC_KEY, EC_KEY_new, d2i_ECPrivateKey, bp, eckey);
+}
+
+int
+i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey)
+{
+ return ASN1_i2d_bio_of(EC_KEY, i2d_ECPrivateKey, bp, eckey);
+}
#endif
-int X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
- unsigned int *len)
- {
+int
+X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
+ unsigned int *len)
+{
ASN1_BIT_STRING *key;
key = X509_get0_pubkey_bitstr(data);
- if(!key) return 0;
+ if (!key)
+ return 0;
return EVP_Digest(key->data, key->length, md, len, type, NULL);
- }
-
-int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
- unsigned int *len)
- {
- return(ASN1_item_digest(ASN1_ITEM_rptr(X509),type,(char *)data,md,len));
- }
-
-int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md,
- unsigned int *len)
- {
- return(ASN1_item_digest(ASN1_ITEM_rptr(X509_CRL),type,(char *)data,md,len));
- }
-
-int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, unsigned char *md,
- unsigned int *len)
- {
- return(ASN1_item_digest(ASN1_ITEM_rptr(X509_REQ),type,(char *)data,md,len));
- }
-
-int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, unsigned char *md,
- unsigned int *len)
- {
- return(ASN1_item_digest(ASN1_ITEM_rptr(X509_NAME),type,(char *)data,md,len));
- }
-
-int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, const EVP_MD *type,
- unsigned char *md, unsigned int *len)
- {
- return(ASN1_item_digest(ASN1_ITEM_rptr(PKCS7_ISSUER_AND_SERIAL),type,
- (char *)data,md,len));
- }
+}
+
+int
+X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
+ unsigned int *len)
+{
+ return (ASN1_item_digest(ASN1_ITEM_rptr(X509), type, (char *)data,
+ md, len));
+}
+
+int
+X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md,
+ unsigned int *len)
+{
+ return (ASN1_item_digest(ASN1_ITEM_rptr(X509_CRL), type, (char *)data,
+ md, len));
+}
+
+int
+X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, unsigned char *md,
+ unsigned int *len)
+{
+ return (ASN1_item_digest(ASN1_ITEM_rptr(X509_REQ), type,(char *)data,
+ md, len));
+}
+
+int
+X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, unsigned char *md,
+ unsigned int *len)
+{
+ return (ASN1_item_digest(ASN1_ITEM_rptr(X509_NAME), type,(char *)data,
+ md, len));
+}
+
+int
+PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,
+ const EVP_MD *type, unsigned char *md, unsigned int *len)
+{
+ return(ASN1_item_digest(ASN1_ITEM_rptr(PKCS7_ISSUER_AND_SERIAL), type,
+ (char *)data, md, len));
+}
#ifndef OPENSSL_NO_FP_API
-X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8)
- {
- return ASN1_d2i_fp_of(X509_SIG,X509_SIG_new,d2i_X509_SIG,fp,p8);
- }
-
-int i2d_PKCS8_fp(FILE *fp, X509_SIG *p8)
- {
- return ASN1_i2d_fp_of(X509_SIG,i2d_X509_SIG,fp,p8);
- }
+X509_SIG
+*d2i_PKCS8_fp(FILE *fp, X509_SIG **p8)
+{
+ return ASN1_d2i_fp_of(X509_SIG, X509_SIG_new, d2i_X509_SIG, fp, p8);
+}
+
+int
+i2d_PKCS8_fp(FILE *fp, X509_SIG *p8)
+{
+ return ASN1_i2d_fp_of(X509_SIG, i2d_X509_SIG, fp, p8);
+}
#endif
-X509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8)
- {
- return ASN1_d2i_bio_of(X509_SIG,X509_SIG_new,d2i_X509_SIG,bp,p8);
- }
+X509_SIG
+*d2i_PKCS8_bio(BIO *bp, X509_SIG **p8)
+{
+ return ASN1_d2i_bio_of(X509_SIG, X509_SIG_new, d2i_X509_SIG, bp, p8);
+}
-int i2d_PKCS8_bio(BIO *bp, X509_SIG *p8)
- {
- return ASN1_i2d_bio_of(X509_SIG,i2d_X509_SIG,bp,p8);
- }
+int
+i2d_PKCS8_bio(BIO *bp, X509_SIG *p8)
+{
+ return ASN1_i2d_bio_of(X509_SIG, i2d_X509_SIG, bp, p8);
+}
#ifndef OPENSSL_NO_FP_API
-PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
- PKCS8_PRIV_KEY_INFO **p8inf)
- {
- return ASN1_d2i_fp_of(PKCS8_PRIV_KEY_INFO,PKCS8_PRIV_KEY_INFO_new,
- d2i_PKCS8_PRIV_KEY_INFO,fp,p8inf);
- }
-
-int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf)
- {
- return ASN1_i2d_fp_of(PKCS8_PRIV_KEY_INFO,i2d_PKCS8_PRIV_KEY_INFO,fp,
- p8inf);
- }
-
-int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key)
- {
+PKCS8_PRIV_KEY_INFO
+*d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
+PKCS8_PRIV_KEY_INFO **p8inf)
+{
+ return ASN1_d2i_fp_of(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_new,
+ d2i_PKCS8_PRIV_KEY_INFO, fp, p8inf);
+}
+
+int
+i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf)
+{
+ return ASN1_i2d_fp_of(PKCS8_PRIV_KEY_INFO, i2d_PKCS8_PRIV_KEY_INFO,
+ fp, p8inf);
+}
+
+int
+i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key)
+{
PKCS8_PRIV_KEY_INFO *p8inf;
int ret;
p8inf = EVP_PKEY2PKCS8(key);
- if(!p8inf) return 0;
+ if (!p8inf)
+ return 0;
ret = i2d_PKCS8_PRIV_KEY_INFO_fp(fp, p8inf);
PKCS8_PRIV_KEY_INFO_free(p8inf);
return ret;
- }
+}
-int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey)
- {
- return ASN1_i2d_fp_of(EVP_PKEY,i2d_PrivateKey,fp,pkey);
- }
+int
+i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey)
+{
+ return ASN1_i2d_fp_of(EVP_PKEY, i2d_PrivateKey, fp, pkey);
+}
-EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a)
+EVP_PKEY
+*d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a)
{
- return ASN1_d2i_fp_of(EVP_PKEY,EVP_PKEY_new,d2i_AutoPrivateKey,fp,a);
+ return ASN1_d2i_fp_of(EVP_PKEY, EVP_PKEY_new, d2i_AutoPrivateKey,
+ fp, a);
}
-int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey)
- {
- return ASN1_i2d_fp_of(EVP_PKEY,i2d_PUBKEY,fp,pkey);
- }
+int
+i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey)
+{
+ return ASN1_i2d_fp_of(EVP_PKEY, i2d_PUBKEY, fp, pkey);
+}
-EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a)
+EVP_PKEY
+*d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a)
{
- return ASN1_d2i_fp_of(EVP_PKEY,EVP_PKEY_new,d2i_PUBKEY,fp,a);
+ return ASN1_d2i_fp_of(EVP_PKEY, EVP_PKEY_new, d2i_PUBKEY, fp, a);
}
#endif
-PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
- PKCS8_PRIV_KEY_INFO **p8inf)
- {
- return ASN1_d2i_bio_of(PKCS8_PRIV_KEY_INFO,PKCS8_PRIV_KEY_INFO_new,
- d2i_PKCS8_PRIV_KEY_INFO,bp,p8inf);
- }
-
-int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf)
- {
- return ASN1_i2d_bio_of(PKCS8_PRIV_KEY_INFO,i2d_PKCS8_PRIV_KEY_INFO,bp,
- p8inf);
- }
-
-int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key)
- {
+PKCS8_PRIV_KEY_INFO
+*d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
+PKCS8_PRIV_KEY_INFO **p8inf)
+{
+ return ASN1_d2i_bio_of(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_new,
+ d2i_PKCS8_PRIV_KEY_INFO, bp, p8inf);
+}
+
+int
+i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf)
+{
+ return ASN1_i2d_bio_of(PKCS8_PRIV_KEY_INFO, i2d_PKCS8_PRIV_KEY_INFO,
+ bp, p8inf);
+}
+
+int
+i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key)
+{
PKCS8_PRIV_KEY_INFO *p8inf;
int ret;
p8inf = EVP_PKEY2PKCS8(key);
- if(!p8inf) return 0;
+ if (!p8inf)
+ return 0;
ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf);
PKCS8_PRIV_KEY_INFO_free(p8inf);
return ret;
- }
-
-int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey)
- {
- return ASN1_i2d_bio_of(EVP_PKEY,i2d_PrivateKey,bp,pkey);
- }
-
-EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a)
- {
- return ASN1_d2i_bio_of(EVP_PKEY,EVP_PKEY_new,d2i_AutoPrivateKey,bp,a);
- }
-
-int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey)
- {
- return ASN1_i2d_bio_of(EVP_PKEY,i2d_PUBKEY,bp,pkey);
- }
-
-EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a)
- {
- return ASN1_d2i_bio_of(EVP_PKEY,EVP_PKEY_new,d2i_PUBKEY,bp,a);
- }
+}
+
+int
+i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey)
+{
+ return ASN1_i2d_bio_of(EVP_PKEY, i2d_PrivateKey, bp, pkey);
+}
+
+EVP_PKEY
+*d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a)
+{
+ return ASN1_d2i_bio_of(EVP_PKEY, EVP_PKEY_new, d2i_AutoPrivateKey, bp, a);
+}
+
+int
+i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey)
+{
+ return ASN1_i2d_bio_of(EVP_PKEY, i2d_PUBKEY, bp, pkey);
+}
+
+EVP_PKEY
+*d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a)
+{
+ return ASN1_d2i_bio_of(EVP_PKEY, EVP_PKEY_new, d2i_PUBKEY, bp, a);
+}