int TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint) { TS_MSG_IMPRINT *new_msg_imprint; if (a->msg_imprint == msg_imprint) return 1; new_msg_imprint = TS_MSG_IMPRINT_dup(msg_imprint); if (new_msg_imprint == NULL) { TSerr(TS_F_TS_TST_INFO_SET_MSG_IMPRINT, ERR_R_MALLOC_FAILURE); return 0; } TS_MSG_IMPRINT_free(a->msg_imprint); a->msg_imprint = new_msg_imprint; return 1; }
int TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *status_info) { TS_STATUS_INFO *new_status_info; if (a->status_info == status_info) return 1; new_status_info = TS_STATUS_INFO_dup(status_info); if (new_status_info == NULL) { TSerr(TS_F_TS_RESP_SET_STATUS_INFO, ERR_R_MALLOC_FAILURE); return 0; } TS_STATUS_INFO_free(a->status_info); a->status_info = new_status_info; return 1; }
int TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy) { ASN1_OBJECT *new_policy; if (a->policy_id == policy) return 1; new_policy = OBJ_dup(policy); if (new_policy == NULL) { TSerr(TS_F_TS_TST_INFO_SET_POLICY_ID, ERR_R_MALLOC_FAILURE); return 0; } ASN1_OBJECT_free(a->policy_id); a->policy_id = new_policy; return 1; }
/* Default callback for response generation. */ static ASN1_INTEGER *def_serial_cb(struct TS_resp_ctx *ctx, void *data) { ASN1_INTEGER *serial = ASN1_INTEGER_new(); if (serial == NULL) goto err; if (!ASN1_INTEGER_set(serial, 1)) goto err; return serial; err: TSerr(TS_F_DEF_SERIAL_CB, ERR_R_MALLOC_FAILURE); TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Error during serial number generation."); return NULL; }
int TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime) { ASN1_GENERALIZEDTIME *new_time; if (a->time == gtime) return 1; new_time = ASN1_STRING_dup(gtime); if (new_time == NULL) { TSerr(TS_F_TS_TST_INFO_SET_TIME, ERR_R_MALLOC_FAILURE); return 0; } ASN1_GENERALIZEDTIME_free(a->time); a->time = new_time; return 1; }
static int def_time_cb(struct TS_resp_ctx *ctx, void *data, long *sec, long *usec) { struct timeval tv; if (gettimeofday(&tv, NULL) != 0) { TSerr(TS_F_DEF_TIME_CB, TS_R_TIME_SYSCALL_ERROR); TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Time is not available."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_TIME_NOT_AVAILABLE); return 0; } *sec = tv.tv_sec; *usec = tv.tv_usec; return 1; }
int TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce) { ASN1_INTEGER *new_nonce; if (a->nonce == nonce) return 1; new_nonce = ASN1_INTEGER_dup(nonce); if (new_nonce == NULL) { TSerr(TS_F_TS_TST_INFO_SET_NONCE, ERR_R_MALLOC_FAILURE); return 0; } ASN1_INTEGER_free(a->nonce); a->nonce = new_nonce; return 1; }
int TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa) { GENERAL_NAME *new_tsa; if (a->tsa == tsa) return 1; new_tsa = GENERAL_NAME_dup(tsa); if (new_tsa == NULL) { TSerr(TS_F_TS_TST_INFO_SET_TSA, ERR_R_MALLOC_FAILURE); return 0; } GENERAL_NAME_free(a->tsa); a->tsa = new_tsa; return 1; }
int TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds) { ASN1_INTEGER *new_seconds; if (a->seconds == seconds) return 1; new_seconds = ASN1_INTEGER_dup(seconds); if (new_seconds == NULL) { TSerr(TS_F_TS_ACCURACY_SET_SECONDS, ERR_R_MALLOC_FAILURE); return 0; } ASN1_INTEGER_free(a->seconds); a->seconds = new_seconds; return 1; }
int TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy) { TS_ACCURACY *new_accuracy; if (a->accuracy == accuracy) return 1; new_accuracy = TS_ACCURACY_dup(accuracy); if (new_accuracy == NULL) { TSerr(TS_F_TS_TST_INFO_SET_ACCURACY, ERR_R_MALLOC_FAILURE); return 0; } TS_ACCURACY_free(a->accuracy); a->accuracy = new_accuracy; return 1; }
int TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg) { X509_ALGOR *new_alg; if (a->hash_algo == alg) return 1; new_alg = X509_ALGOR_dup(alg); if (new_alg == NULL) { TSerr(TS_F_TS_MSG_IMPRINT_SET_ALGO, ERR_R_MALLOC_FAILURE); return 0; } X509_ALGOR_free(a->hash_algo); a->hash_algo = new_alg; return 1; }
int TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial) { ASN1_INTEGER *new_serial; if (a->serial == serial) return 1; new_serial = ASN1_INTEGER_dup(serial); if (new_serial == NULL) { TSerr(TS_F_TS_TST_INFO_SET_SERIAL, ERR_R_MALLOC_FAILURE); return 0; } ASN1_INTEGER_free(a->serial); a->serial = new_serial; return 1; }
static int def_time_cb(struct TS_resp_ctx *ctx, void *data, long *sec, long *usec) { time_t t; if (time(&t) == (time_t)-1) { TSerr(TS_F_DEF_TIME_CB, TS_R_TIME_SYSCALL_ERROR); TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Time is not available."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_TIME_NOT_AVAILABLE); return 0; } *sec = (long)t; *usec = 0; return 1; }
TS_RESP_CTX *TS_RESP_CTX_new() { TS_RESP_CTX *ctx; if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL) { TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } ctx->signer_md = EVP_sha256(); ctx->serial_cb = def_serial_cb; ctx->time_cb = def_time_cb; ctx->extension_cb = def_extension_cb; return ctx; }
TS_RESP_CTX *TS_RESP_CTX_new() { TS_RESP_CTX *ctx; if ((ctx = OPENSSL_malloc(sizeof(*ctx))) == NULL) { TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } memset(ctx, 0, sizeof(*ctx)); /* Setting default callbacks. */ ctx->serial_cb = def_serial_cb; ctx->time_cb = def_time_cb; ctx->extension_cb = def_extension_cb; return ctx; }
int TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros) { ASN1_INTEGER *new_micros = NULL; if (a->micros == micros) return 1; if (micros != NULL) { new_micros = ASN1_INTEGER_dup(micros); if (new_micros == NULL) { TSerr(TS_F_TS_ACCURACY_SET_MICROS, ERR_R_MALLOC_FAILURE); return 0; } } ASN1_INTEGER_free(a->micros); a->micros = new_micros; return 1; }
TS_RESP_CTX *TS_RESP_CTX_new() { TS_RESP_CTX *ctx; if (!(ctx = (TS_RESP_CTX *) OPENSSL_malloc(sizeof(TS_RESP_CTX)))) { TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } TINYCLR_SSL_MEMSET(ctx, 0, sizeof(TS_RESP_CTX)); /* Setting default callbacks. */ ctx->serial_cb = def_serial_cb; ctx->time_cb = def_time_cb; ctx->extension_cb = def_extension_cb; return ctx; }
/* Use the gettimeofday function call. */ static int def_time_cb(struct TS_resp_ctx *ctx, void *data, long *sec, long *usec) { struct TINYCLR_SSL_TIMEVAL tv; if (TINYCLR_SSL_GETTIMEOFDAY(&tv, NULL) != 0) { TSerr(TS_F_DEF_TIME_CB, TS_R_TIME_SYSCALL_ERROR); TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Time is not available."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_TIME_NOT_AVAILABLE); return 0; } /* Return time to caller. */ *sec = tv.tv_sec; *usec = tv.tv_usec; return 1; }
int TS_CONF_set_default_engine(const char *name) { ENGINE *e = NULL; int ret = 0; if (strcmp(name, "builtin") == 0) return 1; if ((e = ENGINE_by_id(name)) == NULL) goto err; if (strcmp(name, "chil") == 0) ENGINE_ctrl(e, ENGINE_CTRL_CHIL_SET_FORKCHECK, 1, 0, 0); if (!ENGINE_set_default(e, ENGINE_METHOD_ALL)) goto err; ret = 1; err: if (!ret) { TSerr(TS_F_TS_CONF_SET_DEFAULT_ENGINE, TS_R_COULD_NOT_SET_ENGINE); ERR_add_error_data(2, "engine:", name); } ENGINE_free(e); return ret; }
static void ts_CONF_invalid(const char *name, const char *tag) { TSerr(TS_F_TS_CONF_INVALID, TS_R_VAR_BAD_VALUE); ERR_add_error_data(3, name, "::", tag); }
static void ts_CONF_lookup_fail(const char *name, const char *tag) { TSerr(TS_F_TS_CONF_LOOKUP_FAIL, TS_R_VAR_LOOKUP_FAILURE); ERR_add_error_data(3, name, "::", tag); }