summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/gost/gost89imit_pmeth.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/gost/gost89imit_pmeth.c')
-rw-r--r--src/lib/libcrypto/gost/gost89imit_pmeth.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/lib/libcrypto/gost/gost89imit_pmeth.c b/src/lib/libcrypto/gost/gost89imit_pmeth.c
index 00eaf1decc..1959b36163 100644
--- a/src/lib/libcrypto/gost/gost89imit_pmeth.c
+++ b/src/lib/libcrypto/gost/gost89imit_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: gost89imit_pmeth.c,v 1.3 2014/11/13 20:29:55 miod Exp $ */ 1/* $OpenBSD: gost89imit_pmeth.c,v 1.4 2017/01/29 17:49:23 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> 3 * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
4 * Copyright (c) 2005-2006 Cryptocom LTD 4 * Copyright (c) 2005-2006 Cryptocom LTD
@@ -110,13 +110,13 @@ pkey_gost_mac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
110 unsigned char *keydata; 110 unsigned char *keydata;
111 111
112 if (!data->key_set) { 112 if (!data->key_set) {
113 GOSTerr(GOST_F_PKEY_GOST_MAC_KEYGEN, GOST_R_MAC_KEY_NOT_SET); 113 GOSTerror(GOST_R_MAC_KEY_NOT_SET);
114 return 0; 114 return 0;
115 } 115 }
116 116
117 keydata = malloc(32); 117 keydata = malloc(32);
118 if (keydata == NULL) { 118 if (keydata == NULL) {
119 GOSTerr(GOST_F_PKEY_GOST_MAC_KEYGEN, ERR_R_MALLOC_FAILURE); 119 GOSTerror(ERR_R_MALLOC_FAILURE);
120 return 0; 120 return 0;
121 } 121 }
122 memcpy(keydata, data->key, 32); 122 memcpy(keydata, data->key, 32);
@@ -133,8 +133,7 @@ pkey_gost_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
133 switch (type) { 133 switch (type) {
134 case EVP_PKEY_CTRL_MD: 134 case EVP_PKEY_CTRL_MD:
135 if (EVP_MD_type(p2) != NID_id_Gost28147_89_MAC) { 135 if (EVP_MD_type(p2) != NID_id_Gost28147_89_MAC) {
136 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL, 136 GOSTerror(GOST_R_INVALID_DIGEST_TYPE);
137 GOST_R_INVALID_DIGEST_TYPE);
138 return 0; 137 return 0;
139 } 138 }
140 data->md = p2; 139 data->md = p2;
@@ -142,8 +141,7 @@ pkey_gost_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
142 141
143 case EVP_PKEY_CTRL_SET_MAC_KEY: 142 case EVP_PKEY_CTRL_SET_MAC_KEY:
144 if (p1 != 32) { 143 if (p1 != 32) {
145 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL, 144 GOSTerror(GOST_R_INVALID_MAC_KEY_LENGTH);
146 GOST_R_INVALID_MAC_KEY_LENGTH);
147 return 0; 145 return 0;
148 } 146 }
149 147
@@ -159,14 +157,12 @@ pkey_gost_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
159 if (!data->key_set) { 157 if (!data->key_set) {
160 EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx); 158 EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx);
161 if (pkey == NULL) { 159 if (pkey == NULL) {
162 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL, 160 GOSTerror(GOST_R_MAC_KEY_NOT_SET);
163 GOST_R_MAC_KEY_NOT_SET);
164 return 0; 161 return 0;
165 } 162 }
166 key = EVP_PKEY_get0(pkey); 163 key = EVP_PKEY_get0(pkey);
167 if (key == NULL) { 164 if (key == NULL) {
168 GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL, 165 GOSTerror(GOST_R_MAC_KEY_NOT_SET);
169 GOST_R_MAC_KEY_NOT_SET);
170 return 0; 166 return 0;
171 } 167 }
172 } else { 168 } else {