[Mono-list] RSA with SHA512 hash

jeremy.poulter jeremy.poulter at oregan.net
Mon Jan 10 04:50:17 EST 2011


I have been developing an application that uses an SHA512 hash signed with a
RSA private key for a digital signature.

This is working fine on Windows under .Net but when I try this on Linux
under Mono I get the following exception;

System.NotSupportedException: 2.16.840.1.101.3.4.2.3 is an unsupported hash
algorithm for RSA signing
  at
System.Security.Cryptography.RSACryptoServiceProvider.GetHashNameFromOID
(System.String oid) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.RSACryptoServiceProvider.SignHash
(System.Byte[] rgbHash, System.String str) [0x00000] in <filename unknown>:0 
  at Oregan.Utilities.DigitalSignature.DigitalSignature.Sign (HashType
hashType, System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at Oregan.FilePackBuilder.FilePack.Save (System.String sPath,
Oregan.Utilities.DigitalSignature.DigitalSignature digitalSignature, Boolean
bPreserveName) [0x00000] in <filename unknown>:0 
  at Oregan.FilePackBuilder.FilePackViewer.filepackToolStripMenuItem1_Click
(System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStripItem.OnClick (System.EventArgs e)
[0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStripMenuItem.OnClick (System.EventArgs e)
[0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStripMenuItem.HandleClick (System.EventArgs e)
[0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStripItem.FireEvent (System.EventArgs e,
ToolStripItemEventType met) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check)
System.Windows.Forms.ToolStripItem:FireEvent
(System.EventArgs,System.Windows.Forms.ToolStripItemEventType)
  at System.Windows.Forms.ToolStrip.OnMouseUp
(System.Windows.Forms.MouseEventArgs mea) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStripDropDown.OnMouseUp
(System.Windows.Forms.MouseEventArgs mea) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control.WmLButtonUp (System.Windows.Forms.Message&
m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m)
[0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ScrollableControl.WndProc
(System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStrip.WndProc (System.Windows.Forms.Message&
m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStripDropDown.WndProc
(System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage
(System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc
(System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr
wParam, IntPtr lParam) [0x00000] in <filename unknown>:0 

FYI the code I used is;

    public byte[] Sign(HashType hashType, Stream stream)
    {
      switch (hashType)
      {
        case HashType.MD5:
        {
          MD5 md5 = new MD5CryptoServiceProvider();
          byte[] hash = md5.ComputeHash(stream);

          return key.SignHash(hash, CryptoConfig.MapNameToOID("MD5"));
        }
        case HashType.SHA512:
        {
          SHA512 shaM = new SHA512Managed();
          byte[] hash = shaM.ComputeHash(stream);

          return key.SignHash(hash, CryptoConfig.MapNameToOID("SHA512"));
        }
      }

      return null;
    }

Any feedback is appreciated.

Cheers,

Jeremy

-- 
View this message in context: http://mono.1490590.n4.nabble.com/RSA-with-SHA512-hash-tp3206847p3206847.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list