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