xref: /illumos-gate/usr/src/lib/gss_mechs/mech_dh/dh192/fakensl.c (revision ed093b41a93e8563e6e1e5dae0768dda2a7bcc27)
1 /*
2  * CDDL HEADER START
3  *
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.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	fakensl.c
24  *
25  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 #include <rpc/rpc.h>
30 #include <rpc/key_prot.h>
31 
32 #ifndef HEX_KEY_BYTES
33 #define	HEX_KEY_BYTES HEXKEYBYTES
34 #endif
35 
36 extern int key_encryptsession_pk(const char *, netobj *, des_block *);
37 extern int key_decryptsession_pk(const char *, netobj *, des_block *);
38 
39 /*ARGSUSED*/
40 int
41 __getpublickey_cached_g(const char remotename[], int keylen,
42     int algtype, char *pkey, size_t pkeylen, int *cached)
43 {
44 	return (getpublickey(remotename, pkey));
45 }
46 
47 #pragma weak getpublickey_g
48 /*ARGSUSED*/
49 int
50 getpublickey_g(const char remotename[], int keylen,
51     int algtype, char *pkey, size_t pkeylen)
52 {
53 	return (getpublickey(remotename, pkey));
54 }
55 
56 #pragma weak key_encryptsession_pk_g
57 /*ARGSUSED*/
58 int
59 key_encryptsession_pk_g(const char *remotename, const char *pk, int keylen,
60     int algtype, des_block deskeys[], int no_keys)
61 {
62 	int i;
63 	netobj npk;
64 
65 	npk.n_len = HEX_KEY_BYTES;
66 	npk.n_bytes = (char *)pk;
67 
68 	for (i = 0; i < no_keys; i++) {
69 		if (key_encryptsession_pk(remotename, &npk, &deskeys[i]))
70 			return (-1);
71 	}
72 	return (0);
73 }
74 
75 #pragma weak key_decryptsession_pk_g
76 /*ARGSUSED*/
77 int
78 key_decryptsession_pk_g(const char *remotename, const char *pk, int keylen,
79     int algtype, des_block deskeys[], int no_keys)
80 {
81 	int i;
82 	netobj npk;
83 
84 	npk.n_len = HEX_KEY_BYTES;
85 	npk.n_bytes = (char *)pk;
86 
87 	for (i = 0; i < no_keys; i++) {
88 		if (key_decryptsession_pk(remotename, &npk, &deskeys[i]))
89 			return (-1);
90 	}
91 	return (0);
92 }
93 
94 #pragma weak key_gendes_g
95 int
96 key_gendes_g(des_block deskeys[], int no_keys)
97 {
98 	int i;
99 
100 	memset(deskeys, 0, no_keys* sizeof (des_block));
101 	for (i = 0; i < no_keys; i++) {
102 		if (key_gendes(&deskeys[i]))
103 			return (-1);
104 	}
105 	return (0);
106 }
107 
108 #pragma weak key_secretkey_is_set_g
109 /*ARGSUSED*/
110 int
111 key_secretkey_is_set_g(int Keylen, int algtype)
112 {
113 	return (key_secretkey_is_set());
114 }
115 
116 #pragma weak des_setparity
117 void
118 des_setparity_g(des_block *key)
119 {
120 	des_setparity((char *)key);
121 }
122