First set of licensing changes
[mono.git] / mono / metadata / security-manager.h
1 /*
2  * security-manager.h:  Security Manager
3  *
4  * Author:
5  *      Sebastien Pouliot  <sebastien@ximian.com>
6  *
7  * Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
8  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
9  */
10
11 #ifndef _MONO_METADATA_SECURITY_MANAGER_H_
12 #define _MONO_METADATA_SECURITY_MANAGER_H_
13
14 #include <string.h>
15
16 #include "object.h"
17 #include "metadata-internals.h"
18 #include "domain-internals.h"
19 #include "tokentype.h"
20 #include "threads.h"
21 #include "marshal.h"
22 #include "image.h"
23 #include "reflection.h"
24 #include "tabledefs.h"
25
26
27 /* Definitions */
28
29 #define MONO_ECMA_KEY_LENGTH                    16
30 #define MONO_PUBLIC_KEY_HEADER_LENGTH           32
31 #define MONO_MINIMUM_PUBLIC_KEY_LENGTH          48
32 #define MONO_DEFAULT_PUBLIC_KEY_LENGTH          128
33
34 #define MONO_PUBLIC_KEY_BIT_SIZE(x)             ((x - MONO_PUBLIC_KEY_HEADER_LENGTH) << 3)
35
36 enum {
37         MONO_METADATA_SECURITY_OK               = 0x00,
38         MONO_METADATA_INHERITANCEDEMAND_CLASS   = 0x01,
39         MONO_METADATA_INHERITANCEDEMAND_METHOD  = 0x02
40 };
41
42 typedef enum {
43         MONO_SECURITY_MODE_NONE,
44         MONO_SECURITY_MODE_CORE_CLR,
45 } MonoSecurityMode;
46
47 /* Structures */
48
49 typedef struct {
50         MonoClass *securitymanager;             /* System.Security.SecurityManager */
51 } MonoSecurityManager;
52
53 gboolean mono_is_ecma_key (const char *publickey, int size);
54 MonoMethod* mono_get_context_capture_method (void);
55
56 MonoSecurityManager* mono_security_manager_get_methods (void);
57
58 /* Security mode */
59 void mono_security_set_mode (MonoSecurityMode mode);
60 MonoSecurityMode mono_security_get_mode (void);
61
62 /* internal calls */
63 MonoBoolean ves_icall_System_Security_SecurityManager_get_SecurityEnabled (void);
64 void ves_icall_System_Security_SecurityManager_set_SecurityEnabled (MonoBoolean value);
65
66 #ifndef DISABLE_SECURITY
67 #define mono_security_core_clr_enabled() (mono_security_get_mode () == MONO_SECURITY_MODE_CORE_CLR)
68 #else
69 #define mono_security_core_clr_enabled() (FALSE)
70 #endif
71
72 #endif /* _MONO_METADATA_SECURITY_MANAGER_H_ */