Click here to Skip to main content
15,886,258 members
Articles / Programming Languages / C#

Parsing strong name signatures generated with sn.exe

Rate me:
Please Sign up or sign in to vote.
4.58/5 (14 votes)
4 May 20042 min read 114.9K   1.6K   25  
This article shows how to parse Assembly "strong name keyfiles" generated with sn.exe
//------------------------------------------------------------------------
// (c) 2002-2004 by Per Anderson.  All rights reserved.
//------------------------------------------------------------------------


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Bullfrog.KeyGen
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class KeyGenForm : System.Windows.Forms.Form
	{
		public System.Windows.Forms.Button BtnOpen;
		public System.Windows.Forms.TextBox TextBoxPlain;
		public System.Windows.Forms.TextBox TextBoxSignature;
		public System.Windows.Forms.Label LabelPlain;
		public System.Windows.Forms.Button BtnSignIt;
		public System.Windows.Forms.Label LabelSig;
		public System.Windows.Forms.Button BtnVerifyIt;
		public System.Windows.Forms.Button BtnCreate;
		public System.Windows.Forms.Label LabelPriv;
		public System.Windows.Forms.Label LabelPub;
		public System.Windows.Forms.TextBox TextBoxKeyPriv;
		public System.Windows.Forms.TextBox TextBoxKeyPub;
		public System.Windows.Forms.Button BtnOpenSnk;
		public System.Windows.Forms.Button BtnOpenPub;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public KeyGenForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.BtnOpen = new System.Windows.Forms.Button();
			this.TextBoxPlain = new System.Windows.Forms.TextBox();
			this.TextBoxSignature = new System.Windows.Forms.TextBox();
			this.LabelPriv = new System.Windows.Forms.Label();
			this.LabelPlain = new System.Windows.Forms.Label();
			this.BtnSignIt = new System.Windows.Forms.Button();
			this.LabelSig = new System.Windows.Forms.Label();
			this.BtnVerifyIt = new System.Windows.Forms.Button();
			this.TextBoxKeyPriv = new System.Windows.Forms.TextBox();
			this.BtnCreate = new System.Windows.Forms.Button();
			this.TextBoxKeyPub = new System.Windows.Forms.TextBox();
			this.LabelPub = new System.Windows.Forms.Label();
			this.BtnOpenSnk = new System.Windows.Forms.Button();
			this.BtnOpenPub = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// BtnOpen
			// 
			this.BtnOpen.Location = new System.Drawing.Point(592, 168);
			this.BtnOpen.Name = "BtnOpen";
			this.BtnOpen.Size = new System.Drawing.Size(144, 24);
			this.BtnOpen.TabIndex = 1;
			this.BtnOpen.Text = "Open XML Keypair File...";
			// 
			// TextBoxPlain
			// 
			this.TextBoxPlain.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.TextBoxPlain.Location = new System.Drawing.Point(0, 232);
			this.TextBoxPlain.Multiline = true;
			this.TextBoxPlain.Name = "TextBoxPlain";
			this.TextBoxPlain.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.TextBoxPlain.Size = new System.Drawing.Size(360, 120);
			this.TextBoxPlain.TabIndex = 2;
			this.TextBoxPlain.Text = "";
			// 
			// TextBoxSignature
			// 
			this.TextBoxSignature.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.TextBoxSignature.Location = new System.Drawing.Point(376, 232);
			this.TextBoxSignature.Multiline = true;
			this.TextBoxSignature.Name = "TextBoxSignature";
			this.TextBoxSignature.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.TextBoxSignature.Size = new System.Drawing.Size(360, 120);
			this.TextBoxSignature.TabIndex = 3;
			this.TextBoxSignature.Text = "";
			// 
			// LabelPriv
			// 
			this.LabelPriv.Location = new System.Drawing.Point(8, 16);
			this.LabelPriv.Name = "LabelPriv";
			this.LabelPriv.Size = new System.Drawing.Size(168, 16);
			this.LabelPriv.TabIndex = 5;
			this.LabelPriv.Text = "Private Key XML";
			// 
			// LabelPlain
			// 
			this.LabelPlain.Location = new System.Drawing.Point(8, 208);
			this.LabelPlain.Name = "LabelPlain";
			this.LabelPlain.Size = new System.Drawing.Size(216, 16);
			this.LabelPlain.TabIndex = 6;
			this.LabelPlain.Text = "Text To Sign";
			// 
			// BtnSignIt
			// 
			this.BtnSignIt.Location = new System.Drawing.Point(280, 360);
			this.BtnSignIt.Name = "BtnSignIt";
			this.BtnSignIt.TabIndex = 7;
			this.BtnSignIt.Text = "Sign It";
			// 
			// LabelSig
			// 
			this.LabelSig.Location = new System.Drawing.Point(376, 208);
			this.LabelSig.Name = "LabelSig";
			this.LabelSig.Size = new System.Drawing.Size(216, 16);
			this.LabelSig.TabIndex = 8;
			this.LabelSig.Text = "Signature";
			// 
			// BtnVerifyIt
			// 
			this.BtnVerifyIt.Location = new System.Drawing.Point(656, 360);
			this.BtnVerifyIt.Name = "BtnVerifyIt";
			this.BtnVerifyIt.TabIndex = 9;
			this.BtnVerifyIt.Text = "Verify It";
			// 
			// TextBoxKeyPriv
			// 
			this.TextBoxKeyPriv.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.TextBoxKeyPriv.Location = new System.Drawing.Point(0, 40);
			this.TextBoxKeyPriv.Multiline = true;
			this.TextBoxKeyPriv.Name = "TextBoxKeyPriv";
			this.TextBoxKeyPriv.ReadOnly = true;
			this.TextBoxKeyPriv.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.TextBoxKeyPriv.Size = new System.Drawing.Size(360, 120);
			this.TextBoxKeyPriv.TabIndex = 10;
			this.TextBoxKeyPriv.Text = "";
			// 
			// BtnCreate
			// 
			this.BtnCreate.Location = new System.Drawing.Point(160, 168);
			this.BtnCreate.Name = "BtnCreate";
			this.BtnCreate.Size = new System.Drawing.Size(136, 24);
			this.BtnCreate.TabIndex = 0;
			this.BtnCreate.Text = "Create New Keypair";
			// 
			// TextBoxKeyPub
			// 
			this.TextBoxKeyPub.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.TextBoxKeyPub.Location = new System.Drawing.Point(376, 40);
			this.TextBoxKeyPub.Multiline = true;
			this.TextBoxKeyPub.Name = "TextBoxKeyPub";
			this.TextBoxKeyPub.ReadOnly = true;
			this.TextBoxKeyPub.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.TextBoxKeyPub.Size = new System.Drawing.Size(360, 120);
			this.TextBoxKeyPub.TabIndex = 12;
			this.TextBoxKeyPub.Text = "";
			// 
			// LabelPub
			// 
			this.LabelPub.Location = new System.Drawing.Point(376, 16);
			this.LabelPub.Name = "LabelPub";
			this.LabelPub.Size = new System.Drawing.Size(168, 16);
			this.LabelPub.TabIndex = 11;
			this.LabelPub.Text = "Public Key XML";
			// 
			// BtnOpenSnk
			// 
			this.BtnOpenSnk.Location = new System.Drawing.Point(304, 168);
			this.BtnOpenSnk.Name = "BtnOpenSnk";
			this.BtnOpenSnk.Size = new System.Drawing.Size(136, 24);
			this.BtnOpenSnk.TabIndex = 13;
			this.BtnOpenSnk.Text = "Open SNK File...";
			// 
			// BtnOpenPub
			// 
			this.BtnOpenPub.Location = new System.Drawing.Point(448, 168);
			this.BtnOpenPub.Name = "BtnOpenPub";
			this.BtnOpenPub.Size = new System.Drawing.Size(136, 24);
			this.BtnOpenPub.TabIndex = 14;
			this.BtnOpenPub.Text = "Open PUB File...";
			// 
			// KeyGenForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(744, 389);
			this.Controls.Add(this.BtnOpenPub);
			this.Controls.Add(this.BtnOpenSnk);
			this.Controls.Add(this.TextBoxKeyPub);
			this.Controls.Add(this.TextBoxKeyPriv);
			this.Controls.Add(this.TextBoxSignature);
			this.Controls.Add(this.TextBoxPlain);
			this.Controls.Add(this.LabelPub);
			this.Controls.Add(this.BtnCreate);
			this.Controls.Add(this.BtnVerifyIt);
			this.Controls.Add(this.LabelSig);
			this.Controls.Add(this.BtnSignIt);
			this.Controls.Add(this.LabelPlain);
			this.Controls.Add(this.LabelPriv);
			this.Controls.Add(this.BtnOpen);
			this.Name = "KeyGenForm";
			this.Text = "KeyGen";
			this.Load += new System.EventHandler(this.KeyGenForm_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void KeyGenForm_Load(object sender, System.EventArgs e)
		{
		
		}


		
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Per Anderson is the founder of Sunfrog Technologies LLC, http://sunfrog-tech.com .

Comments and Discussions