- retrieve public or secret key
#include <rpc/rpc.h> #include <rpc/key_prot.h> int getpublickey(const char netname[MAXNETNAMELEN], char publickey[HEXKEYBYTES+1]);
int getsecretkey(const char netname[MAXNETNAMELEN], char secretkey[HEXKEYBYTES+1],const char *passwd);
The getpublickey() and getsecretkey() functions get public and secret keys for netname. The key may come from one of the following sources:
/etc/publickey file. See publickey(4).
NIS map ``publickey.byname'' or the NIS+ table ``cred.org_dir''. The sources and their lookup order are specified in the /etc/nsswitch.conf file. See nsswitch.conf(4).
getsecretkey() has an extra argument, passwd, which is used to decrypt the encrypted secret key stored in the database.
Both routines return 1 if they are successful in finding the key. Otherwise, the routines return 0. The keys are returned as null-terminated, hexadecimal strings. If the password supplied to getsecretkey() fails to decrypt the secret key, the routine will return 1 but the secretkey  will be set to NULL.
See attributes(5) for descriptions of the following attributes:
If getpublickey() gets the public key from any source other than NIS+, all authenticated NIS+ operations may fail. To ensure that this does not happen, edit the nsswitch.conf(4) file to make sure that the public key is obtained from NIS+.
NIS+ might not be supported in future releases of the Solaris operating system. Tools to aid the migration from NIS+ to LDAP are available in the current Solaris release. For more information, visit http://www.sun.com/directory/nisplus/transition.html.