优化证书相关的实现

hdrplus
Matthew 1 year ago
parent a6598095bb
commit 34f4c62c1d

@ -833,8 +833,8 @@ Java_com_xypower_mpapp_MicroPhotoService_querySecVersion(
}
extern "C" JNIEXPORT jboolean JNICALL
Java_com_xypower_mpapp_MicroPhotoService_requestCert(
JNIEnv* env, jclass cls, jint type, jint index, jstring subject, jstring outputPath) {
Java_com_xypower_mpapp_MicroPhotoService_genCertRequest(
JNIEnv* env, jclass cls, jint index, jint type, jstring subject, jstring outputPath) {
#ifdef USING_NRSEC
if (env->GetStringUTFLength(subject) <=0 || env->GetStringUTFLength(outputPath) <=0)
@ -852,9 +852,8 @@ Java_com_xypower_mpapp_MicroPhotoService_requestCert(
uint8_t output[1024] = { 0 };
uint16_t len = 0;
const char* subjectStr = env->GetStringUTFChars(subject, 0);
std::string titleStr(subjectStr);
bool res = nrsec.SM2cert(type, index, titleStr, output, &len) == 0;
bool res = nrsec.SM2cert(type, index, MakeString(subjectStr), output, &len) == 0;
nrsec.Close();
env->ReleaseStringUTFChars(subject, subjectStr);
if (!res)
@ -921,7 +920,7 @@ Java_com_xypower_mpapp_MicroPhotoService_exportPublicKeyFile(
#ifdef USING_NRSEC
if (env->GetStringUTFLength(outputPath)<=0)
if (env->GetStringUTFLength(outputPath) <= 0)
{
return JNI_FALSE;
}
@ -934,8 +933,8 @@ Java_com_xypower_mpapp_MicroPhotoService_exportPublicKeyFile(
}
bool res = false;
std::vector<unsigned char> data(64,0);
uint8_t len=0;
std::vector<unsigned char> data(64, 0);
uint8_t len = 0;
res = nrsec.SM2ExportPublicKey(index, &data[0], &len) == 0;
nrsec.Close();
if (!res)
@ -978,8 +977,8 @@ Java_com_xypower_mpapp_MicroPhotoService_exportPrivateFile(
bool res = false;
std::vector<unsigned char> data(64,0);
uint8_t len=0;
res = nrsec.SM2ExportPrivateKey(index, &data[0],&len) == 0;
uint8_t len = 0;
res = nrsec.SM2ExportPrivateKey(index, &data[0], &len) == 0;
nrsec.Close();
if (!res)
{

@ -53,8 +53,11 @@ public class CertActivity extends AppCompatActivity {
int index = intent.getIntExtra("index", 0);
MicroPhotoService.genKeys(index);
} else if (TextUtils.equals(action, ACTION_CERT_REQ)) {
// int index = intent.getIntExtra("index", 0);
// MicroPhotoService.genKeys(index);
int index = intent.getIntExtra("index", 0);
int type = intent.getIntExtra("type", 0);
String subject = intent.getStringExtra("subject");
String path = intent.getStringExtra("path");
MicroPhotoService.genCertRequest(index, type, subject, path);
}
}

@ -1145,7 +1145,7 @@ cellSignalStrengthGsm.getDbm();
public static native boolean genKeys(int index);
public static native String querySecVersion();
public static native boolean requestCert(int type, int index, String subject, String outputPath);
public static native boolean genCertRequest(int index, int type, String subject, String outputPath);
public static native boolean importPrivateKeyFile(int index, String outputPath, String md5);
public static native boolean exportPublicKeyFile(int index, String outputPath);
public static native boolean exportPrivateFile(int index, String outputPath);

Loading…
Cancel
Save