This project is read-only.

SHA1CryptoServiceProvider has to change with SHA256CryptoServiceProvider

Sep 5, 2011 at 3:02 PM

HI

Can we use the  SHA256CryptoServiceProvider instead of the SHA1CryptoServiceProvider?

public override byte[] GetSignature(IEnumerable key)
        {
            var data = key.ToArray();
            //using (var sha1 = new Microsoft.RegSol.Emea.Uk.Flexi.Feeds.Sftp.Security.Cryptography.SHA1Hash())
            using (var sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider())
            {
                using (var cs = new System.Security.Cryptography.CryptoStream(System.IO.Stream.Null, sha1, System.Security.Cryptography.CryptoStreamMode.Write))
                {
                    cs.Write(data, 0, data.Length);
                }

                var dsaKeyInfo = new System.Security.Cryptography.DSAParameters();

                dsaKeyInfo.X = this._privateKey.TrimLeadingZero().ToArray();
                dsaKeyInfo.P = this._p.TrimLeadingZero().ToArray();
                dsaKeyInfo.Q = this._q.TrimLeadingZero().ToArray();
                dsaKeyInfo.G = this._g.TrimLeadingZero().ToArray();

                using (var DSA = new System.Security.Cryptography.DSACryptoServiceProvider())
                {
                    DSA.ImportParameters(dsaKeyInfo);
                    var DSAFormatter = new DSASignatureFormatter(DSA);
                    DSAFormatter.SetHashAlgorithm("SHA1");

                    var signature = DSAFormatter.CreateSignature(sha1);

                    return new SignatureKeyData
                    {
                        AlgorithmName = this.Name,
                        Signature = signature,
                    }.GetBytes().ToArray();
                }
            }
        }

Please let me know what are the changes are required if i use the SHA256CryptoServiceProvider.

Thanks & Regards
Rambhopal
Sep 6, 2011 at 8:15 PM

Hi,

Sorry for late response, I am on vacation now.

Can you please download latest source code since I am not using SHA1CryptoServiceProvider provider anymore.

 

Also,

Please let me know under what scenarion you need to support SHA256 so I could add it to the solution for future releases.

 

Thanks,

Oleg

Sep 7, 2011 at 10:34 AM

Hi Oleg,

 

I have downloaded the latest version. i can't see what algorithem it has been using for SFTP.

Could you please let me know. but this code works for me no errors in FxCop.

We are using Fxcop for code anlaysis.. we had exception do not use "SHA1CryptoServiceProvider"

We are using .Net 4.0 which is the latest version. SHA1 has to use for lower verion compatability.

That is the reason,  is it possibe SHA256. let me know what are the changes required for this?

 

Regards

Rambhopal Reddy E

Sep 8, 2011 at 6:04 PM

I removed usage of SHA1CryptoServiceProvider so please download latest source code, not the version that you see on the front page.

This version have differnt approach to security components that used by library and should allow more easly to add new methods.

 

Currently I am away on vacation so I could take a look at it later when  I am back.

 

Also, Can you let me know what server do you use that uses SHA256 s I could test it myself or perhaps you can give me an access to test account that I could test aganst.

 

Thanks,

Oleg

Sep 9, 2011 at 5:28 AM

Hi Oleg,

 

Our both parties are using Windows 2008 R2 server.

is it possible to use the algorithm SHA256?

Sep 12, 2011 at 8:51 PM

Can you please download latest source code?

 

In this version you can easy change SHA1 to SHA256.

_hash = new SHA1Hash();

with this one:

_hash = new SHA256Hash();

 

Please let me know if it works and you have any more questions.

 

Thanks,

Oleg

Sep 13, 2011 at 4:41 AM
Thanks oleg,

SSH.Net library helps me lot. it makes me easy to solve the SFTP.

Regards
Rambhopal






On Tue, Sep 13, 2011 at 1:21 AM, olegkap <notifications@codeplex.com> wrote:

From: olegkap

Can you please download latest source code?

In this version you can easy change SHA1 to SHA256.

_hash = new SHA1Hash();

with this one:

_hash = new SHA256Hash();

Please let me know if it works and you have any more questions.

Thanks,

Oleg

Read the full discussion online.

To add a post to this discussion, reply to this email (sshnet@discussions.codeplex.com)

To start a new discussion for this project, email sshnet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com