<commit_before>/*
 * Copyright 2013-2016 Guardtime, Inc.
 *
 * This file is part of the Guardtime client SDK.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES, CONDITIONS, OR OTHER LICENSES OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 * "Guardtime" and "KSI" are trademarks or registered trademarks of
 * Guardtime, Inc., and no license to trademarks is granted; Guardtime
 * reserves and retains all trademark rights.
 */

#ifndef POLICY_H
#define	POLICY_H

#include "types.h"
#include "ksi.h"

#ifdef	__cplusplus
extern "C" {
#endif

	struct KSI_VerificationContext_st {
		KSI_CTX *ctx;

		/** Signature being verified. */
		KSI_Signature *signature;

		/** Indicates whether signature extention is allowed (0 means no, and any non-zero is considered to be true). */
		int extendingAllowed;

		/** Initial aggregation level. */
		KSI_uint64_t docAggrLevel;

		/** Document hash to be verified. */
		KSI_DataHash *documentHash;

		/** Publication string to be used. */
		KSI_PublicationData *userPublication;

		/** Publication file to be used. */
		KSI_PublicationsFile *userPublicationsFile;

		void *tempData;
	};

	/**
	 * Enumeration of all KSI policy (#KSI_Policy) verification result codes.
	 */
	typedef enum KSI_VerificationResultCode_en {
		/** Verification succeeded, which means there's a way to prove the correctness of the signature. */
		KSI_VER_RES_OK = 0x00,
		/** Verification not possible, which means there is not enough data to prove or disprove the correctness of the signature. */
		KSI_VER_RES_NA = 0x01,
		/** Verification failed, which means the signature is definitely invalid or the document does not match with the signature. */
		KSI_VER_RES_FAIL = 0x02,
	} KSI_VerificationResultCode;

	/**
	 * Enumeration of all KSI policy (#KSI_Policy) verification error codes.
	 */
	typedef enum KSI_VerificationErrorCode_en {
		/** No error. */
		KSI_VER_ERR_NONE = 0x00,
		/** Wrong document. */
		KSI_VER_ERR_GEN_1 = 0x101,
		/** Verification inconclusive. */
		KSI_VER_ERR_GEN_2 = 0x102,
		/** Inconsistent aggregation hash chains. */
		KSI_VER_ERR_INT_1 = 0x201,
		/** Inconsistent aggregation hash chain aggregation times. */
		KSI_VER_ERR_INT_2 = 0x202,
		/** Calendar hash chain input hash mismatch. */
		KSI_VER_ERR_INT_3 = 0x203,
		/** Calendar hash chain aggregation time mismatch. */
		KSI_VER_ERR_INT_4 = 0x204,
		/** Calendar hash chain shape inconsistent with aggregation time. */
		KSI_VER_ERR_INT_5 = 0x205,
		/** Calendar hash chain time inconsistent with calendar auth record time. */
		KSI_VER_ERR_INT_6 = 0x206,
		/** Calendar hash chain time inconsistent with publication time. */
		KSI_VER_ERR_INT_7 = 0x207,
		/** Calendar hash chain root hash is inconsistent with calendar auth record input hash. */
		KSI_VER_ERR_INT_8 = 0x208,
		/** Calendar hash chain root hash is inconsistent with published hash value. */
		KSI_VER_ERR_INT_9 = 0x209,
		/** Aggregation hash chain chain index mismatch. */
		KSI_VER_ERR_INT_10 = 0x20a,
		/** The meta-data record in the aggregation hash chain may not be trusted. */
		KSI_VER_ERR_INT_11 = 0x20b,
		/** Extender response calendar root hash mismatch. */
		KSI_VER_ERR_PUB_1 = 0x301,
		/** Extender response inconsistent. */
		KSI_VER_ERR_PUB_2 = 0x302,
		/** Extender response input hash mismatch. */
		KSI_VER_ERR_PUB_3 = 0x303,
		/** Certificate not found. */
		KSI_VER_ERR_KEY_1 = 0x401,
		/** PKI signature not verified with certificate. */
		KSI_VER_ERR_KEY_2 = 0x402,
		/** Calendar root hash mismatch. */
		KSI_VER_ERR_CAL_1 = 0x501,
		/** Aggregation hash chain root hash and calendar hash chain input hash mismatch. */
		KSI_VER_ERR_CAL_2 = 0x502,
		/** Aggregation time mismatch. */
		KSI_VER_ERR_CAL_3 = 0x503,
		/** Aggregation hash chain right links are inconsistent. */
		KSI_VER_ERR_CAL_4 = 0x504,
	} KSI_VerificationErrorCode;

	struct KSI_RuleVerificationResult_st {
		/** The result of the verification. */
		KSI_VerificationResultCode resultCode;<commit_msg>Typo fixed in CAL_04 error message comment.<commit_after>/*
 * Copyright 2013-2016 Guardtime, Inc.
 *
 * This file is part of the Guardtime client SDK.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES, CONDITIONS, OR OTHER LICENSES OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 * "Guardtime" and "KSI" are trademarks or registered trademarks of
 * Guardtime, Inc., and no license to trademarks is granted; Guardtime
 * reserves and retains all trademark rights.
 */

#ifndef POLICY_H
#define	POLICY_H

#include "types.h"
#include "ksi.h"

#ifdef	__cplusplus
extern "C" {
#endif

	struct KSI_VerificationContext_st {
		KSI_CTX *ctx;

		/** Signature being verified. */
		KSI_Signature *signature;

		/** Indicates whether signature extention is allowed (0 means no, and any non-zero is considered to be true). */
		int extendingAllowed;

		/** Initial aggregation level. */
		KSI_uint64_t docAggrLevel;

		/** Document hash to be verified. */
		KSI_DataHash *documentHash;

		/** Publication string to be used. */
		KSI_PublicationData *userPublication;

		/** Publication file to be used. */
		KSI_PublicationsFile *userPublicationsFile;

		void *tempData;
	};

	/**
	 * Enumeration of all KSI policy (#KSI_Policy) verification result codes.
	 */
	typedef enum KSI_VerificationResultCode_en {
		/** Verification succeeded, which means there's a way to prove the correctness of the signature. */
		KSI_VER_RES_OK = 0x00,
		/** Verification not possible, which means there is not enough data to prove or disprove the correctness of the signature. */
		KSI_VER_RES_NA = 0x01,
		/** Verification failed, which means the signature is definitely invalid or the document does not match with the signature. */
		KSI_VER_RES_FAIL = 0x02,
	} KSI_VerificationResultCode;

	/**
	 * Enumeration of all KSI policy (#KSI_Policy) verification error codes.
	 */
	typedef enum KSI_VerificationErrorCode_en {
		/** No error. */
		KSI_VER_ERR_NONE = 0x00,
		/** Wrong document. */
		KSI_VER_ERR_GEN_1 = 0x101,
		/** Verification inconclusive. */
		KSI_VER_ERR_GEN_2 = 0x102,
		/** Inconsistent aggregation hash chains. */
		KSI_VER_ERR_INT_1 = 0x201,
		/** Inconsistent aggregation hash chain aggregation times. */
		KSI_VER_ERR_INT_2 = 0x202,
		/** Calendar hash chain input hash mismatch. */
		KSI_VER_ERR_INT_3 = 0x203,
		/** Calendar hash chain aggregation time mismatch. */
		KSI_VER_ERR_INT_4 = 0x204,
		/** Calendar hash chain shape inconsistent with aggregation time. */
		KSI_VER_ERR_INT_5 = 0x205,
		/** Calendar hash chain time inconsistent with calendar auth record time. */
		KSI_VER_ERR_INT_6 = 0x206,
		/** Calendar hash chain time inconsistent with publication time. */
		KSI_VER_ERR_INT_7 = 0x207,
		/** Calendar hash chain root hash is inconsistent with calendar auth record input hash. */
		KSI_VER_ERR_INT_8 = 0x208,
		/** Calendar hash chain root hash is inconsistent with published hash value. */
		KSI_VER_ERR_INT_9 = 0x209,
		/** Aggregation hash chain chain index mismatch. */
		KSI_VER_ERR_INT_10 = 0x20a,
		/** The meta-data record in the aggregation hash chain may not be trusted. */
		KSI_VER_ERR_INT_11 = 0x20b,
		/** Extender response calendar root hash mismatch. */
		KSI_VER_ERR_PUB_1 = 0x301,
		/** Extender response inconsistent. */
		KSI_VER_ERR_PUB_2 = 0x302,
		/** Extender response input hash mismatch. */
		KSI_VER_ERR_PUB_3 = 0x303,
		/** Certificate not found. */
		KSI_VER_ERR_KEY_1 = 0x401,
		/** PKI signature not verified with certificate. */
		KSI_VER_ERR_KEY_2 = 0x402,
		/** Calendar root hash mismatch. */
		KSI_VER_ERR_CAL_1 = 0x501,
		/** Aggregation hash chain root hash and calendar hash chain input hash mismatch. */
		KSI_VER_ERR_CAL_2 = 0x502,
		/** Aggregation time mismatch. */
		KSI_VER_ERR_CAL_3 = 0x503,
		/** Calendar hash chain right links are inconsistent. */
		KSI_VER_ERR_CAL_4 = 0x504,
	} KSI_VerificationErrorCode;

	struct KSI_RuleVerificationResult_st {
		/** The result of the verification. */
		KSI_VerificationResultCode resultCode;
{'fraction_non_alphanumeric': 0.08638061813653346, 'fraction_numerical': 0.03124646213064644, 'mean_word_length': 3.8326039387308533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2175742', 'n_tokens_mistral': 3183, 'n_tokens_neox': 2727, 'n_words': 947}