代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/openjdk-1.8.0 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
commit ab97dd8f89c5a3ce17b9d90bc8ae2e407c450012
Author: Noah <hedongbo@huawei.com>
Date: Wed May 19 09:38:34 2021 +0800
I3RWVC: Add kaeEngine to rsa
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_cipher_rsa.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_cipher_rsa.c
index 3fbacf77..cbab7bdb 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_cipher_rsa.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_cipher_rsa.c
@@ -28,6 +28,8 @@
#include "kae_exception.h"
#include "org_openeuler_security_openssl_KAERSACipher.h"
+static ENGINE* kaeEngine = NULL;
+
typedef int RSACryptOperation(int, const unsigned char*, unsigned char*, RSA*, int);
typedef int EvpPkeyCryptOperation(EVP_PKEY_CTX*, unsigned char*, size_t*, const unsigned char*, size_t);
@@ -171,12 +173,13 @@ static int RSACryptOAEPPadding(JNIEnv* env, jlong keyAddress, jint inLen, jbyteA
// outLen type should be size_t
// EVP_PKEY_encrypt takes the outLen address as a parameter, and the parameter type is size_t*
size_t outLen = 0;
+ kaeEngine = (kaeEngine == NULL) ? GetKaeEngine() : kaeEngine;
EVP_PKEY* pkey = (EVP_PKEY*) keyAddress;
// new ctx
// rsa encrypt/decrypt init
- if ((pkeyCtx = EVP_PKEY_CTX_new(pkey, NULL)) == NULL || cryptInitOperation(pkeyCtx) <= 0) {
+ if ((pkeyCtx = EVP_PKEY_CTX_new(pkey, kaeEngine)) == NULL || cryptInitOperation(pkeyCtx) <= 0) {
KAE_ThrowFromOpenssl(env, pkeyCtx == NULL ? "EVP_PKEY_CTX_new" : cryptInitName, KAE_ThrowInvalidKeyException);
goto cleanup;
}
@@ -192,8 +195,7 @@ static int RSACryptOAEPPadding(JNIEnv* env, jlong keyAddress, jint inLen, jbyteA
* set rsa mgf1 md
* set rsa oaep md
*/
- if(!SetRSAPadding(env, pkeyCtx, paddingType) ||
- !SetRSAMgf1Md(env, pkeyCtx, mgf1MdAlgoUTF) ||
+ if(!SetRSAPadding(env, pkeyCtx, paddingType) || !SetRSAMgf1Md(env, pkeyCtx, mgf1MdAlgoUTF) ||
!SetRSAOaepMd(env, pkeyCtx, oaepMdAlgoUTF)) {
goto cleanup;
}
@@ -267,6 +269,7 @@ JNIEXPORT jlong JNICALL Java_org_openeuler_security_openssl_KAERSACipher_nativeC
BIGNUM* bnIQMP = NULL;
RSA* rsa = NULL;
EVP_PKEY* pkey = NULL;
+ kaeEngine = (kaeEngine == NULL) ? GetKaeEngine() : kaeEngine;
// convert to big num
if ((bnN = KAE_GetBigNumFromByteArray(env, n)) == NULL ||
@@ -288,9 +291,9 @@ JNIEXPORT jlong JNICALL Java_org_openeuler_security_openssl_KAERSACipher_nativeC
}
// new rsa
- rsa = RSA_new();
+ rsa = RSA_new_method(kaeEngine);
if (rsa == NULL) {
- KAE_ThrowFromOpenssl(env, "RSA_new", KAE_ThrowRuntimeException);
+ KAE_ThrowFromOpenssl(env, "RSA_new_method", KAE_ThrowRuntimeException);
goto cleanup;
}
@@ -328,6 +331,7 @@ JNIEXPORT jlong JNICALL Java_org_openeuler_security_openssl_KAERSACipher_nativeC
BIGNUM* bnE = NULL;
RSA* rsa = NULL;
EVP_PKEY* pkey = NULL;
+ kaeEngine = (kaeEngine == NULL) ? GetKaeEngine() : kaeEngine;
// get public key param n
bnN = KAE_GetBigNumFromByteArray(env, n);
@@ -341,10 +345,10 @@ JNIEXPORT jlong JNICALL Java_org_openeuler_security_openssl_KAERSACipher_nativeC
goto cleanup;
}
- // new RSA
- rsa = RSA_new();
+ // new rsa
+ rsa = RSA_new_method(kaeEngine);
if (rsa == NULL) {
- KAE_ThrowFromOpenssl(env, "RSA_new", KAE_ThrowRuntimeException);
+ KAE_ThrowFromOpenssl(env, "RSA_new_method", KAE_ThrowRuntimeException);
goto cleanup;
}
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_rsa.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_rsa.c
index ddbc2958..de724593 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_rsa.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_keypairgenerator_rsa.c
@@ -65,10 +65,12 @@ static const BIGNUM* (* GetRSAParamFunctionList[])(const RSA*) = {
* step 3.Generate rsa key, and all key information is stored in RSA
*/
static RSA* NewRSA(JNIEnv* env, jint keySize, jbyteArray publicExponent) {
- // RSA_new
- RSA* rsa = RSA_new();
+ static ENGINE* kaeEngine = NULL;
+ kaeEngine = (kaeEngine == NULL) ? GetKaeEngine() : kaeEngine;
+ // new rsa
+ RSA* rsa = RSA_new_method(kaeEngine);
if (rsa == NULL) {
- KAE_ThrowFromOpenssl(env, "RSA_new", KAE_ThrowRuntimeException);
+ KAE_ThrowFromOpenssl(env, "RSA_new_method", KAE_ThrowRuntimeException);
return NULL;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。