summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/e_gost2814789.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/e_gost2814789.c')
-rw-r--r--src/lib/libcrypto/evp/e_gost2814789.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/lib/libcrypto/evp/e_gost2814789.c b/src/lib/libcrypto/evp/e_gost2814789.c
index e2235a64b5..730de4fed1 100644
--- a/src/lib/libcrypto/evp/e_gost2814789.c
+++ b/src/lib/libcrypto/evp/e_gost2814789.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_gost2814789.c,v 1.3 2014/11/18 05:30:07 miod Exp $ */ 1/* $OpenBSD: e_gost2814789.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
@@ -107,13 +107,12 @@ gost2814789_set_asn1_params(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)
107 GOST_CIPHER_PARAMS *gcp = GOST_CIPHER_PARAMS_new(); 107 GOST_CIPHER_PARAMS *gcp = GOST_CIPHER_PARAMS_new();
108 108
109 if (gcp == NULL) { 109 if (gcp == NULL) {
110 GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, 110 GOSTerror(ERR_R_MALLOC_FAILURE);
111 ERR_R_MALLOC_FAILURE);
112 return 0; 111 return 0;
113 } 112 }
114 if (ASN1_OCTET_STRING_set(gcp->iv, ctx->iv, ctx->cipher->iv_len) == 0) { 113 if (ASN1_OCTET_STRING_set(gcp->iv, ctx->iv, ctx->cipher->iv_len) == 0) {
115 GOST_CIPHER_PARAMS_free(gcp); 114 GOST_CIPHER_PARAMS_free(gcp);
116 GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, ERR_R_ASN1_LIB); 115 GOSTerror(ERR_R_ASN1_LIB);
117 return 0; 116 return 0;
118 } 117 }
119 ASN1_OBJECT_free(gcp->enc_param_set); 118 ASN1_OBJECT_free(gcp->enc_param_set);
@@ -123,8 +122,7 @@ gost2814789_set_asn1_params(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)
123 p = buf = malloc(len); 122 p = buf = malloc(len);
124 if (buf == NULL) { 123 if (buf == NULL) {
125 GOST_CIPHER_PARAMS_free(gcp); 124 GOST_CIPHER_PARAMS_free(gcp);
126 GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, 125 GOSTerror(ERR_R_MALLOC_FAILURE);
127 ERR_R_MALLOC_FAILURE);
128 return 0; 126 return 0;
129 } 127 }
130 i2d_GOST_CIPHER_PARAMS(gcp, &p); 128 i2d_GOST_CIPHER_PARAMS(gcp, &p);
@@ -133,14 +131,13 @@ gost2814789_set_asn1_params(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)
133 os = ASN1_OCTET_STRING_new(); 131 os = ASN1_OCTET_STRING_new();
134 if (os == NULL) { 132 if (os == NULL) {
135 free(buf); 133 free(buf);
136 GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, 134 GOSTerror(ERR_R_MALLOC_FAILURE);
137 ERR_R_MALLOC_FAILURE);
138 return 0; 135 return 0;
139 } 136 }
140 if (ASN1_OCTET_STRING_set(os, buf, len) == 0) { 137 if (ASN1_OCTET_STRING_set(os, buf, len) == 0) {
141 ASN1_OCTET_STRING_free(os); 138 ASN1_OCTET_STRING_free(os);
142 free(buf); 139 free(buf);
143 GOSTerr(GOST_F_GOST89_SET_ASN1_PARAMETERS, ERR_R_ASN1_LIB); 140 GOSTerror(ERR_R_ASN1_LIB);
144 return 0; 141 return 0;
145 } 142 }
146 free(buf); 143 free(buf);
@@ -169,8 +166,7 @@ gost2814789_get_asn1_params(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)
169 len = gcp->iv->length; 166 len = gcp->iv->length;
170 if (len != ctx->cipher->iv_len) { 167 if (len != ctx->cipher->iv_len) {
171 GOST_CIPHER_PARAMS_free(gcp); 168 GOST_CIPHER_PARAMS_free(gcp);
172 GOSTerr(GOST_F_GOST89_GET_ASN1_PARAMETERS, 169 GOSTerror(GOST_R_INVALID_IV_LENGTH);
173 GOST_R_INVALID_IV_LENGTH);
174 return -1; 170 return -1;
175 } 171 }
176 172