提交 930e0310 编写于 作者: B Bernd Edlinger

Do the error handling in pkey_rsa_decrypt in constant time

Reviewed-by: NKurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/8365)

(cherry picked from commit 049e64cbb08df1fbf256bb79e950e8d0959de091)
上级 25e410ee
/* /*
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved. * Copyright 2006-2019 The OpenSSL Project Authors. All Rights Reserved.
* *
* Licensed under the OpenSSL license (the "License"). You may not use * Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy * this file except in compliance with the License. You can obtain a copy
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#include "internal/constant_time_locl.h"
#include <stdio.h> #include <stdio.h>
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
...@@ -340,10 +342,9 @@ static int pkey_rsa_decrypt(EVP_PKEY_CTX *ctx, ...@@ -340,10 +342,9 @@ static int pkey_rsa_decrypt(EVP_PKEY_CTX *ctx,
ret = RSA_private_decrypt(inlen, in, out, ctx->pkey->pkey.rsa, ret = RSA_private_decrypt(inlen, in, out, ctx->pkey->pkey.rsa,
rctx->pad_mode); rctx->pad_mode);
} }
if (ret < 0) *outlen = constant_time_select_s(constant_time_msb_s(ret), *outlen, ret);
return ret; ret = constant_time_select_int(constant_time_msb(ret), ret, 1);
*outlen = ret; return ret;
return 1;
} }
static int check_padding_md(const EVP_MD *md, int padding) static int check_padding_md(const EVP_MD *md, int padding)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册