{ERR_FUNC(GOST_F_PKEY_GOST_MAC_CTRL), "PKEY_GOST_MAC_CTRL"},
{ERR_FUNC(GOST_F_PKEY_GOST_MAC_CTRL_STR), "PKEY_GOST_MAC_CTRL_STR"},
{ERR_FUNC(GOST_F_PKEY_GOST_MAC_KEYGEN), "PKEY_GOST_MAC_KEYGEN"},
+ {ERR_FUNC(GOST_F_PKEY_GOST_MAC_SIGNCTX_INIT),
+ "PKEY_GOST_MAC_SIGNCTX_INIT"},
{ERR_FUNC(GOST_F_PRINT_GOST_EC_PUB), "PRINT_GOST_EC_PUB"},
{ERR_FUNC(GOST_F_PRIV_DECODE_GOST), "PRIV_DECODE_GOST"},
{ERR_FUNC(GOST_F_PUB_DECODE_GOST_EC), "PUB_DECODE_GOST_EC"},
* The following lines are auto generated by the script mkerr.pl. Any changes
* made after this point may be overwritten when the script is next run.
*/
- void ERR_load_GOST_strings(void);
- void ERR_unload_GOST_strings(void);
- void ERR_GOST_error(int function, int reason, char *file, int line);
+void ERR_load_GOST_strings(void);
+void ERR_unload_GOST_strings(void);
+void ERR_GOST_error(int function, int reason, char *file, int line);
# define GOSTerr(f,r) ERR_GOST_error((f),(r),__FILE__,__LINE__)
/* Error codes for the GOST functions. */
# define GOST_F_PKEY_GOST_MAC_CTRL 123
# define GOST_F_PKEY_GOST_MAC_CTRL_STR 124
# define GOST_F_PKEY_GOST_MAC_KEYGEN 125
+# define GOST_F_PKEY_GOST_MAC_SIGNCTX_INIT 132
# define GOST_F_PRINT_GOST_EC_PUB 126
# define GOST_F_PRIV_DECODE_GOST 127
# define GOST_F_PUB_DECODE_GOST_EC 128
# define GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND 126
# define GOST_R_UNSUPPORTED_PARAMETER_SET 127
-# ifdef __cplusplus
+#ifdef __cplusplus
}
-# endif
+#endif
#endif
struct gost_mac_key {
int mac_param_nid;
unsigned char key[32];
+ short int mac_size;
};
/* GOST-specific ASN1 structures */
struct gost_mac_key *key = EVP_PKEY_get0(pkey);
if (key) {
data->mac_param_nid = key->mac_param_nid;
+ data->mac_size = key->mac_size;
}
}
{
struct gost_cipher_info *param = p2;
data->mac_param_nid = param->nid;
- struct gost_mac_key *key = NULL;
- EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx);
- if (pkey) {
- key = EVP_PKEY_get0(pkey);
- if (key) {
- key->mac_param_nid = param->nid;
- }
- }
return 1;
}
case EVP_PKEY_CTRL_DIGESTINIT:
return 0;
memcpy(keydata->key, data->key, 32);
keydata->mac_param_nid = data->mac_param_nid;
+ keydata->mac_size = data->mac_size;
EVP_PKEY_assign(pkey, mac_nid, keydata);
return 1;
}
static int pkey_gost_mac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
{
+ struct gost_mac_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
+
+ if (data == NULL) {
+ pkey_gost_mac_init(ctx);
+ }
+
+ data = EVP_PKEY_CTX_get_data(ctx);
+ if (!data) {
+ GOSTerr(GOST_F_PKEY_GOST_MAC_SIGNCTX_INIT, GOST_R_MAC_KEY_NOT_SET);
+ return 0;
+ }
+
return 1;
}