AS3Crypto RSA Signing

爱⌒轻易说出口 提交于 2019-12-25 04:39:28

问题


I'm having some troubles matching the value returned from RSA signing a Base64 SHA1 hash in the actionscript as3crypto library with the result returned in c#.

I'm passing in a Base64 hash decoded as a byte array to the sign() function provided in as3crypto and base64 encoding the result. However, this result never matches the returned result from a c# function which performs the same task. Does it matter that the function takes in and returns hex even though it works at the byte array level?

Please see my below signing function to check i haven't missed anything!

private function signHash(hashInBase64:String):String
{
       var src:ByteArray = Base64.decodeToByteArray(hashInBase64);
       var key:RSAKey = getRSAKey();
       var dst:ByteArray = new ByteArray();

       key.sign(src, dst, src.length);

       return Base64.encodeByteArray(dst);
}

Anyone had much experience with the AS3Crypto library?

Any help would be great!!!

Thanks,

Jon


回答1:


I assume that your C# version is using RSA PKCS #1 version 1.5. The standard computes signatures by doing an RSA private key operation over a byte string composed as

0x00 0x01 || 0xff* || 0x00 || OID || hash

Looking at the as3crypto code shows that the RSAKey class does not add any OID during the sign operation. Hence if you don't do it you'll get incorrect results.

Looking at the code also shows that as3crypto is vulnerable to this attack, because it does not verify the padding properly. This attack is more than 3 years old. Hence it seems like a good to use a different library than as3crypto.




回答2:


Now there is an ActionScript crypto library compatible with .NET. Here it is: http://code.google.com/p/flame. Looks like it supports RSA exactly the way .NET does.



来源:https://stackoverflow.com/questions/1489269/as3crypto-rsa-signing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!