summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/heimdal')
-rw-r--r--crypto/heimdal/FREEBSD-Xlist14
-rw-r--r--crypto/heimdal/acinclude.m49
-rw-r--r--crypto/heimdal/admin/ktutil_locl.h17
-rw-r--r--crypto/heimdal/appl/ftp/ftp/ftp_locl.h3
-rw-r--r--crypto/heimdal/appl/su/Makefile.am12
-rw-r--r--crypto/heimdal/appl/su/su.c187
-rw-r--r--crypto/heimdal/kadmin/kadmin_locl.h92
-rw-r--r--crypto/heimdal/kdc/headers.h20
-rw-r--r--crypto/heimdal/lib/gssapi/gssapi_locl.h3
-rw-r--r--crypto/heimdal/lib/hdb/hdb_locl.h6
-rw-r--r--crypto/heimdal/lib/krb5/crypto.c1571
-rw-r--r--crypto/heimdal/lib/krb5/krb5_locl.h135
12 files changed, 752 insertions, 1317 deletions
diff --git a/crypto/heimdal/FREEBSD-Xlist b/crypto/heimdal/FREEBSD-Xlist
new file mode 100644
index 0000000..6695918
--- /dev/null
+++ b/crypto/heimdal/FREEBSD-Xlist
@@ -0,0 +1,14 @@
+# $FreeBSD$
+TODO*
+*.info*
+*.cat[0-9]
+appl/dceutils
+appl/kx
+appl/otp
+appl/popper
+appl/xnlock
+doc/standardisation
+lib/des
+lib/editline
+lib/kdfs
+lib/otp
diff --git a/crypto/heimdal/acinclude.m4 b/crypto/heimdal/acinclude.m4
deleted file mode 100644
index eecf7cf..0000000
--- a/crypto/heimdal/acinclude.m4
+++ /dev/null
@@ -1,9 +0,0 @@
-dnl $Id: acinclude.m4 13337 2004-02-12 14:19:16Z lha $
-dnl
-dnl Only put things that for some reason can't live in the `cf'
-dnl directory in this file.
-dnl
-
-dnl $xId: misc.m4,v 1.1 1997/12/14 15:59:04 joda Exp $
-dnl
-m4_define([upcase],`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`)dnl
diff --git a/crypto/heimdal/admin/ktutil_locl.h b/crypto/heimdal/admin/ktutil_locl.h
index 676f27b..cf6a6f3 100644
--- a/crypto/heimdal/admin/ktutil_locl.h
+++ b/crypto/heimdal/admin/ktutil_locl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -32,7 +32,8 @@
*/
/*
- * $Id: ktutil_locl.h 14799 2005-04-15 05:02:39Z lha $
+ * $Id: ktutil_locl.h,v 1.18 2002/09/10 20:03:45 joda Exp $
+ * $FreeBSD$
*/
#ifndef __KTUTIL_LOCL_H__
@@ -61,7 +62,6 @@
#include <sl.h>
#include <getarg.h>
-#include <hex.h>
extern krb5_context context;
@@ -70,6 +70,15 @@ extern char *keytab_string;
krb5_keytab ktutil_open_keytab(void);
-#include "ktutil-commands.h"
+int kt_add (int argc, char **argv);
+int kt_change (int argc, char **argv);
+int kt_copy (int argc, char **argv);
+int kt_get (int argc, char **argv);
+int kt_list(int argc, char **argv);
+int kt_purge(int argc, char **argv);
+int kt_remove(int argc, char **argv);
+int kt_rename(int argc, char **argv);
+int srvconv(int argc, char **argv);
+int srvcreate(int argc, char **argv);
#endif /* __KTUTIL_LOCL_H__ */
diff --git a/crypto/heimdal/appl/ftp/ftp/ftp_locl.h b/crypto/heimdal/appl/ftp/ftp/ftp_locl.h
index 51808c1..f371ca1 100644
--- a/crypto/heimdal/appl/ftp/ftp/ftp_locl.h
+++ b/crypto/heimdal/appl/ftp/ftp/ftp_locl.h
@@ -31,7 +31,8 @@
* SUCH DAMAGE.
*/
-/* $Id: ftp_locl.h 11444 2002-09-10 20:03:49Z joda $ */
+/* $Id: ftp_locl.h,v 1.37 2002/09/10 20:03:46 joda Exp $ */
+/* $FreeBSD$ */
#ifndef __FTP_LOCL_H__
#define __FTP_LOCL_H__
diff --git a/crypto/heimdal/appl/su/Makefile.am b/crypto/heimdal/appl/su/Makefile.am
index 91e0ee3..357152e 100644
--- a/crypto/heimdal/appl/su/Makefile.am
+++ b/crypto/heimdal/appl/su/Makefile.am
@@ -1,19 +1,17 @@
-# $Id: Makefile.am 21986 2007-10-19 05:22:57Z lha $
+# $Id: Makefile.am,v 1.7 2001/08/28 08:31:22 assar Exp $
+# $FreeBSD$
include $(top_srcdir)/Makefile.am.common
-AM_CPPFLAGS += $(INCLUDE_krb4) $(INCLUDE_hcrypto)
+INCLUDES += $(INCLUDE_krb4) $(INCLUDE_des)
bin_PROGRAMS = su
bin_SUIDS = su
-su_SOURCES = su.c supaths.h
-man_MANS = su.1
+su_SOURCES = su.c
LDADD = $(LIB_kafs) \
$(top_builddir)/lib/krb5/libkrb5.la \
$(LIB_krb4) \
- $(LIB_hcrypto) \
+ $(LIB_des) \
$(top_builddir)/lib/asn1/libasn1.la \
$(LIB_roken)
-
-EXTRA_DIST = $(man_MANS)
diff --git a/crypto/heimdal/appl/su/su.c b/crypto/heimdal/appl/su/su.c
index fc21595..757f39d 100644
--- a/crypto/heimdal/appl/su/su.c
+++ b/crypto/heimdal/appl/su/su.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999 - 2007 Kungliga Tekniska Högskolan
+ * Copyright (c) 1999 - 2003 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -30,9 +30,13 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
+/*
+ * $FreeBSD$
+ */
+
#include <config.h>
-RCSID("$Id: su.c 21988 2007-10-19 05:36:54Z lha $");
+RCSID("$Id: su.c,v 1.26.2.1 2003/05/06 12:06:44 joda Exp $");
#include <stdio.h>
#include <stdlib.h>
@@ -49,9 +53,6 @@ RCSID("$Id: su.c 21988 2007-10-19 05:36:54Z lha $");
#endif
#include <pwd.h>
-#ifdef HAVE_CRYPT_H
-#include <crypt.h>
-#endif
#include "crypto-headers.h"
#ifdef KRB5
@@ -65,7 +66,13 @@ RCSID("$Id: su.c 21988 2007-10-19 05:36:54Z lha $");
#include <roken.h>
#include <getarg.h>
-#include "supaths.h"
+#ifndef _PATH_DEFPATH
+#define _PATH_DEFPATH "/usr/bin:/bin"
+#endif
+
+#ifndef _PATH_BSHELL
+#define _PATH_BSHELL "/bin/sh"
+#endif
int kerberos_flag = 1;
int csh_f_flag;
@@ -168,9 +175,7 @@ krb5_verify(const struct passwd *login_info,
{
krb5_error_code ret;
krb5_principal p;
- krb5_realm *realms, *r;
char *login_name = NULL;
- int user_ok = 0;
#if defined(HAVE_GETLOGIN) && !defined(POSIX_GETLOGIN)
login_name = getlogin();
@@ -183,63 +188,50 @@ krb5_verify(const struct passwd *login_info,
return 1;
}
- ret = krb5_get_default_realms(context, &realms);
- if (ret)
+ if (login_name == NULL || strcmp (login_name, "root") == 0)
+ login_name = login_info->pw_name;
+ if (strcmp (su_info->pw_name, "root") == 0)
+ ret = krb5_make_principal(context, &p, NULL,
+ login_name,
+ kerberos_instance,
+ NULL);
+ else
+ ret = krb5_make_principal(context, &p, NULL,
+ su_info->pw_name,
+ NULL);
+ if(ret)
return 1;
-
- /* Check all local realms */
- for (r = realms; *r != NULL && !user_ok; r++) {
-
- if (login_name == NULL || strcmp (login_name, "root") == 0)
- login_name = login_info->pw_name;
- if (strcmp (su_info->pw_name, "root") == 0)
- ret = krb5_make_principal(context, &p, *r,
- login_name,
- kerberos_instance,
- NULL);
- else
- ret = krb5_make_principal(context, &p, *r,
- su_info->pw_name,
- NULL);
- if (ret) {
- krb5_free_host_realm(context, realms);
- return 1;
- }
- /* if we are su-ing too root, check with krb5_kuserok */
- if (su_info->pw_uid == 0 && !krb5_kuserok(context, p, su_info->pw_name))
- continue;
-
+ if(su_info->pw_uid != 0 || krb5_kuserok(context, p, su_info->pw_name)) {
ret = krb5_cc_gen_new(context, &krb5_mcc_ops, &ccache);
if(ret) {
- krb5_free_host_realm(context, realms);
+#if 1
+ krb5_warn(context, ret, "krb5_cc_gen_new");
+#endif
krb5_free_principal (context, p);
return 1;
}
- ret = krb5_verify_user(context, p, ccache, NULL, TRUE, NULL);
+ ret = krb5_verify_user_lrealm(context, p, ccache, NULL, TRUE, NULL);
krb5_free_principal (context, p);
- switch (ret) {
- case 0:
- user_ok = 1;
- break;
- case KRB5_LIBOS_PWDINTR :
- krb5_cc_destroy(context, ccache);
- break;
- case KRB5KRB_AP_ERR_BAD_INTEGRITY:
- case KRB5KRB_AP_ERR_MODIFIED:
- krb5_cc_destroy(context, ccache);
- krb5_warnx(context, "Password incorrect");
- break;
- default :
+ if(ret) {
krb5_cc_destroy(context, ccache);
- krb5_warn(context, ret, "krb5_verify_user");
- break;
+ switch (ret) {
+ case KRB5_LIBOS_PWDINTR :
+ break;
+ case KRB5KRB_AP_ERR_BAD_INTEGRITY:
+ case KRB5KRB_AP_ERR_MODIFIED:
+ krb5_warnx(context, "Password incorrect");
+ break;
+ default :
+ krb5_warn(context, ret, "krb5_verify_user");
+ break;
+ }
+ return 1;
}
+ return 0;
}
- krb5_free_host_realm(context, realms);
- if (!user_ok)
- return 1;
- return 0;
+ krb5_free_principal (context, p);
+ return 1;
}
static int
@@ -257,10 +249,8 @@ krb5_start_session(void)
ret = krb5_cc_copy_cache(context, ccache, ccache2);
- ret = asprintf(&cc_name, "%s:%s", krb5_cc_get_type(context, ccache2),
- krb5_cc_get_name(context, ccache2));
- if (ret == -1)
- errx(1, "malloc - out of memory");
+ asprintf(&cc_name, "%s:%s", krb5_cc_get_type(context, ccache2),
+ krb5_cc_get_name(context, ccache2));
esetenv("KRB5CCNAME", cc_name, 1);
/* we want to export this even if we don't directly support KRB4 */
@@ -310,12 +300,10 @@ krb_verify(const struct passwd *login_info,
krb_kuserok(name, instance, realm, su_info->pw_name) == 0) {
char password[128];
char *prompt;
- ret = asprintf (&prompt,
+ asprintf (&prompt,
"%s's Password: ",
krb_unparse_name_long (name, instance, realm));
- if (ret == -1)
- return (1);
- if (UI_UTIL_read_pw_string (password, sizeof (password), prompt, 0)) {
+ if (des_read_pw_string (password, sizeof (password), prompt, 0)) {
memset (password, 0, sizeof (password));
free(prompt);
return (1);
@@ -353,29 +341,8 @@ krb_start_session(void)
}
#endif
-#define GROUP_MEMBER 0
-#define GROUP_MISSING 1
-#define GROUP_EMPTY 2
-#define GROUP_NOT_MEMBER 3
-
static int
-group_member_p(const char *group, const char *user)
-{
- struct group *g;
- int i;
- g = getgrnam(group);
- if(g == NULL)
- return GROUP_MISSING;
- if(g->gr_mem[0] == NULL)
- return GROUP_EMPTY;
- for(i = 0; g->gr_mem[i] != NULL; i++)
- if(strcmp(user, g->gr_mem[i]) == 0)
- return GROUP_MEMBER;
- return GROUP_NOT_MEMBER;
-}
-
-static int
-verify_unix(struct passwd *login, struct passwd *su)
+verify_unix(struct passwd *su)
{
char prompt[128];
char pw_buf[1024];
@@ -383,31 +350,13 @@ verify_unix(struct passwd *login, struct passwd *su)
int r;
if(su->pw_passwd != NULL && *su->pw_passwd != '\0') {
snprintf(prompt, sizeof(prompt), "%s's password: ", su->pw_name);
- r = UI_UTIL_read_pw_string(pw_buf, sizeof(pw_buf), prompt, 0);
+ r = des_read_pw_string(pw_buf, sizeof(pw_buf), prompt, 0);
if(r != 0)
exit(0);
pw = crypt(pw_buf, su->pw_passwd);
memset(pw_buf, 0, sizeof(pw_buf));
- if(strcmp(pw, su->pw_passwd) != 0) {
- syslog (LOG_ERR | LOG_AUTH, "%s to %s: incorrect password",
- login->pw_name, su->pw_name);
+ if(strcmp(pw, su->pw_passwd) != 0)
return 1;
- }
- }
- /* if su:ing to root, check membership of group wheel or root; if
- that group doesn't exist, or is empty, allow anyone to su
- root */
- if(su->pw_uid == 0) {
-#ifndef ROOT_GROUP
-#define ROOT_GROUP "wheel"
-#endif
- int gs = group_member_p(ROOT_GROUP, login->pw_name);
- if(gs == GROUP_NOT_MEMBER) {
- syslog (LOG_ERR | LOG_AUTH, "%s to %s: not in group %s",
- login->pw_name, su->pw_name, ROOT_GROUP);
- return 1;
- }
- return 0;
}
return 0;
}
@@ -449,9 +398,6 @@ main(int argc, char **argv)
else
su_user = argv[optind++];
- if (!issuid() && getuid() != 0)
- warnx("Not setuid and you are root, expect this to fail");
-
pwd = k_getpwnam(su_user);
if(pwd == NULL)
errx (1, "unknown login %s", su_user);
@@ -488,7 +434,7 @@ main(int argc, char **argv)
ok = 4;
#endif
- if(ok == 0 && login_info->pw_uid && verify_unix(login_info, su_info) != 0) {
+ if(ok == 0 && login_info->pw_uid && verify_unix(su_info) != 0) {
printf("Sorry!\n");
exit(1);
}
@@ -527,7 +473,7 @@ main(int argc, char **argv)
#endif
{
char *tty = ttyname (STDERR_FILENO);
- syslog (LOG_NOTICE | LOG_AUTH, tty ? "%s to %s on %s" : "%s to %s",
+ syslog (LOG_NOTICE | LOG_AUTH, tty ? "%s to %s" : "%s to %s on %s",
login_info->pw_name, su_info->pw_name, tty);
}
@@ -535,23 +481,11 @@ main(int argc, char **argv)
if(!env_flag) {
if(full_login) {
char *t = getenv ("TERM");
- char **newenv = NULL;
- int i, j;
-
- i = read_environment(_PATH_ETC_ENVIRONMENT, &newenv);
-
- environ = malloc ((10 + i) * sizeof (char *));
+
+ environ = malloc (10 * sizeof (char *));
if (environ == NULL)
err (1, "malloc");
environ[0] = NULL;
-
- for (j = 0; j < i; j++) {
- char *p = strchr(newenv[j], '=');
- *p++ = 0;
- esetenv (newenv[j], p, 1);
- }
- free(newenv);
-
esetenv ("PATH", _PATH_DEFPATH, 1);
if (t)
esetenv ("TERM", t, 1);
@@ -582,10 +516,9 @@ main(int argc, char **argv)
if (args == NULL)
err (1, "malloc");
i = 0;
- if(full_login) {
- if (asprintf(&args[i++], "-%s", p) == -1)
- errx (1, "malloc");
- } else
+ if(full_login)
+ asprintf(&args[i++], "-%s", p);
+ else
args[i++] = p;
if (cmd) {
args[i++] = "-c";
diff --git a/crypto/heimdal/kadmin/kadmin_locl.h b/crypto/heimdal/kadmin/kadmin_locl.h
index 7d0f774..0b36127 100644
--- a/crypto/heimdal/kadmin/kadmin_locl.h
+++ b/crypto/heimdal/kadmin/kadmin_locl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997-2001 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -32,7 +32,8 @@
*/
/*
- * $Id: kadmin_locl.h 17580 2006-05-13 21:28:56Z lha $
+ * $Id: kadmin_locl.h,v 1.41 2002/09/10 20:04:45 joda Exp $
+ * $FreeBSD$
*/
#ifndef __ADMIN_LOCL_H__
@@ -90,57 +91,92 @@
#include <krb5_locl.h>
#include <hdb.h>
#include <hdb_err.h>
-#include <hex.h>
#include <kadm5/admin.h>
#include <kadm5/private.h>
#include <kadm5/kadm5_err.h>
#include <parse_time.h>
#include <getarg.h>
+
extern krb5_context context;
extern void * kadm_handle;
+#define DECL(X) int X(int, char **)
+
+DECL(add_new_key);
+DECL(cpw_entry);
+DECL(del_entry);
+DECL(del_enctype);
+DECL(exit_kadmin);
+DECL(ext_keytab);
+DECL(get_entry);
+DECL(get_privs);
+DECL(help);
+DECL(list_princs);
+DECL(mod_entry);
+DECL(rename_entry);
+DECL(init);
+DECL(dump);
+DECL(load);
+DECL(merge);
+
#undef ALLOC
#define ALLOC(X) ((X) = malloc(sizeof(*(X))))
/* util.c */
-void attributes2str(krb5_flags, char *, size_t);
-int str2attributes(const char *, krb5_flags *);
-int parse_attributes (const char *, krb5_flags *, int *, int);
-int edit_attributes (const char *, krb5_flags *, int *, int);
-
-void time_t2str(time_t, char *, size_t, int);
-int str2time_t (const char *, time_t *);
-int parse_timet (const char *, krb5_timestamp *, int *, int);
-int edit_timet (const char *, krb5_timestamp *, int *,
- int);
-
-void deltat2str(unsigned, char *, size_t);
-int str2deltat(const char *, krb5_deltat *);
-int parse_deltat (const char *, krb5_deltat *, int *, int);
-int edit_deltat (const char *, krb5_deltat *, int *, int);
-
-int edit_entry(kadm5_principal_ent_t, int *, kadm5_principal_ent_t, int);
-void set_defaults(kadm5_principal_ent_t, int *, kadm5_principal_ent_t, int);
-int set_entry(krb5_context, kadm5_principal_ent_t, int *,
- const char *, const char *, const char *,
- const char *, const char *);
+void attributes2str(krb5_flags attributes, char *str, size_t len);
+int str2attributes(const char *str, krb5_flags *flags);
+int parse_attributes (const char *resp, krb5_flags *attr, int *mask, int bit);
+int edit_attributes (const char *prompt, krb5_flags *attr, int *mask,
+ int bit);
+
+void time_t2str(time_t t, char *str, size_t len, int include_time);
+int str2time_t (const char *str, time_t *time);
+int parse_timet (const char *resp, krb5_timestamp *value, int *mask, int bit);
+int edit_timet (const char *prompt, krb5_timestamp *value, int *mask,
+ int bit);
+
+void deltat2str(unsigned t, char *str, size_t len);
+int str2deltat(const char *str, krb5_deltat *delta);
+int parse_deltat (const char *resp, krb5_deltat *value, int *mask, int bit);
+int edit_deltat (const char *prompt, krb5_deltat *value, int *mask, int bit);
+
+int edit_entry(kadm5_principal_ent_t ent, int *mask,
+ kadm5_principal_ent_t default_ent, int default_mask);
+void set_defaults(kadm5_principal_ent_t ent, int *mask,
+ kadm5_principal_ent_t default_ent, int default_mask);
+int set_entry(krb5_context context,
+ kadm5_principal_ent_t ent,
+ int *mask,
+ const char *max_ticket_life,
+ const char *max_renewable_life,
+ const char *expiration,
+ const char *pw_expiration,
+ const char *attributes);
int
-foreach_principal(const char *, int (*)(krb5_principal, void*),
- const char *, void *);
+foreach_principal(const char *exp,
+ int (*func)(krb5_principal, void*),
+ const char *funcname,
+ void *data);
-int parse_des_key (const char *, krb5_key_data *, const char **);
+int parse_des_key (const char *key_string,
+ krb5_key_data *key_data, const char **err);
/* server.c */
krb5_error_code
kadmind_loop (krb5_context, krb5_auth_context, krb5_keytab, int);
+/* version4.c */
+
+void
+handle_v4(krb5_context context, krb5_keytab keytab, int len, int fd);
+
/* random_password.c */
void
-random_password(char *, size_t);
+random_password(char *pw, size_t len);
/* kadm_conn.c */
diff --git a/crypto/heimdal/kdc/headers.h b/crypto/heimdal/kdc/headers.h
index 64f6b6e..96db924 100644
--- a/crypto/heimdal/kdc/headers.h
+++ b/crypto/heimdal/kdc/headers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997 - 2006 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -32,7 +32,8 @@
*/
/*
- * $Id: headers.h 19658 2007-01-04 00:15:34Z lha $
+ * $Id: headers.h,v 1.15 2002/09/10 20:04:46 joda Exp $
+ * $FreeBSD$
*/
#ifndef __HEADERS_H__
@@ -72,9 +73,6 @@
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
@@ -91,14 +89,16 @@
#include <parse_units.h>
#include <krb5.h>
#include <krb5_locl.h>
-#include <digest_asn1.h>
-#include <kx509_asn1.h>
#include <hdb.h>
#include <hdb_err.h>
-#include <der.h>
+#include <der.h> /* copy_octet_string */
-#include <heimntlm.h>
-#include <windc_plugin.h>
+#ifdef KRB4
+#include <krb.h>
+#include <prot.h>
+#define Principal Principal4
+#include <krb_db.h>
+#endif
#undef ALLOC
#define ALLOC(X) ((X) = malloc(sizeof(*(X))))
diff --git a/crypto/heimdal/lib/gssapi/gssapi_locl.h b/crypto/heimdal/lib/gssapi/gssapi_locl.h
index 154c4b1..5b2274f 100644
--- a/crypto/heimdal/lib/gssapi/gssapi_locl.h
+++ b/crypto/heimdal/lib/gssapi/gssapi_locl.h
@@ -32,6 +32,7 @@
*/
/* $Id: gssapi_locl.h,v 1.24.2.5 2003/09/18 22:01:52 lha Exp $ */
+/* $FreeBSD$ */
#ifndef GSSAPI_LOCL_H
#define GSSAPI_LOCL_H
@@ -41,7 +42,7 @@
#endif
#include <krb5_locl.h>
-#include <gssapi.h>
+#include "gssapi.h"
#include <assert.h>
#include "arcfour.h"
diff --git a/crypto/heimdal/lib/hdb/hdb_locl.h b/crypto/heimdal/lib/hdb/hdb_locl.h
index abb4cd4..c4f1ea2 100644
--- a/crypto/heimdal/lib/hdb/hdb_locl.h
+++ b/crypto/heimdal/lib/hdb/hdb_locl.h
@@ -31,7 +31,8 @@
* SUCH DAMAGE.
*/
-/* $Id: hdb_locl.h 22209 2007-12-07 19:03:41Z lha $ */
+/* $Id: hdb_locl.h,v 1.18.4.1 2003/09/10 22:04:39 lha Exp $ */
+/* $FreeBSD$ */
#ifndef __HDB_LOCL_H__
#define __HDB_LOCL_H__
@@ -64,7 +65,4 @@
#include <hdb.h>
#include <hdb-private.h>
-#define HDB_DEFAULT_DB HDB_DB_DIR "/heimdal"
-#define HDB_DB_FORMAT_ENTRY "hdb/db-format"
-
#endif /* __HDB_LOCL_H__ */
diff --git a/crypto/heimdal/lib/krb5/crypto.c b/crypto/heimdal/lib/krb5/crypto.c
index 2e63490..d1c1c9d 100644
--- a/crypto/heimdal/lib/krb5/crypto.c
+++ b/crypto/heimdal/lib/krb5/crypto.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997 - 2005 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2004 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -32,7 +32,8 @@
*/
#include "krb5_locl.h"
-RCSID("$Id: crypto.c 22200 2007-12-07 13:48:01Z lha $");
+RCSID("$Id: crypto.c,v 1.73.2.4 2004/03/06 16:38:00 lha Exp $");
+/* RCSID("$FreeBSD$"); */
#undef CRYPTO_DEBUG
#ifdef CRYPTO_DEBUG
@@ -66,7 +67,6 @@ struct krb5_crypto_data {
#define F_VARIANT 8 /* uses `variant' keys (6.4.3) */
#define F_PSEUDO 16 /* not a real protocol type */
#define F_SPECIAL 32 /* backwards */
-#define F_DISABLED 64 /* enctype/checksum disabled */
struct salt_type {
krb5_salttype type;
@@ -87,7 +87,6 @@ struct key_type {
void (*random_key)(krb5_context, krb5_keyblock*);
void (*schedule)(krb5_context, struct key_data *);
struct salt_type *string_to_key;
- void (*random_to_key)(krb5_context, krb5_keyblock*, const void*, size_t);
};
struct checksum_type {
@@ -111,7 +110,6 @@ struct checksum_type {
struct encryption_type {
krb5_enctype type;
const char *name;
- heim_oid *oid;
size_t blocksize;
size_t padsize;
size_t confoundersize;
@@ -122,12 +120,9 @@ struct encryption_type {
krb5_error_code (*encrypt)(krb5_context context,
struct key_data *key,
void *data, size_t len,
- krb5_boolean encryptp,
+ krb5_boolean encrypt,
int usage,
void *ivec);
- size_t prf_length;
- krb5_error_code (*prf)(krb5_context,
- krb5_crypto, const krb5_data *, krb5_data *);
};
#define ENCRYPTION_USAGE(U) (((U) << 8) | 0xAA)
@@ -153,38 +148,92 @@ static krb5_error_code hmac(krb5_context context,
struct key_data *keyblock,
Checksum *result);
static void free_key_data(krb5_context context, struct key_data *key);
-static krb5_error_code usage2arcfour (krb5_context, unsigned *);
-static void xor (DES_cblock *, const unsigned char *);
+static krb5_error_code usage2arcfour (krb5_context, int *);
/************************************************************
* *
************************************************************/
-static HEIMDAL_MUTEX crypto_mutex = HEIMDAL_MUTEX_INITIALIZER;
-
-
static void
krb5_DES_random_key(krb5_context context,
krb5_keyblock *key)
{
- DES_cblock *k = key->keyvalue.data;
+ des_cblock *k = key->keyvalue.data;
do {
- krb5_generate_random_block(k, sizeof(DES_cblock));
- DES_set_odd_parity(k);
- } while(DES_is_weak_key(k));
+ krb5_generate_random_block(k, sizeof(des_cblock));
+ des_set_odd_parity(k);
+ } while(des_is_weak_key(k));
}
static void
krb5_DES_schedule(krb5_context context,
- struct key_data *key)
+ struct key_data *key)
+{
+ des_set_key(key->key->keyvalue.data, key->schedule->data);
+}
+
+static void
+DES_string_to_key_int(unsigned char *data, size_t length, des_cblock *key)
{
- DES_set_key(key->key->keyvalue.data, key->schedule->data);
+ des_key_schedule schedule;
+ int i;
+ int reverse = 0;
+ unsigned char *p;
+
+ unsigned char swap[] = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
+ 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf };
+ memset(key, 0, 8);
+
+ p = (unsigned char*)key;
+ for (i = 0; i < length; i++) {
+ unsigned char tmp = data[i];
+ if (!reverse)
+ *p++ ^= (tmp << 1);
+ else
+ *--p ^= (swap[tmp & 0xf] << 4) | swap[(tmp & 0xf0) >> 4];
+ if((i % 8) == 7)
+ reverse = !reverse;
+ }
+ des_set_odd_parity(key);
+ if(des_is_weak_key(key))
+ (*key)[7] ^= 0xF0;
+ des_set_key(key, schedule);
+ des_cbc_cksum((void*)data, key, length, schedule, key);
+ memset(schedule, 0, sizeof(schedule));
+ des_set_odd_parity(key);
}
-#ifdef ENABLE_AFS_STRING_TO_KEY
+static krb5_error_code
+krb5_DES_string_to_key(krb5_context context,
+ krb5_enctype enctype,
+ krb5_data password,
+ krb5_salt salt,
+ krb5_data opaque,
+ krb5_keyblock *key)
+{
+ unsigned char *s;
+ size_t len;
+ des_cblock tmp;
+
+ len = password.length + salt.saltvalue.length;
+ s = malloc(len);
+ if(len > 0 && s == NULL) {
+ krb5_set_error_string(context, "malloc: out of memory");
+ return ENOMEM;
+ }
+ memcpy(s, password.data, password.length);
+ memcpy(s + password.length, salt.saltvalue.data, salt.saltvalue.length);
+ DES_string_to_key_int(s, len, &tmp);
+ key->keytype = enctype;
+ krb5_data_copy(&key->keyvalue, tmp, sizeof(tmp));
+ memset(&tmp, 0, sizeof(tmp));
+ memset(s, 0, len);
+ free(s);
+ return 0;
+}
/* This defines the Andrew string_to_key function. It accepts a password
- * string as input and converts it via a one-way encryption algorithm to a DES
+ * string as input and converts its via a one-way encryption algorithm to a DES
* encryption key. It is compatible with the original Andrew authentication
* service password database.
*/
@@ -195,7 +244,7 @@ krb5_DES_schedule(krb5_context context,
static void
krb5_DES_AFS3_CMU_string_to_key (krb5_data pw,
krb5_data cell,
- DES_cblock *key)
+ des_cblock *key)
{
char password[8+1]; /* crypt is limited to 8 chars anyway */
int i;
@@ -208,14 +257,14 @@ krb5_DES_AFS3_CMU_string_to_key (krb5_data pw,
}
password[8] = '\0';
- memcpy(key, crypt(password, "p1") + 2, sizeof(DES_cblock));
+ memcpy(key, crypt(password, "p1") + 2, sizeof(des_cblock));
/* parity is inserted into the LSB so left shift each byte up one
bit. This allows ascii characters with a zero MSB to retain as
much significance as possible. */
- for (i = 0; i < sizeof(DES_cblock); i++)
+ for (i = 0; i < sizeof(des_cblock); i++)
((unsigned char*)key)[i] <<= 1;
- DES_set_odd_parity (key);
+ des_set_odd_parity (key);
}
/*
@@ -224,11 +273,11 @@ krb5_DES_AFS3_CMU_string_to_key (krb5_data pw,
static void
krb5_DES_AFS3_Transarc_string_to_key (krb5_data pw,
krb5_data cell,
- DES_cblock *key)
+ des_cblock *key)
{
- DES_key_schedule schedule;
- DES_cblock temp_key;
- DES_cblock ivec;
+ des_key_schedule schedule;
+ des_cblock temp_key;
+ des_cblock ivec;
char password[512];
size_t passlen;
@@ -244,20 +293,20 @@ krb5_DES_AFS3_Transarc_string_to_key (krb5_data pw,
passlen = min(sizeof(password), pw.length + cell.length);
memcpy(&ivec, "kerberos", 8);
memcpy(&temp_key, "kerberos", 8);
- DES_set_odd_parity (&temp_key);
- DES_set_key (&temp_key, &schedule);
- DES_cbc_cksum ((void*)password, &ivec, passlen, &schedule, &ivec);
+ des_set_odd_parity (&temp_key);
+ des_set_key (&temp_key, schedule);
+ des_cbc_cksum (password, &ivec, passlen, schedule, &ivec);
memcpy(&temp_key, &ivec, 8);
- DES_set_odd_parity (&temp_key);
- DES_set_key (&temp_key, &schedule);
- DES_cbc_cksum ((void*)password, key, passlen, &schedule, &ivec);
+ des_set_odd_parity (&temp_key);
+ des_set_key (&temp_key, schedule);
+ des_cbc_cksum (password, key, passlen, schedule, &ivec);
memset(&schedule, 0, sizeof(schedule));
memset(&temp_key, 0, sizeof(temp_key));
memset(&ivec, 0, sizeof(ivec));
memset(password, 0, sizeof(password));
- DES_set_odd_parity (key);
+ des_set_odd_parity (key);
}
static krb5_error_code
@@ -268,7 +317,7 @@ DES_AFS3_string_to_key(krb5_context context,
krb5_data opaque,
krb5_keyblock *key)
{
- DES_cblock tmp;
+ des_cblock tmp;
if(password.length > 8)
krb5_DES_AFS3_Transarc_string_to_key(password, salt.saltvalue, &tmp);
else
@@ -278,121 +327,31 @@ DES_AFS3_string_to_key(krb5_context context,
memset(&key, 0, sizeof(key));
return 0;
}
-#endif /* ENABLE_AFS_STRING_TO_KEY */
-
-static void
-DES_string_to_key_int(unsigned char *data, size_t length, DES_cblock *key)
-{
- DES_key_schedule schedule;
- int i;
- int reverse = 0;
- unsigned char *p;
-
- unsigned char swap[] = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
- 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf };
- memset(key, 0, 8);
-
- p = (unsigned char*)key;
- for (i = 0; i < length; i++) {
- unsigned char tmp = data[i];
- if (!reverse)
- *p++ ^= (tmp << 1);
- else
- *--p ^= (swap[tmp & 0xf] << 4) | swap[(tmp & 0xf0) >> 4];
- if((i % 8) == 7)
- reverse = !reverse;
- }
- DES_set_odd_parity(key);
- if(DES_is_weak_key(key))
- (*key)[7] ^= 0xF0;
- DES_set_key(key, &schedule);
- DES_cbc_cksum((void*)data, key, length, &schedule, key);
- memset(&schedule, 0, sizeof(schedule));
- DES_set_odd_parity(key);
- if(DES_is_weak_key(key))
- (*key)[7] ^= 0xF0;
-}
-
-static krb5_error_code
-krb5_DES_string_to_key(krb5_context context,
- krb5_enctype enctype,
- krb5_data password,
- krb5_salt salt,
- krb5_data opaque,
- krb5_keyblock *key)
-{
- unsigned char *s;
- size_t len;
- DES_cblock tmp;
-
-#ifdef ENABLE_AFS_STRING_TO_KEY
- if (opaque.length == 1) {
- unsigned long v;
- _krb5_get_int(opaque.data, &v, 1);
- if (v == 1)
- return DES_AFS3_string_to_key(context, enctype, password,
- salt, opaque, key);
- }
-#endif
-
- len = password.length + salt.saltvalue.length;
- s = malloc(len);
- if(len > 0 && s == NULL) {
- krb5_set_error_string(context, "malloc: out of memory");
- return ENOMEM;
- }
- memcpy(s, password.data, password.length);
- memcpy(s + password.length, salt.saltvalue.data, salt.saltvalue.length);
- DES_string_to_key_int(s, len, &tmp);
- key->keytype = enctype;
- krb5_data_copy(&key->keyvalue, tmp, sizeof(tmp));
- memset(&tmp, 0, sizeof(tmp));
- memset(s, 0, len);
- free(s);
- return 0;
-}
-
-static void
-krb5_DES_random_to_key(krb5_context context,
- krb5_keyblock *key,
- const void *data,
- size_t size)
-{
- DES_cblock *k = key->keyvalue.data;
- memcpy(k, data, key->keyvalue.length);
- DES_set_odd_parity(k);
- if(DES_is_weak_key(k))
- xor(k, (const unsigned char*)"\0\0\0\0\0\0\0\xf0");
-}
-
-/*
- *
- */
static void
DES3_random_key(krb5_context context,
krb5_keyblock *key)
{
- DES_cblock *k = key->keyvalue.data;
+ des_cblock *k = key->keyvalue.data;
do {
- krb5_generate_random_block(k, 3 * sizeof(DES_cblock));
- DES_set_odd_parity(&k[0]);
- DES_set_odd_parity(&k[1]);
- DES_set_odd_parity(&k[2]);
- } while(DES_is_weak_key(&k[0]) ||
- DES_is_weak_key(&k[1]) ||
- DES_is_weak_key(&k[2]));
+ krb5_generate_random_block(k, 3 * sizeof(des_cblock));
+ des_set_odd_parity(&k[0]);
+ des_set_odd_parity(&k[1]);
+ des_set_odd_parity(&k[2]);
+ } while(des_is_weak_key(&k[0]) ||
+ des_is_weak_key(&k[1]) ||
+ des_is_weak_key(&k[2]));
}
static void
DES3_schedule(krb5_context context,
struct key_data *key)
{
- DES_cblock *k = key->key->keyvalue.data;
- DES_key_schedule *s = key->schedule->data;
- DES_set_key(&k[0], &s[0]);
- DES_set_key(&k[1], &s[1]);
- DES_set_key(&k[2], &s[2]);
+ des_cblock *k = key->key->keyvalue.data;
+ des_key_schedule *s = key->schedule->data;
+ des_set_key(&k[0], s[0]);
+ des_set_key(&k[1], s[1]);
+ des_set_key(&k[2], s[2]);
}
/*
@@ -400,7 +359,7 @@ DES3_schedule(krb5_context context,
*/
static void
-xor (DES_cblock *key, const unsigned char *b)
+xor (des_cblock *key, const unsigned char *b)
{
unsigned char *a = (unsigned char*)key;
a[0] ^= b[0];
@@ -424,8 +383,7 @@ DES3_string_to_key(krb5_context context,
char *str;
size_t len;
unsigned char tmp[24];
- DES_cblock keys[3];
- krb5_error_code ret;
+ des_cblock keys[3];
len = password.length + salt.saltvalue.length;
str = malloc(len);
@@ -436,35 +394,29 @@ DES3_string_to_key(krb5_context context,
memcpy(str, password.data, password.length);
memcpy(str + password.length, salt.saltvalue.data, salt.saltvalue.length);
{
- DES_cblock ivec;
- DES_key_schedule s[3];
+ des_cblock ivec;
+ des_key_schedule s[3];
int i;
- ret = _krb5_n_fold(str, len, tmp, 24);
- if (ret) {
- memset(str, 0, len);
- free(str);
- krb5_set_error_string(context, "out of memory");
- return ret;
- }
+ _krb5_n_fold(str, len, tmp, 24);
for(i = 0; i < 3; i++){
memcpy(keys + i, tmp + i * 8, sizeof(keys[i]));
- DES_set_odd_parity(keys + i);
- if(DES_is_weak_key(keys + i))
+ des_set_odd_parity(keys + i);
+ if(des_is_weak_key(keys + i))
xor(keys + i, (const unsigned char*)"\0\0\0\0\0\0\0\xf0");
- DES_set_key(keys + i, &s[i]);
+ des_set_key(keys + i, s[i]);
}
memset(&ivec, 0, sizeof(ivec));
- DES_ede3_cbc_encrypt(tmp,
+ des_ede3_cbc_encrypt(tmp,
tmp, sizeof(tmp),
- &s[0], &s[1], &s[2], &ivec, DES_ENCRYPT);
+ s[0], s[1], s[2], &ivec, DES_ENCRYPT);
memset(s, 0, sizeof(s));
memset(&ivec, 0, sizeof(ivec));
for(i = 0; i < 3; i++){
memcpy(keys + i, tmp + i * 8, sizeof(keys[i]));
- DES_set_odd_parity(keys + i);
- if(DES_is_weak_key(keys + i))
+ des_set_odd_parity(keys + i);
+ if(des_is_weak_key(keys + i))
xor(keys + i, (const unsigned char*)"\0\0\0\0\0\0\0\xf0");
}
memset(tmp, 0, sizeof(tmp));
@@ -506,47 +458,19 @@ DES3_string_to_key_derived(krb5_context context,
return ret;
}
-static void
-DES3_random_to_key(krb5_context context,
- krb5_keyblock *key,
- const void *data,
- size_t size)
-{
- unsigned char *x = key->keyvalue.data;
- const u_char *q = data;
- DES_cblock *k;
- int i, j;
-
- memset(x, 0, sizeof(x));
- for (i = 0; i < 3; ++i) {
- unsigned char foo;
- for (j = 0; j < 7; ++j) {
- unsigned char b = q[7 * i + j];
-
- x[8 * i + j] = b;
- }
- foo = 0;
- for (j = 6; j >= 0; --j) {
- foo |= q[7 * i + j] & 1;
- foo <<= 1;
- }
- x[8 * i + 7] = foo;
- }
- k = key->keyvalue.data;
- for (i = 0; i < 3; i++) {
- DES_set_odd_parity(&k[i]);
- if(DES_is_weak_key(&k[i]))
- xor(&k[i], (const unsigned char*)"\0\0\0\0\0\0\0\xf0");
- }
-}
-
/*
* ARCFOUR
*/
static void
-ARCFOUR_schedule(krb5_context context,
- struct key_data *kd)
+ARCFOUR_random_key(krb5_context context, krb5_keyblock *key)
+{
+ krb5_generate_random_block (key->keyvalue.data,
+ key->keyvalue.length);
+}
+
+static void
+ARCFOUR_schedule(krb5_context context, struct key_data *kd)
{
RC4_set_key (kd->schedule->data,
kd->key->keyvalue.length, kd->key->keyvalue.data);
@@ -564,14 +488,12 @@ ARCFOUR_string_to_key(krb5_context context,
size_t len;
int i;
MD4_CTX m;
- krb5_error_code ret;
len = 2 * password.length;
s = malloc (len);
if (len != 0 && s == NULL) {
krb5_set_error_string(context, "malloc: out of memory");
- ret = ENOMEM;
- goto out;
+ return ENOMEM;
}
for (p = s, i = 0; i < password.length; ++i) {
*p++ = ((char *)password.data)[i];
@@ -580,24 +502,125 @@ ARCFOUR_string_to_key(krb5_context context,
MD4_Init (&m);
MD4_Update (&m, s, len);
key->keytype = enctype;
- ret = krb5_data_alloc (&key->keyvalue, 16);
- if (ret) {
- krb5_set_error_string(context, "malloc: out of memory");
- goto out;
- }
+ krb5_data_alloc (&key->keyvalue, 16);
MD4_Final (key->keyvalue.data, &m);
memset (s, 0, len);
- ret = 0;
-out:
free (s);
- return ret;
+ return 0;
}
+#ifdef ENABLE_AES
/*
* AES
*/
-int _krb5_AES_string_to_default_iterator = 4096;
+/* iter is really 1 based, so iter == 0 will be 1 iteration */
+
+krb5_error_code
+krb5_PKCS5_PBKDF2(krb5_context context, krb5_cksumtype cktype,
+ krb5_data password, krb5_salt salt, u_int32_t iter,
+ krb5_keytype type, krb5_keyblock *key)
+{
+ struct checksum_type *c = _find_checksum(cktype);
+ struct key_type *kt;
+ size_t datalen, leftofkey;
+ krb5_error_code ret;
+ u_int32_t keypart;
+ struct key_data ksign;
+ krb5_keyblock kb;
+ Checksum result;
+ char *data, *tmpcksum;
+ int i, j;
+ char *p;
+
+ if (c == NULL) {
+ krb5_set_error_string(context, "checksum %d not supported", cktype);
+ return KRB5_PROG_KEYTYPE_NOSUPP;
+ }
+
+ kt = _find_keytype(type);
+ if (kt == NULL) {
+ krb5_set_error_string(context, "key type %d not supported", type);
+ return KRB5_PROG_KEYTYPE_NOSUPP;
+ }
+
+ key->keytype = type;
+ ret = krb5_data_alloc (&key->keyvalue, kt->bits / 8);
+ if (ret) {
+ krb5_set_error_string(context, "malloc: out of memory");
+ return ret;
+ }
+
+ ret = krb5_data_alloc (&result.checksum, c->checksumsize);
+ if (ret) {
+ krb5_set_error_string(context, "malloc: out of memory");
+ krb5_data_free (&key->keyvalue);
+ return ret;
+ }
+
+ tmpcksum = malloc(c->checksumsize);
+ if (tmpcksum == NULL) {
+ krb5_set_error_string(context, "malloc: out of memory");
+ krb5_data_free (&key->keyvalue);
+ krb5_data_free (&result.checksum);
+ return ENOMEM;
+ }
+
+ datalen = salt.saltvalue.length + 4;
+ data = malloc(datalen);
+ if (data == NULL) {
+ krb5_set_error_string(context, "malloc: out of memory");
+ free(tmpcksum);
+ krb5_data_free (&key->keyvalue);
+ krb5_data_free (&result.checksum);
+ return ENOMEM;
+ }
+
+ kb.keyvalue = password;
+ ksign.key = &kb;
+
+ memcpy(data, salt.saltvalue.data, salt.saltvalue.length);
+
+ keypart = 1;
+ leftofkey = key->keyvalue.length;
+ p = key->keyvalue.data;
+
+ while (leftofkey) {
+ int len;
+
+ if (leftofkey > c->checksumsize)
+ len = c->checksumsize;
+ else
+ len = leftofkey;
+
+ _krb5_put_int(data + datalen - 4, keypart, 4);
+
+ ret = hmac(context, c, data, datalen, 0, &ksign, &result);
+ if (ret)
+ krb5_abortx(context, "hmac failed");
+ memcpy(p, result.checksum.data, len);
+ memcpy(tmpcksum, result.checksum.data, result.checksum.length);
+ for (i = 0; i < iter; i++) {
+ ret = hmac(context, c, tmpcksum, result.checksum.length,
+ 0, &ksign, &result);
+ if (ret)
+ krb5_abortx(context, "hmac failed");
+ memcpy(tmpcksum, result.checksum.data, result.checksum.length);
+ for (j = 0; j < len; j++)
+ p[j] ^= tmpcksum[j];
+ }
+
+ p += len;
+ leftofkey -= len;
+ keypart++;
+ }
+
+ free(data);
+ free(tmpcksum);
+ krb5_data_free (&result.checksum);
+
+ return 0;
+}
static krb5_error_code
AES_string_to_key(krb5_context context,
@@ -608,132 +631,66 @@ AES_string_to_key(krb5_context context,
krb5_keyblock *key)
{
krb5_error_code ret;
- uint32_t iter;
+ u_int32_t iter;
struct encryption_type *et;
struct key_data kd;
if (opaque.length == 0)
- iter = _krb5_AES_string_to_default_iterator;
+ iter = 45056 - 1;
else if (opaque.length == 4) {
unsigned long v;
_krb5_get_int(opaque.data, &v, 4);
- iter = ((uint32_t)v);
+ iter = ((u_int32_t)v) - 1;
} else
return KRB5_PROG_KEYTYPE_NOSUPP; /* XXX */
+
et = _find_enctype(enctype);
if (et == NULL)
return KRB5_PROG_KEYTYPE_NOSUPP;
- kd.schedule = NULL;
- ALLOC(kd.key, 1);
- if(kd.key == NULL) {
- krb5_set_error_string (context, "malloc: out of memory");
- return ENOMEM;
- }
- kd.key->keytype = enctype;
- ret = krb5_data_alloc(&kd.key->keyvalue, et->keytype->size);
- if (ret) {
- krb5_set_error_string(context, "Failed to allocate pkcs5 key");
+ ret = krb5_PKCS5_PBKDF2(context, CKSUMTYPE_SHA1, password, salt,
+ iter, enctype, key);
+ if (ret)
return ret;
- }
- ret = PKCS5_PBKDF2_HMAC_SHA1(password.data, password.length,
- salt.saltvalue.data, salt.saltvalue.length,
- iter,
- et->keytype->size, kd.key->keyvalue.data);
- if (ret != 1) {
- free_key_data(context, &kd);
- krb5_set_error_string(context, "Error calculating s2k");
- return KRB5_PROG_KEYTYPE_NOSUPP;
- }
+ ret = krb5_copy_keyblock(context, key, &kd.key);
+ kd.schedule = NULL;
ret = derive_key(context, et, &kd, "kerberos", strlen("kerberos"));
- if (ret == 0)
+
+ if (ret) {
+ krb5_data_free(&key->keyvalue);
+ } else {
ret = krb5_copy_keyblock_contents(context, kd.key, key);
- free_key_data(context, &kd);
+ free_key_data(context, &kd);
+ }
return ret;
}
-struct krb5_aes_schedule {
- AES_KEY ekey;
- AES_KEY dkey;
-};
-
static void
-AES_schedule(krb5_context context,
- struct key_data *kd)
+AES_schedule(krb5_context context, struct key_data *kd)
{
- struct krb5_aes_schedule *key = kd->schedule->data;
+ AES_KEY *key = kd->schedule->data;
int bits = kd->key->keyvalue.length * 8;
-
- memset(key, 0, sizeof(*key));
- AES_set_encrypt_key(kd->key->keyvalue.data, bits, &key->ekey);
- AES_set_decrypt_key(kd->key->keyvalue.data, bits, &key->dkey);
+
+ AES_set_encrypt_key(kd->key->keyvalue.data, bits, &key[0]);
+ AES_set_decrypt_key(kd->key->keyvalue.data, bits, &key[1]);
}
/*
*
*/
-static struct salt_type des_salt[] = {
- {
- KRB5_PW_SALT,
- "pw-salt",
- krb5_DES_string_to_key
- },
-#ifdef ENABLE_AFS_STRING_TO_KEY
- {
- KRB5_AFS3_SALT,
- "afs3-salt",
- DES_AFS3_string_to_key
- },
-#endif
- { 0 }
-};
+extern struct salt_type AES_salt[];
-static struct salt_type des3_salt[] = {
- {
- KRB5_PW_SALT,
- "pw-salt",
- DES3_string_to_key
- },
- { 0 }
-};
+#endif /* ENABLE_AES */
-static struct salt_type des3_salt_derived[] = {
- {
- KRB5_PW_SALT,
- "pw-salt",
- DES3_string_to_key_derived
- },
- { 0 }
-};
+extern struct salt_type des_salt[],
+ des3_salt[], des3_salt_derived[], arcfour_salt[];
-static struct salt_type AES_salt[] = {
- {
- KRB5_PW_SALT,
- "pw-salt",
- AES_string_to_key
- },
- { 0 }
-};
-
-static struct salt_type arcfour_salt[] = {
- {
- KRB5_PW_SALT,
- "pw-salt",
- ARCFOUR_string_to_key
- },
- { 0 }
-};
-
-/*
- *
- */
-
-static struct key_type keytype_null = {
+struct key_type keytype_null = {
KEYTYPE_NULL,
"null",
0,
@@ -744,82 +701,83 @@ static struct key_type keytype_null = {
NULL
};
-static struct key_type keytype_des = {
+struct key_type keytype_des = {
KEYTYPE_DES,
"des",
56,
- sizeof(DES_cblock),
- sizeof(DES_key_schedule),
+ sizeof(des_cblock),
+ sizeof(des_key_schedule),
krb5_DES_random_key,
krb5_DES_schedule,
- des_salt,
- krb5_DES_random_to_key
+ des_salt
};
-static struct key_type keytype_des3 = {
+struct key_type keytype_des3 = {
KEYTYPE_DES3,
"des3",
168,
- 3 * sizeof(DES_cblock),
- 3 * sizeof(DES_key_schedule),
+ 3 * sizeof(des_cblock),
+ 3 * sizeof(des_key_schedule),
DES3_random_key,
DES3_schedule,
- des3_salt,
- DES3_random_to_key
+ des3_salt
};
-static struct key_type keytype_des3_derived = {
+struct key_type keytype_des3_derived = {
KEYTYPE_DES3,
"des3",
168,
- 3 * sizeof(DES_cblock),
- 3 * sizeof(DES_key_schedule),
+ 3 * sizeof(des_cblock),
+ 3 * sizeof(des_key_schedule),
DES3_random_key,
DES3_schedule,
- des3_salt_derived,
- DES3_random_to_key
+ des3_salt_derived
};
-static struct key_type keytype_aes128 = {
+#ifdef ENABLE_AES
+struct key_type keytype_aes128 = {
KEYTYPE_AES128,
"aes-128",
128,
16,
- sizeof(struct krb5_aes_schedule),
+ sizeof(AES_KEY) * 2,
NULL,
AES_schedule,
AES_salt
};
-static struct key_type keytype_aes256 = {
+struct key_type keytype_aes256 = {
KEYTYPE_AES256,
"aes-256",
256,
- 32,
- sizeof(struct krb5_aes_schedule),
+ 16,
+ sizeof(AES_KEY) * 2,
NULL,
AES_schedule,
AES_salt
};
+#endif /* ENABLE_AES */
-static struct key_type keytype_arcfour = {
+struct key_type keytype_arcfour = {
KEYTYPE_ARCFOUR,
"arcfour",
128,
16,
sizeof(RC4_KEY),
- NULL,
+ ARCFOUR_random_key,
ARCFOUR_schedule,
arcfour_salt
};
-static struct key_type *keytypes[] = {
+struct key_type *keytypes[] = {
&keytype_null,
&keytype_des,
&keytype_des3_derived,
&keytype_des3,
+#ifdef ENABLE_AES
&keytype_aes128,
&keytype_aes256,
+#endif /* ENABLE_AES */
&keytype_arcfour
};
@@ -836,7 +794,59 @@ _find_keytype(krb5_keytype type)
}
-krb5_error_code KRB5_LIB_FUNCTION
+struct salt_type des_salt[] = {
+ {
+ KRB5_PW_SALT,
+ "pw-salt",
+ krb5_DES_string_to_key
+ },
+ {
+ KRB5_AFS3_SALT,
+ "afs3-salt",
+ DES_AFS3_string_to_key
+ },
+ { 0 }
+};
+
+struct salt_type des3_salt[] = {
+ {
+ KRB5_PW_SALT,
+ "pw-salt",
+ DES3_string_to_key
+ },
+ { 0 }
+};
+
+struct salt_type des3_salt_derived[] = {
+ {
+ KRB5_PW_SALT,
+ "pw-salt",
+ DES3_string_to_key_derived
+ },
+ { 0 }
+};
+
+#ifdef ENABLE_AES
+struct salt_type AES_salt[] = {
+ {
+ KRB5_PW_SALT,
+ "pw-salt",
+ AES_string_to_key
+ },
+ { 0 }
+};
+#endif /* ENABLE_AES */
+
+struct salt_type arcfour_salt[] = {
+ {
+ KRB5_PW_SALT,
+ "pw-salt",
+ ARCFOUR_string_to_key
+ },
+ { 0 }
+};
+
+krb5_error_code
krb5_salttype_to_string (krb5_context context,
krb5_enctype etype,
krb5_salttype stype,
@@ -865,7 +875,7 @@ krb5_salttype_to_string (krb5_context context,
return HEIM_ERR_SALTTYPE_NOSUPP;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_string_to_salttype (krb5_context context,
krb5_enctype etype,
const char *string,
@@ -890,7 +900,7 @@ krb5_string_to_salttype (krb5_context context,
return HEIM_ERR_SALTTYPE_NOSUPP;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_get_pw_salt(krb5_context context,
krb5_const_principal principal,
krb5_salt *salt)
@@ -919,7 +929,7 @@ krb5_get_pw_salt(krb5_context context,
return 0;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_free_salt(krb5_context context,
krb5_salt salt)
{
@@ -927,7 +937,7 @@ krb5_free_salt(krb5_context context,
return 0;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_string_to_key_data (krb5_context context,
krb5_enctype enctype,
krb5_data password,
@@ -945,7 +955,7 @@ krb5_string_to_key_data (krb5_context context,
return ret;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_string_to_key (krb5_context context,
krb5_enctype enctype,
const char *password,
@@ -953,12 +963,12 @@ krb5_string_to_key (krb5_context context,
krb5_keyblock *key)
{
krb5_data pw;
- pw.data = rk_UNCONST(password);
+ pw.data = (void*)password;
pw.length = strlen(password);
return krb5_string_to_key_data(context, enctype, pw, principal, key);
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_string_to_key_data_salt (krb5_context context,
krb5_enctype enctype,
krb5_data password,
@@ -977,7 +987,7 @@ krb5_string_to_key_data_salt (krb5_context context,
* `opaque'), returning the resulting key in `key'
*/
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_string_to_key_data_salt_opaque (krb5_context context,
krb5_enctype enctype,
krb5_data password,
@@ -1007,7 +1017,7 @@ krb5_string_to_key_data_salt_opaque (krb5_context context,
* in `key'
*/
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_string_to_key_salt (krb5_context context,
krb5_enctype enctype,
const char *password,
@@ -1015,27 +1025,12 @@ krb5_string_to_key_salt (krb5_context context,
krb5_keyblock *key)
{
krb5_data pw;
- pw.data = rk_UNCONST(password);
+ pw.data = (void*)password;
pw.length = strlen(password);
return krb5_string_to_key_data_salt(context, enctype, pw, salt, key);
}
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_string_to_key_salt_opaque (krb5_context context,
- krb5_enctype enctype,
- const char *password,
- krb5_salt salt,
- krb5_data opaque,
- krb5_keyblock *key)
-{
- krb5_data pw;
- pw.data = rk_UNCONST(password);
- pw.length = strlen(password);
- return krb5_string_to_key_data_salt_opaque(context, enctype,
- pw, salt, opaque, key);
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_keytype_to_string(krb5_context context,
krb5_keytype keytype,
char **string)
@@ -1053,7 +1048,7 @@ krb5_keytype_to_string(krb5_context context,
return 0;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_string_to_keytype(krb5_context context,
const char *string,
krb5_keytype *keytype)
@@ -1068,7 +1063,7 @@ krb5_string_to_keytype(krb5_context context,
return KRB5_PROG_KEYTYPE_NOSUPP;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_enctype_keysize(krb5_context context,
krb5_enctype type,
size_t *keysize)
@@ -1083,22 +1078,7 @@ krb5_enctype_keysize(krb5_context context,
return 0;
}
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_enctype_keybits(krb5_context context,
- krb5_enctype type,
- size_t *keybits)
-{
- struct encryption_type *et = _find_enctype(type);
- if(et == NULL) {
- krb5_set_error_string(context, "encryption type %d not supported",
- type);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
- *keybits = et->keytype->bits;
- return 0;
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_generate_random_keyblock(krb5_context context,
krb5_enctype type,
krb5_keyblock *key)
@@ -1171,7 +1151,7 @@ CRC32_checksum(krb5_context context,
unsigned usage,
Checksum *C)
{
- uint32_t crc;
+ u_int32_t crc;
unsigned char *r = C->checksum.data;
_krb5_crc_init_table ();
crc = _krb5_crc_update (data, len, 0);
@@ -1205,7 +1185,7 @@ RSA_MD4_DES_checksum(krb5_context context,
Checksum *cksum)
{
MD4_CTX md4;
- DES_cblock ivec;
+ des_cblock ivec;
unsigned char *p = cksum->checksum.data;
krb5_generate_random_block(p, 8);
@@ -1214,7 +1194,7 @@ RSA_MD4_DES_checksum(krb5_context context,
MD4_Update (&md4, data, len);
MD4_Final (p + 8, &md4);
memset (&ivec, 0, sizeof(ivec));
- DES_cbc_encrypt(p,
+ des_cbc_encrypt(p,
p,
24,
key->schedule->data,
@@ -1233,11 +1213,11 @@ RSA_MD4_DES_verify(krb5_context context,
MD4_CTX md4;
unsigned char tmp[24];
unsigned char res[16];
- DES_cblock ivec;
+ des_cblock ivec;
krb5_error_code ret = 0;
memset(&ivec, 0, sizeof(ivec));
- DES_cbc_encrypt(C->checksum.data,
+ des_cbc_encrypt(C->checksum.data,
(void*)tmp,
C->checksum.length,
key->schedule->data,
@@ -1280,7 +1260,7 @@ RSA_MD5_DES_checksum(krb5_context context,
Checksum *C)
{
MD5_CTX md5;
- DES_cblock ivec;
+ des_cblock ivec;
unsigned char *p = C->checksum.data;
krb5_generate_random_block(p, 8);
@@ -1289,7 +1269,7 @@ RSA_MD5_DES_checksum(krb5_context context,
MD5_Update (&md5, data, len);
MD5_Final (p + 8, &md5);
memset (&ivec, 0, sizeof(ivec));
- DES_cbc_encrypt(p,
+ des_cbc_encrypt(p,
p,
24,
key->schedule->data,
@@ -1308,15 +1288,15 @@ RSA_MD5_DES_verify(krb5_context context,
MD5_CTX md5;
unsigned char tmp[24];
unsigned char res[16];
- DES_cblock ivec;
- DES_key_schedule *sched = key->schedule->data;
+ des_cblock ivec;
+ des_key_schedule *sched = key->schedule->data;
krb5_error_code ret = 0;
memset(&ivec, 0, sizeof(ivec));
- DES_cbc_encrypt(C->checksum.data,
+ des_cbc_encrypt(C->checksum.data,
(void*)tmp,
C->checksum.length,
- &sched[0],
+ sched[0],
&ivec,
DES_DECRYPT);
MD5_Init (&md5);
@@ -1341,9 +1321,9 @@ RSA_MD5_DES3_checksum(krb5_context context,
Checksum *C)
{
MD5_CTX md5;
- DES_cblock ivec;
+ des_cblock ivec;
unsigned char *p = C->checksum.data;
- DES_key_schedule *sched = key->schedule->data;
+ des_key_schedule *sched = key->schedule->data;
krb5_generate_random_block(p, 8);
MD5_Init (&md5);
@@ -1351,10 +1331,10 @@ RSA_MD5_DES3_checksum(krb5_context context,
MD5_Update (&md5, data, len);
MD5_Final (p + 8, &md5);
memset (&ivec, 0, sizeof(ivec));
- DES_ede3_cbc_encrypt(p,
+ des_ede3_cbc_encrypt(p,
p,
24,
- &sched[0], &sched[1], &sched[2],
+ sched[0], sched[1], sched[2],
&ivec,
DES_ENCRYPT);
}
@@ -1370,15 +1350,15 @@ RSA_MD5_DES3_verify(krb5_context context,
MD5_CTX md5;
unsigned char tmp[24];
unsigned char res[16];
- DES_cblock ivec;
- DES_key_schedule *sched = key->schedule->data;
+ des_cblock ivec;
+ des_key_schedule *sched = key->schedule->data;
krb5_error_code ret = 0;
memset(&ivec, 0, sizeof(ivec));
- DES_ede3_cbc_encrypt(C->checksum.data,
+ des_ede3_cbc_encrypt(C->checksum.data,
(void*)tmp,
C->checksum.length,
- &sched[0], &sched[1], &sched[2],
+ sched[0], sched[1], sched[2],
&ivec,
DES_DECRYPT);
MD5_Init (&md5);
@@ -1467,7 +1447,7 @@ hmac(krb5_context context,
return 0;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_hmac(krb5_context context,
krb5_cksumtype cktype,
const void *data,
@@ -1599,16 +1579,16 @@ HMAC_MD5_checksum_enc(krb5_context context,
krb5_abortx(context, "hmac failed");
}
-static struct checksum_type checksum_none = {
+struct checksum_type checksum_none = {
CKSUMTYPE_NONE,
"none",
1,
0,
- 0,
+ 0,
NONE_checksum,
NULL
};
-static struct checksum_type checksum_crc32 = {
+struct checksum_type checksum_crc32 = {
CKSUMTYPE_CRC32,
"crc32",
1,
@@ -1617,7 +1597,7 @@ static struct checksum_type checksum_crc32 = {
CRC32_checksum,
NULL
};
-static struct checksum_type checksum_rsa_md4 = {
+struct checksum_type checksum_rsa_md4 = {
CKSUMTYPE_RSA_MD4,
"rsa-md4",
64,
@@ -1626,7 +1606,7 @@ static struct checksum_type checksum_rsa_md4 = {
RSA_MD4_checksum,
NULL
};
-static struct checksum_type checksum_rsa_md4_des = {
+struct checksum_type checksum_rsa_md4_des = {
CKSUMTYPE_RSA_MD4_DES,
"rsa-md4-des",
64,
@@ -1636,7 +1616,7 @@ static struct checksum_type checksum_rsa_md4_des = {
RSA_MD4_DES_verify
};
#if 0
-static struct checksum_type checksum_des_mac = {
+struct checksum_type checksum_des_mac = {
CKSUMTYPE_DES_MAC,
"des-mac",
0,
@@ -1644,7 +1624,7 @@ static struct checksum_type checksum_des_mac = {
0,
DES_MAC_checksum
};
-static struct checksum_type checksum_des_mac_k = {
+struct checksum_type checksum_des_mac_k = {
CKSUMTYPE_DES_MAC_K,
"des-mac-k",
0,
@@ -1652,7 +1632,7 @@ static struct checksum_type checksum_des_mac_k = {
0,
DES_MAC_K_checksum
};
-static struct checksum_type checksum_rsa_md4_des_k = {
+struct checksum_type checksum_rsa_md4_des_k = {
CKSUMTYPE_RSA_MD4_DES_K,
"rsa-md4-des-k",
0,
@@ -1662,7 +1642,7 @@ static struct checksum_type checksum_rsa_md4_des_k = {
RSA_MD4_DES_K_verify
};
#endif
-static struct checksum_type checksum_rsa_md5 = {
+struct checksum_type checksum_rsa_md5 = {
CKSUMTYPE_RSA_MD5,
"rsa-md5",
64,
@@ -1671,7 +1651,7 @@ static struct checksum_type checksum_rsa_md5 = {
RSA_MD5_checksum,
NULL
};
-static struct checksum_type checksum_rsa_md5_des = {
+struct checksum_type checksum_rsa_md5_des = {
CKSUMTYPE_RSA_MD5_DES,
"rsa-md5-des",
64,
@@ -1680,7 +1660,7 @@ static struct checksum_type checksum_rsa_md5_des = {
RSA_MD5_DES_checksum,
RSA_MD5_DES_verify
};
-static struct checksum_type checksum_rsa_md5_des3 = {
+struct checksum_type checksum_rsa_md5_des3 = {
CKSUMTYPE_RSA_MD5_DES3,
"rsa-md5-des3",
64,
@@ -1689,7 +1669,7 @@ static struct checksum_type checksum_rsa_md5_des3 = {
RSA_MD5_DES3_checksum,
RSA_MD5_DES3_verify
};
-static struct checksum_type checksum_sha1 = {
+struct checksum_type checksum_sha1 = {
CKSUMTYPE_SHA1,
"sha1",
64,
@@ -1698,7 +1678,7 @@ static struct checksum_type checksum_sha1 = {
SHA1_checksum,
NULL
};
-static struct checksum_type checksum_hmac_sha1_des3 = {
+struct checksum_type checksum_hmac_sha1_des3 = {
CKSUMTYPE_HMAC_SHA1_DES3,
"hmac-sha1-des3",
64,
@@ -1708,7 +1688,8 @@ static struct checksum_type checksum_hmac_sha1_des3 = {
NULL
};
-static struct checksum_type checksum_hmac_sha1_aes128 = {
+#ifdef ENABLE_AES
+struct checksum_type checksum_hmac_sha1_aes128 = {
CKSUMTYPE_HMAC_SHA1_96_AES_128,
"hmac-sha1-96-aes128",
64,
@@ -1718,7 +1699,7 @@ static struct checksum_type checksum_hmac_sha1_aes128 = {
NULL
};
-static struct checksum_type checksum_hmac_sha1_aes256 = {
+struct checksum_type checksum_hmac_sha1_aes256 = {
CKSUMTYPE_HMAC_SHA1_96_AES_256,
"hmac-sha1-96-aes256",
64,
@@ -1727,8 +1708,9 @@ static struct checksum_type checksum_hmac_sha1_aes256 = {
SP_HMAC_SHA1_checksum,
NULL
};
+#endif /* ENABLE_AES */
-static struct checksum_type checksum_hmac_md5 = {
+struct checksum_type checksum_hmac_md5 = {
CKSUMTYPE_HMAC_MD5,
"hmac-md5",
64,
@@ -1738,7 +1720,7 @@ static struct checksum_type checksum_hmac_md5 = {
NULL
};
-static struct checksum_type checksum_hmac_md5_enc = {
+struct checksum_type checksum_hmac_md5_enc = {
CKSUMTYPE_HMAC_MD5_ENC,
"hmac-md5-enc",
64,
@@ -1748,7 +1730,7 @@ static struct checksum_type checksum_hmac_md5_enc = {
NULL
};
-static struct checksum_type *checksum_types[] = {
+struct checksum_type *checksum_types[] = {
&checksum_none,
&checksum_crc32,
&checksum_rsa_md4,
@@ -1763,8 +1745,10 @@ static struct checksum_type *checksum_types[] = {
&checksum_rsa_md5_des3,
&checksum_sha1,
&checksum_hmac_sha1_des3,
+#ifdef ENABLE_AES
&checksum_hmac_sha1_aes128,
&checksum_hmac_sha1_aes256,
+#endif
&checksum_hmac_md5,
&checksum_hmac_md5_enc
};
@@ -1826,15 +1810,9 @@ create_checksum (krb5_context context,
struct key_data *dkey;
int keyed_checksum;
- if (ct->flags & F_DISABLED) {
- krb5_clear_error_string (context);
- return KRB5_PROG_SUMTYPE_NOSUPP;
- }
keyed_checksum = (ct->flags & F_KEYED) != 0;
if(keyed_checksum && crypto == NULL) {
- krb5_set_error_string (context, "Checksum type %s is keyed "
- "but no crypto context (key) was passed in",
- ct->name);
+ krb5_clear_error_string (context);
return KRB5_PROG_SUMTYPE_NOSUPP; /* XXX */
}
if(keyed_checksum) {
@@ -1844,9 +1822,7 @@ create_checksum (krb5_context context,
} else
dkey = NULL;
result->cksumtype = ct->type;
- ret = krb5_data_alloc(&result->checksum, ct->checksumsize);
- if (ret)
- return (ret);
+ krb5_data_alloc(&result->checksum, ct->checksumsize);
(*ct->checksum)(context, dkey, data, len, usage, result);
return 0;
}
@@ -1858,7 +1834,7 @@ arcfour_checksum_p(struct checksum_type *ct, krb5_crypto crypto)
(crypto->key.key->keytype == KEYTYPE_ARCFOUR);
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_create_checksum(krb5_context context,
krb5_crypto crypto,
krb5_key_usage usage,
@@ -1910,7 +1886,7 @@ verify_checksum(krb5_context context,
struct checksum_type *ct;
ct = _find_checksum(cksum->cksumtype);
- if (ct == NULL || (ct->flags & F_DISABLED)) {
+ if (ct == NULL) {
krb5_set_error_string (context, "checksum type %d not supported",
cksum->cksumtype);
return KRB5_PROG_SUMTYPE_NOSUPP;
@@ -1921,9 +1897,7 @@ verify_checksum(krb5_context context,
}
keyed_checksum = (ct->flags & F_KEYED) != 0;
if(keyed_checksum && crypto == NULL) {
- krb5_set_error_string (context, "Checksum type %s is keyed "
- "but no crypto context (key) was passed in",
- ct->name);
+ krb5_clear_error_string (context);
return KRB5_PROG_SUMTYPE_NOSUPP; /* XXX */
}
if(keyed_checksum)
@@ -1950,7 +1924,7 @@ verify_checksum(krb5_context context,
return ret;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_verify_checksum(krb5_context context,
krb5_crypto crypto,
krb5_key_usage usage,
@@ -1978,31 +1952,7 @@ krb5_verify_checksum(krb5_context context,
data, len, cksum);
}
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_crypto_get_checksum_type(krb5_context context,
- krb5_crypto crypto,
- krb5_cksumtype *type)
-{
- struct checksum_type *ct = NULL;
-
- if (crypto != NULL) {
- ct = crypto->et->keyed_checksum;
- if (ct == NULL)
- ct = crypto->et->checksum;
- }
-
- if (ct == NULL) {
- krb5_set_error_string (context, "checksum type not found");
- return KRB5_PROG_SUMTYPE_NOSUPP;
- }
-
- *type = ct->type;
-
- return 0;
-}
-
-
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_checksumsize(krb5_context context,
krb5_cksumtype type,
size_t *size)
@@ -2017,49 +1967,32 @@ krb5_checksumsize(krb5_context context,
return 0;
}
-krb5_boolean KRB5_LIB_FUNCTION
+krb5_boolean
krb5_checksum_is_keyed(krb5_context context,
krb5_cksumtype type)
{
struct checksum_type *ct = _find_checksum(type);
if(ct == NULL) {
- if (context)
- krb5_set_error_string (context, "checksum type %d not supported",
- type);
+ krb5_set_error_string (context, "checksum type %d not supported",
+ type);
return KRB5_PROG_SUMTYPE_NOSUPP;
}
return ct->flags & F_KEYED;
}
-krb5_boolean KRB5_LIB_FUNCTION
+krb5_boolean
krb5_checksum_is_collision_proof(krb5_context context,
krb5_cksumtype type)
{
struct checksum_type *ct = _find_checksum(type);
if(ct == NULL) {
- if (context)
- krb5_set_error_string (context, "checksum type %d not supported",
- type);
+ krb5_set_error_string (context, "checksum type %d not supported",
+ type);
return KRB5_PROG_SUMTYPE_NOSUPP;
}
return ct->flags & F_CPROOF;
}
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_checksum_disable(krb5_context context,
- krb5_cksumtype type)
-{
- struct checksum_type *ct = _find_checksum(type);
- if(ct == NULL) {
- if (context)
- krb5_set_error_string (context, "checksum type %d not supported",
- type);
- return KRB5_PROG_SUMTYPE_NOSUPP;
- }
- ct->flags |= F_DISABLED;
- return 0;
-}
-
/************************************************************
* *
************************************************************/
@@ -2069,7 +2002,7 @@ NULL_encrypt(krb5_context context,
struct key_data *key,
void *data,
size_t len,
- krb5_boolean encryptp,
+ krb5_boolean encrypt,
int usage,
void *ivec)
{
@@ -2081,14 +2014,14 @@ DES_CBC_encrypt_null_ivec(krb5_context context,
struct key_data *key,
void *data,
size_t len,
- krb5_boolean encryptp,
+ krb5_boolean encrypt,
int usage,
void *ignore_ivec)
{
- DES_cblock ivec;
- DES_key_schedule *s = key->schedule->data;
+ des_cblock ivec;
+ des_key_schedule *s = key->schedule->data;
memset(&ivec, 0, sizeof(ivec));
- DES_cbc_encrypt(data, data, len, s, &ivec, encryptp);
+ des_cbc_encrypt(data, data, len, *s, &ivec, encrypt);
return 0;
}
@@ -2097,14 +2030,14 @@ DES_CBC_encrypt_key_ivec(krb5_context context,
struct key_data *key,
void *data,
size_t len,
- krb5_boolean encryptp,
+ krb5_boolean encrypt,
int usage,
void *ignore_ivec)
{
- DES_cblock ivec;
- DES_key_schedule *s = key->schedule->data;
+ des_cblock ivec;
+ des_key_schedule *s = key->schedule->data;
memcpy(&ivec, key->key->keyvalue.data, sizeof(ivec));
- DES_cbc_encrypt(data, data, len, s, &ivec, encryptp);
+ des_cbc_encrypt(data, data, len, *s, &ivec, encrypt);
return 0;
}
@@ -2113,17 +2046,17 @@ DES3_CBC_encrypt(krb5_context context,
struct key_data *key,
void *data,
size_t len,
- krb5_boolean encryptp,
+ krb5_boolean encrypt,
int usage,
void *ivec)
{
- DES_cblock local_ivec;
- DES_key_schedule *s = key->schedule->data;
+ des_cblock local_ivec;
+ des_key_schedule *s = key->schedule->data;
if(ivec == NULL) {
ivec = &local_ivec;
memset(local_ivec, 0, sizeof(local_ivec));
}
- DES_ede3_cbc_encrypt(data, data, len, &s[0], &s[1], &s[2], ivec, encryptp);
+ des_ede3_cbc_encrypt(data, data, len, s[0], s[1], s[2], ivec, encrypt);
return 0;
}
@@ -2132,16 +2065,16 @@ DES_CFB64_encrypt_null_ivec(krb5_context context,
struct key_data *key,
void *data,
size_t len,
- krb5_boolean encryptp,
+ krb5_boolean encrypt,
int usage,
void *ignore_ivec)
{
- DES_cblock ivec;
+ des_cblock ivec;
int num = 0;
- DES_key_schedule *s = key->schedule->data;
+ des_key_schedule *s = key->schedule->data;
memset(&ivec, 0, sizeof(ivec));
- DES_cfb64_encrypt(data, data, len, s, &ivec, &num, encryptp);
+ des_cfb64_encrypt(data, data, len, *s, &ivec, &num, encrypt);
return 0;
}
@@ -2150,28 +2083,31 @@ DES_PCBC_encrypt_key_ivec(krb5_context context,
struct key_data *key,
void *data,
size_t len,
- krb5_boolean encryptp,
+ krb5_boolean encrypt,
int usage,
void *ignore_ivec)
{
- DES_cblock ivec;
- DES_key_schedule *s = key->schedule->data;
+ des_cblock ivec;
+ des_key_schedule *s = key->schedule->data;
memcpy(&ivec, key->key->keyvalue.data, sizeof(ivec));
- DES_pcbc_encrypt(data, data, len, s, &ivec, encryptp);
+ des_pcbc_encrypt(data, data, len, *s, &ivec, encrypt);
return 0;
}
+#ifdef ENABLE_AES
+
/*
* AES draft-raeburn-krb-rijndael-krb-02
*/
-void KRB5_LIB_FUNCTION
+void
_krb5_aes_cts_encrypt(const unsigned char *in, unsigned char *out,
- size_t len, const AES_KEY *key,
- unsigned char *ivec, const int encryptp)
+ size_t len, const void *aes_key,
+ unsigned char *ivec, const int enc)
{
unsigned char tmp[AES_BLOCK_SIZE];
+ const AES_KEY *key = aes_key; /* XXX remove this when we always have AES */
int i;
/*
@@ -2179,7 +2115,7 @@ _krb5_aes_cts_encrypt(const unsigned char *in, unsigned char *out,
* then at least one blocksize.
*/
- if (encryptp) {
+ if (enc == AES_ENCRYPT) {
while(len > AES_BLOCK_SIZE) {
for (i = 0; i < AES_BLOCK_SIZE; i++)
@@ -2199,11 +2135,10 @@ _krb5_aes_cts_encrypt(const unsigned char *in, unsigned char *out,
AES_encrypt(tmp, out - AES_BLOCK_SIZE, key);
memcpy(out, ivec, len);
- memcpy(ivec, out - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
} else {
- unsigned char tmp2[AES_BLOCK_SIZE];
- unsigned char tmp3[AES_BLOCK_SIZE];
+ char tmp2[AES_BLOCK_SIZE];
+ char tmp3[AES_BLOCK_SIZE];
while(len > AES_BLOCK_SIZE * 2) {
memcpy(tmp, in, AES_BLOCK_SIZE);
@@ -2218,7 +2153,6 @@ _krb5_aes_cts_encrypt(const unsigned char *in, unsigned char *out,
len -= AES_BLOCK_SIZE;
- memcpy(tmp, in, AES_BLOCK_SIZE); /* save last iv */
AES_decrypt(in, tmp2, key);
memcpy(tmp3, in + AES_BLOCK_SIZE, len);
@@ -2230,7 +2164,6 @@ _krb5_aes_cts_encrypt(const unsigned char *in, unsigned char *out,
AES_decrypt(tmp3, out, key);
for (i = 0; i < AES_BLOCK_SIZE; i++)
out[i] ^= ivec[i];
- memcpy(ivec, tmp, AES_BLOCK_SIZE);
}
}
@@ -2239,23 +2172,22 @@ AES_CTS_encrypt(krb5_context context,
struct key_data *key,
void *data,
size_t len,
- krb5_boolean encryptp,
+ krb5_boolean encrypt,
int usage,
void *ivec)
{
- struct krb5_aes_schedule *aeskey = key->schedule->data;
+ AES_KEY *k = key->schedule->data;
char local_ivec[AES_BLOCK_SIZE];
- AES_KEY *k;
- if (encryptp)
- k = &aeskey->ekey;
+ if (encrypt)
+ k = &k[0];
else
- k = &aeskey->dkey;
+ k = &k[1];
if (len < AES_BLOCK_SIZE)
krb5_abortx(context, "invalid use of AES_CTS_encrypt");
if (len == AES_BLOCK_SIZE) {
- if (encryptp)
+ if (encrypt)
AES_encrypt(data, data, k);
else
AES_decrypt(data, data, k);
@@ -2264,11 +2196,12 @@ AES_CTS_encrypt(krb5_context context,
memset(local_ivec, 0, sizeof(local_ivec));
ivec = local_ivec;
}
- _krb5_aes_cts_encrypt(data, data, len, k, ivec, encryptp);
+ _krb5_aes_cts_encrypt(data, data, len, k, ivec, encrypt);
}
return 0;
}
+#endif /* ENABLE_AES */
/*
* section 6 of draft-brezak-win2k-krb-rc4-hmac-03
@@ -2281,7 +2214,7 @@ ARCFOUR_subencrypt(krb5_context context,
struct key_data *key,
void *data,
size_t len,
- unsigned usage,
+ int usage,
void *ivec)
{
struct checksum_type *c = _find_checksum (CKSUMTYPE_RSA_MD5);
@@ -2344,7 +2277,7 @@ ARCFOUR_subdecrypt(krb5_context context,
struct key_data *key,
void *data,
size_t len,
- unsigned usage,
+ int usage,
void *ivec)
{
struct checksum_type *c = _find_checksum (CKSUMTYPE_RSA_MD5);
@@ -2417,7 +2350,7 @@ ARCFOUR_subdecrypt(krb5_context context,
*/
static krb5_error_code
-usage2arcfour (krb5_context context, unsigned *usage)
+usage2arcfour (krb5_context context, int *usage)
{
switch (*usage) {
case KRB5_KU_AS_REP_ENC_PART : /* 3 */
@@ -2443,98 +2376,40 @@ ARCFOUR_encrypt(krb5_context context,
struct key_data *key,
void *data,
size_t len,
- krb5_boolean encryptp,
+ krb5_boolean encrypt,
int usage,
void *ivec)
{
krb5_error_code ret;
- unsigned keyusage = usage;
-
- if((ret = usage2arcfour (context, &keyusage)) != 0)
+ if((ret = usage2arcfour (context, &usage)) != 0)
return ret;
- if (encryptp)
- return ARCFOUR_subencrypt (context, key, data, len, keyusage, ivec);
+ if (encrypt)
+ return ARCFOUR_subencrypt (context, key, data, len, usage, ivec);
else
- return ARCFOUR_subdecrypt (context, key, data, len, keyusage, ivec);
+ return ARCFOUR_subdecrypt (context, key, data, len, usage, ivec);
}
/*
- *
- */
-
-static krb5_error_code
-AES_PRF(krb5_context context,
- krb5_crypto crypto,
- const krb5_data *in,
- krb5_data *out)
-{
- struct checksum_type *ct = crypto->et->checksum;
- krb5_error_code ret;
- Checksum result;
- krb5_keyblock *derived;
-
- result.cksumtype = ct->type;
- ret = krb5_data_alloc(&result.checksum, ct->checksumsize);
- if (ret) {
- krb5_set_error_string(context, "out memory");
- return ret;
- }
-
- (*ct->checksum)(context, NULL, in->data, in->length, 0, &result);
-
- if (result.checksum.length < crypto->et->blocksize)
- krb5_abortx(context, "internal prf error");
-
- derived = NULL;
- ret = krb5_derive_key(context, crypto->key.key,
- crypto->et->type, "prf", 3, &derived);
- if (ret)
- krb5_abortx(context, "krb5_derive_key");
-
- ret = krb5_data_alloc(out, crypto->et->blocksize);
- if (ret)
- krb5_abortx(context, "malloc failed");
-
- {
- AES_KEY key;
-
- AES_set_encrypt_key(derived->keyvalue.data,
- crypto->et->keytype->bits, &key);
- AES_encrypt(result.checksum.data, out->data, &key);
- memset(&key, 0, sizeof(key));
- }
-
- krb5_data_free(&result.checksum);
- krb5_free_keyblock(context, derived);
-
- return ret;
-}
-
-/*
* these should currently be in reverse preference order.
* (only relevant for !F_PSEUDO) */
static struct encryption_type enctype_null = {
ETYPE_NULL,
"null",
- NULL,
1,
1,
0,
&keytype_null,
&checksum_none,
NULL,
- F_DISABLED,
- NULL_encrypt,
0,
- NULL
+ NULL_encrypt,
};
static struct encryption_type enctype_des_cbc_crc = {
ETYPE_DES_CBC_CRC,
"des-cbc-crc",
- NULL,
8,
8,
8,
@@ -2543,13 +2418,10 @@ static struct encryption_type enctype_des_cbc_crc = {
NULL,
0,
DES_CBC_encrypt_key_ivec,
- 0,
- NULL
};
static struct encryption_type enctype_des_cbc_md4 = {
ETYPE_DES_CBC_MD4,
"des-cbc-md4",
- NULL,
8,
8,
8,
@@ -2558,13 +2430,10 @@ static struct encryption_type enctype_des_cbc_md4 = {
&checksum_rsa_md4_des,
0,
DES_CBC_encrypt_null_ivec,
- 0,
- NULL
};
static struct encryption_type enctype_des_cbc_md5 = {
ETYPE_DES_CBC_MD5,
"des-cbc-md5",
- NULL,
8,
8,
8,
@@ -2573,28 +2442,22 @@ static struct encryption_type enctype_des_cbc_md5 = {
&checksum_rsa_md5_des,
0,
DES_CBC_encrypt_null_ivec,
- 0,
- NULL
};
static struct encryption_type enctype_arcfour_hmac_md5 = {
ETYPE_ARCFOUR_HMAC_MD5,
"arcfour-hmac-md5",
- NULL,
1,
1,
8,
&keytype_arcfour,
&checksum_hmac_md5,
- NULL,
+ /* &checksum_hmac_md5_enc */ NULL,
F_SPECIAL,
- ARCFOUR_encrypt,
- 0,
- NULL
+ ARCFOUR_encrypt
};
static struct encryption_type enctype_des3_cbc_md5 = {
ETYPE_DES3_CBC_MD5,
"des3-cbc-md5",
- NULL,
8,
8,
8,
@@ -2603,13 +2466,10 @@ static struct encryption_type enctype_des3_cbc_md5 = {
&checksum_rsa_md5_des3,
0,
DES3_CBC_encrypt,
- 0,
- NULL
};
static struct encryption_type enctype_des3_cbc_sha1 = {
ETYPE_DES3_CBC_SHA1,
"des3-cbc-sha1",
- NULL,
8,
8,
8,
@@ -2618,13 +2478,10 @@ static struct encryption_type enctype_des3_cbc_sha1 = {
&checksum_hmac_sha1_des3,
F_DERIVED,
DES3_CBC_encrypt,
- 0,
- NULL
};
static struct encryption_type enctype_old_des3_cbc_sha1 = {
ETYPE_OLD_DES3_CBC_SHA1,
"old-des3-cbc-sha1",
- NULL,
8,
8,
8,
@@ -2633,43 +2490,36 @@ static struct encryption_type enctype_old_des3_cbc_sha1 = {
&checksum_hmac_sha1_des3,
0,
DES3_CBC_encrypt,
- 0,
- NULL
};
+#ifdef ENABLE_AES
static struct encryption_type enctype_aes128_cts_hmac_sha1 = {
ETYPE_AES128_CTS_HMAC_SHA1_96,
"aes128-cts-hmac-sha1-96",
- NULL,
16,
1,
16,
&keytype_aes128,
&checksum_sha1,
&checksum_hmac_sha1_aes128,
- F_DERIVED,
+ 0,
AES_CTS_encrypt,
- 16,
- AES_PRF
};
static struct encryption_type enctype_aes256_cts_hmac_sha1 = {
ETYPE_AES256_CTS_HMAC_SHA1_96,
"aes256-cts-hmac-sha1-96",
- NULL,
16,
1,
16,
&keytype_aes256,
&checksum_sha1,
&checksum_hmac_sha1_aes256,
- F_DERIVED,
+ 0,
AES_CTS_encrypt,
- 16,
- AES_PRF
};
+#endif /* ENABLE_AES */
static struct encryption_type enctype_des_cbc_none = {
ETYPE_DES_CBC_NONE,
"des-cbc-none",
- NULL,
8,
8,
0,
@@ -2678,13 +2528,10 @@ static struct encryption_type enctype_des_cbc_none = {
NULL,
F_PSEUDO,
DES_CBC_encrypt_null_ivec,
- 0,
- NULL
};
static struct encryption_type enctype_des_cfb64_none = {
ETYPE_DES_CFB64_NONE,
"des-cfb64-none",
- NULL,
1,
1,
0,
@@ -2693,13 +2540,10 @@ static struct encryption_type enctype_des_cfb64_none = {
NULL,
F_PSEUDO,
DES_CFB64_encrypt_null_ivec,
- 0,
- NULL
};
static struct encryption_type enctype_des_pcbc_none = {
ETYPE_DES_PCBC_NONE,
"des-pcbc-none",
- NULL,
8,
8,
0,
@@ -2708,13 +2552,10 @@ static struct encryption_type enctype_des_pcbc_none = {
NULL,
F_PSEUDO,
DES_PCBC_encrypt_key_ivec,
- 0,
- NULL
};
static struct encryption_type enctype_des3_cbc_none = {
ETYPE_DES3_CBC_NONE,
"des3-cbc-none",
- NULL,
8,
8,
0,
@@ -2723,8 +2564,6 @@ static struct encryption_type enctype_des3_cbc_none = {
NULL,
F_PSEUDO,
DES3_CBC_encrypt,
- 0,
- NULL
};
static struct encryption_type *etypes[] = {
@@ -2736,8 +2575,10 @@ static struct encryption_type *etypes[] = {
&enctype_des3_cbc_md5,
&enctype_des3_cbc_sha1,
&enctype_old_des3_cbc_sha1,
+#ifdef ENABLE_AES
&enctype_aes128_cts_hmac_sha1,
&enctype_aes256_cts_hmac_sha1,
+#endif
&enctype_des_cbc_none,
&enctype_des_cfb64_none,
&enctype_des_pcbc_none,
@@ -2758,7 +2599,7 @@ _find_enctype(krb5_enctype type)
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_enctype_to_string(krb5_context context,
krb5_enctype etype,
char **string)
@@ -2768,7 +2609,6 @@ krb5_enctype_to_string(krb5_context context,
if(e == NULL) {
krb5_set_error_string (context, "encryption type %d not supported",
etype);
- *string = NULL;
return KRB5_PROG_ETYPE_NOSUPP;
}
*string = strdup(e->name);
@@ -2779,7 +2619,7 @@ krb5_enctype_to_string(krb5_context context,
return 0;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_string_to_enctype(krb5_context context,
const char *string,
krb5_enctype *etype)
@@ -2795,42 +2635,7 @@ krb5_string_to_enctype(krb5_context context,
return KRB5_PROG_ETYPE_NOSUPP;
}
-krb5_error_code KRB5_LIB_FUNCTION
-_krb5_enctype_to_oid(krb5_context context,
- krb5_enctype etype,
- heim_oid *oid)
-{
- struct encryption_type *et = _find_enctype(etype);
- if(et == NULL) {
- krb5_set_error_string (context, "encryption type %d not supported",
- etype);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
- if(et->oid == NULL) {
- krb5_set_error_string (context, "%s have not oid", et->name);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
- krb5_clear_error_string(context);
- return der_copy_oid(et->oid, oid);
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
-_krb5_oid_to_enctype(krb5_context context,
- const heim_oid *oid,
- krb5_enctype *etype)
-{
- int i;
- for(i = 0; i < num_etypes; i++) {
- if(etypes[i]->oid && der_heim_oid_cmp(etypes[i]->oid, oid) == 0) {
- *etype = etypes[i]->type;
- return 0;
- }
- }
- krb5_set_error_string(context, "enctype for oid not supported");
- return KRB5_PROG_ETYPE_NOSUPP;
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_enctype_to_keytype(krb5_context context,
krb5_enctype etype,
krb5_keytype *keytype)
@@ -2846,7 +2651,7 @@ krb5_enctype_to_keytype(krb5_context context,
}
#if 0
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_keytype_to_enctype(krb5_context context,
krb5_keytype keytype,
krb5_enctype *etype)
@@ -2860,7 +2665,7 @@ krb5_keytype_to_enctype(krb5_context context,
}
#endif
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_keytype_to_enctypes (krb5_context context,
krb5_keytype keytype,
unsigned *len,
@@ -2896,7 +2701,7 @@ krb5_keytype_to_enctypes (krb5_context context,
* else, do `krb5_keytype_to_enctypes'.
*/
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_keytype_to_enctypes_default (krb5_context context,
krb5_keytype keytype,
unsigned *len,
@@ -2922,45 +2727,15 @@ krb5_keytype_to_enctypes_default (krb5_context context,
return 0;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_enctype_valid(krb5_context context,
krb5_enctype etype)
{
- struct encryption_type *e = _find_enctype(etype);
- if(e == NULL) {
- krb5_set_error_string (context, "encryption type %d not supported",
- etype);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
- if (e->flags & F_DISABLED) {
- krb5_set_error_string (context, "encryption type %s is disabled",
- e->name);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
- return 0;
+ return _find_enctype(etype) != NULL;
}
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_cksumtype_valid(krb5_context context,
- krb5_cksumtype ctype)
-{
- struct checksum_type *c = _find_checksum(ctype);
- if (c == NULL) {
- krb5_set_error_string (context, "checksum type %d not supported",
- ctype);
- return KRB5_PROG_SUMTYPE_NOSUPP;
- }
- if (c->flags & F_DISABLED) {
- krb5_set_error_string (context, "checksum type %s is disabled",
- c->name);
- return KRB5_PROG_SUMTYPE_NOSUPP;
- }
- return 0;
-}
-
-
/* if two enctypes have compatible keys */
-krb5_boolean KRB5_LIB_FUNCTION
+krb5_boolean
krb5_enctypes_compatible_keys(krb5_context context,
krb5_enctype etype1,
krb5_enctype etype2)
@@ -2991,7 +2766,7 @@ static krb5_error_code
encrypt_internal_derived(krb5_context context,
krb5_crypto crypto,
unsigned usage,
- const void *data,
+ void *data,
size_t len,
krb5_data *result,
void *ivec)
@@ -3060,7 +2835,7 @@ encrypt_internal_derived(krb5_context context,
static krb5_error_code
encrypt_internal(krb5_context context,
krb5_crypto crypto,
- const void *data,
+ void *data,
size_t len,
krb5_data *result,
void *ivec)
@@ -3129,7 +2904,7 @@ static krb5_error_code
encrypt_internal_special(krb5_context context,
krb5_crypto crypto,
int usage,
- const void *data,
+ void *data,
size_t len,
krb5_data *result,
void *ivec)
@@ -3180,10 +2955,9 @@ decrypt_internal_derived(krb5_context context,
unsigned long l;
checksum_sz = CHECKSUMSIZE(et->keyed_checksum);
- if (len < checksum_sz + et->confoundersize) {
- krb5_set_error_string(context, "Encrypted data shorter then "
- "checksum + confunder");
- return KRB5_BAD_MSIZE;
+ if (len < checksum_sz) {
+ krb5_clear_error_string (context);
+ return EINVAL; /* XXX - better error code? */
}
if (((len - checksum_sz) % et->padsize) != 0) {
@@ -3236,7 +3010,7 @@ decrypt_internal_derived(krb5_context context,
l = len - et->confoundersize;
memmove(p, p + et->confoundersize, l);
result->data = realloc(p, l);
- if(result->data == NULL && l != 0) {
+ if(result->data == NULL) {
free(p);
krb5_set_error_string(context, "malloc: out of memory");
return ENOMEM;
@@ -3301,7 +3075,7 @@ decrypt_internal(krb5_context context,
l = len - et->confoundersize - checksum_sz;
memmove(p, p + et->confoundersize + checksum_sz, l);
result->data = realloc(p, l);
- if(result->data == NULL && l != 0) {
+ if(result->data == NULL) {
free(p);
krb5_set_error_string(context, "malloc: out of memory");
return ENOMEM;
@@ -3345,7 +3119,7 @@ decrypt_internal_special(krb5_context context,
memmove (p, p + cksum_sz + et->confoundersize, sz);
result->data = realloc(p, sz);
- if(result->data == NULL && sz != 0) {
+ if(result->data == NULL) {
free(p);
krb5_set_error_string(context, "malloc: out of memory");
return ENOMEM;
@@ -3355,11 +3129,11 @@ decrypt_internal_special(krb5_context context,
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_encrypt_ivec(krb5_context context,
krb5_crypto crypto,
unsigned usage,
- const void *data,
+ void *data,
size_t len,
krb5_data *result,
void *ivec)
@@ -3374,18 +3148,18 @@ krb5_encrypt_ivec(krb5_context context,
return encrypt_internal(context, crypto, data, len, result, ivec);
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_encrypt(krb5_context context,
krb5_crypto crypto,
unsigned usage,
- const void *data,
+ void *data,
size_t len,
krb5_data *result)
{
return krb5_encrypt_ivec(context, crypto, usage, data, len, result, NULL);
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_encrypt_EncryptedData(krb5_context context,
krb5_crypto crypto,
unsigned usage,
@@ -3403,7 +3177,7 @@ krb5_encrypt_EncryptedData(krb5_context context,
return krb5_encrypt(context, crypto, usage, data, len, &result->cipher);
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_decrypt_ivec(krb5_context context,
krb5_crypto crypto,
unsigned usage,
@@ -3422,7 +3196,7 @@ krb5_decrypt_ivec(krb5_context context,
return decrypt_internal(context, crypto, data, len, result, ivec);
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_decrypt(krb5_context context,
krb5_crypto crypto,
unsigned usage,
@@ -3434,7 +3208,7 @@ krb5_decrypt(krb5_context context,
NULL);
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_decrypt_EncryptedData(krb5_context context,
krb5_crypto crypto,
unsigned usage,
@@ -3449,24 +3223,25 @@ krb5_decrypt_EncryptedData(krb5_context context,
* *
************************************************************/
-#define ENTROPY_NEEDED 128
+#ifdef HAVE_OPENSSL
+#include <openssl/rand.h>
+/* From openssl/crypto/rand/rand_lcl.h */
+#define ENTROPY_NEEDED 20
static int
seed_something(void)
{
+ int fd = -1;
char buf[1024], seedfile[256];
/* If there is a seed file, load it. But such a file cannot be trusted,
so use 0 for the entropy estimate */
if (RAND_file_name(seedfile, sizeof(seedfile))) {
- int fd;
fd = open(seedfile, O_RDONLY);
if (fd >= 0) {
- ssize_t ret;
- ret = read(fd, buf, sizeof(buf));
- if (ret > 0)
- RAND_add(buf, ret, 0.0);
- close(fd);
+ read(fd, buf, sizeof(buf));
+ /* Use the full buffer anyway */
+ RAND_add(buf, sizeof(buf), 0.0);
} else
seedfile[0] = '\0';
} else
@@ -3498,34 +3273,82 @@ seed_something(void)
return -1;
}
-void KRB5_LIB_FUNCTION
+void
krb5_generate_random_block(void *buf, size_t len)
{
static int rng_initialized = 0;
- HEIMDAL_MUTEX_lock(&crypto_mutex);
if (!rng_initialized) {
if (seed_something())
- krb5_abortx(NULL, "Fatal: could not seed the "
- "random number generator");
+ krb5_abortx(NULL, "Fatal: could not seed the random number generator");
rng_initialized = 1;
}
- HEIMDAL_MUTEX_unlock(&crypto_mutex);
- if (RAND_bytes(buf, len) != 1)
- krb5_abortx(NULL, "Failed to generate random block");
+ RAND_bytes(buf, len);
+}
+
+#else
+
+void
+krb5_generate_random_block(void *buf, size_t len)
+{
+ des_cblock key, out;
+ static des_cblock counter;
+ static des_key_schedule schedule;
+ int i;
+ static int initialized = 0;
+
+ if(!initialized) {
+ des_new_random_key(&key);
+ des_set_key(&key, schedule);
+ memset(&key, 0, sizeof(key));
+ des_new_random_key(&counter);
+ }
+ while(len > 0) {
+ des_ecb_encrypt(&counter, &out, schedule, DES_ENCRYPT);
+ for(i = 7; i >=0; i--)
+ if(counter[i]++)
+ break;
+ memcpy(buf, out, min(len, sizeof(out)));
+ len -= min(len, sizeof(out));
+ buf = (char*)buf + sizeof(out);
+ }
}
+#endif
static void
DES3_postproc(krb5_context context,
unsigned char *k, size_t len, struct key_data *key)
{
- DES3_random_to_key(context, key->key, k, len);
+ unsigned char x[24];
+ int i, j;
+ memset(x, 0, sizeof(x));
+ for (i = 0; i < 3; ++i) {
+ unsigned char foo;
+
+ for (j = 0; j < 7; ++j) {
+ unsigned char b = k[7 * i + j];
+
+ x[8 * i + j] = b;
+ }
+ foo = 0;
+ for (j = 6; j >= 0; --j) {
+ foo |= k[7 * i + j] & 1;
+ foo <<= 1;
+ }
+ x[8 * i + 7] = foo;
+ }
+ k = key->key->keyvalue.data;
+ memcpy(k, x, 24);
+ memset(x, 0, sizeof(x));
if (key->schedule) {
krb5_free_data(context, key->schedule);
key->schedule = NULL;
}
+ des_set_odd_parity((des_cblock*)k);
+ des_set_odd_parity((des_cblock*)(k + 8));
+ des_set_odd_parity((des_cblock*)(k + 16));
}
static krb5_error_code
@@ -3538,24 +3361,20 @@ derive_key(krb5_context context,
unsigned char *k;
unsigned int nblocks = 0, i;
krb5_error_code ret = 0;
+
struct key_type *kt = et->keytype;
-
ret = _key_schedule(context, key);
if(ret)
return ret;
- if(et->blocksize * 8 < kt->bits || len != et->blocksize) {
+ if(et->blocksize * 8 < kt->bits ||
+ len != et->blocksize) {
nblocks = (kt->bits + et->blocksize * 8 - 1) / (et->blocksize * 8);
k = malloc(nblocks * et->blocksize);
if(k == NULL) {
krb5_set_error_string(context, "malloc: out of memory");
return ENOMEM;
}
- ret = _krb5_n_fold(constant, len, k, et->blocksize);
- if (ret) {
- free(k);
- krb5_set_error_string(context, "out of memory");
- return ret;
- }
+ _krb5_n_fold(constant, len, k, et->blocksize);
for(i = 0; i < nblocks; i++) {
if(i > 0)
memcpy(k + i * et->blocksize,
@@ -3581,12 +3400,7 @@ derive_key(krb5_context context,
krb5_set_error_string(context, "malloc: out of memory");
return ENOMEM;
}
- ret = _krb5_n_fold(c, len, k, res_len);
- if (ret) {
- free(k);
- krb5_set_error_string(context, "out of memory");
- return ret;
- }
+ _krb5_n_fold(c, len, k, res_len);
free(c);
}
@@ -3595,10 +3409,12 @@ derive_key(krb5_context context,
case KEYTYPE_DES3:
DES3_postproc(context, k, nblocks * et->blocksize, key);
break;
+#ifdef ENABLE_AES
case KEYTYPE_AES128:
case KEYTYPE_AES256:
memcpy(key->key->keyvalue.data, k, key->key->keyvalue.length);
break;
+#endif /* ENABLE_AES */
default:
krb5_set_error_string(context,
"derive_key() called with unknown keytype (%u)",
@@ -3606,10 +3422,6 @@ derive_key(krb5_context context,
ret = KRB5_CRYPTO_INTERNAL;
break;
}
- if (key->schedule) {
- krb5_free_data(context, key->schedule);
- key->schedule = NULL;
- }
memset(k, 0, nblocks * et->blocksize);
free(k);
return ret;
@@ -3629,7 +3441,7 @@ _new_derived_key(krb5_crypto crypto, unsigned usage)
return &d->key;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_derive_key(krb5_context context,
const krb5_keyblock *key,
krb5_enctype etype,
@@ -3641,8 +3453,6 @@ krb5_derive_key(krb5_context context,
struct encryption_type *et;
struct key_data d;
- *derived_key = NULL;
-
et = _find_enctype (etype);
if (et == NULL) {
krb5_set_error_string(context, "encryption type %d not supported",
@@ -3650,15 +3460,16 @@ krb5_derive_key(krb5_context context,
return KRB5_PROG_ETYPE_NOSUPP;
}
- ret = krb5_copy_keyblock(context, key, &d.key);
+ ret = krb5_copy_keyblock(context, key, derived_key);
if (ret)
return ret;
+ d.key = *derived_key;
d.schedule = NULL;
ret = derive_key(context, et, &d, constant, constant_len);
- if (ret == 0)
- ret = krb5_copy_keyblock(context, d.key, derived_key);
- free_key_data(context, &d);
+ if (ret)
+ return ret;
+ ret = krb5_copy_keyblock(context, d.key, derived_key);
return ret;
}
@@ -3690,7 +3501,7 @@ _get_derived_key(krb5_context context,
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_crypto_init(krb5_context context,
const krb5_keyblock *key,
krb5_enctype etype,
@@ -3705,23 +3516,20 @@ krb5_crypto_init(krb5_context context,
if(etype == ETYPE_NULL)
etype = key->keytype;
(*crypto)->et = _find_enctype(etype);
- if((*crypto)->et == NULL || ((*crypto)->et->flags & F_DISABLED)) {
+ if((*crypto)->et == NULL) {
free(*crypto);
- *crypto = NULL;
krb5_set_error_string (context, "encryption type %d not supported",
etype);
return KRB5_PROG_ETYPE_NOSUPP;
}
if((*crypto)->et->keytype->size != key->keyvalue.length) {
free(*crypto);
- *crypto = NULL;
krb5_set_error_string (context, "encryption key has bad length");
return KRB5_BAD_KEYSIZE;
}
ret = krb5_copy_keyblock(context, key, &(*crypto)->key.key);
if(ret) {
free(*crypto);
- *crypto = NULL;
return ret;
}
(*crypto)->key.schedule = NULL;
@@ -3746,7 +3554,7 @@ free_key_usage(krb5_context context, struct key_usage *ku)
free_key_data(context, &ku->key);
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_crypto_destroy(krb5_context context,
krb5_crypto crypto)
{
@@ -3760,7 +3568,7 @@ krb5_crypto_destroy(krb5_context context,
return 0;
}
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_crypto_getblocksize(krb5_context context,
krb5_crypto crypto,
size_t *blocksize)
@@ -3769,49 +3577,7 @@ krb5_crypto_getblocksize(krb5_context context,
return 0;
}
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_crypto_getenctype(krb5_context context,
- krb5_crypto crypto,
- krb5_enctype *enctype)
-{
- *enctype = crypto->et->type;
- return 0;
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_crypto_getpadsize(krb5_context context,
- krb5_crypto crypto,
- size_t *padsize)
-{
- *padsize = crypto->et->padsize;
- return 0;
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_crypto_getconfoundersize(krb5_context context,
- krb5_crypto crypto,
- size_t *confoundersize)
-{
- *confoundersize = crypto->et->confoundersize;
- return 0;
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_enctype_disable(krb5_context context,
- krb5_enctype enctype)
-{
- struct encryption_type *et = _find_enctype(enctype);
- if(et == NULL) {
- if (context)
- krb5_set_error_string (context, "encryption type %d not supported",
- enctype);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
- et->flags |= F_DISABLED;
- return 0;
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
+krb5_error_code
krb5_string_to_key_derived(krb5_context context,
const void *str,
size_t len,
@@ -3821,7 +3587,7 @@ krb5_string_to_key_derived(krb5_context context,
struct encryption_type *et = _find_enctype(etype);
krb5_error_code ret;
struct key_data kd;
- size_t keylen;
+ size_t keylen = et->keytype->bits / 8;
u_char *tmp;
if(et == NULL) {
@@ -3829,8 +3595,6 @@ krb5_string_to_key_derived(krb5_context context,
etype);
return KRB5_PROG_ETYPE_NOSUPP;
}
- keylen = et->keytype->bits / 8;
-
ALLOC(kd.key, 1);
if(kd.key == NULL) {
krb5_set_error_string (context, "malloc: out of memory");
@@ -3848,12 +3612,7 @@ krb5_string_to_key_derived(krb5_context context,
krb5_set_error_string (context, "malloc: out of memory");
return ENOMEM;
}
- ret = _krb5_n_fold(str, len, tmp, keylen);
- if (ret) {
- free(tmp);
- krb5_set_error_string(context, "out of memory");
- return ret;
- }
+ _krb5_n_fold(str, len, tmp, keylen);
kd.schedule = NULL;
DES3_postproc (context, tmp, keylen, &kd); /* XXX */
memset(tmp, 0, keylen);
@@ -3875,10 +3634,9 @@ wrapped_length (krb5_context context,
{
struct encryption_type *et = crypto->et;
size_t padsize = et->padsize;
- size_t checksumsize = CHECKSUMSIZE(et->checksum);
size_t res;
- res = et->confoundersize + checksumsize + data_len;
+ res = et->confoundersize + et->checksum->checksumsize + data_len;
res = (res + padsize - 1) / padsize * padsize;
return res;
}
@@ -3894,10 +3652,7 @@ wrapped_length_dervied (krb5_context context,
res = et->confoundersize + data_len;
res = (res + padsize - 1) / padsize * padsize;
- if (et->keyed_checksum)
- res += et->keyed_checksum->checksumsize;
- else
- res += et->checksum->checksumsize;
+ res += et->checksum->checksumsize;
return res;
}
@@ -3916,185 +3671,12 @@ krb5_get_wrapped_length (krb5_context context,
return wrapped_length (context, crypto, data_len);
}
-/*
- * Return the size of an encrypted packet of length `data_len'
- */
-
-static size_t
-crypto_overhead (krb5_context context,
- krb5_crypto crypto)
-{
- struct encryption_type *et = crypto->et;
- size_t res;
-
- res = CHECKSUMSIZE(et->checksum);
- res += et->confoundersize;
- if (et->padsize > 1)
- res += et->padsize;
- return res;
-}
-
-static size_t
-crypto_overhead_dervied (krb5_context context,
- krb5_crypto crypto)
-{
- struct encryption_type *et = crypto->et;
- size_t res;
-
- if (et->keyed_checksum)
- res = CHECKSUMSIZE(et->keyed_checksum);
- else
- res = CHECKSUMSIZE(et->checksum);
- res += et->confoundersize;
- if (et->padsize > 1)
- res += et->padsize;
- return res;
-}
-
-size_t
-krb5_crypto_overhead (krb5_context context, krb5_crypto crypto)
-{
- if (derived_crypto (context, crypto))
- return crypto_overhead_dervied (context, crypto);
- else
- return crypto_overhead (context, crypto);
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_random_to_key(krb5_context context,
- krb5_enctype type,
- const void *data,
- size_t size,
- krb5_keyblock *key)
-{
- krb5_error_code ret;
- struct encryption_type *et = _find_enctype(type);
- if(et == NULL) {
- krb5_set_error_string(context, "encryption type %d not supported",
- type);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
- if ((et->keytype->bits + 7) / 8 > size) {
- krb5_set_error_string(context, "encryption key %s needs %d bytes "
- "of random to make an encryption key out of it",
- et->name, (int)et->keytype->size);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
- ret = krb5_data_alloc(&key->keyvalue, et->keytype->size);
- if(ret)
- return ret;
- key->keytype = type;
- if (et->keytype->random_to_key)
- (*et->keytype->random_to_key)(context, key, data, size);
- else
- memcpy(key->keyvalue.data, data, et->keytype->size);
-
- return 0;
-}
-
-krb5_error_code
-_krb5_pk_octetstring2key(krb5_context context,
- krb5_enctype type,
- const void *dhdata,
- size_t dhsize,
- const heim_octet_string *c_n,
- const heim_octet_string *k_n,
- krb5_keyblock *key)
-{
- struct encryption_type *et = _find_enctype(type);
- krb5_error_code ret;
- size_t keylen, offset;
- void *keydata;
- unsigned char counter;
- unsigned char shaoutput[20];
-
- if(et == NULL) {
- krb5_set_error_string(context, "encryption type %d not supported",
- type);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
- keylen = (et->keytype->bits + 7) / 8;
-
- keydata = malloc(keylen);
- if (keydata == NULL) {
- krb5_set_error_string(context, "malloc: out of memory");
- return ENOMEM;
- }
-
- counter = 0;
- offset = 0;
- do {
- SHA_CTX m;
-
- SHA1_Init(&m);
- SHA1_Update(&m, &counter, 1);
- SHA1_Update(&m, dhdata, dhsize);
- if (c_n)
- SHA1_Update(&m, c_n->data, c_n->length);
- if (k_n)
- SHA1_Update(&m, k_n->data, k_n->length);
- SHA1_Final(shaoutput, &m);
-
- memcpy((unsigned char *)keydata + offset,
- shaoutput,
- min(keylen - offset, sizeof(shaoutput)));
-
- offset += sizeof(shaoutput);
- counter++;
- } while(offset < keylen);
- memset(shaoutput, 0, sizeof(shaoutput));
-
- ret = krb5_random_to_key(context, type, keydata, keylen, key);
- memset(keydata, 0, sizeof(keylen));
- free(keydata);
- return ret;
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_crypto_prf_length(krb5_context context,
- krb5_enctype type,
- size_t *length)
-{
- struct encryption_type *et = _find_enctype(type);
-
- if(et == NULL || et->prf_length == 0) {
- krb5_set_error_string(context, "encryption type %d not supported",
- type);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
-
- *length = et->prf_length;
- return 0;
-}
-
-krb5_error_code KRB5_LIB_FUNCTION
-krb5_crypto_prf(krb5_context context,
- const krb5_crypto crypto,
- const krb5_data *input,
- krb5_data *output)
-{
- struct encryption_type *et = crypto->et;
-
- krb5_data_zero(output);
-
- if(et->prf == NULL) {
- krb5_set_error_string(context, "kerberos prf for %s not supported",
- et->name);
- return KRB5_PROG_ETYPE_NOSUPP;
- }
-
- return (*et->prf)(context, crypto, input, output);
-}
-
-
-
-
#ifdef CRYPTO_DEBUG
static krb5_error_code
krb5_get_keyid(krb5_context context,
krb5_keyblock *key,
- uint32_t *keyid)
+ u_int32_t *keyid)
{
MD5_CTX md5;
unsigned char tmp[16];
@@ -4108,16 +3690,16 @@ krb5_get_keyid(krb5_context context,
static void
krb5_crypto_debug(krb5_context context,
- int encryptp,
+ int encrypt,
size_t len,
krb5_keyblock *key)
{
- uint32_t keyid;
+ u_int32_t keyid;
char *kt;
krb5_get_keyid(context, key, &keyid);
krb5_enctype_to_string(context, key->keytype, &kt);
krb5_warnx(context, "%s %lu bytes with key-id %#x (%s)",
- encryptp ? "encrypting" : "decrypting",
+ encrypt ? "encrypting" : "decrypting",
(unsigned long)len,
keyid,
kt);
@@ -4154,7 +3736,7 @@ main()
d = _new_derived_key(crypto, usage);
if(d == NULL)
- krb5_errx(context, 1, "_new_derived_key failed");
+ return ENOMEM;
krb5_copy_keyblock(context, crypto->key.key, &d->key);
_krb5_put_int(constant, usage, 4);
derive_key(context, crypto->et, d, constant, sizeof(constant));
@@ -4180,10 +3762,11 @@ main()
"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; */
key.keyvalue.length = 4;
- d = ecalloc(1, sizeof(*d));
+ d = calloc(1, sizeof(*d));
+
d->key = &key;
res.checksum.length = 20;
- res.checksum.data = emalloc(res.checksum.length);
+ res.checksum.data = malloc(res.checksum.length);
SP_HMAC_SHA1_checksum(context, d, data, 28, &res);
return 0;
diff --git a/crypto/heimdal/lib/krb5/krb5_locl.h b/crypto/heimdal/lib/krb5/krb5_locl.h
index 8b7c41c..be7997e 100644
--- a/crypto/heimdal/lib/krb5/krb5_locl.h
+++ b/crypto/heimdal/lib/krb5/krb5_locl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2006 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997-2002 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -31,7 +31,8 @@
* SUCH DAMAGE.
*/
-/* $Id: krb5_locl.h 22226 2007-12-08 21:31:53Z lha $ */
+/* $Id: krb5_locl.h,v 1.71 2002/09/10 20:10:45 joda Exp $ */
+/* $FreeBSD$ */
#ifndef __KRB5_LOCL_H__
#define __KRB5_LOCL_H__
@@ -50,9 +51,6 @@
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -64,9 +62,6 @@
#include <sys/ioctl.h>
#endif
#ifdef HAVE_PWD_H
-#undef _POSIX_PTHREAD_SEMANTICS
-/* This gets us the 5-arg getpwnam_r on Solaris 9. */
-#define _POSIX_PTHREAD_SEMANTICS
#include <pwd.h>
#endif
@@ -115,51 +110,20 @@ struct sockaddr_dl;
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
-
-#ifdef HAVE_CRYPT_H
-#undef des_encrypt
-#define des_encrypt wingless_pigs_mostly_fail_to_fly
-#include <crypt.h>
-#undef des_encrypt
-#endif
-
-#ifdef HAVE_DOOR_CREATE
-#include <door.h>
-#endif
-
#include <roken.h>
#include <parse_time.h>
#include <base64.h>
#include "crypto-headers.h"
-
#include <krb5_asn1.h>
-
-struct send_to_kdc;
-
-/* XXX glue for pkinit */
-struct krb5_pk_identity;
-struct krb5_pk_cert;
-struct ContentInfo;
-typedef struct krb5_pk_init_ctx_data *krb5_pk_init_ctx;
-struct krb5_dh_moduli;
-
-/* v4 glue */
-struct _krb5_krb_auth_data;
-
#include <der.h>
#include <krb5.h>
#include <krb5_err.h>
#include <asn1_err.h>
-#ifdef PKINIT
-#include <hx509_err.h>
-#endif
#include <krb5-private.h>
-#include "heim_threads.h"
-
#define ALLOC(X, N) (X) = calloc((N), sizeof(*(X)))
#define ALLOC_SEQ(X, N) do { (X)->len = (N); ALLOC((X)->val, (N)); } while(0)
@@ -167,101 +131,8 @@ struct _krb5_krb_auth_data;
#define KEYTAB_DEFAULT "ANY:FILE:" SYSCONFDIR "/krb5.keytab,krb4:" SYSCONFDIR "/srvtab"
#define KEYTAB_DEFAULT_MODIFY "FILE:" SYSCONFDIR "/krb5.keytab"
-#define MODULI_FILE SYSCONFDIR "/krb5.moduli"
-
#ifndef O_BINARY
#define O_BINARY 0
#endif
-#define KRB5_BUFSIZ 1024
-
-typedef enum {
- KRB5_INIT_CREDS_TRISTATE_UNSET = 0,
- KRB5_INIT_CREDS_TRISTATE_TRUE,
- KRB5_INIT_CREDS_TRISTATE_FALSE
-} krb5_get_init_creds_tristate;
-
-struct _krb5_get_init_creds_opt_private {
- int refcount;
- /* ENC_TIMESTAMP */
- const char *password;
- krb5_s2k_proc key_proc;
- /* PA_PAC_REQUEST */
- krb5_get_init_creds_tristate req_pac;
- /* PKINIT */
- krb5_pk_init_ctx pk_init_ctx;
- KRB_ERROR *error;
- krb5_get_init_creds_tristate addressless;
- int flags;
-#define KRB5_INIT_CREDS_CANONICALIZE 1
-#define KRB5_INIT_CREDS_NO_C_CANON_CHECK 2
-};
-
-typedef struct krb5_context_data {
- krb5_enctype *etypes;
- krb5_enctype *etypes_des;
- char **default_realms;
- time_t max_skew;
- time_t kdc_timeout;
- unsigned max_retries;
- int32_t kdc_sec_offset;
- int32_t kdc_usec_offset;
- krb5_config_section *cf;
- struct et_list *et_list;
- struct krb5_log_facility *warn_dest;
- krb5_cc_ops *cc_ops;
- int num_cc_ops;
- const char *http_proxy;
- const char *time_fmt;
- krb5_boolean log_utc;
- const char *default_keytab;
- const char *default_keytab_modify;
- krb5_boolean use_admin_kdc;
- krb5_addresses *extra_addresses;
- krb5_boolean scan_interfaces; /* `ifconfig -a' */
- krb5_boolean srv_lookup; /* do SRV lookups */
- krb5_boolean srv_try_txt; /* try TXT records also */
- int32_t fcache_vno; /* create cache files w/ this
- version */
- int num_kt_types; /* # of registered keytab types */
- struct krb5_keytab_data *kt_types; /* registered keytab types */
- const char *date_fmt;
- char *error_string;
- char error_buf[256];
- krb5_addresses *ignore_addresses;
- char *default_cc_name;
- char *default_cc_name_env;
- int default_cc_name_set;
- void *mutex; /* protects error_string/error_buf */
- int large_msg_size;
- int flags;
-#define KRB5_CTX_F_DNS_CANONICALIZE_HOSTNAME 1
-#define KRB5_CTX_F_CHECK_PAC 2
- struct send_to_kdc *send_to_kdc;
-} krb5_context_data;
-
-#define KRB5_DEFAULT_CCNAME_FILE "FILE:/tmp/krb5cc_%{uid}"
-#define KRB5_DEFAULT_CCNAME_API "API:"
-#define KRB5_DEFAULT_CCNAME_KCM "KCM:%{uid}"
-
-#define EXTRACT_TICKET_ALLOW_CNAME_MISMATCH 1
-#define EXTRACT_TICKET_ALLOW_SERVER_MISMATCH 2
-#define EXTRACT_TICKET_MATCH_REALM 4
-
-/*
- * Configurable options
- */
-
-#ifndef KRB5_DEFAULT_CCTYPE
-#ifdef __APPLE__
-#define KRB5_DEFAULT_CCTYPE (&krb5_acc_ops)
-#else
-#define KRB5_DEFAULT_CCTYPE (&krb5_fcc_ops)
-#endif
-#endif
-
-#ifndef KRB5_ADDRESSLESS_DEFAULT
-#define KRB5_ADDRESSLESS_DEFAULT TRUE
-#endif
-
#endif /* __KRB5_LOCL_H__ */
OpenPOWER on IntegriCloud