1*de0e0e4dSAntonio Huete Jimenez /* $OpenBSD: m_gostr341194.c,v 1.4 2022/01/14 08:38:05 tb Exp $ */
2f5b1c8a1SJohn Marino /*
3f5b1c8a1SJohn Marino  * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
4f5b1c8a1SJohn Marino  * Copyright (c) 2005-2006 Cryptocom LTD
5f5b1c8a1SJohn Marino  *
6f5b1c8a1SJohn Marino  * Redistribution and use in source and binary forms, with or without
7f5b1c8a1SJohn Marino  * modification, are permitted provided that the following conditions
8f5b1c8a1SJohn Marino  * are met:
9f5b1c8a1SJohn Marino  *
10f5b1c8a1SJohn Marino  * 1. Redistributions of source code must retain the above copyright
11f5b1c8a1SJohn Marino  *    notice, this list of conditions and the following disclaimer.
12f5b1c8a1SJohn Marino  *
13f5b1c8a1SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
14f5b1c8a1SJohn Marino  *    notice, this list of conditions and the following disclaimer in
15f5b1c8a1SJohn Marino  *    the documentation and/or other materials provided with the
16f5b1c8a1SJohn Marino  *    distribution.
17f5b1c8a1SJohn Marino  *
18f5b1c8a1SJohn Marino  * 3. All advertising materials mentioning features or use of this
19f5b1c8a1SJohn Marino  *    software must display the following acknowledgment:
20f5b1c8a1SJohn Marino  *    "This product includes software developed by the OpenSSL Project
21f5b1c8a1SJohn Marino  *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
22f5b1c8a1SJohn Marino  *
23f5b1c8a1SJohn Marino  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
24f5b1c8a1SJohn Marino  *    endorse or promote products derived from this software without
25f5b1c8a1SJohn Marino  *    prior written permission. For written permission, please contact
26f5b1c8a1SJohn Marino  *    openssl-core@openssl.org.
27f5b1c8a1SJohn Marino  *
28f5b1c8a1SJohn Marino  * 5. Products derived from this software may not be called "OpenSSL"
29f5b1c8a1SJohn Marino  *    nor may "OpenSSL" appear in their names without prior written
30f5b1c8a1SJohn Marino  *    permission of the OpenSSL Project.
31f5b1c8a1SJohn Marino  *
32f5b1c8a1SJohn Marino  * 6. Redistributions of any form whatsoever must retain the following
33f5b1c8a1SJohn Marino  *    acknowledgment:
34f5b1c8a1SJohn Marino  *    "This product includes software developed by the OpenSSL Project
35f5b1c8a1SJohn Marino  *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
36f5b1c8a1SJohn Marino  *
37f5b1c8a1SJohn Marino  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
38f5b1c8a1SJohn Marino  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39f5b1c8a1SJohn Marino  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40f5b1c8a1SJohn Marino  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
41f5b1c8a1SJohn Marino  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42f5b1c8a1SJohn Marino  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43f5b1c8a1SJohn Marino  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44f5b1c8a1SJohn Marino  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45f5b1c8a1SJohn Marino  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46f5b1c8a1SJohn Marino  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47f5b1c8a1SJohn Marino  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48f5b1c8a1SJohn Marino  * OF THE POSSIBILITY OF SUCH DAMAGE.
49f5b1c8a1SJohn Marino  * ====================================================================
50f5b1c8a1SJohn Marino  */
51*de0e0e4dSAntonio Huete Jimenez 
52f5b1c8a1SJohn Marino #include <stdio.h>
53f5b1c8a1SJohn Marino 
54f5b1c8a1SJohn Marino #include <openssl/opensslconf.h>
55f5b1c8a1SJohn Marino 
56f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_GOST
57f5b1c8a1SJohn Marino 
58f5b1c8a1SJohn Marino #include <openssl/evp.h>
59f5b1c8a1SJohn Marino #include <openssl/gost.h>
60f5b1c8a1SJohn Marino #include <openssl/objects.h>
61f5b1c8a1SJohn Marino 
62*de0e0e4dSAntonio Huete Jimenez #include "evp_locl.h"
63*de0e0e4dSAntonio Huete Jimenez 
64f5b1c8a1SJohn Marino static int
gostr341194_init(EVP_MD_CTX * ctx)65f5b1c8a1SJohn Marino gostr341194_init(EVP_MD_CTX *ctx)
66f5b1c8a1SJohn Marino {
67f5b1c8a1SJohn Marino 	return GOSTR341194_Init(ctx->md_data,
68f5b1c8a1SJohn Marino 	    NID_id_GostR3411_94_CryptoProParamSet);
69f5b1c8a1SJohn Marino }
70f5b1c8a1SJohn Marino 
71f5b1c8a1SJohn Marino static int
gostr341194_update(EVP_MD_CTX * ctx,const void * data,size_t count)72f5b1c8a1SJohn Marino gostr341194_update(EVP_MD_CTX *ctx, const void *data, size_t count)
73f5b1c8a1SJohn Marino {
74f5b1c8a1SJohn Marino 	return GOSTR341194_Update(ctx->md_data, data, count);
75f5b1c8a1SJohn Marino }
76f5b1c8a1SJohn Marino 
77f5b1c8a1SJohn Marino static int
gostr341194_final(EVP_MD_CTX * ctx,unsigned char * md)78f5b1c8a1SJohn Marino gostr341194_final(EVP_MD_CTX *ctx, unsigned char *md)
79f5b1c8a1SJohn Marino {
80f5b1c8a1SJohn Marino 	return GOSTR341194_Final(md, ctx->md_data);
81f5b1c8a1SJohn Marino }
82f5b1c8a1SJohn Marino 
83f5b1c8a1SJohn Marino static const EVP_MD gostr341194_md = {
84f5b1c8a1SJohn Marino 	.type = NID_id_GostR3411_94,
85f5b1c8a1SJohn Marino 	.pkey_type = NID_undef,
86f5b1c8a1SJohn Marino 	.md_size = GOSTR341194_LENGTH,
87*de0e0e4dSAntonio Huete Jimenez 	.flags = 0,
88f5b1c8a1SJohn Marino 	.init = gostr341194_init,
89f5b1c8a1SJohn Marino 	.update = gostr341194_update,
90f5b1c8a1SJohn Marino 	.final = gostr341194_final,
91f5b1c8a1SJohn Marino 	.block_size = GOSTR341194_CBLOCK,
92f5b1c8a1SJohn Marino 	.ctx_size = sizeof(EVP_MD *) + sizeof(GOSTR341194_CTX),
93f5b1c8a1SJohn Marino };
94f5b1c8a1SJohn Marino 
95f5b1c8a1SJohn Marino const EVP_MD *
EVP_gostr341194(void)96f5b1c8a1SJohn Marino EVP_gostr341194(void)
97f5b1c8a1SJohn Marino {
98f5b1c8a1SJohn Marino 	return (&gostr341194_md);
99f5b1c8a1SJohn Marino }
100f5b1c8a1SJohn Marino #endif
101