lua_passwd.h revision 553f11a8f542196fd02498006338dd33c64045c3
860N/A/* Licensed to the Apache Software Foundation (ASF) under one or more
860N/A * contributor license agreements. See the NOTICE file distributed with
860N/A * this work for additional information regarding copyright ownership.
860N/A * The ASF licenses this file to You under the Apache License, Version 2.0
860N/A * (the "License"); you may not use this file except in compliance with
860N/A * the License. You may obtain a copy of the License at
860N/A *
860N/A * http://www.apache.org/licenses/LICENSE-2.0
860N/A *
860N/A * Unless required by applicable law or agreed to in writing, software
860N/A * distributed under the License is distributed on an "AS IS" BASIS,
860N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
860N/A * See the License for the specific language governing permissions and
860N/A * limitations under the License.
860N/A */
860N/A
860N/A#ifndef _LUA_PASSWD_H
860N/A#define _LUA_PASSWD_H
860N/A
860N/A#include "apr.h"
860N/A#include "apr_lib.h"
860N/A#include "apr_strings.h"
860N/A#include "apr_errno.h"
860N/A#include "apr_file_io.h"
860N/A#include "apr_general.h"
860N/A#include "apr_version.h"
860N/A#if !APR_VERSION_AT_LEAST(2,0,0)
860N/A#include "apu_version.h"
860N/A#endif
860N/A
860N/A#define MAX_PASSWD_LEN 256
860N/A
860N/A#define ALG_APMD5 0
#define ALG_APSHA 1
#define ALG_BCRYPT 2
#define ALG_CRYPT 3
#define BCRYPT_DEFAULT_COST 5
#define ERR_FILEPERM 1
#define ERR_SYNTAX 2
#define ERR_PWMISMATCH 3
#define ERR_INTERRUPTED 4
#define ERR_OVERFLOW 5
#define ERR_BADUSER 6
#define ERR_INVALID 7
#define ERR_RANDOM 8
#define ERR_GENERAL 9
#define ERR_ALG_NOT_SUPP 10
#if defined(WIN32) || defined(NETWARE)
#define CRYPT_ALGO_SUPPORTED 0
#define PLAIN_ALGO_SUPPORTED 1
#else
#define CRYPT_ALGO_SUPPORTED 1
#define PLAIN_ALGO_SUPPORTED 0
#endif
#if APR_VERSION_AT_LEAST(2,0,0) || \
(APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 5)
#define BCRYPT_ALGO_SUPPORTED 1
#else
#define BCRYPT_ALGO_SUPPORTED 0
#endif
typedef struct passwd_ctx passwd_ctx;
struct passwd_ctx {
apr_pool_t *pool;
const char *errstr;
char *out;
apr_size_t out_len;
// const char *passwd;
char *passwd;
int alg;
int cost;
};
/*
* The following functions return zero on success; otherwise, one of
* the ERR_* codes is returned and an error message is stored in ctx->errstr.
*/
/*
* Make a password record from the given information.
*/
int mk_password_hash(passwd_ctx *ctx);
#endif /* _LUA_PASSWD_H */