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