Re: Public Keys and Signed Executables

From: Steven Pratschner [MS] (
Date: 04/23/03

From: "Steven Pratschner [MS]" <>
Date: Tue, 22 Apr 2003 17:47:44 -0700

Hi Heath - How are you extracting the public key from the assembly? Can you
send us the code snippet? .snk files have a little header that we stick on
the front that contains things like the algorithm, key length and so on.
Its possible that the key you're getting out of the assembly doesn't have
this header.


"Heath Stewart" <> wrote in message
> I've been doing some work with signed XML where I sign the original XML
> document as an enveloped signature and I don't store the public key in the
> KeyInfo section. The NT Service that would read the file would use the
> public key from the same key pair file it was signed with (as well as the
> XML doc) to verify the signature. After doing a lot of research and
> I've discovered something very odd and hopefully someone here can explain
> me what is happening.
> Let say my key pair is KeyFile.snk. All .NET assemblies are signed with
> key pair and it is in a key store. If I extract the public key with
> "sn.exe -pc Proplanner Pubkey.key", it gives me the public key. Through a
> little console-based application I wrote, I get the public key from the
> assembly (remember, it was signed with the same key pair), do some
> byte-swapping (since it's stored as big-endian), and save that to
> Pubkey2.key. Now, these should be the same, right? Actually, only the
> Exponent is the same. The modulus is completely different!
> Why would the public key be different between the key pair file and the
> assembly that was signed with the same key pair file? Or, at least why is
> the modulus different? Looking at the actual structure of each, everything
> else is the same (i.e., the BLOBHEADER and RSAPUBKEY structures).
> Also, I'm using different combinations of the .NET Frameworks security
> implementation, the WSE, the CryptoAPI, and even direct byte manipulation
> and I always come up with the same results.
> --
> Heath Stewart
> Software Engineer / Network Administrator
> Proplanner.NET: Web-based Production Planning Solutions