Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Preventing unauthorized code execution

Preventing unauthorized code execution

Scheduled Pinned Locked Moved C#
comquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Office Lineman
    wrote on last edited by
    #1

    Is there a way to actually stop unauthorized use of code in a DLL? The article on SecUtil[^] sounds nice, but doesn't work at all, unless I'm missing something painfully obvious. I've got a signed DLL with a single public class exposing a single public method:

    public class Thingy
    {
    private const string PUBLIC_KEY = "0x00..." // a 160-byte hex string

    [StrongNameIdentityPermission(SecurityAction.Demand, PublicKey = PUBLIC_KEY)]
    public Thingy ()
    {
    }

    [StrongNameIdentityPermission(SecurityAction.Demand, PublicKey = PUBLIC_KEY)]
    public int Add (int v1, int v2)
    {
    return (v1 + v2);
    }
    }

    And I'm calling it in a separate unsigned application:

    private void button1_Click (object sender, EventArgs e)
    {
    Thingy thingy = new Thingy();

    int result = thingy.Add(6, 7);

    MessageBox.Show("6 + 7 = " + result.ToString());
    }

    It should be protected, and yet I get my message box "6 + 7 = 13" just fine. Any ideas? -- I've killed again, haven't I?

    O 1 Reply Last reply
    0
    • O Office Lineman

      Is there a way to actually stop unauthorized use of code in a DLL? The article on SecUtil[^] sounds nice, but doesn't work at all, unless I'm missing something painfully obvious. I've got a signed DLL with a single public class exposing a single public method:

      public class Thingy
      {
      private const string PUBLIC_KEY = "0x00..." // a 160-byte hex string

      [StrongNameIdentityPermission(SecurityAction.Demand, PublicKey = PUBLIC_KEY)]
      public Thingy ()
      {
      }

      [StrongNameIdentityPermission(SecurityAction.Demand, PublicKey = PUBLIC_KEY)]
      public int Add (int v1, int v2)
      {
      return (v1 + v2);
      }
      }

      And I'm calling it in a separate unsigned application:

      private void button1_Click (object sender, EventArgs e)
      {
      Thingy thingy = new Thingy();

      int result = thingy.Add(6, 7);

      MessageBox.Show("6 + 7 = " + result.ToString());
      }

      It should be protected, and yet I get my message box "6 + 7 = 13" just fine. Any ideas? -- I've killed again, haven't I?

      O Offline
      O Offline
      Office Lineman
      wrote on last edited by
      #2

      Okay, it seems to work in .NET 1.1, but not in .NET 2.0. :wtf: Apparently .NET 2.0 has said, "The hell with security." One can easily run any code in a trusted zone without any regard whatsoever to standing individual assembly security requirements set by StrongNameIdentityPermission. :mad: -- I've killed again, haven't I?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups