key_encryptsession Subroutine

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

key_encryptsession Subroutine Exported from the libc Library

Purpose

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

Library

C Library (libc.a)

Syntax

#include <rpc/rpc.h>

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

Description

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

This subroutine is the inverse of the key_decryptsession 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_encryptsession Subroutine Exported from the libnsl Library

Purpose

Encrypts the Data Encryption Standard (DES) key.

Library

Network Services Library (libnsl.a)

Syntax

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

Description

The key_encryptsession 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 encrypts the key by using the public key of the server and the secret key associated with the effective UID of the calling process. However, user programs rarely need to call this subroutine.
Note: This subroutine is the inverse of the key_decryptsession 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[255]; /* 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);
  }

  strcpy(dblock.c, "deskey");
  if (key_encryptsession(name, &dblock) != 0) {
    fprintf(stderr, "\nkey_encryptsession() failed\n");
    exit(1);
  }

  return 0;
}