/*
 * PV error related definitions and functions
 *
 * Copyright IBM Corp. 2020
 *
 * s390-tools is free software; you can redistribute it and/or modify
 * it under the terms of the MIT license. See LICENSE for details.
 */

#ifndef PV_ERROR_H
#define PV_ERROR_H

#include <glib.h>

GQuark pv_error_quark(void);
GQuark pv_parse_error_quark(void);
GQuark pv_component_error_quark(void);
GQuark pv_crypto_error_quark(void);
GQuark pv_image_error_quark(void);

#define PV_ERROR	   pv_error_quark()
#define PV_PARSE_ERROR	   pv_parse_error_quark()
#define PV_CRYPTO_ERROR	   pv_crypto_error_quark()
#define PV_COMPONENT_ERROR pv_component_error_quark()
#define PV_IMAGE_ERROR	   pv_image_error_quark()

typedef enum {
	PV_ERROR_IPIB_SIZE,
	PV_ERROR_PV_HDR_SIZE,
	PV_ERROR_INTERNAL,
	PV_ERROR_CURL_INIT_FAILED,
	PV_ERROR_DOWNLOAD_FAILED,
} PvErrors;

typedef enum {
	PV_PARSE_ERROR_OK = 0,
	PV_PARSE_ERROR_SYNTAX,
	PR_PARSE_ERROR_INVALID_ARGUMENT,
	PR_PARSE_ERROR_MISSING_ARGUMENT,
} PvParseErrors;

typedef enum {
	PV_COMPONENT_ERROR_UNALIGNED,
	PV_COMPONENT_ERROR_FINALIZED,
} PvComponentErrors;

typedef enum {
	PV_IMAGE_ERROR_OFFSET,
	PV_IMAGE_ERROR_FINALIZED,
} PvImageErrors;

typedef enum {
	PV_CRYPTO_ERROR_VERIFICATION,
	PV_CRYPTO_ERROR_INIT,
	PV_CRYPTO_ERROR_READ_CERTIFICATE,
	PV_CRYPTO_ERROR_INTERNAL,
	PV_CRYPTO_ERROR_DERIVE,
	PV_CRYPTO_ERROR_KEYGENERATION,
	PV_CRYPTO_ERROR_RANDOMIZATION,
	PV_CRYPTO_ERROR_INVALID_PARM,
	PV_CRYPTO_ERROR_INVALID_KEY_SIZE,
	PV_CRYPTO_ERROR_INVALID_VALIDITY_PERIOD,
	PV_CRYPTO_ERROR_EXPIRED,
	PV_CRYPTO_ERROR_NOT_VALID_YET,
	PV_CRYPTO_ERROR_LOAD_CRL,
	PV_CRYPTO_ERROR_NO_PUBLIC_KEY,
	PV_CRYPTO_ERROR_INVALID_SIGNATURE_ALGORITHM,
	PV_CRYPTO_ERROR_SIGNATURE_ALGORITHM_MISMATCH,
	PV_CRYPTO_ERROR_INVALID_URI,
	PV_CRYPTO_ERROR_CRL_DOWNLOAD_FAILED,
	PV_CRYPTO_ERROR_CERT_SIGNATURE_INVALID,
	PV_CRYPTO_ERROR_CRL_SIGNATURE_INVALID,
	PV_CRYPTO_ERROR_CERT_SUBJECT_ISSUER_MISMATCH,
	PV_CRYPTO_ERROR_CRL_SUBJECT_ISSUER_MISMATCH,
	PV_CRYPTO_ERROR_NO_IBM_Z_SIGNING_KEY,
	PV_CRYPTO_ERROR_MALFORMED_CERTIFICATE,
	PV_CRYPTO_ERROR_NO_CRL,
	PV_CRYPTO_ERROR_LOAD_ROOT_CA,
	PV_CRYPTO_ERROR_LOAD_DEFAULT_CA,
	PV_CRYPTO_ERROR_MALFORMED_ROOT_CA,
	PV_CRYPTO_ERROR_WRONG_CA_USED,
	PV_CRYPTO_ERROR_SKID_AKID_MISMATCH,
	PV_CRYPTO_ERROR_NO_ISSUER_IBM_Z_FOUND,
	PV_CRYPTO_ERROR_FAILED_DOWNLOAD_CRL,
	PV_CRYPTO_ERROR_NO_CRLDP,
	PV_CRYPTO_ERROR_CERT_REVOKED,
} PvCryptoErrors;

#endif
