当前位置: 首页>>代码示例>>C++>>正文


C++ KSI_ERR_clearErrors函数代码示例

本文整理汇总了C++中KSI_ERR_clearErrors函数的典型用法代码示例。如果您正苦于以下问题:C++ KSI_ERR_clearErrors函数的具体用法?C++ KSI_ERR_clearErrors怎么用?C++ KSI_ERR_clearErrors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了KSI_ERR_clearErrors函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:GuardTime,项目名称:libksi,代码行数:35,代码来源:verify_deprecated.c

示例2: testLoadPublicationsFileWithNoCerts

static void testLoadPublicationsFileWithNoCerts(CuTest *tc) {
	int res;
	KSI_PublicationsFile *pubFile = NULL;
	KSI_LIST(KSI_CertificateRecord) *certList = NULL;
	KSI_PKICertificate *cert = NULL;

	unsigned char dummy[] = {0xca, 0xfe, 0xba, 0xbe};
	KSI_OctetString *certId = NULL;

	KSI_ERR_clearErrors(ctx);

	res = KSI_PublicationsFile_fromFile(ctx, getFullResourcePath("resource/publications/publications-nocerts.bin"), &pubFile);
	CuAssert(tc, "Unable to read publications file", res == KSI_OK && pubFile != NULL);

	res = KSI_PublicationsFile_getCertificates(pubFile, &certList);
	CuAssert(tc, "Unable to get certificate list", res == KSI_OK);
	CuAssert(tc, "Unexpected certificate list length.", KSI_CertificateRecordList_length(certList) == 0);

	res = KSI_OctetString_new(ctx, dummy, sizeof(dummy), &certId);
	CuAssert(tc, "Creating an octetstring failed", res == KSI_OK && certId != NULL);

	res = KSI_PublicationsFile_getPKICertificateById(pubFile, certId, &cert);
	CuAssert(tc, "Searching for a non existend certificate failed", res == KSI_OK && cert == NULL);

	KSI_OctetString_free(certId);
	KSI_PublicationsFile_free(pubFile);
}
开发者ID:GuardTime,项目名称:libksi,代码行数:27,代码来源:ksi_publicationsfile_test.c

示例3: 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;
}
开发者ID:GuardTime,项目名称:libksi,代码行数:28,代码来源:publicationsfile.c

示例4: KSI_PKITruststore_addLookupFile

/*TODO: Not supported*/
int KSI_PKITruststore_addLookupFile(KSI_PKITruststore *trust, const char *path) {
	int res = KSI_UNKNOWN_ERROR;
	HCERTSTORE tmp_FileTrustStore = NULL;
	char buf[1024];

	if (trust == NULL || path == NULL){
		res = KSI_INVALID_ARGUMENT;
		goto cleanup;
	}
	KSI_ERR_clearErrors(trust->ctx);

	/*Open new store */
	tmp_FileTrustStore = CertOpenStore(CERT_STORE_PROV_FILENAME_A, 0, 0, 0, path);
	if (tmp_FileTrustStore == NULL) {
		KSI_LOG_debug(trust->ctx, "%s", getMSError(GetLastError(), buf, sizeof(buf)));
		KSI_pushError(trust->ctx, res = KSI_INVALID_FORMAT, NULL);
		goto cleanup;
	}

	/*Update with priority 0 store*/
	if (!CertAddStoreToCollection(trust->collectionStore, tmp_FileTrustStore, 0, 0)) {
		KSI_LOG_debug(trust->ctx, "%s", getMSError(GetLastError(), buf, sizeof(buf)));
		KSI_pushError(trust->ctx, res = KSI_INVALID_FORMAT, NULL);
		goto cleanup;
	}

	tmp_FileTrustStore = NULL;

	res = KSI_OK;

cleanup:

	if (tmp_FileTrustStore) CertCloseStore(tmp_FileTrustStore, CERT_CLOSE_STORE_CHECK_FLAG);
	return res;
}
开发者ID:khushil,项目名称:libksi,代码行数:36,代码来源:pkitruststore_cryptoapi.c

