8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / keyserv / keyserv_cache.h
blobfe4cf7c8c1cf1359386e00bd3d146296b48f1f44
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _KEYSERV_CACHE_H
28 #define _KEYSERV_CACHE_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 /* uid_t, size_t, caddr_t, u_int, etc. */
37 #include <sys/types.h>
38 /* des_block, keylen_t, algtype_t */
39 #include <rpc/key_prot.h>
41 struct dhkey {
42 u_short length; /* Length in bytes */
43 u_char key[1]; /* Binary data; allocated to correct length */
46 /* Round up to multiple of four */
47 #define ALIGN4(addr) (4 * (((addr)+3)/4))
48 /* Round up to multiple of eight */
49 #define ALIGN8(addr) (8 * (((addr)+7)/8))
51 /* Convert key length in bits to bytes */
52 #define KEYLEN(keylen) (((keylen)+7)/8)
54 /* Bytes to allocate for struct dhkey holding key of specified length (bits) */
55 #define DHKEYALLOC(keylen) ALIGN4(sizeof (struct dhkey) + KEYLEN(keylen))
56 /* Bytes used for a struct dhkey (already allocated */
57 #define DHKEYSIZE(dhkey_ptr) ALIGN4(sizeof (struct dhkey) + \
58 (dhkey_ptr)->length)
60 struct cachekey3_list {
61 keybuf3 *public;
62 keybuf3 *secret;
63 int refcnt;
64 deskeyarray deskey;
65 struct cachekey3_list *next;
68 #define CACHEKEY3_LIST_SIZE(keylen) (sizeof (struct cachekey3_list) + \
69 2*sizeof (keybuf3) + \
70 2*(ALIGN4(2*KEYLEN(keylen)+1)) + \
71 3*sizeof (des_block))
73 int create_cache_file(keylen_t keylen, algtype_t algtype,
74 int sizespec);
76 int cache_insert(keylen_t keylen, algtype_t algtype,
77 uid_t uid,
78 deskeyarray common, des_block key,
79 keybuf3 *public,
80 keybuf3 *secret);
82 struct cachekey3_list *cache_retrieve(keylen_t keylen, algtype_t algtype,
83 uid_t uid,
84 keybuf3 *public, des_block key);
86 int cache_remove(keylen_t keylen, algtype_t algtype,
87 uid_t uid,
88 keybuf3 *public);
90 void print_cache(keylen_t keylen, algtype_t algtype);
92 #ifdef __cplusplus
94 #endif
96 #endif /* _KEYSERV_CACHE_H */