2011-06-30 17:47:05 -05:00
|
|
|
/*
|
|
|
|
* Password related utils for FreeIPA
|
|
|
|
*
|
|
|
|
* Authors: Simo Sorce <ssorce@redhat.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Simo Sorce, Red Hat
|
|
|
|
* see file 'COPYING' for use and warranty information
|
|
|
|
*
|
|
|
|
* This program is free software you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-05-24 09:18:43 -05:00
|
|
|
#pragma once
|
2011-06-30 17:47:05 -05:00
|
|
|
|
2020-06-04 14:36:31 -05:00
|
|
|
#include <stdbool.h>
|
2017-02-17 09:33:34 -06:00
|
|
|
#include <stdint.h>
|
2017-02-17 08:28:41 -06:00
|
|
|
#include <time.h> /* for time_t */
|
|
|
|
|
2011-06-30 17:47:05 -05:00
|
|
|
/* 90 days default pwd max lifetime */
|
|
|
|
#define IPAPWD_DEFAULT_PWDLIFE (90 * 24 *3600)
|
|
|
|
#define IPAPWD_DEFAULT_MINLEN 0
|
|
|
|
|
2013-01-14 09:19:44 -06:00
|
|
|
/* 1 Jan 2038, 00:00 GMT */
|
|
|
|
#define IPAPWD_END_OF_TIME 2145916800
|
|
|
|
|
2012-02-02 04:55:14 -06:00
|
|
|
/*
|
|
|
|
* IMPORTANT: please update error string table in ipa_pwd.c if you change this
|
|
|
|
* error code table.
|
|
|
|
*/
|
2011-06-30 17:47:05 -05:00
|
|
|
enum ipapwd_error {
|
|
|
|
IPAPWD_POLICY_ERROR = -1,
|
|
|
|
IPAPWD_POLICY_OK = 0,
|
|
|
|
IPAPWD_POLICY_ACCOUNT_EXPIRED = 1,
|
|
|
|
IPAPWD_POLICY_PWD_TOO_YOUNG = 2,
|
|
|
|
IPAPWD_POLICY_PWD_TOO_SHORT = 3,
|
|
|
|
IPAPWD_POLICY_PWD_IN_HISTORY = 4,
|
|
|
|
IPAPWD_POLICY_PWD_COMPLEXITY = 5
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ipapwd_policy {
|
|
|
|
int min_pwd_life;
|
|
|
|
int max_pwd_life;
|
|
|
|
int min_pwd_length;
|
|
|
|
int history_length;
|
|
|
|
int min_complexity;
|
2012-02-13 11:15:07 -06:00
|
|
|
int max_fail;
|
|
|
|
int failcnt_interval;
|
|
|
|
int lockout_duration;
|
2011-06-30 17:47:05 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
time_t ipapwd_gentime_to_time_t(char *timestr);
|
|
|
|
|
2020-06-04 14:36:31 -05:00
|
|
|
int ipapwd_hash_password(char *password,
|
2020-06-03 21:55:38 -05:00
|
|
|
const char *hash_type,
|
2020-06-04 14:36:31 -05:00
|
|
|
unsigned char *salt,
|
|
|
|
unsigned char **full_hash,
|
|
|
|
unsigned int *full_hash_len);
|
|
|
|
|
2011-06-30 17:47:05 -05:00
|
|
|
int ipapwd_check_policy(struct ipapwd_policy *policy,
|
|
|
|
char *password,
|
|
|
|
time_t cur_time,
|
|
|
|
time_t acct_expiration,
|
|
|
|
time_t pwd_expiration,
|
|
|
|
time_t last_pwd_change,
|
|
|
|
char **pwd_history);
|
|
|
|
|
2012-02-02 04:55:14 -06:00
|
|
|
char * ipapwd_error2string(enum ipapwd_error err);
|
|
|
|
|
2011-06-30 17:47:05 -05:00
|
|
|
int ipapwd_generate_new_history(char *password,
|
|
|
|
time_t cur_time,
|
|
|
|
int history_length,
|
|
|
|
char **pwd_history,
|
|
|
|
char ***new_pwd_history,
|
|
|
|
int *new_pwd_hlen);
|
|
|
|
|
2013-10-29 06:19:01 -05:00
|
|
|
int encode_nt_key(char *newPasswd, uint8_t *nt_key);
|
2018-08-08 04:28:53 -05:00
|
|
|
|
|
|
|
bool ipapwd_fips_enabled(void);
|