C#使用椭圆签名算法制作软件序列号
发布时间:2020-12-15 17:59:13 所属栏目:百科 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 ? ? 椭圆曲线密码学(Elliptic curve cryptography,缩写为ECC)是基于椭圆曲线数学的一种公钥密码的方法。椭圆曲线在密码学中的使用是在1985年由Neal
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 ? ? 椭圆曲线密码学(Elliptic curve cryptography,缩写为ECC)是基于椭圆曲线数学的一种公钥密码的方法。椭圆曲线在密码学中的使用是在1985年由Neal Koblitz和Victor Miller分别独立提出的。// 生成R=r*G TBCryptoBigInteger r = null; Random random = new SecureRandom(); do // Generate r { r = new TBCryptoBigInteger(this.ecdomainpsCDKey.N.BitLength,random); } while (r.SignValue == 0); ECPoint R = this.ecdomainpsCDKey.G.Multiply(r); // Hash = SHA1(data,Rx,Ry) string hashStr = Sha1(31,rawKeyBytes,R.X.ToBigInteger().ToByteArray(),R.Y.ToBigInteger().ToByteArray()); TBCryptoBigInteger hashInt = new TBCryptoBigInteger(hashStr,2); // sig = r-Hash*D (mod n) TBCryptoBigInteger sig = r.Subtract(hashInt.Multiply(this.ecDCDKey)).Mod(this.ecdomainpsCDKey.N); // 验证签名 X9ECParameters ecps = X962NamedCurves.GetByOid(X9ObjectIdentifiers.Prime256v1); ECPublicKeyParameters pk = new ECPublicKeyParameters("ECDSA",ecps.Curve.DecodePoint(Hex.Decode(KeyAttribute.GetKey(type.Assembly))),new ECDomainParameters(ecps.Curve,ecps.G,ecps.N,ecps.H)); ISigner s = SignerUtilities.GetSigner("ECDSA"); s.Init(false,pk); s.BlockUpdate(bytes,dataLen); if (s.VerifySignature(sig)) { this.data = new byte[dataLen]; Array.Copy(bytes,this.data,data.Length); } 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- git add -A 和 git add . 的区别
- c – 如何在不破坏Decorator模式的情况下减少胖界面?
- react-native-navigation – 如何使用本机导航v2添加侧栏抽
- 外壳 – 禁止“为所有人做任何事情”
- PostgreSQL系统列 System Columns
- Oracle恢复ORA-00600: 内部错误代码, 参数: [kcratr_scan_l
- c# – System.Security.VerificationException:操作可能会
- 当XSLT for-each处于循环中时.如何根据其他XML值向该XML添加
- 用lazarus快速创建xml格式文件
- DWR3.0推送技术实现QQ即时通信功能(1)