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

34 lines
879 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 str_t *cert_thumbprint;
const str_t *password;
} cryptopro_context_t;
static inline void
cryptopro_context_set(cryptopro_context_t *ctx, const str_t *cert_thumbprint, const str_t *password)
{
assert(ctx != NULL);
ctx->cert_thumbprint = cert_thumbprint;
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);
int cryptopro_gen_random(unsigned char* data, size_t len);
#endif // CRYPTOPRO_H_INCLUDED