AssemblySignatureKeyAttribute 类

定义

提供从更早、更简单的名称键值到更大、散列值算法更安全的键值的迁移。Provides migration from an older, simpler strong name key to a larger key with a stronger hashing algorithm.

public ref class AssemblySignatureKeyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
public sealed class AssemblySignatureKeyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)>]
type AssemblySignatureKeyAttribute = class
    inherit Attribute
Public NotInheritable Class AssemblySignatureKeyAttribute
Inherits Attribute
继承
AssemblySignatureKeyAttribute
属性

注解

新的较大键是签名密钥。The new larger key is the signature key. 在 .NET Framework 4.5 之前的版本中,签名密钥与标识密钥完全相同。In versions before the .NET Framework 4.5, the signature key was identical to the identity key. 从 .NET Framework 4.5 开始,该 AssemblySignatureKeyAttribute 特性允许程序集元数据继续具有旧的公钥标记和二进制大型对象 (BLOB) 以便现有的程序集引用继续工作。Starting with the .NET Framework 4.5, the AssemblySignatureKeyAttribute attribute allows the assembly metadata to continue to have the old public key token and binary large object (BLOB) so that existing assembly references continue to work. 它还可确保映射来自标识密钥的所有者。It also ensures that the mapping comes from an owner of the identity key.

特性的存在并不一定意味着会发生强名称验证。The presence of the attribute does not necessarily mean that strong name validation takes place. 在常见的完全信任情况下,永远不会考虑属性,因为强名称签名从不进行验证。In common full-trust scenarios, the attribute is never considered, because strong name signatures are never validated. 但是,如果必须验证强名称签名,则必须验证强名称签名和副署。However, when the strong name signature does have to be validated, both the strong name signature and the countersignature must be validated. 程序集的标识键不必与签名密钥相同 (用于执行实际签名和验证) 的密钥。The assembly's identity key does not have to be identical to the signature key (the key used to do the actual signing and validation). 标识密钥可以映射到不同 (更可靠) 签名密钥。The identity key can be mapped to a different (more robust) signing key. 这使您可以设置程序集的标识,并将签名密钥和算法更新为更安全的版本。This lets you set the identity of an assembly, and update the signing keys and algorithms to more secure versions.

副署解决了恶意程序集声明某些其他标识时的安全问题。The countersignature addresses security concerns when a malicious assembly claims some other identity. 例如,恶意的 System.Core.dll 程序集可能会在其元数据中包含 Microsoft 公钥,并使用属性来指示强名称验证,以便在不存在副署的情况下使用攻击者的签名密钥。For example, a malicious System.Core.dll assembly could contain the Microsoft public key in its metadata, and use the attribute to tell strong name validation to use the attacker's signature key if no countersignature is present. 因此,它可能伪装成经过强名称验证的 Microsoft 程序集。Thus, it could masquerade as a strong name-validated Microsoft assembly.

有关如何使用此新属性对程序集进行签名的信息,请参阅 增强的强名称For information about how to sign assemblies for use with this new attribute, see Enhanced Strong Naming.

构造函数

AssemblySignatureKeyAttribute(String, String)

使用指定的公钥和副署创建 AssemblySignatureKeyAttribute 类的新实例。Creates a new instance of the AssemblySignatureKeyAttribute class by using the specified public key and countersignature.

属性

Countersignature

获取此程序集强名称的副署。Gets the countersignature for the strong name for this assembly.

PublicKey

获取用于签名程序集的强名称的公钥。Gets the public key for the strong name used to sign the assembly.

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(继承自 Attribute)

方法

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(继承自 Attribute)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(继承自 Attribute)
Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

显式接口实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(继承自 Attribute)

适用于