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