"景先生毕设|www.jxszl.com

C# ASN1类代码示例

2023-12-29 17:05编辑: www.jxszl.com景先生毕设
本文整理汇总了C#中ASN1类的典型用法代码示例。如果您正苦于以下问题:C#ASN1类的具体用法?C#ASN1怎么用?C#ASN1使用的例子?这里精选的类代码示例或许可以为您提供帮助。 示例1:VerifySignature internalboolVerifySignature(DSAdsa) { if(signatureOID!="1.2.840.10040.4.3") thrownewCryptographicException("Unsupportedhashalgorithm:"+signatureOID); DSASignatureDeformatterv=newDSASignatureDeformatter(dsa); //onlySHA-1issupported v.SetHashAlgorithm("SHA1"); ASN1sign=newASN1(signature); if((sign==null)||(sign.Count!=2)) returnfalse; //partsmaybelessthan20bytes(i.e.firstbyteswere0x00) byte[]part1=sign[0].Value; byte[]part2=sign[1].Value; byte[]sig=newbyte[40]; //partsmaybelessthan20bytes(i.e.firstbyteswere0x00) //partsmaybemorethan20bytes(i.e.firstbyte>0x80,negative) ints1=System.Math.Max(0,part1.Length-20); inte1=System.Math.Max(0,20-part1.Length); Buffer.BlockCopy(part1,s1,sig,e1,part1.Length-s1); ints2=System.Math.Max(0,part2.Length-20); inte2=System.Math.Max(20,40-part2.Length); Buffer.BlockCopy(part2,s2,sig,e2,part2.Length-s2); returnv.VerifySignature(Hash,sig); }
原文链接:http://www.jxszl.com/biancheng/C/556579.html