资源简介
SM9.zip

代码片段和文件信息
using System;
using System.Text;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Math.EC;
using Org.BouncyCastle.Security; //SecureRandom
using Org.BouncyCastle.Utilities.Encoders;
namespace CTIDTestKit
{
#region SM9工具类函数
public class SM9Tools
{
#region 二次扩域下操作(实一次多项式操作)
//一次多项式相乘【(a * x + b) * (c * x + d) mod (x^2 + 2) mod q】
public static BigInteger[] FxMultiply(BigInteger q BigInteger[] Fxa BigInteger[] Fxb)
{
BigInteger[] Fx = new BigInteger[2];
if (null != Fxa[0] && null != Fxa[1] && null != Fxb[0] && null != Fxb[1])
{
Fx[0] = Fxa[0].Multiply(Fxb[1]).Add(Fxa[1].Multiply(Fxb[0])).Mod(q);
Fx[1] = Fxa[1].Multiply(Fxb[1]).Subtract(BigInteger.Two.Multiply(Fxa[0].Multiply(Fxb[0]))).Mod(q);
}
return Fx;
}
//一次多项式逆【(a * x + b)^-1 mod (x^2 + 2) mod q】
public static BigInteger[] FxInverse(BigInteger q BigInteger[] Fxa)
{
BigInteger[] Fx = new BigInteger[2];
BigInteger temp = null;
if(BigInteger.Zero.CompareTo(Fxa[0]) != 0 && BigInteger.Zero.CompareTo(Fxa[1]) != 0)
{
temp = Fxa[1].Pow(2).Add(BigInteger.Two.Multiply(Fxa[0].Pow(2)).Mod(q)).ModInverse(q);
Fx[0] = (BigInteger.Zero.Subtract(Fxa[0])).Multiply(temp).Mod(q);
Fx[1] = Fxa[1].Multiply(temp).Mod(q);
}
return Fx;
}
//一次多项式与整数相乘【(a * x + b) * n mod (x^2 + 2) mod q】
public static BigInteger[] nFx(BigInteger q BigInteger[] Fxa BigInteger n)
{
BigInteger[] Fx = new BigInteger[2];
Fx[0] = Fxa[0].Multiply(n).Mod(q);
Fx[1] = Fxa[1].Multiply(n).Mod(q);
return Fx;
}
//一次多项式加减【(a * x + b) ± (c * x + d) mod (x^2 + 2) mod q type = true:加法 / type = false:减法】
public static BigInteger[] FxAddSub(BigInteger q BigInteger[] Fxa BigInteger[] Fxb bool type)
{
BigInteger[] Fx = new BigInteger[2];
if (null != Fxa[0] && null != Fxa[1] && null != Fxb[0] && null != Fxb[1])
{
if (type) { Fx[0] = Fxa[0].Add(Fxb[0]).Mod(q); Fx[1] = Fxa[1].Add(Fxb[1]).Mod(q); }
else { Fx[0] = Fxa[0].Subtract(Fxb[0]).Mod(q); Fx[1] = Fxa[1].Subtract(Fxb[1]).Mod(q);}
}
return Fx;
}
#endregion
#region 十二次扩域乘法盒
public static void G12boxik(int a int b ref int i ref BigInteger k)
{
int[] box = { 11 5 8 2 10 4 7 1 9 3 6 0 };
if (box[a] + box[b] < 12) { k = BigInteger.One; } else { k = BigInteger.ValueOf(-2); }
i = Array.IndexOf(box (box[a] + box[b]) % 12)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 43722 2020-09-23 11:56 SM9.cs
文件 10278867 2020-09-07 14:18 GB∕T 38635.2-2020 信息安全技术 SM9标识密码算法 第2部分:算法.pdf
文件 2602857 2020-05-15 20:45 GB∕T 38635.1-2020 信息安全技术 SM9标识密码算法 第1部分:总则.pdf
相关资源
- 价值2k的H漫画小说系统
- Pythonamp;课堂amp;笔记(高淇amp;400;集第
- ddos压力测试工具99657
- UML建模大全
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- FTP课程设计(服务端+客户端)
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
- 联想启天M4350 BIOS升级文件
- 操作系统教程课后答案华中科技大学
评论
共有 条评论