key_decryptsession Subroutine

Important: The subroutine is exported from both the libc and the libnsl libraries.

key_decryptsession Subroutine Exported from the libc Library

Purpose

Decrypts a server network name and a Data Encryption Standard (DES) key.

Library

C Library (libc.a)

Syntax

#include <rpc/rpc.h>

key_decryptsession ( remotename,  deskey)
char *remotename;
des_block *deskey;

Description

The key_decryptsession subroutine interfaces to the keyserv daemon, which is associated with the secure authentication system known as DES. The subroutine takes a server network name and a DES key and decrypts the DES key by using the public key of the server and the secret key associated with the effective user number (UID) of the calling process. User programs rarely need to call this subroutine. System commands such as keylogin and the Remote Procedure Call (RPC) library are the main clients.

This subroutine is the inverse of the key_encryptsession subroutine.

Parameters

Item Description
remotename Points to the remote host name.
deskey Points to the des_block structure.

Return Values

Upon successful completion, this subroutine returns a value of 0. If unsuccessful, it returns a value of -1.

key_decryptsession Subroutine Exported from the libnsl Library

Purpose

Decrypts the Data Encryption Standard (DES) key.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
int key_decryptsession ( remotename, deskey)
const char *remotename;
des_block *deskey;

Description

The key_decryptsession subroutine, which belongs to the secure remote procedure call (RPC) category, is an interface subroutine to the keyserver daemon. The subroutine takes a server network name and a DES key and decrypts the DES key by using the public key of the server and the secret key associated with the effective user number (UID) of the calling process. User programs rarely need to call this subroutine.
Note: This subroutine is the inverse of the key_encryptsession subroutine. You must run the keyserv daemon to enable this subroutine.

Parameters

Item Description
remotename Specifies the remote host name.
deskname Specifies the DES key.

Return Values

Item Description
0 successful
-1 unsuccessful

Examples

#include <rpc/rpc.h>
int main()
{
  des_block dblock;
  char name[MAXNETNAMELEN + 1]; /* contains netname of owner of server process */
  char rhost[255]; /* The Remote host */

  /* Obtain network name of remote host */
  if (!host2netname(name, rhost, NULL)) 
  {
    fprintf(stderr,"\nhost2netname() failed\n");
    exit(1);
  }

  if (key_decryptsession(name, &dblock)!=0) {
    fprintf(stderr,"\nkey_decryptsession() failed\n");
    exit(1);
  }
  return 0;
}