/***************************************************************************
*
Copyright 2013 CertiVox UK Ltd. *
*
This file is part of CertiVox MIRACL Crypto SDK. *
*
The CertiVox MIRACL Crypto SDK provides developers with an *
extensive and efficient set of cryptographic functions. *
For further information about its features and functionalities please *
refer to http://www.certivox.com *
*
* The CertiVox MIRACL Crypto SDK is free software: you can *
redistribute it and/or modify it under the terms of the *
GNU Affero General Public License as published by the *
Free Software Foundation, either version 3 of the License, *
or (at your option) any later version. *
*
* The CertiVox MIRACL Crypto SDK is distributed in the hope *
that it will be useful, but WITHOUT ANY WARRANTY; without even the *
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
See the GNU Affero General Public License for more details. *
*
* You should have received a copy of the GNU Affero General Public *
License along with CertiVox MIRACL Crypto SDK. *
If not, see <http://www.gnu.org/licenses/>. *
*
You can be released from the requirements of the license by purchasing *
a commercial license. Buying such a license is mandatory as soon as you *
develop commercial activities involving the CertiVox MIRACL Crypto SDK *
without disclosing the source code of your own applications, or shipping *
the CertiVox MIRACL Crypto SDK with a closed source product. *
*
***************************************************************************/
/*
* MIRACL E(F_p^2) support functions
* mrecn2.c
*/
#include <stdlib.h>
#include "miracl.h"
#ifdef MR_STATIC
#include <string.h>
#endif
#ifndef MR_EDWARDS
BOOL ecn2_iszero(ecn2 *a)
{
if (a->marker==MR_EPOINT_INFINITY) return TRUE;
return FALSE;
}
void ecn2_copy(ecn2 *a,ecn2 *b)
{
zzn2_copy(&(a->x),&(b->x));
zzn2_copy(&(a->y),&(b->y));
#ifndef MR_AFFINE_ONLY
if (a->marker==MR_EPOINT_GENERAL) zzn2_copy(&(a->z),&(b->z));
#endif
b->marker=a->marker;
}
void ecn2_zero(ecn2 *a)
{
zzn2_zero(&(a->x)); zzn2_zero(&(a->y));
#ifndef MR_AFFINE_ONLY
if (a->marker==MR_EPOINT_GENERAL) zzn2_zero(&(a->z));
#endif
a->marker=MR_EPOINT_INFINITY;
}
BOOL ecn2_compare(_MIPD_ ecn2 *a,ecn2 *b)
{
#ifdef MR_OS_THREADS
miracl *mr_mip=get_mip();
#endif
if (mr_mip->ERNUM) return FALSE;
MR_IN(193)
ecn2_norm(_MIPP_ a);
ecn2_norm(_MIPP_ b);
MR_OUT
if (zzn2_compare(&(a->x),&(b->x)) && zzn2_compare(&(a->y),&(b->y)) && a->marker==b->marker) return TRUE;
return FALSE;
}
void ecn2_norm(_MIPD_ ecn2 *a)
{
zzn2 t;
#ifdef MR_OS_THREADS
miracl *mr_mip=get_mip();
#endif
#ifndef MR_AFFINE_ONLY
if (mr_mip->ERNUM) return;
if (a->marker!=MR_EPOINT_GENERAL) return;
MR_IN(194)
zzn2_inv(_MIPP_ &(a->z));
t.a=mr_mip->w3;
t.b=mr_mip->w4;
zzn2_copy(&(a->z),&t);
zzn2_sqr(_MIPP_ &(a->z),&(a->z));
zzn2_mul(_MIPP_ &(a->x),&(a->z),&(a->x));
zzn2_mul(_MIPP_ &(a->z),&t,&(a->z));
zzn2_mul(_MIPP_ &(a->y),&(a->z),&(a->y));
zzn2_from_zzn(mr_mip->one,&(a->z));
a->marker=MR_EPOINT_NORMALIZED;
MR_OUT
#endif
}
void ecn2_get(_MIPD_ ecn2 *e,zzn2 *x,zzn2 *y,zzn2 *z)
{
#ifdef MR_OS_THREADS
miracl *mr_mip=get_mip();
#endif
zzn2_copy(&(e->x),x);
zzn2_copy(&(e->y),y);
#ifndef MR_AFFINE_ONLY
if (e->marker==MR_EPOINT_GENERAL) zzn2_copy(&(e->z),z);
else zzn2_from_zzn(mr_mip->one,z);
#endif
}
void ecn2_getxy(ecn2 *e,zzn2 *x,zzn2 *y)
{
zzn2_copy(&(e->x),x);
zzn2_copy(&(e->y),y);
}
void ecn2_getx(ecn2 *e,zzn2 *x)
{
zzn2_copy(&(e->x),x);
}
void ecn2_psi(_MIPD_ zzn2 *psi,ecn2 *P)
{ /* apply GLS morphism to P */
#ifdef MR_OS_THREADS
miracl *mr_mip=get_mip();
#endif
MR_IN(212)
ecn2_norm(_MIPP_ P);
zzn2_conj(_MIPP_ &(P->x),&(P->x));
zzn2_conj(_MIPP_ &(P->y),&(P->y));
zzn2_mul(_MIPP_ &(P->x),&psi[0],&(P->x));
zzn2_mul(_MIPP_ &(P->y),&psi[1],&(P->y));
MR_OUT
}
#ifndef MR_AFFINE_ONLY
void ecn2_getz(_MIPD_ ecn2 *e,zzn2 *z)
{
#ifdef MR_OS_THREADS
miracl *mr_mip=get_mip();
#endif
if (e->marker==MR_EPOINT_GENERAL) zzn2_copy(&(e->z),z);
else zzn2_from_zzn(mr_mip->one,z);
}
#endif
void ecn2_rhs(_MIPD_ zzn2 *x,zzn2 *rhs)
{ /* calculate RHS of elliptic curve equation */
int twist;
zzn2 A,B;
#ifdef MR_OS_THREADS
miracl *mr_mip=get_mip();
#endif
if (mr_mip->ERNUM) return;
twist=mr_mip->TWIST;
MR_IN(202)
A.a=mr_mip->w10;
A.b=mr_mip->w11;
B.a=mr_mip->w12;
B.b=mr_mip->w13;
if (mr_abs(mr_mip->Asize)<MR_TOOBIG) zzn2_from_int(_MIPP_ mr_mip->Asize,&A);
else zzn2_from_zzn(mr_mip->A,&A);
if (mr_abs(mr_mip->Bsize)<MR_TOOBIG) zzn2_from_int(_MIPP_ mr_mip->Bsize,&B);
else zzn2_from_zzn(mr_mip->B,&B);
if (twist)
{ /* assume its the quartic or sextic twist, if such is possible */
if (twist==MR_QUARTIC_M)
{
zzn2_mul(_MIPP_ &A,x,&B);
zzn2_txx(_MIPP_ &B);
}
if (twist==MR_QUARTIC_D)
{
zzn2_mul(_MIPP_ &A,x,&B);
zzn2_txd(_MIPP_ &B);
}
if (twist==MR_SEXTIC_M)
{
zzn2_txx(_MIPP_ &B);
}
if (twist==MR_SEXTIC_D)
{
zzn2_txd(_MIPP_ &B);
}
if (twist==MR_QUADRATIC)
{
zzn2_txx(_MIPP_ &B);
zzn2_txx(_MIPP_ &B);
zzn2_txx(_MIPP_ &B);
zzn2_mul(_MIPP_ &A,x,&A);
zzn2_txx(_MIPP_ &A);
zzn2_txx(_MIPP_ &A);
zzn2_add(_MIPP_ &B,&A,&B);
}
/*
if (mr_mip->Asize==0 || mr_mip->Bsize==0)
{
if (mr_mip->Asize==0)
{ // CM Discriminant D=3 - its the sextic twist (Hope I got the right one!). This works for BN curves
zzn2_txd(_MIPP_ &B);
}
if (mr_mip->Bsize==0)
{ // CM Discriminant D=1 - its the quartic twist.
zzn2_mul(_MIPP_ &A,x,&B);
zzn2_txx(_MIPP_ &B);
}
}
else
{ // its the quadratic twist
zzn2_txx(_MIPP_ &B);
zzn2_txx(_MIPP_ &B);
zzn2_txx(_MIPP_ &B);
zzn2_mul(_MIPP_ &A,x,&A);
zzn2_txx(_MIPP_ &A);
zzn2_txx(_MIPP_ &A);
zzn2_add(_MIPP_ &B,&A,&B);
}
*/
}
else
{
zzn2_mul(_MIPP_ &A,x,&A);
zzn2_add(_MIPP_ &B,&A,&B);
}
zzn2_sqr(_MIPP_ x,&A);
zzn2_mul(_MIPP_ &A,x,&A);
zzn2_add(_MIPP_ &B,&A,rhs);
MR_OUT
}
BOOL ecn2_set(_MIPD_ zzn2 *x,zzn2 *y,ecn2 *e)
{
zzn2 lhs,rhs;
#ifdef MR_OS_THREADS
miracl *mr_mip=get_mip();
#endif
if (mr_mip->ERNUM) return FALSE;
MR_IN(195)
lhs.a=mr_mip->w10;
lhs.b=mr_mip->w11;
rhs.a=mr_mip->w12;
rhs.b=mr_mip-
没有合适的资源?快使用搜索试试~ 我知道了~
sm2国密算法加解密、签名、验签QT工具源码(包含sm2,sm3和sm4源代码)
共160个文件
c:44个
o:41个
h:15个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 19 下载量 106 浏览量
2022-04-23
06:27:45
上传
评论 12
收藏 2.09MB ZIP 举报
温馨提示
sm2国密算法加解密,签名、验签QT工具的源代码(包含sm2,sm3和sm4源码)。 环境我使用的QT5.14的IDE编译,其他版本qt未测试。不过仅使用了几个简单控件应该关系不大。 详细介绍参见个人博客:SM2 (含SM3、SM4)国密算法工具QT版,彻底搞懂国密算法的使用 https://blog.csdn.net/yyz_1987/article/details/120501076
资源推荐
资源详情
资源评论
收起资源包目录
sm2国密算法加解密、签名、验签QT工具源码(包含sm2,sm3和sm4源代码) (160个子文件)
sm2Tool.pro.user.95d04ca.4.8-pre1 39KB
libsm2.a 422KB
libsm2.a 422KB
libsm2.a 422KB
libmiracl.a 226KB
miracl.h.bak 47KB
miracl.h.bak 42KB
sm2.c.bak 9KB
MessageLogger.cpp.bak 3KB
makefile.bak 2KB
sm2.h.bak 2KB
sm2Tool.pro.bak 1KB
sm2.pri.bak 127B
libmiracl.pri.bak 122B
utils.pri.bak 93B
mrecn2.c 88KB
mrgf2m.c 79KB
mrcurve.c 70KB
mrcore.c 55KB
mrec2m.c 55KB
mraes.c 45KB
mrarth2.c 43KB
mrfast.c 40KB
mrmonty.c 33KB
sm2.c 31KB
mrarth1.c 24KB
mrpower.c 18KB
mrzzn2.c 16KB
mrio1.c 14KB
mrxgcd.c 14KB
SM2_sv.c 14KB
mrzzn3.c 13KB
mrprime.c 11KB
sm4.c 11KB
mrgcm.c 10KB
mrjack.c 10KB
mrshs512.c 10KB
mrarth0.c 9KB
mrscrt.c 8KB
mrebrick.c 8KB
mrarth3.c 7KB
mrround.c 7KB
mrstrong.c 7KB
mrbuild.c 7KB
mrsmall.c 7KB
mrsroot.c 7KB
mrbrick.c 7KB
mrshs256.c 7KB
mrbits.c 7KB
mrio2.c 6KB
mrshs.c 6KB
mrgcd.c 6KB
mrlucas.c 6KB
mrzzn2b.c 6KB
sm3.c 5KB
mrcrt.c 5KB
mrrand.c 4KB
mralloc.c 3KB
mrfrnd.c 3KB
config 299B
mainwindow.cpp 21KB
MessageLogger.cpp 3KB
stringutils.cpp 3KB
utils.cpp 1KB
main.cpp 317B
description 73B
libsm2.dll 349KB
libsm2.dll 349KB
exclude 240B
miracl.h 47KB
miracl.h 46KB
miracl.h 42KB
KDF.h 11KB
sm2.h 4KB
SM2_sv.h 4KB
MessageLogger.h 4KB
sm4.h 2KB
mirdef.h 1KB
mirdef.h 1KB
sm3.h 960B
mainwindow.h 768B
mirdef.h 402B
stringutils.h 274B
utils.h 126B
HEAD 180B
HEAD 180B
HEAD 32B
HEAD 23B
myicon.ico 17KB
pack-eedfc3119a3ea71e5c5744a515f939de86e393ac.idx 6KB
index 11KB
makefile 2KB
master 180B
master 41B
mrec2m.o 41KB
mrecn2.o 37KB
mrgf2m.o 36KB
mrcurve.o 35KB
mrcore.o 30KB
mrfast.o 27KB
共 160 条
- 1
- 2
特立独行的猫a
- 粉丝: 7w+
- 资源: 37
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Win64OpenSSL-3-3-0.exe
- 课高分程设计-基于C++实现的民航飞行与地图简易管理系统-南京航空航天大学
- 航天器遥测数据故障检测系统python源码+文档说明+数据库(课程设计)
- 北京航空航天大学操作系统课设+ppt+实验报告
- 基于Vue+Echarts实现风力发电机中传感器的数据展示监控可视化系统+源代码+文档说明(高分课程设计)
- 基于单片机的风力发电机转速控制源码
- 基于C++实现的风力发电气动平衡监测系统+源代码+测量数据(高分课程设计)
- 毕业设计- 基于STM32F103C8T6 单片机,物联网技术的太阳能发电装置+源代码+文档说明+架构图+界面截图
- 基于 LSTM(长短期记忆)(即改进的循环神经网络)预测风力发电厂中风力涡轮机产生的功率+源代码+文档说明
- 基于stm32f103+空心杯电机+oled按键+运动算法
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页