2 * Copyright (c) 2020 Dmitry Belyavskiy <beldmit@gmail.com>
4 * Contents licensed under the terms of the OpenSSL license
5 * See https://www.openssl.org/source/license.html for details
7 #ifndef GOST_GOST2015_H
8 #define GOST_GOST2015_H
10 #include <openssl/evp.h>
11 #include <openssl/x509.h>
13 #define MAGMA_MAC_MAX_SIZE 8
14 #define KUZNYECHIK_MAC_MAX_SIZE 16
15 #define OID_GOST_CMS_MAC "1.2.643.7.1.0.6.1.1"
17 int gost2015_final_call(EVP_CIPHER_CTX *ctx, EVP_MD_CTX *omac_ctx, size_t mac_size,
18 unsigned char *encrypted_mac,
19 int (*do_cipher) (EVP_CIPHER_CTX *ctx,
21 const unsigned char *in,
24 /* IV is expected to be 16 bytes*/
25 int gost2015_get_asn1_params(const ASN1_TYPE *params, size_t ukm_size,
26 unsigned char *iv, size_t ukm_offset, unsigned char *kdf_seed);
28 int gost2015_set_asn1_params(ASN1_TYPE *params,
29 const unsigned char *iv, size_t iv_size, const unsigned char *kdf_seed);
31 int gost2015_process_unprotected_attributes(STACK_OF(X509_ATTRIBUTE) *attrs,
32 int encryption, size_t mac_len, unsigned char *final_tag);
34 int gost2015_acpkm_omac_init(int nid, int enc, const unsigned char *inkey,
36 unsigned char *outkey, unsigned char *kdf_seed);
37 int init_zero_kdf_seed(unsigned char *kdf_seed);