开发者

pseudo-random number generator based on FIPS 186-2

Hi guys I need to generate a random number (160 bytes) based on FIPS 186-2 in .net based on a given key ( Discussion can be found on RFC 4186 eap-sim implementation). What I know is that FIPS 186-2 is implemented as DSA on .net that will give a 40 byte signature bytes not 160. Can someone tell me what I'm doi开发者_如何学Gong wrong?


You need to implement the algorithm in appendix B of RFC 4186 (alternatively appendix 3 of FIPS 186-2). There is no implementation of it in the .NET framework. Since the algorithm in this case is used for key derivation, you cannot replace it with another random number generator.

In the process, you will also need to reimplement most of SHA-1, since the G-function needed is the compression function of SHA-1, which is not accessible from the public interface to the .NET framework.

Good luck :-)


Not my area, but I think FIPS 186 uses 160 bit key and salt (or seed). That's only 20 bytes.

In any case, the System.Security.Cryptography.RandomNumberGenerator will happily fill a byte array of any length for you. And it's considered safe for Cryptographic work.


i modify the code found at SHA1 Source code

The trick is to pad the message with (512 - message.length in bits) 0 instead of the padding defined in SECURE HASH STANDARD

if the message to hash is in hexa string use:

message = message.PadRight((512/4),'0');

for Modulo and exponential operation i used Org.BouncyCastle.Math.BigInteger

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