Quite special PublicKey in .NET core assemblies

不打扰是莪最后的温柔 提交于 2019-12-01 03:42:54

That's the ECMA Standard defined public key.

It's to deal with three conflicting requirements:

  1. A mechanism that ensures that assemblies are signed by their creators and could not have been created by a fraudulent other party.
  2. That CLI be defined openly in such a way that other people are free to implement a version (Mono would be a real-life example).
  3. That there be a standard library of classes made available with every version of the framework.

These three things can't happen at the same time!

If I create a version of .NET (point 2), then I need to provide a version of the standard library (point 3), which needs to be trusted (point 1), so I need to sign it to prove that I'm Microsoft. Oh wait, I'm not Microsoft! (eh, point 2 again).

Instead what happens is:

  1. I create a public-private key pair. People trusted to build new release versions of the assemblies in my framework library implementation have access to the private key, the public key can be known to anyone doing any work on the CLI implementation.

  2. I mark the relevant assemblies as having been signed with the key corresponding to the public key 00000000000000000400000000000000 (defined in the ECMA standard), though really they were signed with the private key mentioned above.

  3. In the code in the CLI any check on an assembly that claims to have been signed with the key corresponding to the public key 00000000000000000400000000000000 is checked with the real public key. If this checks out, then it can only have been signed by someone we trust in building those assemblies.

Of course, MS's framework won't trust our assemblies, Mono's won't trust them, and we won't trust either of theirs, because we all have different real keys corresponding to the ECMA standard key. Which is as it should be.

Meanwhile, the fact that 00000000000000000400000000000000 doesn't match any real valid public key means it's not possible for it to clash with any other public key.

This is NOT the proper answer to the question. The only thing this answer provides is the pointer to ECMA standard, apparently ECMA-335 with CLI specs. But this ECMA standard provides only a basic definition in terms of unique/fixed value and the name it should be called. Otherwise, it provides nothing about how and where the actual public key is found. The value 00000000000000000400000000000000 is NOT a public key, it is only a marker called Standard Public Key which has nothing to do with a real public key. This value is used to compute Public Key Token for the assembly that uses it but this value is not used to as any public key of RSA algorithm when processing the assembly signature. You need a real Public Key. The proper answer to the question should be how and where the actual Public Key is found for the assembly that uses it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!