1
0
mirror of https://github.com/kakwa/uts-server synced 2024-11-11 12:08:54 +01:00
uts-server/inc/rfc3161.h

67 lines
2.1 KiB
C
Raw Normal View History

2016-11-02 18:58:14 +01:00
#include "context.h"
#include <openssl/bio.h>
2016-11-02 18:58:14 +01:00
#include <openssl/bn.h>
#include <openssl/err.h>
2016-11-02 18:58:14 +01:00
#include <openssl/opensslconf.h>
2016-12-04 13:39:27 +01:00
#include <openssl/opensslv.h>
#include <openssl/pem.h>
#include <openssl/rand.h>
#include <openssl/ts.h>
2016-11-02 18:58:14 +01:00
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syslog.h>
#if OPENSSL_VERSION_NUMBER < 0x10000000L
#error OpenSSL version too old
#endif
/* LibreSSL is really annoying
* the OPENSSL_VERSION_NUMBER #define in opensslv.h
* is 0x20000000L but the API is that of openssl 1.0.
* That breaks version matching to determine which API
* to use.
* So, special case here for LibreSSL...
* (why didn't you just keep 0x100000L LibreSSL?)
*/
#ifdef LIBRESSL_VERSION_NUMBER
// for now, LibreSSL is 1.0 API only
#define OPENSSL_API_1_0
#else
// for OpenSSL, we must differenciate between 1.0 and 1.1
2016-12-04 13:39:27 +01:00
#if OPENSSL_VERSION_NUMBER < 0x10100000L && \
OPENSSL_VERSION_NUMBER >= 0x10000000L
#define OPENSSL_API_1_0
#endif
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
#define OPENSSL_API_1_1
#endif
#endif
2016-09-12 08:39:03 +02:00
// number of char we get to log for the serial
#define SERIAL_ID_SIZE 8
2016-08-26 01:28:34 +02:00
#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. */
2016-09-12 08:39:03 +02:00
static ASN1_INTEGER *serial_cb(TS_RESP_CTX *ctx, void *data);
static TS_RESP *read_PKCS7(BIO *in_bio);
int create_response(rfc3161_context *ct, char *query, int query_len,
2016-08-31 00:09:17 +02:00
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);
2016-08-27 11:39:53 +02:00
int add_oid_section(rfc3161_context *ct, CONF *conf);
ts_resp_ctx_wrapper *get_ctxw(rfc3161_context *ct);
void init_ssl();
void free_ssl();