X-Git-Url: http://www.wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_keyexpimp.c;fp=gost_keyexpimp.c;h=e4af4180944cae514cbe334b6b99d85d04c7cea7;hb=fde4a66ddaaf97ee103d02b400fb7f1b79320ac9;hp=b9602002f617c69e2fd5a4f6b87590d25aaa66f2;hpb=a02bb3d2bc3ce93d83bde6efb87ada7f4ea4f0c7;p=openssl-gost%2Fengine.git diff --git a/gost_keyexpimp.c b/gost_keyexpimp.c index b960200..e4af418 100644 --- a/gost_keyexpimp.c +++ b/gost_keyexpimp.c @@ -46,6 +46,11 @@ int gost_kexp15(const unsigned char *shared_key, const int shared_len, goto err; } + if (shared_len + mac_len > (unsigned int)(*out_len)) { + GOSTerr(GOST_F_GOST_KEXP15, ERR_R_INTERNAL_ERROR); + goto err; + } + /* we expect IV of half length */ memset(iv_full, 0, 16); memcpy(iv_full, iv, ivlen); @@ -123,6 +128,16 @@ int gost_kimp15(const unsigned char *expkey, const size_t expkeylen, goto err; } + if (expkeylen > sizeof(out)) { + GOSTerr(GOST_F_GOST_KIMP15, ERR_R_INTERNAL_ERROR); + goto err; + } + + if (ivlen > 16) { + GOSTerr(GOST_F_GOST_KIMP15, ERR_R_INTERNAL_ERROR); + goto err; + } + /* we expect IV of half length */ memset(iv_full, 0, 16); memcpy(iv_full, iv, ivlen);