]> git.saurik.com Git - apple/libc.git/blob - mach/servers/key_defs.h
Libc-391.4.1.tar.gz
[apple/libc.git] / mach / servers / key_defs.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * Mach Operating System
25 * Copyright (c) 1987 Carnegie-Mellon University
26 * All rights reserved. The CMU software License Agreement specifies
27 * the terms and conditions for use and redistribution.
28 */
29
30 /*
31 * Definitions of encryption keys etc..
32 */
33
34 /*
35 * HISTORY:
36 * 5-Jun-87 Robert Sansom (rds) at Carnegie Mellon University
37 * Added macros to convert keys between network and host order.
38 *
39 * 12-Apr-87 Robert Sansom (rds) at Carnegie Mellon University
40 * Added KEY_IS_NULL.
41 *
42 * 2-Feb-87 Robert Sansom (rds) at Carnegie Mellon University
43 * Added KEY_EQUAL.
44 *
45 * 5-Nov-86 Robert Sansom (rds) at Carnegie-Mellon University
46 * Started.
47 *
48 */
49
50 #ifndef _KEY_DEFS_
51 #define _KEY_DEFS_
52
53 /*
54 * An encrytion key.
55 */
56 typedef union {
57 unsigned char key_bytes[16];
58 unsigned long key_longs[4];
59 } key_t, *key_ptr_t;
60
61 #define KEY_EQUAL(key1, key2) \
62 ((key1.key_longs[0] == key2.key_longs[0]) \
63 && (key1.key_longs[1] == key2.key_longs[1]) \
64 && (key1.key_longs[2] == key2.key_longs[2]) \
65 && (key1.key_longs[3] == key2.key_longs[3]))
66
67 #define KEY_IS_NULL(key) \
68 (((key).key_longs[0] == 0) && ((key).key_longs[1] == 0) \
69 && ((key).key_longs[2] == 0) && ((key).key_longs[3] == 0))
70
71
72 /*
73 * Macros to convert keys between network and host byte order.
74 */
75 #define NTOH_KEY(key) { \
76 (key).key_longs[0] = ntohl((key).key_longs[0]); \
77 (key).key_longs[1] = ntohl((key).key_longs[1]); \
78 (key).key_longs[2] = ntohl((key).key_longs[2]); \
79 (key).key_longs[3] = ntohl((key).key_longs[3]); \
80 }
81
82 #define HTON_KEY(key) { \
83 (key).key_longs[0] = htonl((key).key_longs[0]); \
84 (key).key_longs[1] = htonl((key).key_longs[1]); \
85 (key).key_longs[2] = htonl((key).key_longs[2]); \
86 (key).key_longs[3] = htonl((key).key_longs[3]); \
87 }
88
89 /*
90 * Structure used to transmit or store a token or a key.
91 */
92 typedef union {
93 key_t si_key;
94 key_t si_token;
95 } secure_info_t, *secure_info_ptr_t;
96
97 /*
98 * Security Level of ports and messages.
99 */
100 #define PORT_NOT_SECURE 0
101 #define MESSAGE_NOT_SECURE 0
102
103 #endif /* _KEY_DEFS_ */