From e7f2f454753651fffd4b86d565e08e1fa7458dbc Mon Sep 17 00:00:00 2001 From: Zhanna Tsitkov Date: Tue, 29 Dec 2009 20:08:42 +0000 Subject: Combine the related code into one file git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23537 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/krb/Makefile.in | 16 +---- src/lib/crypto/krb/enctype_compare.c | 44 ------------- src/lib/crypto/krb/enctype_to_string.c | 42 ------------- src/lib/crypto/krb/enctype_util.c | 110 +++++++++++++++++++++++++++++++++ src/lib/crypto/krb/string_to_enctype.c | 58 ----------------- src/lib/crypto/krb/valid_enctype.c | 44 ------------- 6 files changed, 113 insertions(+), 201 deletions(-) delete mode 100644 src/lib/crypto/krb/enctype_compare.c delete mode 100644 src/lib/crypto/krb/enctype_to_string.c create mode 100644 src/lib/crypto/krb/enctype_util.c delete mode 100644 src/lib/crypto/krb/string_to_enctype.c delete mode 100644 src/lib/crypto/krb/valid_enctype.c diff --git a/src/lib/crypto/krb/Makefile.in b/src/lib/crypto/krb/Makefile.in index 5c08de610..9e019115f 100644 --- a/src/lib/crypto/krb/Makefile.in +++ b/src/lib/crypto/krb/Makefile.in @@ -39,8 +39,7 @@ STLIBOBJS=\ encrypt.o \ encrypt_iov.o \ encrypt_length.o \ - enctype_compare.o \ - enctype_to_string.o \ + enctype_util.o \ etypes.o \ key.o \ keyblocks.o \ @@ -58,10 +57,8 @@ STLIBOBJS=\ random_to_key.o \ state.o \ string_to_cksumtype.o \ - string_to_enctype.o \ string_to_key.o \ valid_cksumtype.o \ - valid_enctype.o \ verify_checksum.o \ verify_checksum_iov.o @@ -82,8 +79,7 @@ OBJS=\ $(OUTPRE)encrypt.$(OBJEXT) \ $(OUTPRE)encrypt_iov.$(OBJEXT) \ $(OUTPRE)encrypt_length.$(OBJEXT) \ - $(OUTPRE)enctype_compare.$(OBJEXT) \ - $(OUTPRE)enctype_to_string.$(OBJEXT) \ + $(OUTPRE)enctype_util.$(OBJEXT) \ $(OUTPRE)etypes.$(OBJEXT) \ $(OUTPRE)key.$(OBJECT) \ $(OUTPRE)keyblocks.$(OBJEXT) \ @@ -101,10 +97,7 @@ OBJS=\ $(OUTPRE)random_to_key.$(OBJEXT) \ $(OUTPRE)state.$(OBJEXT) \ $(OUTPRE)string_to_cksumtype.$(OBJEXT) \ - $(OUTPRE)string_to_enctype.$(OBJEXT) \ - $(OUTPRE)string_to_key.$(OBJEXT) \ $(OUTPRE)valid_cksumtype.$(OBJEXT) \ - $(OUTPRE)valid_enctype.$(OBJEXT) \ $(OUTPRE)verify_checksum.$(OBJEXT) \ $(OUTPRE)verify_checksum_iov.$(OBJEXT) @@ -124,8 +117,7 @@ SRCS=\ $(srcdir)/encrypt.c \ $(srcdir)/encrypt_iov.c \ $(srcdir)/encrypt_length.c \ - $(srcdir)/enctype_compare.c \ - $(srcdir)/enctype_to_string.c \ + $(srcdir)/enctype_util.c \ $(srcdir)/etypes.c \ $(srcdir)/key.c \ $(srcdir)/keyblocks.c \ @@ -144,10 +136,8 @@ SRCS=\ $(srcdir)/random_to_key.c \ $(srcdir)/state.c \ $(srcdir)/string_to_cksumtype.c \ - $(srcdir)/string_to_enctype.c \ $(srcdir)/string_to_key.c \ $(srcdir)/valid_cksumtype.c \ - $(srcdir)/valid_enctype.c \ $(srcdir)/verify_checksum.c \ $(srcdir)/verify_checksum_iov.c diff --git a/src/lib/crypto/krb/enctype_compare.c b/src/lib/crypto/krb/enctype_compare.c deleted file mode 100644 index 327188021..000000000 --- a/src/lib/crypto/krb/enctype_compare.c +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* - * Copyright (C) 1998 by the FundsXpress, INC. - * - * All rights reserved. - * - * Export of this software from the United States of America may require - * a specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of FundsXpress. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. FundsXpress makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include "k5-int.h" -#include "etypes.h" - -krb5_error_code KRB5_CALLCONV -krb5_c_enctype_compare(krb5_context context, krb5_enctype e1, krb5_enctype e2, - krb5_boolean *similar) -{ - const struct krb5_keytypes *ktp1, *ktp2; - - ktp1 = find_enctype(e1); - ktp2 = find_enctype(e2); - if (ktp1 == NULL || ktp2 == NULL) - return KRB5_BAD_ENCTYPE; - - *similar = (ktp1->enc == ktp2->enc && ktp1->str2key == ktp2->str2key); - return 0; -} diff --git a/src/lib/crypto/krb/enctype_to_string.c b/src/lib/crypto/krb/enctype_to_string.c deleted file mode 100644 index f0e8962d8..000000000 --- a/src/lib/crypto/krb/enctype_to_string.c +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* - * Copyright (C) 1998 by the FundsXpress, INC. - * - * All rights reserved. - * - * Export of this software from the United States of America may require - * a specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of FundsXpress. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. FundsXpress makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include "k5-int.h" -#include "etypes.h" - -krb5_error_code KRB5_CALLCONV -krb5_enctype_to_string(krb5_enctype enctype, char *buffer, size_t buflen) -{ - const struct krb5_keytypes *ktp; - - ktp = find_enctype(enctype); - if (ktp == NULL) - return EINVAL; - if (strlcpy(buffer, ktp->out_string, buflen) >= buflen) - return ENOMEM; - return 0; -} diff --git a/src/lib/crypto/krb/enctype_util.c b/src/lib/crypto/krb/enctype_util.c new file mode 100644 index 000000000..dd1a388ab --- /dev/null +++ b/src/lib/crypto/krb/enctype_util.c @@ -0,0 +1,110 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/* + * lib/crypto/krb/enctype_util.c + * + * Copyright (C) 1998 by the FundsXpress, INC. + * + * All rights reserved. + * + * Export of this software from the United States of America may require + * a specific license from the United States Government. It is the + * responsibility of any person or organization contemplating export to + * obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of FundsXpress. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. FundsXpress makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * + * krb5int_c_valid_enctype() + * krb5int_c_weak_enctype() + * krb5_c_enctype_compare() + * krb5_string_to_enctype() + * krb5_enctype_to_string() + */ + +#include "k5-int.h" +#include "etypes.h" + +krb5_boolean KRB5_CALLCONV +krb5_c_valid_enctype(krb5_enctype etype) +{ + return (find_enctype(etype) != NULL); +} + +krb5_boolean KRB5_CALLCONV +krb5int_c_weak_enctype(krb5_enctype etype) +{ + const struct krb5_keytypes *ktp; + + ktp = find_enctype(etype); + return (ktp != NULL && (ktp->flags & ETYPE_WEAK) != 0); +} + +krb5_error_code KRB5_CALLCONV +krb5_c_enctype_compare(krb5_context context, krb5_enctype e1, krb5_enctype e2, + krb5_boolean *similar) +{ + const struct krb5_keytypes *ktp1, *ktp2; + + ktp1 = find_enctype(e1); + ktp2 = find_enctype(e2); + if (ktp1 == NULL || ktp2 == NULL) + return KRB5_BAD_ENCTYPE; + + *similar = (ktp1->enc == ktp2->enc && ktp1->str2key == ktp2->str2key); + return 0; +} + +krb5_error_code KRB5_CALLCONV +krb5_string_to_enctype(char *string, krb5_enctype *enctypep) +{ + int i; + unsigned int j; + const char *alias; + const struct krb5_keytypes *ktp; + + for (i = 0; i < krb5int_enctypes_length; i++) { + ktp = &krb5int_enctypes_list[i]; + if (strcasecmp(ktp->name, string) == 0) { + *enctypep = ktp->etype; + return 0; + } +#define MAX_ALIASES (sizeof(ktp->aliases) / sizeof(ktp->aliases[0])) + for (j = 0; j < MAX_ALIASES; j++) { + alias = ktp->aliases[j]; + if (alias == NULL) + break; + if (strcasecmp(alias, string) == 0) { + *enctypep = ktp->etype; + return 0; + } + } + } + + return EINVAL; +} + +krb5_error_code KRB5_CALLCONV +krb5_enctype_to_string(krb5_enctype enctype, char *buffer, size_t buflen) +{ + const struct krb5_keytypes *ktp; + + ktp = find_enctype(enctype); + if (ktp == NULL) + return EINVAL; + if (strlcpy(buffer, ktp->out_string, buflen) >= buflen) + return ENOMEM; + return 0; +} diff --git a/src/lib/crypto/krb/string_to_enctype.c b/src/lib/crypto/krb/string_to_enctype.c deleted file mode 100644 index 25091fed3..000000000 --- a/src/lib/crypto/krb/string_to_enctype.c +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* - * Copyright (C) 1998 by the FundsXpress, INC. - * - * All rights reserved. - * - * Export of this software from the United States of America may require - * a specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of FundsXpress. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. FundsXpress makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include "k5-int.h" -#include "etypes.h" - -krb5_error_code KRB5_CALLCONV -krb5_string_to_enctype(char *string, krb5_enctype *enctypep) -{ - int i; - unsigned int j; - const char *alias; - const struct krb5_keytypes *ktp; - - for (i = 0; i < krb5int_enctypes_length; i++) { - ktp = &krb5int_enctypes_list[i]; - if (strcasecmp(ktp->name, string) == 0) { - *enctypep = ktp->etype; - return 0; - } -#define MAX_ALIASES (sizeof(ktp->aliases) / sizeof(ktp->aliases[0])) - for (j = 0; j < MAX_ALIASES; j++) { - alias = ktp->aliases[j]; - if (alias == NULL) - break; - if (strcasecmp(alias, string) == 0) { - *enctypep = ktp->etype; - return 0; - } - } - } - - return EINVAL; -} diff --git a/src/lib/crypto/krb/valid_enctype.c b/src/lib/crypto/krb/valid_enctype.c deleted file mode 100644 index 095721978..000000000 --- a/src/lib/crypto/krb/valid_enctype.c +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* - * Copyright (C) 1998 by the FundsXpress, INC. - * - * All rights reserved. - * - * Export of this software from the United States of America may require - * a specific license from the United States Government. It is the - * responsibility of any person or organization contemplating export to - * obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of FundsXpress. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. FundsXpress makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include "k5-int.h" -#include "etypes.h" - -krb5_boolean KRB5_CALLCONV -krb5_c_valid_enctype(krb5_enctype etype) -{ - return (find_enctype(etype) != NULL); -} - -krb5_boolean KRB5_CALLCONV -krb5int_c_weak_enctype(krb5_enctype etype) -{ - const struct krb5_keytypes *ktp; - - ktp = find_enctype(etype); - return (ktp != NULL && (ktp->flags & ETYPE_WEAK) != 0); -} -- cgit