1
0
mirror of https://github.com/kakwa/uts-server synced 2024-11-11 12:08:54 +01:00
uts-server/inc/rfc3161.h
kakwa e948177a41 enabling multi-threads support
as TS_RESP_CTX is not thread safe, this commit implement a pool of
TS_RESP_CTX in which a thread can pick one in a thread safe maner.

* implement a ts_resp_ctx_wrapper containing a TS_RESP_CTX and a
  lock and bool to mark the availability of the TS_RESP_CTX
* implement the get_ctxw to recover a given TS_RESP_CTX in a thread safe
   maner
* adapt the rest of the code to accomodate the new way of doing things
* set the default number of threads to 10 as it's now safe to do so
2016-09-08 23:21:53 +02:00

44 lines
1.6 KiB
C

#include <openssl/opensslconf.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <sys/syslog.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/rand.h>
#include <openssl/ts.h>
#include <openssl/bn.h>
#include "context.h"
/* Name of config entry that defines the OID file. */
#define ENV_OID_FILE "oid_file"
#define B_FORMAT_TEXT 0x8000
#define FORMAT_UNDEF 0
#define FORMAT_TEXT (1 | B_FORMAT_TEXT) /* Generic text */
#define FORMAT_ASN1 4 /* ASN.1/DER */
static ASN1_OBJECT *txt2obj(const char *oid);
/* Reply related functions. */
static int reply_command(CONF *conf, char *section, char *engine, char *query,
char *passin, char *inkey, const EVP_MD *md,
char *signer, char *chain, const char *policy,
char *in, int token_in, char *out, int token_out,
int text);
static TS_RESP *read_PKCS7(BIO *in_bio);
int create_response(rfc3161_context *ct, char *query, int query_len,
TS_RESP_CTX *resp_ctx, size_t *resp_size,
unsigned char **resp, char **serial_id);
static ASN1_INTEGER *serial_cb(TS_RESP_CTX *ctx, void *data);
static ASN1_INTEGER *next_serial(const char *serialfile);
static int save_ts_serial(const char *serialfile, ASN1_INTEGER *serial);
TS_RESP_CTX *create_tsctx(rfc3161_context *ct, CONF *conf, const char *section,
const char *policy);
int add_oid_section(rfc3161_context *ct, CONF *conf);
ts_resp_ctx_wrapper *get_ctxw(rfc3161_context *ct);
void init_ssl();
void free_ssl();