Click here to Skip to main content
15,886,689 members
Articles / Desktop Programming / Win32

Cryptographic Interoperability: Digital Signatures

Rate me:
Please Sign up or sign in to vote.
4.98/5 (48 votes)
20 Oct 2009CPOL21 min read 219.7K   12.4K   176  
Sign and verify messages using Crypto++, Java, and C#.
using System;
using System.Text;
using System.Security.Permissions;
using System.Runtime.Serialization;

  [Serializable]
  public sealed class BERDecodeException : Exception, ISerializable
  {
    private int m_position;
    public int Position
    { get { return m_position; } }

    public override string Message
    {
      get
      {
        StringBuilder sb = new StringBuilder(base.Message);

        sb.AppendFormat(" (Position {0}){1}",
          m_position, Environment.NewLine);

        return sb.ToString();
      }
    }

    public BERDecodeException()
      : base() { }

    public BERDecodeException(String message)
      : base(message) { }

    public BERDecodeException(String message, Exception ex)
      : base(message, ex) { }

    public BERDecodeException(int position)
    { m_position = position; }

    public BERDecodeException(String message, int position)
      : this( message ) { m_position = position; }

    public BERDecodeException(int position, Exception ex)
      : this( "", ex ) { m_position = position; }

    public BERDecodeException(String message, int position, Exception ex)
      : this(message, ex) { m_position = position; }

    private BERDecodeException(SerializationInfo info, StreamingContext context)
      : base( info, context)
    {
      m_position = info.GetInt32("Position");
    }

    [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
    public override void GetObjectData(SerializationInfo info, StreamingContext context)
    {
      base.GetObjectData(info, context);
      info.AddValue("Position", m_position);
    }
  }

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems / Hardware Administrator
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions