diff --git a/Openssl/sign/sm2withsm3/CMakeLists.txt b/Openssl/sign/sm2withsm3/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..06757b69c3dbdabbe2ed8239f72eaa5500c600c4 --- /dev/null +++ b/Openssl/sign/sm2withsm3/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required (VERSION 3.5 FATAL_ERROR) +project(Test) + +# 一般当前目录设置为直接包含目录 + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +# 添加外部库的头文件目录 +include_directories( + /home/arv000/openssl/include +) +link_directories(/home/arv000/openssl/lib64) + +# 生成可执行程序 +add_executable(Test main.cc) + +# 链接QT使用的库文件 +target_link_libraries (Test libcrypto.a libssl.a pthread dl) + diff --git a/Openssl/sign/sm2withsm3/main.cc b/Openssl/sign/sm2withsm3/main.cc new file mode 100644 index 0000000000000000000000000000000000000000..686f128db2645f72d23fc4398a90b58c792775c9 --- /dev/null +++ b/Openssl/sign/sm2withsm3/main.cc @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include +#include +#include +#include +int main(void) +{ + EVP_MD_CTX *cmd_ctx = EVP_MD_CTX_new(); + EVP_PKEY_CTX* pctx = nullptr; // Owned by |ctx|. + const char* filePath = "/media/arv000/c19ee280-30c9-43bc-a890-05e8c96984bc/00-work/01-bug/证书验证问题/国密SM2服务器根证书V3_client.pem"; + const char* signature_value_bytes_filePath = "/home/arv000/signature_value_bytes.der"; + const char* signed_data_filePath = "/home/arv000/signed_data.der"; + const EVP_MD *digest = EVP_sm3(); + // 读取公钥 + FILE* file = fopen(filePath, "rb"); + if(nullptr == file){ + printf("public_key opens is failed ;\r\n"); + } + EVP_PKEY* public_key = PEM_read_PUBKEY(file, nullptr,nullptr,nullptr); + if(nullptr == public_key){ + printf("public_key is null ;\r\n"); + } + fclose(file); + + // 读取签名内容 + FILE* file2 = fopen(signature_value_bytes_filePath, "rb"); + // 获取文件大小 + fseek(file2, 0, SEEK_END); + long signature_value_bytes_length = ftell(file2); + fseek(file2, 0, SEEK_SET); + char* signature_value_bytes = (char*)malloc(signature_value_bytes_length); + memset(signature_value_bytes,0,signature_value_bytes_length); + fread(signature_value_bytes, 1, signature_value_bytes_length, file2); + fclose(file2); + // 读取签名值内容 + + FILE* file3 = fopen(signed_data_filePath, "rb"); + // 获取文件大小 + fseek(file3, 0, SEEK_END); + long signed_data_length = ftell(file3); + fseek(file3, 0, SEEK_SET); + char* signed_data = (char*)malloc(signed_data_length); + memset(signed_data,0,signed_data_length); + fread(signed_data, 1, signed_data_length, file3); + fclose(file3); + + + if (!EVP_DigestVerifyInit(cmd_ctx, &pctx, digest, nullptr, public_key)) + { + printf("EVP_DigestVerifyInit failed ;\r\n"); + return false; + } + + + if (!EVP_DigestVerifyUpdate(cmd_ctx, signed_data, + signed_data_length)) { + printf("EVP_DigestVerifyUpdate failed ;\r\n"); + return false; + } + + bool ret = + 1 == EVP_DigestVerifyFinal(cmd_ctx, reinterpret_cast(signature_value_bytes), + signature_value_bytes_length); + + printf("ret = %d ;\r\n",ret); + return 0; +} \ No newline at end of file diff --git a/Openssl/sign/sm2withsm3/signature_value_bytes.der b/Openssl/sign/sm2withsm3/signature_value_bytes.der new file mode 100644 index 0000000000000000000000000000000000000000..92191aa548489fc6e18922579999d8aa25780a92 --- /dev/null +++ b/Openssl/sign/sm2withsm3/signature_value_bytes.der @@ -0,0 +1,2 @@ +0D hjwFlҵDY +[0/#UtȜ ^mmT|'#ohv{$GVl  \ No newline at end of file diff --git a/Openssl/sign/sm2withsm3/signed_data.der b/Openssl/sign/sm2withsm3/signed_data.der new file mode 100644 index 0000000000000000000000000000000000000000..56715f18a3d795be374b855eb51897684937fb87 Binary files /dev/null and b/Openssl/sign/sm2withsm3/signed_data.der differ diff --git "a/Openssl/sign/sm2withsm3/\345\233\275\345\257\206SM2\346\234\215\345\212\241\345\231\250\346\240\271\350\257\201\344\271\246V3_client.pem" "b/Openssl/sign/sm2withsm3/\345\233\275\345\257\206SM2\346\234\215\345\212\241\345\231\250\346\240\271\350\257\201\344\271\246V3_client.pem" new file mode 100644 index 0000000000000000000000000000000000000000..5ccaf3290a6d85c2f424e1eff84e120b612fc27d --- /dev/null +++ "b/Openssl/sign/sm2withsm3/\345\233\275\345\257\206SM2\346\234\215\345\212\241\345\231\250\346\240\271\350\257\201\344\271\246V3_client.pem" @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE76S2wS2wnzVaso2EhpAp9ALrJWkB +scBkpunMEBvwJAwWnWG9SwaefXqnjj1EBiZySYnUl4ZHRsWxXCgcLwdLnw== +-----END PUBLIC KEY----- diff --git a/qt_easy/QWebChannel/QWebChannelJS/QWebChannelJS.pro b/qt_easy/QWebChannel/QWebChannelJS/QWebChannelJS.pro new file mode 100644 index 0000000000000000000000000000000000000000..e4c8b98ed1a68bcaa3c15f809a31b0853fcbcd5c --- /dev/null +++ b/qt_easy/QWebChannel/QWebChannelJS/QWebChannelJS.pro @@ -0,0 +1,37 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2023-11-13T20:49:15 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = QWebChannelJS +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/qt_easy/QWebChannel/QWebChannelJS/jsapiproxy.cpp b/qt_easy/QWebChannel/QWebChannelJS/jsapiproxy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eca39b1414782643c900046f391b62c166c56aa5 --- /dev/null +++ b/qt_easy/QWebChannel/QWebChannelJS/jsapiproxy.cpp @@ -0,0 +1,6 @@ +#include "jsapiproxy.h" + +JSApiProxy::JSApiProxy(QObject *parent) : QObject(parent) +{ + +} diff --git a/qt_easy/QWebChannel/QWebChannelJS/jsapiproxy.h b/qt_easy/QWebChannel/QWebChannelJS/jsapiproxy.h new file mode 100644 index 0000000000000000000000000000000000000000..d16884d9fb6e3737efe0680db38b8dbb7bbe89e8 --- /dev/null +++ b/qt_easy/QWebChannel/QWebChannelJS/jsapiproxy.h @@ -0,0 +1,17 @@ +#ifndef JSAPIPROXY_H +#define JSAPIPROXY_H + +#include + +class JSApiProxy : public QObject +{ + Q_OBJECT +public: + explicit JSApiProxy(QObject *parent = nullptr); + +signals: + +public slots: +}; + +#endif // JSAPIPROXY_H \ No newline at end of file diff --git a/qt_easy/QWebChannel/QWebChannelJS/main.cpp b/qt_easy/QWebChannel/QWebChannelJS/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b48f94ec827033ef073fb3c7f060837e90b935ec --- /dev/null +++ b/qt_easy/QWebChannel/QWebChannelJS/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/qt_easy/QWebChannel/QWebChannelJS/mainwindow.cpp b/qt_easy/QWebChannel/QWebChannelJS/mainwindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9716148bc2026cf172deca6d9160ea90d62a7eda --- /dev/null +++ b/qt_easy/QWebChannel/QWebChannelJS/mainwindow.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ +} + +MainWindow::~MainWindow() +{ + +} diff --git a/qt_easy/QWebChannel/QWebChannelJS/mainwindow.h b/qt_easy/QWebChannel/QWebChannelJS/mainwindow.h new file mode 100644 index 0000000000000000000000000000000000000000..ca7ddb5aa96c7e0c3c9b684d67697573dcd1d547 --- /dev/null +++ b/qt_easy/QWebChannel/QWebChannelJS/mainwindow.h @@ -0,0 +1,15 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); +}; + +#endif // MAINWINDOW_H diff --git a/qt_easy/QWebChannel/QWebChannelJS/resources.qrc b/qt_easy/QWebChannel/QWebChannelJS/resources.qrc new file mode 100644 index 0000000000000000000000000000000000000000..90f4a8379acade70780f13c5755dd6ffe3a4dd19 --- /dev/null +++ b/qt_easy/QWebChannel/QWebChannelJS/resources.qrc @@ -0,0 +1,2 @@ + + diff --git a/qt_easy/QWebChannel/QWebChannelJS/web/css/index.css b/qt_easy/QWebChannel/QWebChannelJS/web/css/index.css new file mode 100644 index 0000000000000000000000000000000000000000..1bd01fe2ca20190316dd537ab33ba950899ad85a --- /dev/null +++ b/qt_easy/QWebChannel/QWebChannelJS/web/css/index.css @@ -0,0 +1,3 @@ +.btn{ + background: red; +} \ No newline at end of file diff --git a/qt_easy/QWebChannel/QWebChannelJS/web/index.html b/qt_easy/QWebChannel/QWebChannelJS/web/index.html new file mode 100644 index 0000000000000000000000000000000000000000..e9d8a3fd578f795514f39b9a4c2481e0f57e8247 --- /dev/null +++ b/qt_easy/QWebChannel/QWebChannelJS/web/index.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/qt_easy/QWebChannel/QWebChannelJS/web/js/index.js b/qt_easy/QWebChannel/QWebChannelJS/web/js/index.js new file mode 100644 index 0000000000000000000000000000000000000000..dab6e1e971cbe093117d59d00a2318fa95027e01 --- /dev/null +++ b/qt_easy/QWebChannel/QWebChannelJS/web/js/index.js @@ -0,0 +1,3 @@ +function cl(){ + alert("asdf"); +} \ No newline at end of file