+2002-03-28 Sam Hartman <hartmans@mit.edu>
+
+ * krb5.hin: krb5_init_keyblock new function.
+
2002-03-28 Ken Raeburn <raeburn@mit.edu>
* k5-int.h: Include errno.h.
(krb5_context,
krb5_const_principal,
krb5_const_principal);
+krb5_error_code KRB5_CALLCONV krb5_init_keyblock
+ (krb5_context, krb5_enctype enctype,
+ size_t length, krb5_keyblock **out);
+ /* Initialize a new keyblock and allocate storage
+ * for the contents of the key, which will be freed along
+ * with the keyblock when krb5_free_keyblock is called.
+ * It is legal to pass in a length of 0, in which
+ * case contents are left unallocated.
+ */
krb5_error_code KRB5_CALLCONV krb5_copy_keyblock
(krb5_context,
const krb5_keyblock *,
+2002-03-28 Sam Hartman <hartmans@mit.edu>
+
+ * t_encrypt.c (main): Test krb5_init_keyblock
+
2002-01-14 Sam Hartman <hartmans@mit.edu>
* t_prng.expected: Update to be correct for 0 MSW in v_i calculation.
$(CC_LINK) -o $@ t_nfold.$(OBJEXT) nfold.$(OBJEXT)
t_encrypt$(EXEEXT): t_encrypt.$(OBJEXT) nfold.$(OBJEXT)
- $(CC_LINK) -o $@ t_encrypt.$(OBJEXT) -lk5crypto -lcom_err
+ $(CC_LINK) -o $@ t_encrypt.$(OBJEXT) -lkrb5 -lk5crypto -lcom_err
t_prng$(EXEEXT): t_prng.$(OBJEXT)
$(CC_LINK) -o $@ t_prng.$(OBJEXT) -lk5crypto -lcom_err
size_t len;
krb5_enc_data enc_out;
krb5_error_code retval;
- krb5_keyblock key;
+ krb5_keyblock *key;
in.data = "This is a test.\n";
in.length = strlen (in.data);
for (i = 0; interesting_enctypes[i]; i++) {
krb5_enctype enctype = interesting_enctypes [i];
printf ("Testing enctype %d\n", enctype);
+ test ("Initializing a keyblock",
+ krb5_init_keyblock (context, enctype, 0, &key));
test ("Generating random key",
- krb5_c_make_random_key (context, enctype, &key));
+ krb5_c_make_random_key (context, enctype, key));
enc_out.ciphertext.data = out.data;
enc_out.ciphertext.length = out.length;
/* We use an intermediate `len' because size_t may be different size
than `int' */
- krb5_c_encrypt_length (context, key.enctype, in.length, &len);
+ krb5_c_encrypt_length (context, key->enctype, in.length, &len);
enc_out.ciphertext.length = len;
test ("Encrypting",
- krb5_c_encrypt (context, &key, 7, 0, &in, &enc_out));
+ krb5_c_encrypt (context, key, 7, 0, &in, &enc_out));
test ("Decrypting",
- krb5_c_decrypt (context, &key, 7, 0, &enc_out, &check));
+ krb5_c_decrypt (context, key, 7, 0, &enc_out, &check));
test ("init_state",
- krb5_c_init_state (context, &key, 7, &state));
+ krb5_c_init_state (context, key, 7, &state));
test ("Encrypting with state",
- krb5_c_encrypt (context, &key, 7, &state, &in, &enc_out));
+ krb5_c_encrypt (context, key, 7, &state, &in, &enc_out));
test ("Decrypting",
- krb5_c_decrypt (context, &key, 7, 0, &enc_out, &check));
+ krb5_c_decrypt (context, key, 7, 0, &enc_out, &check));
test ("free_state",
- krb5_c_free_state (context, &key, &state));
- if(key.contents) {
- free(key.contents);
- key.contents = NULL;
- }
+ krb5_c_free_state (context, key, &state));
+ krb5_free_keyblock (context, key);
}
free(out.data);
+2002-03-28 Sam Hartman <hartmans@mit.edu>
+
+ * Makefile.in : New file init_keyblock.c
+
+ * init_keyblock.c (krb5_init_keyblock): New function
+
2002-03-16 Sam Hartman <hartmans@mit.edu>
* fwd_tgt.c (krb5_fwd_tgt_creds): Fix merge of patch from 1.2.2
in_tkt_pwd.o \
in_tkt_sky.o \
init_ctx.o \
+ init_keyblock.o \
kdc_rep_dc.o \
kfree.o \
mk_cred.o \
$(OUTPRE)in_tkt_pwd.$(OBJEXT) \
$(OUTPRE)in_tkt_sky.$(OBJEXT) \
$(OUTPRE)init_ctx.$(OBJEXT) \
+ $(OUTPRE)init_keyblock.$(OBJEXT) \
$(OUTPRE)kdc_rep_dc.$(OBJEXT) \
$(OUTPRE)kfree.$(OBJEXT) \
$(OUTPRE)mk_cred.$(OBJEXT) \
$(srcdir)/in_tkt_pwd.c \
$(srcdir)/in_tkt_sky.c \
$(srcdir)/init_ctx.c \
+ $(srcdir)/init_keyblock.c \
$(srcdir)/kdc_rep_dc.c \
$(srcdir)/kfree.c \
$(srcdir)/mk_cred.c \
--- /dev/null
+/*
+ * lib/krb5/krb/init_keyblock.c
+ *
+ * Copyright (C) 2002 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ *
+ *
+ * krb5_init_keyblock- a function to set up
+ * an empty keyblock
+ */
+
+
+#include "k5-int.h"
+#include <assert.h>
+
+krb5_error_code KRB5_CALLCONV krb5_init_keyblock
+ (krb5_context context, krb5_enctype enctype,
+ size_t length, krb5_keyblock **out)
+{
+ krb5_keyblock *kb;
+ kb = malloc (sizeof(krb5_keyblock));
+ assert (out);
+ *out = NULL;
+ if (!kb) {
+ return ENOMEM;
+ }
+ kb->magic = KV5M_KEYBLOCK;
+ kb->enctype = enctype;
+ kb->length = length;
+ if(length) {
+ kb->contents = malloc (length);
+ if(!kb->contents) {
+ free (kb);
+ return ENOMEM;
+ }
+ } else {
+ kb->contents = NULL;
+ }
+ *out = kb;
+ return 0;
+}