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