Header And Logo

PostgreSQL
| The world's most advanced open source database.

px-crypt.h

Go to the documentation of this file.
00001 /*
00002  * px-crypt.h
00003  *      Header file for px_crypt().
00004  *
00005  * Copyright (c) 2001 Marko Kreen
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  * contrib/pgcrypto/px-crypt.h
00030  */
00031 
00032 #ifndef _PX_CRYPT_H
00033 #define _PX_CRYPT_H
00034 
00035 /* max room for result */
00036 #define PX_MAX_CRYPT  128
00037 
00038 /* max salt returned by gen_salt() */
00039 #define PX_MAX_SALT_LEN     128
00040 
00041 /* default rounds for xdes salt */
00042 /* NetBSD bin/passwd/local_passwd.c has (29 * 25)*/
00043 #define PX_XDES_ROUNDS      (29 * 25)
00044 
00045 /* default for blowfish salt */
00046 #define PX_BF_ROUNDS        6
00047 
00048 /*
00049  * main interface
00050  */
00051 char       *px_crypt(const char *psw, const char *salt, char *buf, unsigned buflen);
00052 int         px_gen_salt(const char *salt_type, char *dst, int rounds);
00053 
00054 /*
00055  * internal functions
00056  */
00057 
00058 /* crypt-gensalt.c */
00059 char *_crypt_gensalt_traditional_rn(unsigned long count,
00060                  const char *input, int size, char *output, int output_size);
00061 char *_crypt_gensalt_extended_rn(unsigned long count,
00062                  const char *input, int size, char *output, int output_size);
00063 char *_crypt_gensalt_md5_rn(unsigned long count,
00064                  const char *input, int size, char *output, int output_size);
00065 char *_crypt_gensalt_blowfish_rn(unsigned long count,
00066                  const char *input, int size, char *output, int output_size);
00067 
00068 /* disable 'extended DES crypt' */
00069 /* #define DISABLE_XDES */
00070 
00071 /* crypt-blowfish.c */
00072 char *_crypt_blowfish_rn(const char *key, const char *setting,
00073                    char *output, int size);
00074 
00075 /* crypt-des.c */
00076 char       *px_crypt_des(const char *key, const char *setting);
00077 
00078 /* crypt-md5.c */
00079 char *px_crypt_md5(const char *pw, const char *salt,
00080              char *dst, unsigned dstlen);
00081 
00082 #endif   /* _PX_CRYPT_H */