I'm trying to do pushes through SSH on NGit. I am specifying my own keys by using the method set out here: NGit making a connection with a private key file
It works well with a clone, and on the first push. After that, it fails 30% of the time, always in this method in Mono.Security:
Mono.Security.dll!Mono.Math.BigInteger.Kernel.MinusEq(Mono.Math.BigInteger big, Mono.Math.BigInteger small)
Either it fails with the message: "Error occurred during a cryptographic function", or it hangs indefinitely in this function. Again, it seems completely random whether it succeeds or not. It is being called by function in NGit:
DiffieHellmanManaged dh = new DiffieHellmanManaged (pspec.P.GetBytes (), pspec.G.GetBytes (), 0);
in GenerateKeyPair (KeyPairGenerator.cs)
Any ideas? If not, are there any ways to generate the Diffie-Hellman keys through some other method?
Thanks so much,
Cheers,
UPDATE: I have discovered a strange solution that I don't entirely understand:
Previously, I created a new thread, as I was calling it from the UI and didn't want it to hang. This was an STA thread, as we are building a VSTO application and it doesn't support MTA / BackgroundWorker() etc. from UI components (pretty much limiting you to the old Thread(), as you can specify it is STA as required). I found the problem happened more frequently when the user clicked around whilst the push was in progress (thus doing some git checkouts), so I disabled the threading and ran it directly from the UI. Since then, it freezes the UI like hell, but doesn't hang pr crash on the calculation of BigInt. I am completely perplexed as to how this is the case unless: Office (which we are building addons for) somehow won't provide a thread with enough memory for the BigInt calculations (or mismanages this memory, which wouldn't be entirely surprising), or, for some reason, BigInt calculations simply can't be called in a threaded context (maybe Thread->Ngit->Sharpen->Mono.Security->Mono.Math(32 digit number) broke threading??)
Any idea what could be the cause of this?