fetch_mkey.c revision e49962a00eea60555f3c78ebf58a9a641590802c
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* Copyright 1990 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
*
* krb5_db_fetch_mkey():
* Fetch a database master key from somewhere.
*/
/*
* Copyright (C) 1998 by the FundsXpress, INC.
*
* All rights reserved.
*
* Export of this software from the United States of America may require
* a specific license from the United States Government. It is the
* responsibility of any person or organization contemplating export to
* obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of FundsXpress. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. FundsXpress makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include "k5-int.h"
#include <libintl.h>
/* these are available to other funcs, and the pointers may be reassigned */
char *krb5_mkey_pwd_prompt1 = KRB5_KDC_MKEY_1;
char *krb5_mkey_pwd_prompt2 = KRB5_KDC_MKEY_2;
/*
* Get the KDC database master key from somewhere, filling it into *key.
*
* key->enctype should be set to the desired key type.
*
* if fromkeyboard is TRUE, then the master key is read as a password
* from the user's terminal. In this case,
* eblock should point to a block with an appropriate string_to_key function.
* if twice is TRUE, the password is read twice for verification.
*
* mname is the name of the key sought; this can be used by the string_to_key
* function or by some other method to isolate the desired key.
*
*/
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
char *keyfile;
krb5_keyblock * key;
{
if (fromkeyboard) {
"Enter KDC database master key");
"Re-enter KDC database master "
"key to verify");
twice ? krb5_mkey_pwd_prompt2 : 0,
return(retval);
if (!salt) {
if (retval)
return retval;
}
key);
if (!salt)
return retval;
} else {
/* from somewhere else */
retval = 0;
#ifdef ANSI_STDIO
#else
#endif
return KRB5_KDB_CANTREAD_STORED;
goto errout;
}
/*
* If an enctype was specified, it should match.
* If enctype was not specified, then just accept what
* was in the keyfile. If its bad, things will fail later.
*/
goto errout;
}
goto errout;
}
goto errout;
}
goto errout;
}
} else
retval = 0;
return retval;
}
}