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 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #include <rpc/rpc.h> 32 #include <rpc/key_prot.h> 33 34 #ifndef HEX_KEY_BYTES 35 #define HEX_KEY_BYTES HEXKEYBYTES 36 #endif 37 38 extern int key_encryptsession_pk(const char *, netobj *, des_block *); 39 extern int key_decryptsession_pk(const char *, netobj *, des_block *); 40 41 /*ARGSUSED*/ 42 int 43 __getpublickey_cached_g(const char remotename[MAXNETNAMELEN], int keylen, 44 int algtype, char *pkey, size_t pkeylen, int *cached) 45 { 46 return (getpublickey(remotename, pkey)); 47 } 48 49 #pragma weak getpublickey_g 50 /*ARGSUSED*/ 51 int 52 getpublickey_g(const char remotename[MAXNETNAMELEN], int keylen, 53 int algtype, char *pkey, size_t pkeylen) 54 { 55 return (getpublickey(remotename, pkey)); 56 } 57 58 #pragma weak key_encryptsession_pk_g 59 /*ARGSUSED*/ 60 int 61 key_encryptsession_pk_g(const char *remotename, const char *pk, int keylen, 62 int algtype, des_block deskeys[], int no_keys) 63 { 64 int i; 65 netobj npk; 66 67 npk.n_len = HEX_KEY_BYTES; 68 npk.n_bytes = (char *)pk; 69 70 for (i = 0; i < no_keys; i++) { 71 if (key_encryptsession_pk(remotename, &npk, &deskeys[i])) 72 return (-1); 73 } 74 return (0); 75 } 76 77 #pragma weak key_decryptsession_pk_g 78 /*ARGSUSED*/ 79 int 80 key_decryptsession_pk_g(const char *remotename, const char *pk, int keylen, 81 int algtype, des_block deskeys[], int no_keys) 82 { 83 int i; 84 netobj npk; 85 86 npk.n_len = HEX_KEY_BYTES; 87 npk.n_bytes = (char *)pk; 88 89 for (i = 0; i < no_keys; i++) { 90 if (key_decryptsession_pk(remotename, &npk, &deskeys[i])) 91 return (-1); 92 } 93 return (0); 94 } 95 96 #pragma weak key_gendes_g 97 int 98 key_gendes_g(des_block deskeys[], int no_keys) 99 { 100 int i; 101 102 memset(deskeys, 0, no_keys* sizeof (des_block)); 103 for (i = 0; i < no_keys; i++) { 104 if (key_gendes(&deskeys[i])) 105 return (-1); 106 } 107 return (0); 108 } 109 110 #pragma weak key_secretkey_is_set_g 111 /*ARGSUSED*/ 112 int 113 key_secretkey_is_set_g(int Keylen, int algtype) 114 { 115 return (key_secretkey_is_set()); 116 } 117 118 #pragma weak des_setparity 119 void 120 des_setparity_g(des_block *key) 121 { 122 des_setparity((char *)key); 123 } 124