mirror of
https://github.com/postgres/postgres.git
synced 2025-07-21 16:02:15 +03:00
* construct "struct {} list [] = {}" confuses pgindent - split those.
It was a bad style to begin with, and now several loops can be clearer. * pgcrypto.c: Fix function comments * crypt-gensalt.c, crypt-blowfish.c: stop messing with errno * openssl.c: use px_free instead pfree * px.h: make redefining px_alloc/px_realloc/px_free easier Marko Kreen
This commit is contained in:
@ -35,12 +35,6 @@
|
|||||||
#include "px.h"
|
#include "px.h"
|
||||||
#include "px-crypt.h"
|
#include "px-crypt.h"
|
||||||
|
|
||||||
#define __set_errno(v)
|
|
||||||
|
|
||||||
#ifndef __set_errno
|
|
||||||
#define __set_errno(val) errno = (val)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
#define BF_ASM 0 /* 1 */
|
#define BF_ASM 0 /* 1 */
|
||||||
#define BF_SCALE 1
|
#define BF_SCALE 1
|
||||||
@ -600,10 +594,7 @@ _crypt_blowfish_rn(const char *key, const char *setting,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (size < 7 + 22 + 31 + 1)
|
if (size < 7 + 22 + 31 + 1)
|
||||||
{
|
|
||||||
__set_errno(ERANGE);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (setting[0] != '$' ||
|
if (setting[0] != '$' ||
|
||||||
setting[1] != '2' ||
|
setting[1] != '2' ||
|
||||||
@ -613,7 +604,6 @@ _crypt_blowfish_rn(const char *key, const char *setting,
|
|||||||
setting[5] < '0' || setting[5] > '9' ||
|
setting[5] < '0' || setting[5] > '9' ||
|
||||||
setting[6] != '$')
|
setting[6] != '$')
|
||||||
{
|
{
|
||||||
__set_errno(EINVAL);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +611,6 @@ _crypt_blowfish_rn(const char *key, const char *setting,
|
|||||||
if (count < 16 || BF_decode(data.binary.salt, &setting[7], 16))
|
if (count < 16 || BF_decode(data.binary.salt, &setting[7], 16))
|
||||||
{
|
{
|
||||||
memset(data.binary.salt, 0, sizeof(data.binary.salt));
|
memset(data.binary.salt, 0, sizeof(data.binary.salt));
|
||||||
__set_errno(EINVAL);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
BF_swap(data.binary.salt, 4);
|
BF_swap(data.binary.salt, 4);
|
||||||
|
@ -15,11 +15,6 @@
|
|||||||
#include "px.h"
|
#include "px.h"
|
||||||
#include "px-crypt.h"
|
#include "px-crypt.h"
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#ifndef __set_errno
|
|
||||||
#define __set_errno(val) (errno = (val))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef unsigned int BF_word;
|
typedef unsigned int BF_word;
|
||||||
|
|
||||||
unsigned char _crypt_itoa64[64 + 1] =
|
unsigned char _crypt_itoa64[64 + 1] =
|
||||||
@ -33,7 +28,6 @@ _crypt_gensalt_traditional_rn(unsigned long count,
|
|||||||
{
|
{
|
||||||
if (output_size > 0)
|
if (output_size > 0)
|
||||||
output[0] = '\0';
|
output[0] = '\0';
|
||||||
__set_errno((output_size < 2 + 1) ? ERANGE : EINVAL);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +51,6 @@ _crypt_gensalt_extended_rn(unsigned long count,
|
|||||||
{
|
{
|
||||||
if (output_size > 0)
|
if (output_size > 0)
|
||||||
output[0] = '\0';
|
output[0] = '\0';
|
||||||
__set_errno((output_size < 1 + 4 + 4 + 1) ? ERANGE : EINVAL);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +84,6 @@ _crypt_gensalt_md5_rn(unsigned long count,
|
|||||||
{
|
{
|
||||||
if (output_size > 0)
|
if (output_size > 0)
|
||||||
output[0] = '\0';
|
output[0] = '\0';
|
||||||
__set_errno((output_size < 3 + 4 + 1) ? ERANGE : EINVAL);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +165,6 @@ _crypt_gensalt_blowfish_rn(unsigned long count,
|
|||||||
{
|
{
|
||||||
if (output_size > 0)
|
if (output_size > 0)
|
||||||
output[0] = '\0';
|
output[0] = '\0';
|
||||||
__set_errno((output_size < 7 + 22 + 1) ? ERANGE : EINVAL);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.14 2004/10/25 02:15:02 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.15 2005/03/21 05:18:45 neilc Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -57,22 +57,17 @@
|
|||||||
static void init_md5(PX_MD * h);
|
static void init_md5(PX_MD * h);
|
||||||
static void init_sha1(PX_MD * h);
|
static void init_sha1(PX_MD * h);
|
||||||
|
|
||||||
static struct int_digest
|
struct int_digest
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
void (*init) (PX_MD * h);
|
void (*init) (PX_MD * h);
|
||||||
} int_digest_list[] =
|
};
|
||||||
|
|
||||||
{
|
static const struct int_digest
|
||||||
{
|
int_digest_list[] = {
|
||||||
"md5", init_md5
|
{ "md5", init_md5 },
|
||||||
},
|
{ "sha1", init_sha1 },
|
||||||
{
|
{ NULL, NULL }
|
||||||
"sha1", init_sha1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
NULL, NULL
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* MD5 */
|
/* MD5 */
|
||||||
@ -516,31 +511,22 @@ bf_cbc_load(void)
|
|||||||
return bf_load(MODE_CBC);
|
return bf_load(MODE_CBC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct
|
struct int_cipher
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
PX_Cipher *(*load) (void);
|
PX_Cipher *(*load) (void);
|
||||||
} int_ciphers[] =
|
|
||||||
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"bf-cbc", bf_cbc_load
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bf-ecb", bf_ecb_load
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"aes-128-cbc", rj_128_cbc
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"aes-128-ecb", rj_128_ecb
|
|
||||||
},
|
|
||||||
{
|
|
||||||
NULL, NULL
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static PX_Alias int_aliases[] = {
|
static const struct int_cipher
|
||||||
|
int_ciphers[] = {
|
||||||
|
{ "bf-cbc", bf_cbc_load },
|
||||||
|
{ "bf-ecb", bf_ecb_load },
|
||||||
|
{ "aes-128-cbc", rj_128_cbc },
|
||||||
|
{ "aes-128-ecb", rj_128_ecb },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const PX_Alias int_aliases[] = {
|
||||||
{"bf", "bf-cbc"},
|
{"bf", "bf-cbc"},
|
||||||
{"blowfish", "bf-cbc"},
|
{"blowfish", "bf-cbc"},
|
||||||
{"aes", "aes-128-cbc"},
|
{"aes", "aes-128-cbc"},
|
||||||
@ -557,7 +543,7 @@ static PX_Alias int_aliases[] = {
|
|||||||
int
|
int
|
||||||
px_find_digest(const char *name, PX_MD ** res)
|
px_find_digest(const char *name, PX_MD ** res)
|
||||||
{
|
{
|
||||||
struct int_digest *p;
|
const struct int_digest *p;
|
||||||
PX_MD *h;
|
PX_MD *h;
|
||||||
|
|
||||||
for (p = int_digest_list; p->name; p++)
|
for (p = int_digest_list; p->name; p++)
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.14 2005/03/12 06:53:54 neilc Exp $
|
* $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.15 2005/03/21 05:18:45 neilc Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <postgres.h>
|
#include <postgres.h>
|
||||||
@ -208,8 +208,8 @@ gen_ossl_free(PX_Cipher * c)
|
|||||||
ossldata *od = (ossldata *) c->ptr;
|
ossldata *od = (ossldata *) c->ptr;
|
||||||
|
|
||||||
memset(od, 0, sizeof(*od));
|
memset(od, 0, sizeof(*od));
|
||||||
pfree(od);
|
px_free(od);
|
||||||
pfree(c);
|
px_free(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Blowfish */
|
/* Blowfish */
|
||||||
@ -473,37 +473,21 @@ static const struct ossl_cipher ossl_cast_cbc = {
|
|||||||
/*
|
/*
|
||||||
* Special handlers
|
* Special handlers
|
||||||
*/
|
*/
|
||||||
static const struct
|
struct ossl_cipher_lookup
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const struct ossl_cipher *ciph;
|
const struct ossl_cipher *ciph;
|
||||||
} ossl_cipher_types[] =
|
};
|
||||||
|
|
||||||
{
|
static const struct ossl_cipher_lookup ossl_cipher_types[] = {
|
||||||
{
|
{"bf-cbc", &ossl_bf_cbc},
|
||||||
"bf-cbc", &ossl_bf_cbc
|
{"bf-ecb", &ossl_bf_ecb},
|
||||||
},
|
{"bf-cfb", &ossl_bf_cfb},
|
||||||
{
|
{"des-ecb", &ossl_des_ecb},
|
||||||
"bf-ecb", &ossl_bf_ecb
|
{"des-cbc", &ossl_des_cbc},
|
||||||
},
|
{"cast5-ecb", &ossl_cast_ecb},
|
||||||
{
|
{"cast5-cbc", &ossl_cast_cbc},
|
||||||
"bf-cfb", &ossl_bf_cfb
|
{NULL}
|
||||||
},
|
|
||||||
{
|
|
||||||
"des-ecb", &ossl_des_ecb
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"des-cbc", &ossl_des_cbc
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cast5-ecb", &ossl_cast_ecb
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cast5-cbc", &ossl_cast_cbc
|
|
||||||
},
|
|
||||||
{
|
|
||||||
NULL
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* PUBLIC functions */
|
/* PUBLIC functions */
|
||||||
@ -511,38 +495,29 @@ static const struct
|
|||||||
int
|
int
|
||||||
px_find_cipher(const char *name, PX_Cipher ** res)
|
px_find_cipher(const char *name, PX_Cipher ** res)
|
||||||
{
|
{
|
||||||
unsigned i;
|
const struct ossl_cipher_lookup *i;
|
||||||
PX_Cipher *c = NULL,
|
PX_Cipher *c = NULL;
|
||||||
*csrc;
|
|
||||||
ossldata *od;
|
ossldata *od;
|
||||||
const struct ossl_cipher *ossl_ciph = NULL;
|
|
||||||
|
|
||||||
name = px_resolve_alias(ossl_aliases, name);
|
name = px_resolve_alias(ossl_aliases, name);
|
||||||
for (i = 0; ossl_cipher_types[i].name; i++)
|
for (i = ossl_cipher_types; i->name; i++)
|
||||||
{
|
if (!strcmp(i->name, name))
|
||||||
if (!strcmp(ossl_cipher_types[i].name, name))
|
|
||||||
{
|
|
||||||
ossl_ciph = ossl_cipher_types[i].ciph;
|
|
||||||
break;
|
break;
|
||||||
}
|
if (i->name == NULL)
|
||||||
}
|
|
||||||
if (ossl_ciph == NULL)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
od = px_alloc(sizeof(*od));
|
od = px_alloc(sizeof(*od));
|
||||||
memset(od, 0, sizeof(*od));
|
memset(od, 0, sizeof(*od));
|
||||||
od->ciph = ossl_ciph;
|
od->ciph = i->ciph;
|
||||||
|
|
||||||
csrc = NULL;
|
|
||||||
|
|
||||||
c = px_alloc(sizeof(*c));
|
c = px_alloc(sizeof(*c));
|
||||||
c->block_size = gen_ossl_block_size;
|
c->block_size = gen_ossl_block_size;
|
||||||
c->key_size = gen_ossl_key_size;
|
c->key_size = gen_ossl_key_size;
|
||||||
c->iv_size = gen_ossl_iv_size;
|
c->iv_size = gen_ossl_iv_size;
|
||||||
c->free = gen_ossl_free;
|
c->free = gen_ossl_free;
|
||||||
c->init = ossl_ciph->init;
|
c->init = od->ciph->init;
|
||||||
c->encrypt = ossl_ciph->encrypt;
|
c->encrypt = od->ciph->encrypt;
|
||||||
c->decrypt = ossl_ciph->decrypt;
|
c->decrypt = od->ciph->decrypt;
|
||||||
c->ptr = od;
|
c->ptr = od;
|
||||||
|
|
||||||
*res = c;
|
*res = c;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.16 2004/05/07 00:24:57 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.17 2005/03/21 05:18:45 neilc Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
@ -46,7 +46,7 @@ typedef int (*PFN) (const char *name, void **res);
|
|||||||
static void *
|
static void *
|
||||||
find_provider(text *name, PFN pf, char *desc, int silent);
|
find_provider(text *name, PFN pf, char *desc, int silent);
|
||||||
|
|
||||||
/* SQL function: hash(text, text) returns text */
|
/* SQL function: hash(bytea, text) returns bytea */
|
||||||
PG_FUNCTION_INFO_V1(pg_digest);
|
PG_FUNCTION_INFO_V1(pg_digest);
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
@ -111,7 +111,7 @@ pg_digest_exists(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_BOOL(true);
|
PG_RETURN_BOOL(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SQL function: hmac(data:text, key:text, type:text) */
|
/* SQL function: hmac(data:bytea, key:bytea, type:text) returns bytea */
|
||||||
PG_FUNCTION_INFO_V1(pg_hmac);
|
PG_FUNCTION_INFO_V1(pg_hmac);
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
@ -316,7 +316,7 @@ pg_crypt(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_TEXT_P(res);
|
PG_RETURN_TEXT_P(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SQL function: pg_encrypt(text, text, text) returns text */
|
/* SQL function: pg_encrypt(bytea, bytea, text) returns bytea */
|
||||||
PG_FUNCTION_INFO_V1(pg_encrypt);
|
PG_FUNCTION_INFO_V1(pg_encrypt);
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
@ -367,7 +367,7 @@ pg_encrypt(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_BYTEA_P(res);
|
PG_RETURN_BYTEA_P(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SQL function: pg_decrypt(text, text, text) returns text */
|
/* SQL function: pg_decrypt(bytea, bytea, text) returns bytea */
|
||||||
PG_FUNCTION_INFO_V1(pg_decrypt);
|
PG_FUNCTION_INFO_V1(pg_decrypt);
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
@ -417,7 +417,7 @@ pg_decrypt(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_BYTEA_P(res);
|
PG_RETURN_BYTEA_P(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SQL function: pg_encrypt(text, text, text) returns text */
|
/* SQL function: pg_encrypt_iv(bytea, bytea, bytea, text) returns bytea */
|
||||||
PG_FUNCTION_INFO_V1(pg_encrypt_iv);
|
PG_FUNCTION_INFO_V1(pg_encrypt_iv);
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
@ -473,7 +473,7 @@ pg_encrypt_iv(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_BYTEA_P(res);
|
PG_RETURN_BYTEA_P(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SQL function: pg_decrypt_iv(text, text, text) returns text */
|
/* SQL function: pg_decrypt_iv(bytea, bytea, bytea, text) returns bytea */
|
||||||
PG_FUNCTION_INFO_V1(pg_decrypt_iv);
|
PG_FUNCTION_INFO_V1(pg_decrypt_iv);
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
@ -529,7 +529,7 @@ pg_decrypt_iv(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_BYTEA_P(res);
|
PG_RETURN_BYTEA_P(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SQL function: pg_decrypt(text, text, text) returns text */
|
/* SQL function: pg_cipher_exists(text) returns bool */
|
||||||
PG_FUNCTION_INFO_V1(pg_cipher_exists);
|
PG_FUNCTION_INFO_V1(pg_cipher_exists);
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
@ -550,7 +550,6 @@ pg_cipher_exists(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_BOOL((c != NULL) ? true : false);
|
PG_RETURN_BOOL((c != NULL) ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
find_provider(text *name,
|
find_provider(text *name,
|
||||||
PFN provider_lookup,
|
PFN provider_lookup,
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.8 2004/05/07 00:24:57 tgl Exp $
|
* $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.9 2005/03/21 05:18:45 neilc Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <postgres.h>
|
#include <postgres.h>
|
||||||
@ -69,52 +69,41 @@ run_crypt_bf(const char *psw, const char *salt,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct
|
struct px_crypt_algo
|
||||||
{
|
{
|
||||||
char *id;
|
char *id;
|
||||||
unsigned id_len;
|
unsigned id_len;
|
||||||
char *(*crypt) (const char *psw, const char *salt,
|
char *(*crypt) (const char *psw, const char *salt,
|
||||||
char *buf, unsigned len);
|
char *buf, unsigned len);
|
||||||
} px_crypt_list[] =
|
};
|
||||||
|
|
||||||
{
|
static const struct px_crypt_algo
|
||||||
{
|
px_crypt_list[] = {
|
||||||
"$2a$", 4, run_crypt_bf
|
{"$2a$", 4, run_crypt_bf},
|
||||||
},
|
{"$2$", 3, NULL}, /* N/A */
|
||||||
{
|
{"$1$", 3, run_crypt_md5},
|
||||||
"$2$", 3, NULL
|
{"_", 1, run_crypt_des},
|
||||||
}, /* N/A */
|
{"", 0, run_crypt_des},
|
||||||
{
|
{NULL, 0, NULL}
|
||||||
"$1$", 3, run_crypt_md5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"_", 1, run_crypt_des
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"", 0, run_crypt_des
|
|
||||||
},
|
|
||||||
{
|
|
||||||
NULL, 0, NULL
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
char *
|
char *
|
||||||
px_crypt(const char *psw, const char *salt, char *buf, unsigned len)
|
px_crypt(const char *psw, const char *salt, char *buf, unsigned len)
|
||||||
{
|
{
|
||||||
int i;
|
const struct px_crypt_algo *c;
|
||||||
|
|
||||||
for (i = 0; px_crypt_list[i].id; i++)
|
for (c = px_crypt_list; c->id; c++)
|
||||||
{
|
{
|
||||||
if (!px_crypt_list[i].id_len)
|
if (!c->id_len)
|
||||||
break;
|
break;
|
||||||
if (!strncmp(salt, px_crypt_list[i].id, px_crypt_list[i].id_len))
|
if (!strncmp(salt, c->id, c->id_len))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (px_crypt_list[i].crypt == NULL)
|
if (c->crypt == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return px_crypt_list[i].crypt(psw, salt, buf, len);
|
return c->crypt(psw, salt, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* PX_SYSTEM_CRYPT */
|
#else /* PX_SYSTEM_CRYPT */
|
||||||
@ -155,7 +144,7 @@ static struct generator gen_list[] = {
|
|||||||
{"md5", _crypt_gensalt_md5_rn, 6, 0, 0, 0},
|
{"md5", _crypt_gensalt_md5_rn, 6, 0, 0, 0},
|
||||||
{"xdes", _crypt_gensalt_extended_rn, 3, PX_XDES_ROUNDS, 1, 0xFFFFFF},
|
{"xdes", _crypt_gensalt_extended_rn, 3, PX_XDES_ROUNDS, 1, 0xFFFFFF},
|
||||||
{"bf", _crypt_gensalt_blowfish_rn, 16, PX_BF_ROUNDS, 4, 31},
|
{"bf", _crypt_gensalt_blowfish_rn, 16, PX_BF_ROUNDS, 4, 31},
|
||||||
{NULL, NULL, 0, 0, 0}
|
{NULL, NULL, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/contrib/pgcrypto/px.h,v 1.9 2003/11/29 22:39:28 pgsql Exp $
|
* $PostgreSQL: pgsql/contrib/pgcrypto/px.h,v 1.10 2005/03/21 05:18:46 neilc Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __PX_H
|
#ifndef __PX_H
|
||||||
@ -43,21 +43,18 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
#ifndef PX_OWN_ALLOC
|
||||||
|
|
||||||
#define px_alloc(s) palloc(s)
|
#define px_alloc(s) palloc(s)
|
||||||
#define px_realloc(p, s) prealloc(p, s)
|
#define px_realloc(p, s) repalloc(p, s)
|
||||||
#define px_free(p) pfree(p)
|
#define px_free(p) pfree(p)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void *xalloc(size_t s);
|
void *px_alloc(size_t s);
|
||||||
void *xrealloc(void *p, size_t s);
|
void *px_realloc(void *p, size_t s);
|
||||||
void xfree(void *p);
|
void px_free(void *p);
|
||||||
|
|
||||||
#define px_alloc(s) xalloc(s)
|
|
||||||
#define px_realloc(p, s) xrealloc(p, s)
|
|
||||||
#define px_free(p) xfree(p)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* max len of 'type' parms */
|
/* max len of 'type' parms */
|
||||||
|
Reference in New Issue
Block a user