提交 6450ea27 编写于 作者: T Tomas Mraz 提交者: Pauli

DES_set_key(): return values as DES_set_key_checked() but always set

This avoids using accidentally uninitialized key schedule in
applications that use DES_set_key() not expecting it to check the key
which is the default on OpenSSL <= 1.1.1

Fixes #16859
Reviewed-by: NMatt Caswell <matt@openssl.org>
Reviewed-by: NPaul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16944)
上级 af5e63e1
...@@ -279,9 +279,17 @@ static const DES_LONG des_skb[8][64] = { ...@@ -279,9 +279,17 @@ static const DES_LONG des_skb[8][64] = {
} }
}; };
/* Return values as DES_set_key_checked() but always set the key */
int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule) int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule)
{ {
return DES_set_key_checked(key, schedule); int ret = 0;
if (!DES_check_key_parity(key))
ret = -1;
if (DES_is_weak_key(key))
ret = -2;
DES_set_key_unchecked(key, schedule);
return ret;
} }
/*- /*-
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册