#ifndef __OPENSSL_UTILS_H__
#define __OPENSSL_UTILS_H__

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>

struct x509_st;

typedef struct x509_list
{
    struct x509_st* items[10];
    int count;
}x509_list_t;

void free_X509Certs_list(x509_list_t *chain);

void append_X509Certs_fromFile(x509_list_t *chain, const char* filename);

void append_X509SubCert_fromString(x509_list_t *chain, const uint8_t* subStream, int length);

struct x509_st* load_X509Cert_fromString(const uint8_t* stream, int length);

int verify_X509Certs_withV2GMO(struct x509_st* cert, x509_list_t* subCerts, const char* root_cert_path_v2g, const char* root_cert_path_mo);

const uint8_t *get_EMAID_fromX509Cert(struct x509_st* cert);

EVP_PKEY* get_PublicKey_fromX509Cert(struct x509_st* cert);

int verify_Signature_UsePKEY(EVP_PKEY* pkey, const uint8_t* r, const uint8_t* s, const uint8_t* digest);

#endif//__OPENSSL_UTILS_H__
