summaryrefslogtreecommitdiff
path: root/contrib/pgcrypto/px-crypt.c
diff options
context:
space:
mode:
authorBruce Momjian2001-10-25 05:50:21 +0000
committerBruce Momjian2001-10-25 05:50:21 +0000
commitb81844b1738c584d92330a5ccd0fbd8b603d2886 (patch)
tree4fae0d4cd26048177fc5cd1a2dd91abc99ba0f99 /contrib/pgcrypto/px-crypt.c
parent59da2105d8e6d95345b3b942a2e2aba8cead4838 (diff)
pgindent run on all C files. Java run to follow. initdb/regression
tests pass.
Diffstat (limited to 'contrib/pgcrypto/px-crypt.c')
-rw-r--r--contrib/pgcrypto/px-crypt.c85
1 files changed, 51 insertions, 34 deletions
diff --git a/contrib/pgcrypto/px-crypt.c b/contrib/pgcrypto/px-crypt.c
index 7d767279b15..c0821408087 100644
--- a/contrib/pgcrypto/px-crypt.c
+++ b/contrib/pgcrypto/px-crypt.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: px-crypt.c,v 1.2 2001/09/23 04:12:44 momjian Exp $
+ * $Id: px-crypt.c,v 1.3 2001/10/25 05:49:20 momjian Exp $
*/
#include <postgres.h>
@@ -38,7 +38,7 @@
static char *
run_crypt_des(const char *psw, const char *salt,
- char *buf, unsigned len)
+ char *buf, unsigned len)
{
char *res;
@@ -51,37 +51,51 @@ run_crypt_des(const char *psw, const char *salt,
static char *
run_crypt_md5(const char *psw, const char *salt,
- char *buf, unsigned len)
+ char *buf, unsigned len)
{
char *res;
+
res = px_crypt_md5(psw, salt, buf, len);
return res;
}
static char *
run_crypt_bf(const char *psw, const char *salt,
- char *buf, unsigned len)
+ char *buf, unsigned len)
{
char *res;
+
res = _crypt_blowfish_rn(psw, salt, buf, len);
return res;
}
static struct
{
- char *id;
+ char *id;
unsigned id_len;
char *(*crypt) (const char *psw, const char *salt,
char *buf, unsigned len);
} px_crypt_list[] =
{
- { "$2a$", 4, run_crypt_bf },
- { "$2$", 3, NULL }, /* N/A */
- { "$1$", 3, run_crypt_md5 },
- { "_", 1, run_crypt_des },
- { "", 0, run_crypt_des },
- { NULL, 0, NULL }
+ {
+ "$2a$", 4, run_crypt_bf
+ },
+ {
+ "$2$", 3, NULL
+ }, /* N/A */
+ {
+ "$1$", 3, run_crypt_md5
+ },
+ {
+ "_", 1, run_crypt_des
+ },
+ {
+ "", 0, run_crypt_des
+ },
+ {
+ NULL, 0, NULL
+ }
};
char *
@@ -125,41 +139,45 @@ px_crypt(const char *psw, const char *salt,
* salt generators
*/
-struct generator {
- char *name;
- char *(*gen)(unsigned long count, const char *input, int size,
- char *output, int output_size);
- int input_len;
- int def_rounds;
- int min_rounds;
- int max_rounds;
+struct generator
+{
+ char *name;
+ char *(*gen) (unsigned long count, const char *input, int size,
+ char *output, int output_size);
+ int input_len;
+ int def_rounds;
+ int min_rounds;
+ int max_rounds;
};
-static struct generator gen_list [] = {
- { "des", _crypt_gensalt_traditional_rn, 2, 0, 0, 0 },
- { "md5", _crypt_gensalt_md5_rn, 6, 0, 0, 0 },
- { "xdes", _crypt_gensalt_extended_rn, 3, PX_XDES_ROUNDS, 1, 0xFFFFFF },
- { "bf", _crypt_gensalt_blowfish_rn, 16, PX_BF_ROUNDS, 4, 31 },
- { NULL, NULL, 0, 0, 0 }
+static struct generator gen_list[] = {
+ {"des", _crypt_gensalt_traditional_rn, 2, 0, 0, 0},
+ {"md5", _crypt_gensalt_md5_rn, 6, 0, 0, 0},
+ {"xdes", _crypt_gensalt_extended_rn, 3, PX_XDES_ROUNDS, 1, 0xFFFFFF},
+ {"bf", _crypt_gensalt_blowfish_rn, 16, PX_BF_ROUNDS, 4, 31},
+ {NULL, NULL, 0, 0, 0}
};
uint
px_gen_salt(const char *salt_type, char *buf, int rounds)
{
- int i, res;
+ int i,
+ res;
struct generator *g;
- char *p;
- char rbuf[16];
-
- for (i = 0; gen_list[i].name; i++) {
+ char *p;
+ char rbuf[16];
+
+ for (i = 0; gen_list[i].name; i++)
+ {
g = &gen_list[i];
if (strcasecmp(g->name, salt_type) != 0)
continue;
- if (g->def_rounds) {
+ if (g->def_rounds)
+ {
if (rounds == 0)
rounds = g->def_rounds;
-
+
if (rounds < g->min_rounds || rounds > g->max_rounds)
return 0;
}
@@ -170,10 +188,9 @@ px_gen_salt(const char *salt_type, char *buf, int rounds)
p = g->gen(rounds, rbuf, g->input_len, buf, PX_MAX_SALT_LEN);
memset(rbuf, 0, sizeof(rbuf));
-
+
return p != NULL ? strlen(p) : 0;
}
return 0;
}
-