title: Is it possible to generate a private key knowing the public key of a signed assembly?
body: <p>For a signed assembly, using the following code to examine the public key</p>
  
  <pre><code>AssemblyName an = AssemblyName.GetAssemblyName(dllFile);
  Assembly assembly = Assembly.Load(an);
  
  if (assembly != null)
  {
      AssemblyName asmName = assembly.GetName();
      byte[] key = asmName.GetPublicKey();
      bool isSignedAsm = key.Length &gt; 0;
  }
  </code></pre>
  
  <p>Using the byte array for the public key, can an attacker regenerate the private key that is associated with that public key, and create his own set of assemblies that appear to be signed by me?</p>
  
  <p>I want to know this because I want to use the byte array of the public key as a way to prevent loading an assembly that was not signed by a particular private key. (by comparing it to a known public key I already have and trust)</p>