示例5: testVerifyPublicationsFileWithNoConstraints

static void testVerifyPublicationsFileWithNoConstraints(CuTest *tc) {
	int res;
	KSI_PublicationsFile *pubFile = NULL;
	KSI_CertConstraint arr[] = {
			{NULL, NULL},
			{NULL, NULL}
	};

	KSI_ERR_clearErrors(ctx);


	res = KSI_PublicationsFile_fromFile(ctx, getFullResourcePath(TEST_PUBLICATIONS_FILE), &pubFile);
	CuAssert(tc, "Unable to read publications file", res == KSI_OK && pubFile != NULL);

	res = KSI_CTX_setDefaultPubFileCertConstraints(ctx, arr);
	CuAssert(tc, "Unable to delete OID 1.2.840.113549.1.9.1", res == KSI_OK);

	/* Verification should not fail. */
	res = KSI_PublicationsFile_verify(pubFile, ctx);
	CuAssert(tc, "Publications file may not verify with no constraints.", res == KSI_PUBFILE_VERIFICATION_NOT_CONFIGURED);

	arr[0].oid = KSI_CERT_EMAIL;
	arr[0].val = "[email protected]";
	res = KSI_CTX_setDefaultPubFileCertConstraints(ctx, arr);
	CuAssert(tc, "Unable to set OID 1.2.840.113549.1.9.1 back to normal", res == KSI_OK);

	/* Verification should not fail. */
	res = KSI_PublicationsFile_verify(pubFile, ctx);
	CuAssert(tc, "Publications file must verify with e-mail.", res == KSI_OK);

	KSI_PublicationsFile_free(pubFile);
}
开发者ID:GuardTime,项目名称:libksi,代码行数:32,代码来源:ksi_publicationsfile_test.c

示例6: 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;
}
开发者ID:GuardTime,项目名称:libksi,代码行数:27,代码来源:base.c

示例7: 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;
}
开发者ID:GuardTime,项目名称:libksi,代码行数:29,代码来源:base.c

示例8: testVerifySignatureWithUserPublication

static void testVerifySignatureWithUserPublication(CuTest *tc) {
	int res;
	KSI_Signature *sig = NULL;
	const char pubStr[] = "AAAAAA-CTOQBY-AAMJYH-XZPM6T-UO6U6V-2WJMHQ-EJMVXR-JEAGID-2OY7P5-XFFKYI-QIF2LG-YOV7SO";
	const char pubStr_bad[] = "AAAAAA-CT5VGY-AAPUCF-L3EKCC-NRSX56-AXIDFL-VZJQK4-WDCPOE-3KIWGB-XGPPM3-O5BIMW-REOVR4";
	KSI_PublicationData *pubData = NULL;
	KSI_PublicationData *pubData_bad = NULL;


	KSI_ERR_clearErrors(ctx);


	res = KSI_PublicationData_fromBase32(ctx, pubStr, &pubData);
	CuAssert(tc, "Unable to parse publication string.", res == KSI_OK && pubData != NULL);

	res = KSI_PublicationData_fromBase32(ctx, pubStr_bad, &pubData_bad);
	CuAssert(tc, "Unable to parse publication string.", res == KSI_OK && pubData_bad != NULL);

	res = KSI_Signature_fromFile(ctx, getFullResourcePath("resource/tlv/ok-sig-2014-04-30.1-extended.ksig"), &sig);
	CuAssert(tc, "Unable to read signature from file.", res == KSI_OK && sig != NULL);

	res = KSI_Signature_verifyWithPublication(sig, ctx, pubData);
	CuAssert(tc, "Unable to verify signature with publication.", res == KSI_OK);

	res = KSI_Signature_verifyWithPublication(sig, ctx, pubData_bad);
	CuAssert(tc, "Unable to verify signature with publication.", res != KSI_OK);


	KSI_PublicationData_free(pubData);
	KSI_PublicationData_free(pubData_bad);
	KSI_Signature_free(sig);
}
开发者ID:khushil,项目名称:libksi,代码行数:32,代码来源:ksi_signature_test.c

