1 /**********************************************************************
3 * Copyright (c) 2005-2006 Cryptocom LTD *
4 * This file is distributed under the same license as OpenSSL *
6 * OpenSSL interface to GOST R 34.11-94 hash functions *
7 * Requires OpenSSL 0.9.9 for compilation *
8 **********************************************************************/
12 #include "e_gost_err.h"
14 /* implementation of GOST 34.11 hash function See gost_md.c*/
15 static int gost_digest_init(EVP_MD_CTX *ctx);
16 static int gost_digest_update(EVP_MD_CTX *ctx, const void *data, size_t count);
17 static int gost_digest_final(EVP_MD_CTX *ctx,unsigned char *md);
18 static int gost_digest_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from);
19 static int gost_digest_cleanup(EVP_MD_CTX *ctx);
26 EVP_MD_FLAG_PKEY_METHOD_SIGNATURE,
34 {NID_undef,NID_undef,0,0,0},
36 sizeof(struct ossl_gost_digest_ctx ),
40 int gost_digest_init(EVP_MD_CTX *ctx)
42 struct ossl_gost_digest_ctx *c = ctx->md_data;
43 memset(&(c->dctx),0,sizeof(gost_hash_ctx));
44 gost_init(&(c->cctx),&GostR3411_94_CryptoProParamSet);
45 c->dctx.cipher_ctx= &(c->cctx);
49 int gost_digest_update(EVP_MD_CTX *ctx,const void *data,size_t count)
51 return hash_block((gost_hash_ctx *)ctx->md_data,data,count);
54 int gost_digest_final(EVP_MD_CTX *ctx,unsigned char *md)
56 return finish_hash((gost_hash_ctx *)ctx->md_data,md);
60 int gost_digest_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
62 struct ossl_gost_digest_ctx *md_ctx=to->md_data;
63 if (to->md_data && from->md_data) {
64 memcpy(to->md_data,from->md_data,sizeof(struct ossl_gost_digest_ctx));
65 md_ctx->dctx.cipher_ctx=&(md_ctx->cctx);
70 int gost_digest_cleanup(EVP_MD_CTX *ctx)
73 memset(ctx->md_data,0,sizeof(struct ossl_gost_digest_ctx));