Back to index

glibc  2.9
Defines | Functions | Variables
crypt-entry.c File Reference
#include <string.h>
#include "ufc-crypt.h"
#include "crypt.h"
#include "crypt-private.h"

Go to the source code of this file.

Defines

#define STATIC   static

Functions

char * __crypt_r (char *key, const char *salt, struct crypt_data *__restrict data) const
 weak_alias (__crypt_r, crypt_r)
char * __fcrypt (char *key, const char *salt) const

Variables

static const char md5_salt_prefix [] = "$1$"
static const char sha256_salt_prefix [] = "$5$"
static const char sha512_salt_prefix [] = "$6$"

Define Documentation

#define STATIC   static

Definition at line 33 of file crypt-entry.c.


Function Documentation

char* __crypt_r ( char *  key,
const char *  salt,
struct crypt_data * __restrict  data 
) const

Definition at line 85 of file crypt-entry.c.

{
  ufc_long res[4];
  char ktab[9];
  ufc_long xx = 25; /* to cope with GCC long long compiler bugs */

#ifdef _LIBC
  /* Try to find out whether we have to use MD5 encryption replacement.  */
  if (strncmp (md5_salt_prefix, salt, sizeof (md5_salt_prefix) - 1) == 0)
    return __md5_crypt_r (key, salt, (char *) data,
                       sizeof (struct crypt_data));

  /* Try to find out whether we have to use SHA256 encryption replacement.  */
  if (strncmp (sha256_salt_prefix, salt, sizeof (sha256_salt_prefix) - 1) == 0)
    return __sha256_crypt_r (key, salt, (char *) data,
                          sizeof (struct crypt_data));

  /* Try to find out whether we have to use SHA512 encryption replacement.  */
  if (strncmp (sha512_salt_prefix, salt, sizeof (sha512_salt_prefix) - 1) == 0)
    return __sha512_crypt_r (key, salt, (char *) data,
                          sizeof (struct crypt_data));
#endif

  /*
   * Hack DES tables according to salt
   */
  _ufc_setup_salt_r (salt, data);

  /*
   * Setup key schedule
   */
  _ufc_clearmem (ktab, (int) sizeof (ktab));
  (void) strncpy (ktab, key, 8);
  _ufc_mk_keytab_r (ktab, data);

  /*
   * Go for the 25 DES encryptions
   */
  _ufc_clearmem ((char*) res, (int) sizeof (res));
  _ufc_doit_r (xx,  data, &res[0]);

  /*
   * Do final permutations
   */
  _ufc_dofinalperm_r (res, data);

  /*
   * And convert back to 6 bit ASCII
   */
  _ufc_output_conversion_r (res[0], res[1], salt, data);
  return data->crypt_3_buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* __fcrypt ( char *  key,
const char *  salt 
) const

Definition at line 173 of file crypt-entry.c.

{
  return crypt (key, salt);
}

Here is the call graph for this function:

weak_alias ( __crypt_r  ,
crypt_r   
)

Definition at line 140 of file crypt-entry.c.

{
#ifdef _LIBC
  /* Try to find out whether we have to use MD5 encryption replacement.  */
  if (strncmp (md5_salt_prefix, salt, sizeof (md5_salt_prefix) - 1) == 0)
    return __md5_crypt (key, salt);

  /* Try to find out whether we have to use SHA256 encryption replacement.  */
  if (strncmp (sha256_salt_prefix, salt, sizeof (sha256_salt_prefix) - 1) == 0)
    return __sha256_crypt (key, salt);

  /* Try to find out whether we have to use SHA512 encryption replacement.  */
  if (strncmp (sha512_salt_prefix, salt, sizeof (sha512_salt_prefix) - 1) == 0)
    return __sha512_crypt (key, salt);
#endif

  return __crypt_r (key, salt, &_ufc_foobar);
}

Here is the call graph for this function:


Variable Documentation

const char md5_salt_prefix[] = "$1$" [static]

Definition at line 69 of file crypt-entry.c.

const char sha256_salt_prefix[] = "$5$" [static]

Definition at line 72 of file crypt-entry.c.

const char sha512_salt_prefix[] = "$6$" [static]

Definition at line 75 of file crypt-entry.c.