示例9: 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;
}
开发者ID:GuardTime,项目名称:libksi,代码行数:33,代码来源:types_base.c

示例10: testVerifyDocument

static void testVerifyDocument(CuTest *tc) {
	int res;

	unsigned char in[0x1ffff];
	unsigned in_len = 0;

	char doc[] = "LAPTOP";

	FILE *f = NULL;
	KSI_Signature *sig = NULL;

	KSI_ERR_clearErrors(ctx);

	f = fopen(getFullResourcePath(TEST_SIGNATURE_FILE), "rb");
	CuAssert(tc, "Unable to open signature file.", f != NULL);

	in_len = (unsigned)fread(in, 1, sizeof(in), f);
	CuAssert(tc, "Nothing read from signature file.", in_len > 0);

	fclose(f);

	res = KSI_Signature_parse(ctx, in, in_len, &sig);
	CuAssert(tc, "Failed to parse signature", res == KSI_OK && sig != NULL);

	res = KSI_Signature_verifyDocument(sig, ctx, doc, strlen(doc));
	CuAssert(tc, "Failed to verify valid document", res == KSI_OK);

	res = KSI_Signature_verifyDocument(sig, ctx, doc, sizeof(doc));
	CuAssert(tc, "Verification did not fail with expected error.", res == KSI_VERIFICATION_FAILURE);

	KSI_Signature_free(sig);
}
开发者ID:khushil,项目名称:libksi,代码行数:32,代码来源:ksi_signature_test.c

示例11: testVerifyCalendarChainAlgoChange

static void testVerifyCalendarChainAlgoChange(CuTest *tc) {
	int res;

	unsigned char in[0x1ffff];
	unsigned in_len = 0;

	FILE *f = NULL;
	KSI_Signature *sig = NULL;

	KSI_ERR_clearErrors(ctx);

	f = fopen(getFullResourcePath("resource/tlv/cal_algo_switch.ksig"), "rb");
	CuAssert(tc, "Unable to open signature file.", f != NULL);

	in_len = (unsigned)fread(in, 1, sizeof(in), f);
	CuAssert(tc, "Nothing read from signature file.", in_len > 0);

	fclose(f);

	res = KSI_Signature_parse(ctx, in, in_len, &sig);
	CuAssert(tc, "Failed to parse signature", res == KSI_OK && sig != NULL);

	KSITest_setFileMockResponse(tc, getFullResourcePath("resource/tlv/cal_algo_switch-extend_resposne.tlv"));

	ctx->requestCounter = 0;

	res = KSI_Signature_verifyOnline(sig, ctx);
	CuAssert(tc, "Failed to verify valid document", res == KSI_OK);

	KSI_Signature_free(sig);
}
开发者ID:khushil,项目名称:libksi,代码行数:31,代码来源:ksi_signature_test.c

示例12: testSerializeSignature

static void testSerializeSignature(CuTest *tc) {
	int res;

	unsigned char in[0x1ffff];
	unsigned in_len = 0;

	unsigned char *out = NULL;
	unsigned out_len = 0;

	FILE *f = NULL;

	KSI_Signature *sig = NULL;

	KSI_ERR_clearErrors(ctx);

	f = fopen(getFullResourcePath(TEST_SIGNATURE_FILE), "rb");
	CuAssert(tc, "Unable to open signature file.", f != NULL);

	in_len = (unsigned)fread(in, 1, sizeof(in), f);
	CuAssert(tc, "Nothing read from signature file.", in_len > 0);

	fclose(f);

	res = KSI_Signature_parse(ctx, in, in_len, &sig);
	CuAssert(tc, "Failed to parse signature", res == KSI_OK && sig != NULL);

	res = KSI_Signature_serialize(sig, &out, &out_len);
	CuAssert(tc, "Failed to serialize signature", res == KSI_OK);
	CuAssert(tc, "Serialized signature length mismatch", in_len == out_len);
	CuAssert(tc, "Serialized signature content mismatch", !memcmp(in, out, in_len));

	KSI_free(out);
	KSI_Signature_free(sig);
}
开发者ID:khushil,项目名称:libksi,代码行数:34,代码来源:ksi_signature_test.c

