• 大小: 6.11MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-15
  • 语言: 其他
  • 标签: SM9  VC源码  

资源简介

SM9算法源码,包括主密钥对生成,用户私钥生成,签名验签、密钥封装解封、加密解密和密钥交换等算法

资源截图

代码片段和文件信息

// SM9CryptDlg.cpp : 实现文件
//

#include “stdafx.h“
#include “YUtilsDemo.h“
#include “SM9CryptDlg.h“
#include “afxdialogex.h“

#include “yy/utils/YHex.h“
#include “yy/sm9/SM9.h“


extern void ShowTipOK(HWND hwnd CString msg);
extern void ShowTipError(HWND hwnd CString msg);


// CSM9CryptDlg 对话框

IMPLEMENT_DYNAMIC(CSM9CryptDlg CDialogEx)

CSM9CryptDlg::CSM9CryptDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(IDD_DLG_SM9_CRYPT pParent)
{

}

CSM9CryptDlg::~CSM9CryptDlg()
{
}

void CSM9CryptDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX IDC_EDIT2 m_edtMasterPubkey);
DDX_Control(pDX IDC_EDIT4 m_edtUserID);
DDX_Control(pDX IDC_EDIT6 m_edtData);
DDX_Control(pDX IDC_EDIT1 m_edtCipherText);
DDX_Control(pDX IDC_EDIT7 m_edtUserPrikey);
DDX_Control(pDX IDC_EDIT5 m_edtPlainText);
}


BEGIN_MESSAGE_MAP(CSM9CryptDlg CDialogEx)
ON_BN_CLICKED(IDC_BTN_SM9_ENCRYPT &CSM9CryptDlg::OnBnClickedBtnSm9Encrypt)
ON_BN_CLICKED(IDC_BTN_SM9_DECRYPT &CSM9CryptDlg::OnBnClickedBtnSm9Decrypt)
END_MESSAGE_MAP()


// CSM9CryptDlg 消息处理程序


BOOL CSM9CryptDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();

// TODO:  在此添加额外的初始化
initUI();

return TRUE;  // return TRUE unless you set the focus to a control
  // 异常: OCX 属性页应返回 FALSE
}


BOOL CSM9CryptDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 在此添加专用代码和/或调用基类
if( pMsg->message == WM_KEYDOWN ) {
BOOL bCtrl = ::GetKeyState(VK_CONTROL) & KF_UP;
switch( pMsg->wParam ) {
case ‘A‘:
{
if( bCtrl ) {
char pClassName[128] = {0};
GetClassName(pMsg->hwnd pClassName 128);
if( 0 == strcmp(pClassName “Edit“) ) {
CEdit *pEdit = (CEdit*)FromHandle(pMsg->hwnd);
pEdit->SetSel(0 -1);
}
}
}
break;
case VK_RETURN:
{
char pClassName[128] = {0};
GetClassName(pMsg->hwnd pClassName 128);
if( 0 == strcmp(pClassName “Edit“) ) {
CEdit *pEdit = (CEdit*)FromHandle(pMsg->hwnd);
DWORD dwStylt = pEdit->Getstyle();

if( !(dwStylt&ES_MULTILINE) || ((dwStylt&ES_MULTILINE) && !(dwStylt&ES_WANTRETURN)) )
return TRUE;
}
}
break;
default:
break;
}
}


return CDialogEx::PreTranslateMessage(pMsg);
}

bool CSM9CryptDlg::hexStringCheck(CString& value CString tips/*=““*/)
{
if( value.IsEmpty() ) {
ShowTipError(this->m_hWnd tips + _T(“数据为空!“));
return false;
}
if( !YHex::Check(value.GetBuffer()) ) {
ShowTipError(this->m_hWnd tips + _T(“数据的十六进制中包含非法字符!“));
return false;
}
if( value.GetLength() % 2 != 0 ) {
ShowTipError(this->m_hWnd tips + _T(“数据的十六进制长度错误!“));
return false;
}
return true;
}

void CSM9CryptDlg::initUI()
{
m_edtMasterPubkey.SetWindowText(_T(“787ed7b8a51f3ab84e0a66003f32da5c720b17eca7137d39abc66e3c80a892ff769de61791e5adc4b9ff85a31354900b202871279a8c49dc3f220f644c57a7b1“));
m_edtUserPrikey.SetWindowText(_T(“9473

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.    158720  2018-11-12 21:00  SM9Project\.vs\SM9Project\v14\.suo

     文件     661504  2018-11-12 20:51  SM9Project\Bin\YUtilsDemo\Debug\YUtilsDemo.exe

     文件     275456  2018-11-12 21:00  SM9Project\Bin\YUtilsDemo\Release\YUtilsDemo.exe

     文件       1042  2016-11-25 08:58  SM9Project\CleanTools_VS2015.bat

     文件      15704  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\big.h

     文件        731  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\brick.h

     文件       1541  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\complex.h

     文件        681  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\crt.h

     文件        915  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ebrick.h

     文件        931  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ebrick2.h

     文件       5928  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ec2.h

     文件       5371  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ecdh.h

     文件       6288  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ecn.h

     文件       7952  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ecn2.h

     文件       5192  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ecn3.h

     文件       4389  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ecn4.h

     文件       4347  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ecn6.h

     文件       4398  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ecn8.h

     文件        374  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\ecnzzn.h

     文件       4705  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\flash.h

     文件       2812  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\floating.h

     文件       1494  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\flpoly.h

     文件       6679  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\gf2m.h

     文件       3776  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\gf2m12x.h

     文件       5870  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\gf2m4x.h

     文件       3512  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\gf2m6x.h

     文件      46036  2018-06-22 23:37  SM9Project\miracl\inlucde\miracl\miracl.h

     文件       1180  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\mirdef.h

     文件       3517  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\octet.h

     文件      13866  2018-06-06 08:03  SM9Project\miracl\inlucde\miracl\p1363.h

............此处省略111个文件信息

评论

共有 条评论