1 /* $NetBSD: test_mkey.c,v 1.1.1.2 2014/04/24 12:45:28 pettai Exp $ */
5 #include <krb5/getarg.h>
6 #include <krb5/base64.h>
8 static char *mkey_file
;
10 static int version_flag
;
12 struct getargs args
[] = {
13 { "mkey-file", 0, arg_string
, &mkey_file
},
14 { "help", 'h', arg_flag
, &help_flag
},
15 { "version", 0, arg_flag
, &version_flag
}
18 static int num_args
= sizeof(args
) / sizeof(args
[0]);
21 main(int argc
, char **argv
)
28 if(getarg(args
, num_args
, argc
, argv
, &o
))
29 krb5_std_usage(1, args
, num_args
);
32 krb5_std_usage(0, args
, num_args
);
39 ret
= krb5_init_context(&context
);
41 errx(1, "krb5_init_context failed: %d", ret
);
46 ret
= hdb_read_master_key(context
, mkey_file
, &mkey
);
48 krb5_err(context
, 1, ret
, "failed to read master key %s", mkey_file
);
50 hdb_free_master_key(context
, mkey
);
52 krb5_errx(context
, 1, "no command option given");
54 krb5_free_context(context
);