summaryrefslogtreecommitdiffstats
path: root/src/lib/des425/read_passwd.c
blob: 409a8ea0564ac83b497e2fe892739e9eac506072 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * $Source$
 * $Author$
 *
 * Copyright 1985,1986,1987,1988,1991 by the Massachusetts Institute
 * of Technology.
 * All Rights Reserved.
 *
 * For copying and distribution information, please see the file
 * <krb5/copyright.h>.
 *
 * This routine prints the supplied string to standard
 * output as a prompt, and reads a password string without
 * echoing.
 */

#ifndef	lint
static char rcsid_read_password_c[] =
"$Id$";
#endif	/* lint */

#include <krb5/krb5.h>
#include <krb5/libos-proto.h>

#include "des.h"

/*** Routines ****************************************************** */
int
des_read_password/*_v4_compat_crock*/(k,prompt,verify)
    mit_des_cblock *k;
    char *prompt;
    int	verify;
{
    int ok;
    char key_string[BUFSIZ];
    char prompt2[BUFSIZ];
    int string_size = sizeof(key_string);
    krb5_error_code retval;

    if (verify) {
	strcpy(prompt2, "Verifying, please re-enter ");
	strncat(prompt2, prompt, sizeof(prompt2)-(strlen(prompt2)+1));
    }
    ok = krb5_read_password(prompt, verify ? prompt2 : 0,
			    key_string, &string_size);
    
    if (ok == 0)
	mit_des_string_to_key(key_string, k);

    bzero(key_string, sizeof (key_string));
    return ok;
}