示例13: testErrorMessage

static void testErrorMessage(CuTest* tc, const char *expected, const char *tlv_file,
		int (*obj_new)(KSI_CTX *ctx, void **),
		void (*obj_free)(void*),
		const KSI_TlvTemplate *tmplete) {
	int res;
	void *obj = NULL;
	char buf[1024];
	size_t len;
	FILE *f = NULL;
	KSI_FTLV ftlv;

	KSI_ERR_clearErrors(ctx);

	f = fopen(getFullResourcePath(tlv_file), "rb");
	CuAssert(tc, "Failed to open file.", f != NULL);

	res = KSI_FTLV_fileRead(f, (unsigned char *)buf, sizeof(buf), &len, &ftlv);
	CuAssert(tc, "Failed read from file.", res == KSI_OK);

	res = obj_new(ctx, &obj);
	CuAssert(tc, "Unable create new obj.", res == KSI_OK);

	res = KSI_TlvTemplate_parse(ctx, (unsigned char *)buf, (unsigned)len, tmplete, obj);
	CuAssert(tc, "Parsing invalid obj must fail.", res != KSI_OK);

	res = KSI_ERR_getBaseErrorMessage(ctx, buf, sizeof(buf), NULL, NULL);
	CuAssert(tc, "Unable to get base error message.", res == KSI_OK);

	CuAssert(tc, "Wrong error message.", strcmp(buf, expected) == 0);

	if (f != NULL) fclose(f);
	obj_free(obj);
}
开发者ID:GuardTime,项目名称:libksi,代码行数:33,代码来源:ksi_tlv_sample_test.c

示例14: KSI_Signature_verifyWithPublication

int KSI_Signature_verifyWithPublication(KSI_Signature *sig, KSI_CTX *ctx, const KSI_PublicationData *publication) {
	int res;
	KSI_CTX *useCtx = ctx;

	if (sig == NULL || ctx == NULL || publication == NULL) {
		res = KSI_INVALID_ARGUMENT;
		goto cleanup;
	}
	KSI_ERR_clearErrors(sig->ctx);


	if (useCtx == NULL) {
		useCtx = sig->ctx;
	}

	KSI_VerificationResult_reset(&sig->verificationResult);

	/* Set the document hash. */
	sig->verificationResult.userPublication = publication;
	sig->verificationResult.useUserPublication = true;

	res = KSI_Signature_verifyPolicy(sig, KSI_VP_OFFLINE, useCtx);
	if (res != KSI_OK) {
		KSI_pushError(sig->ctx, res, NULL);
		goto cleanup;
	}

	res = KSI_OK;

cleanup:

	return res;
}
开发者ID:GuardTime,项目名称:libksi,代码行数:33,代码来源:verify_deprecated.c

示例15: KSI_sendExtendRequest

int KSI_sendExtendRequest(KSI_CTX *ctx, KSI_ExtendReq *request, KSI_RequestHandle **handle) {
	int res = KSI_UNKNOWN_ERROR;
	KSI_RequestHandle *tmp = NULL;
	KSI_NetworkClient *netProvider = NULL;

	KSI_ERR_clearErrors(ctx);
	if (ctx == NULL || request == NULL || handle == NULL) {
		KSI_pushError(ctx, res = KSI_INVALID_ARGUMENT, NULL);
		goto cleanup;
	}

	netProvider = ctx->netProvider;

	res = KSI_NetworkClient_sendExtendRequest(netProvider, request, &tmp);
	if (res != KSI_OK) {
		KSI_pushError(ctx,res, NULL);
		goto cleanup;
	}

	*handle = tmp;
	tmp = NULL;

	res = KSI_OK;

cleanup:

	KSI_RequestHandle_free(tmp);

	return res;
}
开发者ID:GuardTime,项目名称:libksi,代码行数:30,代码来源:base.c


注:本文中的KSI_ERR_clearErrors函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。