store the input length as the length integer in the encoding
authorJohn Kohl <jtkohl@mit.edu>
Tue, 13 Feb 1990 16:49:47 +0000 (16:49 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Tue, 13 Feb 1990 16:49:47 +0000 (16:49 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@357 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/kdb/encrypt_key.c

index 98a11e910f6d5cd5e6580858efedeab12c85bd63..f3a5a5df478c3b1588c03be7d1f7c1e50c18c465 100644 (file)
@@ -33,14 +33,12 @@ krb5_encrypt_block *eblock;
 krb5_keyblock *in;
 krb5_keyblock *out;
 {
-    /* encrypted rep has a length encrypted along with the key,
-       so that we win if the keysize != blocksize.
-       However, this means an extra block (at least) if
-       keysize == blocksize. */
+    /* encrypted rep has the real (unencrypted) key length stored
+       along with the encrypted key */
 
     krb5_error_code retval;
 
-    *out = *in;
+    out->keytype = in->keytype;
     out->length = krb5_encrypt_size(in->length, eblock->crypto_entry);
     out->length += sizeof(out->length);
     out->contents = (krb5_octet *)malloc(out->length);
@@ -49,7 +47,9 @@ krb5_keyblock *out;
        out->length = 0;
        return ENOMEM;
     }
-    bcopy((char *)&out->length, (char *)out->contents, sizeof(out->length));
+    /* copy in real length */
+    bcopy((char *)&in->length, (char *)out->contents, sizeof(out->length));
+    /* and arrange for encrypted key */
     if (retval = (*eblock->crypto_entry->
                  encrypt_func)((krb5_pointer) in->contents,
                                (krb5_pointer) (((char *) out->contents) +