nshlib:add platform challenge function for nsh login

Signed-off-by: huangjian <huangjian@xiaomi.com>
This commit is contained in:
huangjian
2022-11-04 20:35:07 +08:00
committed by Xiang Xiao
parent 05eadd1bd6
commit 5a623cc9e3
4 changed files with 73 additions and 2 deletions

View File

@@ -143,7 +143,10 @@ static void nsh_token(FAR struct console_stdio_s *pstate,
int nsh_login(FAR struct console_stdio_s *pstate)
{
char username[16];
char password[16];
char password[128];
#ifdef CONFIG_NSH_PLATFORM_CHALLENGE
char challenge[128];
#endif
int ret;
int i;
@@ -168,6 +171,12 @@ int nsh_login(FAR struct console_stdio_s *pstate)
nsh_token(pstate, username, sizeof(username));
}
#ifdef CONFIG_NSH_PLATFORM_CHALLENGE
platform_challenge(challenge, sizeof(challenge));
fputs(challenge, pstate->cn_outstream);
fflush(pstate->cn_outstream);
#endif
/* Ask for the login password */
fputs(g_passwordprompt, pstate->cn_outstream);
@@ -188,7 +197,11 @@ int nsh_login(FAR struct console_stdio_s *pstate)
if (PASSWORD_VERIFY_MATCH(ret))
#elif defined(CONFIG_NSH_LOGIN_PLATFORM)
#ifdef CONFIG_NSH_PLATFORM_CHALLENGE
ret = platform_user_verify(username, challenge, password);
#else
ret = platform_user_verify(username, password);
#endif
if (PASSWORD_VERIFY_MATCH(ret))
#elif defined(CONFIG_NSH_LOGIN_FIXED)