Index: security-manager.h =================================================================== --- security-manager.h (revision 52657) +++ security-manager.h (working copy) @@ -26,7 +26,12 @@ /* Definitions */ #define MONO_ECMA_KEY_LENGTH 16 +#define MONO_PUBLIC_KEY_HEADER_LENGTH 32 +#define MONO_MINIMUM_PUBLIC_KEY_LENGTH 48 +#define MONO_DEFAULT_PUBLIC_KEY_LENGTH 128 +#define MONO_PUBLIC_KEY_BIT_SIZE(x) ((x - MONO_PUBLIC_KEY_HEADER_LENGTH) << 3) + enum { MONO_METADATA_SECURITY_OK = 0x00, MONO_METADATA_INHERITANCEDEMAND_CLASS = 0x01, Index: ChangeLog =================================================================== --- ChangeLog (revision 52657) +++ ChangeLog (working copy) @@ -1,3 +1,10 @@ +2005-11-07 Sebastien Pouliot + + * security-manager.h: Added definitions to deal with strongname key + pairs bigger (and smaller) than 1024 bits. + * reflection.c: Remove hardcoded strongname size (128 bytes) and + adjust wrt the public key length being used. + 2005-11-03 Atsushi Enomoto * marshal.c, icall.c : reverted sig->pinvoke changes which broke Index: reflection.c =================================================================== --- reflection.c (revision 52657) +++ reflection.c (working copy) @@ -20,6 +20,7 @@ #include "mono/metadata/object-internals.h" #include #include +#include #include #include #include @@ -3782,8 +3783,17 @@ token = mono_image_add_stream_data (&assembly->blob, blob_size, b - blob_size); mono_image_add_stream_data (&assembly->blob, mono_array_addr (pkey, guint8, 0), len); - /* need to get the actual value from the key type... */ - assembly->strong_name_size = 128; + /* Special case: check for ECMA key (16 bytes) */ + if ((len == MONO_ECMA_KEY_LENGTH) && mono_is_ecma_key (mono_array_addr (pkey, guint8, 0), len)) { + /* In this case we must reserve 128 bytes (1024 bits) for the signature */ + assembly->strong_name_size = MONO_DEFAULT_PUBLIC_KEY_LENGTH; + } else if (len >= MONO_PUBLIC_KEY_HEADER_LENGTH + MONO_MINIMUM_PUBLIC_KEY_LENGTH) { + /* minimum key size (in 2.0) is 384 bits */ + assembly->strong_name_size = len - MONO_PUBLIC_KEY_HEADER_LENGTH; + } else { + /* FIXME - verifier */ + g_warning ("Invalid public key length: %d bits (total: %d)", MONO_PUBLIC_KEY_BIT_SIZE (len), len); + } assembly->strong_name = g_malloc0 (assembly->strong_name_size); return token;