本文整理汇总了C++中KSI_pushError函数的典型用法代码示例。如果您正苦于以下问题:C++ KSI_pushError函数的具体用法?C++ KSI_pushError怎么用?C++ KSI_pushError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KSI_pushError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KSI_CTX_setTimeoutSeconds
static int KSI_CTX_setTimeoutSeconds(KSI_CTX *ctx, int timeout, int (*setter)(KSI_NetworkClient*, int)){
int res = KSI_UNKNOWN_ERROR;
KSI_NetworkClient *client = NULL;
KSI_ERR_clearErrors(ctx);
if (ctx == NULL || ctx->netProvider == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
if (ctx->isCustomNetProvider){
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, "Unable to set timeout after initial network provider replacement.");
goto cleanup;
}
client = ctx->netProvider;
res = setter(client, timeout);
if (res != KSI_OK) {
KSI_pushError(ctx,res, NULL);
goto cleanup;
}
res = KSI_OK;
cleanup:
return res;
}
示例2: KSI_HmacHasher_reset
int KSI_HmacHasher_reset(KSI_HmacHasher *hasher) {
int res = KSI_UNKNOWN_ERROR;
if (hasher == NULL) {
res = KSI_INVALID_ARGUMENT;
goto cleanup;
}
KSI_ERR_clearErrors(hasher->ctx);
res = KSI_DataHasher_reset(hasher->dataHasher);
if (res != KSI_OK) {
KSI_pushError(hasher->ctx, res, NULL);
goto cleanup;
}
/* Hash inner data. */
KSI_LOG_logBlob(hasher->ctx, KSI_LOG_DEBUG, "Adding ipad", hasher->ipadXORkey, hasher->blockSize);
res = KSI_DataHasher_add(hasher->dataHasher, hasher->ipadXORkey, hasher->blockSize);
if (res != KSI_OK) {
KSI_pushError(hasher->ctx, res, NULL);
goto cleanup;
}
res = KSI_OK;
cleanup:
return res;
}
示例3: KSI_Signature_verifyAggregatedHash
int KSI_Signature_verifyAggregatedHash(KSI_Signature *sig, KSI_CTX *ctx, KSI_DataHash *rootHash, KSI_uint64_t rootLevel) {
int res = KSI_UNKNOWN_ERROR;
KSI_CTX *useCtx = ctx;
KSI_ERR_clearErrors(ctx);
if (ctx == NULL || sig == NULL || rootHash == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
/* Pick a context to use. */
if (useCtx == NULL) {
useCtx = sig->ctx;
}
KSI_VerificationResult_reset(&sig->verificationResult);
/* Set the document hash. */
sig->verificationResult.documentHash = KSI_DataHash_ref(rootHash);
sig->verificationResult.docAggrLevel = rootLevel;
sig->verificationResult.verifyDocumentHash = true;
res = KSI_Signature_verifyPolicy(sig, KSI_VP_DOCUMENT, useCtx);
if (res != KSI_OK) {
KSI_pushError(sig->ctx, res, NULL);
goto cleanup;
}
res = KSI_OK;
cleanup:
return res;
}
示例4: KSI_OctetString_toTlv
int KSI_OctetString_toTlv(KSI_CTX *ctx, KSI_OctetString *o, unsigned tag, int isNonCritical, int isForward, KSI_TLV **tlv) {
int res = KSI_UNKNOWN_ERROR;
KSI_TLV *tmp = NULL;
KSI_ERR_clearErrors(ctx);
if (ctx == NULL || o == NULL || tlv == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
res = KSI_TLV_new(ctx, tag, isNonCritical, isForward, &tmp);
if (res != KSI_OK) {
KSI_pushError(ctx, res, NULL);
goto cleanup;
}
res = KSI_TLV_setRawValue(tmp, o->data, o->data_len);
if (res != KSI_OK) {
KSI_pushError(ctx, res, NULL);
goto cleanup;
}
*tlv = tmp;
tmp = NULL;
res = KSI_OK;
cleanup:
KSI_TLV_free(tmp);
return res;
}
示例5: KSI_createSignature
int KSI_createSignature(KSI_CTX *ctx, KSI_DataHash *dataHash, KSI_Signature **sig) {
int res = KSI_UNKNOWN_ERROR;
KSI_Signature *tmp = NULL;
KSI_ERR_clearErrors(ctx);
if (ctx == NULL || dataHash == NULL || sig == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
res = KSI_Signature_sign(ctx, dataHash, &tmp);
if (res != KSI_OK) {
KSI_pushError(ctx,res, NULL);
goto cleanup;
}
*sig = tmp;
tmp = NULL;
res = KSI_OK;
cleanup:
KSI_Signature_free(tmp);
return res;
}
示例6: KSI_CTX_setUri
static int KSI_CTX_setUri(KSI_CTX *ctx,
const char *uri, const char *loginId, const char *key,
int (*setter)(KSI_NetworkClient*, const char*, const char *, const char *)){
int res = KSI_UNKNOWN_ERROR;
KSI_ERR_clearErrors(ctx);
if (ctx == NULL || uri == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
if (ctx->isCustomNetProvider){
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, "Unable to set url after initial network provider replacement.");
goto cleanup;
}
res = setter(ctx->netProvider, uri, loginId, key);
if (res != KSI_OK) {
KSI_pushError(ctx,res, NULL);
goto cleanup;
}
res = KSI_OK;
cleanup:
return res;
}
示例7: checkSignatureInternals
static int checkSignatureInternals(KSI_CTX *ctx, KSI_Signature *sig) {
int res = KSI_UNKNOWN_ERROR;
if (ctx == NULL || sig == NULL) {
res = KSI_INVALID_ARGUMENT;
goto cleanup;
}
/* A valid signature must have at least one aggregation chain. */
if (sig->aggregationChainList == NULL || KSI_AggregationHashChainList_length(sig->aggregationChainList) == 0) {
KSI_pushError(ctx, res = KSI_INVALID_FORMAT, "A valid signature must have at least one aggregation hash chain.");
goto cleanup;
}
/* If there is no calendar chain, there can not be a calendar auth record nor a publication record. */
if (sig->calendarChain == NULL && (sig->calendarAuthRec != NULL || sig->publication != NULL)) {
KSI_pushError(ctx, KSI_INVALID_FORMAT, "Calendar auth record or publication record may not be specified if the calendar chain is missing.");
goto cleanup;
}
/* Make sure the signature does not have both calendar auth record and a publication in it. */
if (sig->calendarAuthRec != NULL && sig->publication != NULL) {
KSI_pushError(ctx, res = KSI_INVALID_FORMAT, "Only calendar auth record or publication record may be present.");
goto cleanup;
}
res = KSI_OK;
cleanup:
return res;
}
示例8: KSI_SignatureBuilder_setCalendarHashChain
int KSI_SignatureBuilder_setCalendarHashChain(KSI_SignatureBuilder *builder, KSI_CalendarHashChain *cal) {
int res = KSI_UNKNOWN_ERROR;
KSI_CalendarHashChain *tmp = NULL;
if (builder == NULL || cal == NULL) {
res = KSI_INVALID_ARGUMENT;
goto cleanup;
}
/* Do not allow overriding of the value, as it is likely an error. */
if (builder->sig->calendarChain != NULL) {
KSI_pushError(builder->ctx, res = KSI_INVALID_STATE, "The calendar hash chain has already been set.");
goto cleanup;
}
res = KSI_Signature_setCalendarChain(builder->sig, tmp = KSI_CalendarHashChain_ref(cal));
if (res != KSI_OK) {
KSI_pushError(builder->ctx, res, NULL);
goto cleanup;
}
tmp = NULL;
res = KSI_OK;
cleanup:
KSI_CalendarHashChain_free(tmp);
return res;
}
示例9: KSI_CTX_setDefaultPubFileCertConstraints
int KSI_CTX_setDefaultPubFileCertConstraints(KSI_CTX *ctx, const KSI_CertConstraint *arr) {
int res = KSI_UNKNOWN_ERROR;
KSI_CertConstraint *tmp = NULL;
size_t count = 0;
size_t i;
KSI_ERR_clearErrors(ctx);
if (ctx == NULL || arr == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
/* Count the input. */
while(arr[count++].oid != NULL);
/* Allocate buffer with extra space for the trailing {NULL, NULL}. */
tmp = KSI_calloc(count, sizeof(KSI_CertConstraint));
if (tmp == NULL) {
KSI_pushError(ctx, res = KSI_OUT_OF_MEMORY, NULL);
goto cleanup;
}
/* Copy the values. */
for (i = 0; arr[i].oid != NULL; i++) {
res = KSI_strdup(arr[i].oid, &tmp[i].oid);
if (res != KSI_OK) {
KSI_pushError(ctx, res, NULL);
goto cleanup;
}
if (arr[i].val == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, "Expected OID value may not be NULL");
goto cleanup;
}
res = KSI_strdup(arr[i].val, &tmp[i].val);
if (res != KSI_OK) {
KSI_pushError(ctx, res, NULL);
goto cleanup;
}
}
/* Add terminator for the array. */
tmp[i].oid = NULL;
tmp[i].val = NULL;
/* Free the existing constraints. */
freeCertConstraintsArray(ctx->certConstraints);
ctx->certConstraints = tmp;
tmp = NULL;
res = KSI_OK;
cleanup:
freeCertConstraintsArray(tmp);
return res;
}
示例10: KSI_DataHasher_addOctetString
int KSI_DataHasher_addOctetString(KSI_DataHasher *hasher, KSI_OctetString *data) {
int res = KSI_UNKNOWN_ERROR;
const unsigned char *ptr = NULL;
size_t len = 0;
if (hasher == NULL || data == NULL) {
res = KSI_INVALID_ARGUMENT;
goto cleanup;
}
res = KSI_OctetString_extract(data, &ptr, &len);
if (res != KSI_OK) {
KSI_pushError(hasher->ctx, res, NULL);
goto cleanup;
}
res = KSI_DataHasher_add(hasher, ptr, len);
if (res != KSI_OK) {
KSI_pushError(hasher->ctx, res, NULL);
goto cleanup;
}
res = KSI_OK;
cleanup:
return res;
}
示例11: KSI_PublicationRecord_toBase32
int KSI_PublicationRecord_toBase32(KSI_PublicationRecord *pubRec, char **pubStr) {
int res;
if (pubRec == NULL) {
res = KSI_INVALID_ARGUMENT;
goto cleanup;
}
KSI_ERR_clearErrors(pubRec->ctx);
if (pubStr == NULL) {
KSI_pushError(pubRec->ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
res = KSI_PublicationData_toBase32(pubRec->publishedData, pubStr);
if (res != KSI_OK) {
KSI_pushError(pubRec->ctx, res, NULL);
goto cleanup;
}
res = KSI_OK;
cleanup:
return res;
}
示例12: KSI_TlvTemplate_parse
int KSI_TlvTemplate_parse(KSI_CTX *ctx, const unsigned char *raw, unsigned raw_len, const KSI_TlvTemplate *tmpl, void *payload) {
int res = KSI_UNKNOWN_ERROR;
KSI_TLV *tlv = NULL;
struct tlv_track_s tr[0xf];
KSI_ERR_clearErrors(ctx);
if (ctx == NULL || raw == NULL || tmpl == NULL || payload == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
res = KSI_TLV_parseBlob2(ctx, (unsigned char *)raw, raw_len, 0, &tlv);
if (res != KSI_OK) {
KSI_pushError(ctx, res, NULL);
goto cleanup;
}
res = extract(ctx, payload, tlv, tmpl, tr, 0, sizeof(tr));
if (res != KSI_OK) {
KSI_pushError(ctx, res, NULL);
goto cleanup;
}
KSI_LOG_logTlv(ctx, KSI_LOG_DEBUG, "Parsed TLV", tlv);
res = KSI_OK;
cleanup:
KSI_TLV_free(tlv);
return res;
}
示例13: KSI_Utf8StringNZ_toTlv
int KSI_Utf8StringNZ_toTlv(KSI_CTX *ctx, KSI_Utf8String *o, unsigned tag, int isNonCritical, int isForward, KSI_TLV **tlv) {
int res = KSI_UNKNOWN_ERROR;
KSI_TLV *tmp = NULL;
KSI_ERR_clearErrors(ctx);
if (ctx == NULL || o == NULL || tlv == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
if (o->len == 0 || (o->len == 1 && o->value[0] == 0)) {
KSI_pushError(ctx, res = KSI_INVALID_FORMAT, "Empty string value not allowed.");
goto cleanup;
}
res = KSI_Utf8String_toTlv(ctx, o, tag, isNonCritical, isForward, &tmp);
if (res != KSI_OK) {
KSI_pushError(ctx, res, NULL);
goto cleanup;
}
*tlv = tmp;
tmp = NULL;
res = KSI_OK;
cleanup:
KSI_TLV_free(tmp);
return res;
}
示例14: KSI_Utf8StringNZ_fromTlv
int KSI_Utf8StringNZ_fromTlv(KSI_TLV *tlv, KSI_Utf8String **o) {
int res = KSI_UNKNOWN_ERROR;
KSI_CTX *ctx = NULL;
KSI_Utf8String *tmp = NULL;
ctx = KSI_TLV_getCtx(tlv);
KSI_ERR_clearErrors(ctx);
if (tlv == NULL || o == NULL) {
KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
goto cleanup;
}
res = KSI_Utf8String_fromTlv(tlv, &tmp);
if (res != KSI_OK) {
KSI_pushError(ctx, res, NULL);
goto cleanup;
}
if (tmp->len == 0 || (tmp->len == 1 && tmp->value[0] == 0)) {
KSI_pushError(ctx, res = KSI_INVALID_FORMAT, "Empty string value not allowed.");
goto cleanup;
}
*o = tmp;
tmp = NULL;
res = KSI_OK;
cleanup:
KSI_nofree(ctx);
KSI_Utf8String_free(tmp);
return res;
}
示例15: KSI_OctetString_LegacyId_getUtf8String
int KSI_OctetString_LegacyId_getUtf8String(KSI_OctetString *id, KSI_Utf8String **str) {
int res = KSI_UNKNOWN_ERROR;
const unsigned char *raw = NULL;
size_t raw_len;
KSI_Utf8String *tmp = NULL;
if (id == NULL || str == NULL) {
res = KSI_INVALID_ARGUMENT;
goto cleanup;
}
KSI_ERR_clearErrors(id->ctx);
res = KSI_OctetString_extract(id, &raw, &raw_len);
if (res != KSI_OK) {
KSI_pushError(id->ctx, res, NULL);
goto cleanup;
}
res = KSI_Utf8String_new(id->ctx, (char *)(raw + LEGACY_ID_STR_POS), raw[LEGACY_ID_STR_LEN_POS] + 1, &tmp);
if (res != KSI_OK) {
KSI_pushError(id->ctx, res, NULL);
goto cleanup;
}
*str = tmp;
tmp = NULL;
res = KSI_OK;
cleanup:
KSI_Utf8String_free(tmp);
return res;
}