From: Zhanna Tsitkov Date: Tue, 29 Dec 2009 16:41:08 +0000 (+0000) Subject: Functions in enc_helper.c serve different code blocks. Split them X-Git-Tag: krb5-1.8-alpha1~49 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=069b17798b3326d9279a79939756f3150db95eb7;p=krb5.git Functions in enc_helper.c serve different code blocks. Split them git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23535 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/Makefile.in b/src/lib/krb5/krb/Makefile.in index 507be6e80..2cdeb02ba 100644 --- a/src/lib/krb5/krb/Makefile.in +++ b/src/lib/krb5/krb/Makefile.in @@ -37,6 +37,7 @@ STLIBOBJS= \ decrypt_tk.o \ deltat.o \ enc_helper.o \ + enc_keyhelper.o \ encode_kdc.o \ encrypt_tk.o \ fast.o \ @@ -129,6 +130,7 @@ OBJS= $(OUTPRE)addr_comp.$(OBJEXT) \ $(OUTPRE)decrypt_tk.$(OBJEXT) \ $(OUTPRE)deltat.$(OBJEXT) \ $(OUTPRE)enc_helper.$(OBJEXT) \ + $(OUTPRE)enc_keyhelper.$(OBJEXT) \ $(OUTPRE)encode_kdc.$(OBJEXT) \ $(OUTPRE)encrypt_tk.$(OBJEXT) \ $(OUTPRE)fast.$(OBJEXT) \ @@ -222,6 +224,7 @@ SRCS= $(srcdir)/addr_comp.c \ $(srcdir)/decrypt_tk.c \ $(srcdir)/deltat.c \ $(srcdir)/enc_helper.c \ + $(srcdir)/enc_keyhelper.c \ $(srcdir)/encode_kdc.c \ $(srcdir)/encrypt_tk.c \ $(srcdir)/fast.c \ diff --git a/src/lib/krb5/krb/enc_helper.c b/src/lib/krb5/krb/enc_helper.c index 41d2f00f7..0a45857d1 100644 --- a/src/lib/krb5/krb/enc_helper.c +++ b/src/lib/krb5/krb/enc_helper.c @@ -1,5 +1,7 @@ /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* + * lib/krb5/krb/enc_helper.c + * * Copyright (C) 1998 by the FundsXpress, INC. * * All rights reserved. @@ -23,12 +25,17 @@ * 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. + * + * krb5_encrypt_helper() + * */ #include "k5-int.h" krb5_error_code -krb5_encrypt_helper(krb5_context context, const krb5_keyblock *key, krb5_keyusage usage, const krb5_data *plain, krb5_enc_data *cipher) +krb5_encrypt_helper(krb5_context context, + const krb5_keyblock *key, krb5_keyusage usage, + const krb5_data *plain, krb5_enc_data *cipher) { krb5_error_code ret; size_t enclen; @@ -48,29 +55,3 @@ krb5_encrypt_helper(krb5_context context, const krb5_keyblock *key, krb5_keyusag return(ret); } - -krb5_error_code -krb5_encrypt_keyhelper(krb5_context context, krb5_key key, krb5_keyusage usage, - const krb5_data *plain, krb5_enc_data *cipher) -{ - krb5_enctype enctype; - krb5_error_code ret; - size_t enclen; - - enctype = krb5_k_key_enctype(context, key); - ret = krb5_c_encrypt_length(context, enctype, plain->length, &enclen); - if (ret != 0) - return ret; - - cipher->ciphertext.length = enclen; - cipher->ciphertext.data = malloc(enclen); - if (cipher->ciphertext.data == NULL) - return ENOMEM; - ret = krb5_k_encrypt(context, key, usage, 0, plain, cipher); - if (ret) { - free(cipher->ciphertext.data); - cipher->ciphertext.data = NULL; - } - - return ret; -} diff --git a/src/lib/krb5/krb/enc_keyhelper.c b/src/lib/krb5/krb/enc_keyhelper.c new file mode 100644 index 000000000..43db716e4 --- /dev/null +++ b/src/lib/krb5/krb/enc_keyhelper.c @@ -0,0 +1,59 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/* + * lib/krb5/krb/enc_keyhelper.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. + * + * krb5_encrypt_keyhelper() + * + */ + +#include "k5-int.h" + +krb5_error_code +krb5_encrypt_keyhelper(krb5_context context, krb5_key key, krb5_keyusage usage, + const krb5_data *plain, krb5_enc_data *cipher) +{ + krb5_enctype enctype; + krb5_error_code ret; + size_t enclen; + + enctype = krb5_k_key_enctype(context, key); + ret = krb5_c_encrypt_length(context, enctype, plain->length, &enclen); + if (ret != 0) + return ret; + + cipher->ciphertext.length = enclen; + cipher->ciphertext.data = malloc(enclen); + if (cipher->ciphertext.data == NULL) + return ENOMEM; + ret = krb5_k_encrypt(context, key, usage, 0, plain, cipher); + if (ret) { + free(cipher->ciphertext.data); + cipher->ciphertext.data = NULL; + } + + return ret; +}