|
在Java和.NET平台的加密术比较(2) (ASN1Sequence)subjectPublicKeyInfo.PublicKey);
byte[] modulus = pubKey.Modulus; byte[] publicEXPonent = pubKey.PublicExponent;
RSAParameters pram = new RSAParameters(); pram.Modulus = modulus; pram.Exponent = publicExponent;
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); rsa.ImportParameters(pram);
return pram; }
public static byte[] PublicKeyToASN1(RSAParameters pram) { SubjectPublicKeyInfo info = new SubjectPublicKeyInfo( new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPublicKeyStructure(pram.Modulus, pram.Exponent).DERObject);
byte[] rawPublicKey = info.GetDEREncoded(); return rawPublicKey; }
3、总体感觉 1) Java的安全模块设计得还是很好的,简单易用,功能也齐全。 2) .NET 2.0则是有点乱,命名风格和系统框架有些不协调,功能欠缺,代码组织的不够理想。 3) 在Mono中,对安全的支持要比微软已发布的要好,从网上可以看到,.NET Framework 2.0的一些特性也是从Mono中借鉴过来的。 4) 甚至可以认为,.NET加密模块的开发团队能力可能不是很强。就如那一句话“编写糟糕的代码并非我们的专利”。
|