ervu-sign-module/src/utils/cryptopro.h

32 lines
782 B
C

#ifndef CRYPTOPRO_H_INCLUDED
#define CRYPTOPRO_H_INCLUDED
#include "str_t.h"
#include <assert.h>
#include <stdbool.h>
typedef struct cryptopro_context_s {
const char *signer;
const str_t *password;
} cryptopro_context_t;
static inline void
cryptopro_context_set(cryptopro_context_t *ctx, const char *signer, const str_t *password)
{
assert(ctx != NULL);
ctx->signer = signer;
ctx->password = password;
}
bool cryptopro_init(const char* cp_file);
int cryptopro_sign(const cryptopro_context_t *ctx, const str_t *data, /*out*/ str_t *sign);
int cryptopro_verify(const str_t* cert_thumbprint, const str_t* alg, const str_t *data,
const str_t *sign, bool* is_verified, char** verify_error);
#endif // CRYPTOPRO_H_INCLUDED