我真的不明白 _verify 函数在这个类中做了什么:
尤其是它在“dst”变量中添加了什么。我实际上有一个“验证密钥”,它在加密数据上使用这种方法,我在 dst 变量中获得了公钥......
这是一个小图,让你更好地理解:http: //i.imgur.com/R8DqT.png
谢谢
Ps:我必须在.net中做同样的事情,所以如果你知道类似的东西,请告诉我
我真的不明白 _verify 函数在这个类中做了什么:
尤其是它在“dst”变量中添加了什么。我实际上有一个“验证密钥”,它在加密数据上使用这种方法,我在 dst 变量中获得了公钥......
这是一个小图,让你更好地理解:http: //i.imgur.com/R8DqT.png
谢谢
Ps:我必须在.net中做同样的事情,所以如果你知道类似的东西,请告诉我
_verify 函数(包含在下面以供参考)
public function verify(src:ByteArray, dst:ByteArray,
length:uint, pad:Function = null):void {
_decrypt(doPublic, src, dst, length, pad, 0x01);
}
查看您提供的链接,该函数用于验证 RSA 签名数据 - 结果被复制到 dst ByteArray。
分解:
doPublic
= 函数参数,一个包装器BigInteger.modPowInt()
src
= 带符号数据的字节数组dst
= 字节数组,它将保存验证结果的结果length
= src 字节数组中数据的长度pad
pkcs1pad
= 函数参数, ( _encrypt
) 和pkcs1unpad
( _decrypt
)的包装器0x01
= padType - 一个整数值,指定0xff
在填充 (0x01) 中使用固定值 () 还是伪随机值 (0x02) - (仅实际用于pkcs1pad
从 调用的位置_encrypt
)在 RSA 方案中,通过使用公钥解密签名来验证签名数据。
更新:除非您有未涵盖的非常特殊的需求,否则没有理由要移植您发布的 ActionScript-3。使用框架中包含的 c# RSACryptoServiceProvider 。请特别注意Interoperation with the Microsoft Cryptographic API (CAPI)
MSDN 描述中的部分。
Addressing your comments about needing the content of the dst
byte array in a similar manner to the AS3Crypto implementation you could just create a wrapper to decrypt the signed data against the public key. Have a look at RSACryptoServiceProvider.ImportParameters() function which you use to import the public key information. Since you haven't provided details as to how the public key is retrieved I can't be more specific. This implementation example should help with parsing key files to create appropriate RSAParameters
to feed to the ImportParameters
method.