Rename the local_subkey and remote_subkey fields in the auth_context
authorTom Yu <tlyu@mit.edu>
Sat, 10 May 2003 00:01:04 +0000 (00:01 +0000)
committerTom Yu <tlyu@mit.edu>
Sat, 10 May 2003 00:01:04 +0000 (00:01 +0000)
to send_subkey and recv_subkey, respectively.  Add new APIs to query
and set these fields.  Change the behavior of mk_req_ext, rd_req_dec,
and rd_rep to set both subkeys.  Applications wanting to set
unidirectional subkeys may still do so by saving the values of subkeys
and doing overrides.  Cause mk_cred, mk_priv, and mk_safe to never use
the recv_subkey.  Cause rd_cred, rd_priv, and rd_safe to never use the
send_subkey.

ticket: 1415
status: open
tags: pullup
target_version: 1.3

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15407 dc483132-0cff-0310-8789-dd5450dbe970

32 files changed:
src/appl/bsd/ChangeLog
src/appl/bsd/krcp.c
src/appl/bsd/krlogin.c
src/appl/bsd/krlogind.c
src/appl/bsd/krsh.c
src/appl/bsd/krshd.c
src/appl/telnet/libtelnet/ChangeLog
src/appl/telnet/libtelnet/kerberos5.c
src/include/ChangeLog
src/include/krb5.hin
src/kdc/ChangeLog
src/kdc/kdc_util.c
src/lib/ChangeLog
src/lib/gssapi/krb5/ChangeLog
src/lib/gssapi/krb5/accept_sec_context.c
src/lib/gssapi/krb5/init_sec_context.c
src/lib/krb5/krb/ChangeLog
src/lib/krb5/krb/auth_con.c
src/lib/krb5/krb/auth_con.h
src/lib/krb5/krb/chpw.c
src/lib/krb5/krb/mk_cred.c
src/lib/krb5/krb/mk_priv.c
src/lib/krb5/krb/mk_req_ext.c
src/lib/krb5/krb/mk_safe.c
src/lib/krb5/krb/rd_cred.c
src/lib/krb5/krb/rd_priv.c
src/lib/krb5/krb/rd_rep.c
src/lib/krb5/krb/rd_req_dec.c
src/lib/krb5/krb/rd_safe.c
src/lib/krb5/krb/ser_actx.c
src/lib/krb5_32.def
src/mac/MacOSX/Projects/Kerberos5.pbexp

index a6419495a220a30ca6ad721c98f32690ef90bf12..274d2bdfb714680e8a61c4aa1a225c807b8c2199 100644 (file)
@@ -1,3 +1,15 @@
+2003-05-09  Tom Yu  <tlyu@mit.edu>
+
+       * krcp.c (main): Rename getlocalsubkey -> getsendsubkey.
+
+       * krlogin.c (main): Rename getlocalsubkey -> getsendsubkey.
+
+       * krlogind.c (recvauth): Rename getremotesubkey -> getrecvsubkey.
+
+       * krsh.c (main): Rename getlocalsubkey -> getsendsubkey.
+
+       * krshd.c (recvauth): Rename getremotesubkey -> getrecvsubkey.
+
 2003-04-08  Ken Raeburn  <raeburn@mit.edu>
 
        * krshd.c (main): Use LOG_AUTH syslog facility, not LOG_DAEMON,
index 5ad6a25a1e50a1704b99da838939b2e20883b03a..707985a5a873716ecc3b74feb32947414d66c640 100644 (file)
@@ -480,9 +480,9 @@ int main(argc, argv)
                            try_normal(orig_argv); /* doesn't return */
 
                        if (!similar) {
-                           status = krb5_auth_con_getlocalsubkey (bsd_context,
-                                                                  auth_context,
-                                                                  &key);
+                           status = krb5_auth_con_getsendsubkey (bsd_context,
+                                                                 auth_context,
+                                                                 &key);
                            if ((status || !key) && encryptflag)
                                try_normal(orig_argv);
                        }
@@ -599,9 +599,9 @@ int main(argc, argv)
                    krb5_keyblock *key = &cred->keyblock;
 
                    if (kcmd_proto == KCMD_NEW_PROTOCOL) {
-                       status = krb5_auth_con_getlocalsubkey (bsd_context,
-                                                              auth_context,
-                                                              &key);
+                       status = krb5_auth_con_getsendsubkey (bsd_context,
+                                                             auth_context,
+                                                             &key);
                        if (status) {
                            com_err (argv[0], status,
                                     "determining subkey for session");
index c497dc2fb6fe08853f330d5171472cbecd789c0b..a1e63a64502bc9ae5fdf9e6b2dcc515e6df1a32b 100644 (file)
@@ -702,8 +702,8 @@ main(argc, argv)
        if (kcmd_proto == KCMD_NEW_PROTOCOL) {
            do_inband = 1;
 
-           status = krb5_auth_con_getlocalsubkey (bsd_context, auth_context,
-                                                  &key);
+           status = krb5_auth_con_getsendsubkey (bsd_context, auth_context,
+                                                 &key);
            if ((status || !key) && encrypt_flag)
                try_normal(orig_argv);
        }
index 82e560143dd43fa81b63c8bb38e321713ca5d0ad..d2979e1416331f977b3958287b13d708a2df1a86 100644 (file)
@@ -1537,7 +1537,7 @@ recvauth(valid_checksum)
        return status;
 
     key = 0;
-    status = krb5_auth_con_getremotesubkey (bsd_context, auth_context, &key);
+    status = krb5_auth_con_getrecvsubkey (bsd_context, auth_context, &key);
     if (status)
        fatal (netf, "Server can't get session subkey");
     if (!key && do_encrypt && kcmd_proto == KCMD_NEW_PROTOCOL)
index 3f8273ec0b73a4af2667a47c8e353fa2f78b4cc3..bd9c20572412015a35d9424fa1aac55dd54e0007 100644 (file)
@@ -411,8 +411,8 @@ main(argc, argv0)
        krb5_keyblock *key = &cred->keyblock;
 
        if (kcmd_proto == KCMD_NEW_PROTOCOL) {
-           status = krb5_auth_con_getlocalsubkey (bsd_context, auth_context,
-                                                  &key);
+           status = krb5_auth_con_getsendsubkey (bsd_context, auth_context,
+                                                 &key);
            if (status) {
                com_err (argv[0], status, "determining subkey for session");
                exit (1);
index adad7ea2ff96643da040e030ef168a6a57182fba..d625d8bd97707daa437bb8e9acb616e89670fb47 100644 (file)
@@ -1962,8 +1962,8 @@ recvauth(netfd, peersin, valid_checksum)
 
     {
        krb5_keyblock *key;
-       status = krb5_auth_con_getremotesubkey (bsd_context, auth_context,
-                                               &key);
+       status = krb5_auth_con_getrecvsubkey (bsd_context, auth_context,
+                                             &key);
        if (status)
            fatal (netfd, "Server can't get session subkey");
        if (!key && do_encrypt && kcmd_proto == KCMD_NEW_PROTOCOL)
index ea46e4fb8611a62eaccdab51dc498f1a254f9775..4f9de7ade67f10e1259470d0526325e91735b89e 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-09  Tom Yu  <tlyu@mit.edu>
+
+       * kerberos5.c (kerberos5_send): Rename getlocalsubkey ->
+       getsendsubkey.
+       (kerberos5_is): Rename getremotesubkey -> getrecvsubkey.
+
 2003-04-10  Tom Yu  <tlyu@mit.edu>
 
        * Makefile.in: Use library build framework.
index 59982d3bf53e5d09a3a549d837e11484ab5fb4b4..ad36aedda24a8658f2469cfdedf3ffbbd593f02b 100644 (file)
@@ -327,7 +327,7 @@ kerberos5_send(ap)
                                 &check_data, new_creds, &auth);
 
 #ifdef ENCRYPTION
-       krb5_auth_con_getlocalsubkey(telnet_context, auth_context, &newkey);
+       krb5_auth_con_getsendsubkey(telnet_context, auth_context, &newkey);
        if (session_key) {
                krb5_free_keyblock(telnet_context, session_key);
                session_key = 0;
@@ -552,7 +552,7 @@ kerberos5_is(ap, data, cnt)
                
                if (name)
                    free(name);
-               krb5_auth_con_getremotesubkey(telnet_context, auth_context,
+               krb5_auth_con_getrecvsubkey(telnet_context, auth_context,
                                              &newkey);
                if (session_key) {
                    krb5_free_keyblock(telnet_context, session_key);
index 8ae6cd1785a8449b0f0c6a48de95acd52163d4a8..327e3e3974b0027f727fa89e23de079e2afb91fb 100644 (file)
@@ -1,3 +1,10 @@
+2003-05-09  Tom Yu  <tlyu@mit.edu>
+
+       * krb5.hin: Add krb5_auth_con_getsendsubkey,
+       krb5_auth_con_getrecvsubkey, krb5_auth_con_setsendsubkey,
+       krb5_auth_con_setrecvsubkey.  Mark krb5_auth_con_getlocalsubkey
+       and krb5_auth_con_getremotesubkey as deprecated.
+
 2003-05-06  Sam Hartman  <hartmans@mit.edu>
 
        * k5-int.h: Add s2kparams to 
index d43647dd4c5a4ae9738b539913f7d19490bbfdc8..c1f66cb3ee0360672112c3f8a9aba3cbd7e28c31 100644 (file)
@@ -2148,11 +2148,30 @@ krb5_error_code KRB5_CALLCONV krb5_auth_con_getkey
                krb5_auth_context,
                krb5_keyblock **);
 
+krb5_error_code KRB5_CALLCONV krb5_auth_con_getsendsubkey(
+    krb5_context, krb5_auth_context, krb5_keyblock **);
+
+krb5_error_code KRB5_CALLCONV krb5_auth_con_getrecvsubkey(
+    krb5_context, krb5_auth_context, krb5_keyblock **);
+
+krb5_error_code KRB5_CALLCONV krb5_auth_con_setsendsubkey(
+    krb5_context, krb5_auth_context, krb5_keyblock *);
+
+krb5_error_code KRB5_CALLCONV krb5_auth_con_setrecvsubkey(
+    krb5_context, krb5_auth_context, krb5_keyblock *);
+
+#if KRB5_DEPRECATED
 krb5_error_code KRB5_CALLCONV krb5_auth_con_getlocalsubkey
        (krb5_context,
                krb5_auth_context,
                krb5_keyblock **);
 
+krb5_error_code KRB5_CALLCONV krb5_auth_con_getremotesubkey
+       (krb5_context,
+               krb5_auth_context,
+               krb5_keyblock **);
+#endif
+
 #if KRB5_PRIVATE
 krb5_error_code KRB5_CALLCONV krb5_auth_con_set_req_cksumtype
        (krb5_context,
@@ -2220,11 +2239,6 @@ krb5_error_code KRB5_CALLCONV krb5_auth_con_getauthenticator
                krb5_auth_context,
                krb5_authenticator **);
 
-krb5_error_code KRB5_CALLCONV krb5_auth_con_getremotesubkey
-       (krb5_context,
-               krb5_auth_context,
-               krb5_keyblock **);
-
 #define KRB5_REALM_BRANCH_CHAR '.'
 
 /*
index 132da96afcc10d196e464ab20ebf3a46d6bc176f..bf28f9c93b6bfbcf594a657eeecc2257b419a628 100644 (file)
@@ -1,3 +1,8 @@
+2003-05-09  Tom Yu  <tlyu@mit.edu>
+
+       * kdc_util.c (kdc_process_tgs_req): Rename getremotesubkey ->
+       getrecvsubkey.
+
 2003-05-07  Sam Hartman  <hartmans@mit.edu>
 
        * kdc_preauth.c (get_etype_info): Patch from Sun to reorganize
index 9e9aa3f98295e14db8d3da6d9e87c374ecc27208..753f84a0a947cd91db9fb860525ef7611a77f66d 100644 (file)
@@ -313,8 +313,8 @@ kdc_process_tgs_req(krb5_kdc_req *request, const krb5_fulladdr *from,
        goto cleanup_auth_context;
     }
 
-    if ((retval = krb5_auth_con_getremotesubkey(kdc_context,
-                                               auth_context, subkey)))
+    if ((retval = krb5_auth_con_getrecvsubkey(kdc_context,
+                                             auth_context, subkey)))
        goto cleanup_auth_context;
 
     if ((retval = krb5_auth_con_getauthenticator(kdc_context, auth_context,
index fb87043923071686bc45c315003950d31f41a658..2a1601859fc808e086283386cfd046a27e27214e 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-09  Tom Yu  <tlyu@mit.edu>
+
+       * krb5_32.def: Add krb5_auth_con_getrecvsubkey,
+       krb5_auth_con_getsendsubkey, krb5_auth_con_setrecvsubkey,
+       krb5_auth_con_setsendsubkey.
+
 2003-04-15  Sam Hartman  <hartmans@mit.edu>
 
        * krb5_32.def: Add krb5_set_password and krb5_set_password_using_ccache
index 47f718d16293e5978a4a5d9f67ced4a7a3edd6a1..008821022f19e8aa12f9270b85b8c6934c05c74b 100644 (file)
@@ -1,3 +1,11 @@
+2003-05-09  Tom Yu  <tlyu@mit.edu>
+
+       * accept_sec_context.c (krb5_gss_accept_sec_context): Rename
+       remote_subkey -> recv_subkey.
+
+       * init_sec_context.c (krb5_gss_init_sec_context): Rename
+       local_subkey -> send_subkey.
+
 2003-03-14  Sam Hartman  <hartmans@mit.edu>
 
        * accept_sec_context.c (krb5_gss_accept_sec_context): Set
index a004acb2290e99301a784a2fe603600f533b380b..4cc0651afa6929079aabb219bc31c762d8db5b02 100644 (file)
@@ -101,8 +101,8 @@ rd_and_store_for_creds(context, auth_context, inbuf, out_cred)
         * By the time krb5_rd_cred is called here (after krb5_rd_req has been
         * called in krb5_gss_accept_sec_context), the "keyblock" field of
         * auth_context contains a pointer to the session key, and the
-        * "remote_subkey" field might contain a session subkey.  Either of
-        * these (the "remote_subkey" if it isn't NULL, otherwise the
+        * "recv_subkey" field might contain a session subkey.  Either of
+        * these (the "recv_subkey" if it isn't NULL, otherwise the
         * "keyblock") might have been used to encrypt the encrypted part of
         * the KRB_CRED message that contains the forwarded credentials.  (The
         * Java Crypto and Security Implementation from the DSTC in Australia
@@ -592,8 +592,8 @@ krb5_gss_accept_sec_context(minor_status, context_handle,
        goto fail;
    }
 
-   if ((code = krb5_auth_con_getremotesubkey(context, auth_context,
-                                            &ctx->subkey))) { 
+   if ((code = krb5_auth_con_getrecvsubkey(context, auth_context,
+                                          &ctx->subkey))) { 
        major_status = GSS_S_FAILURE;      
        goto fail;
    }
index ba630f1eb45d83bb1b418775fe2d5902e4661b34..ed363115287ea170b93b1559e723d71cd28161f9 100644 (file)
@@ -572,8 +572,8 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle,
 
          krb5_auth_con_getlocalseqnumber(context, ctx->auth_context,
                                          &ctx->seq_send);
-         krb5_auth_con_getlocalsubkey(context, ctx->auth_context,
-                                      &ctx->subkey);
+         krb5_auth_con_getsendsubkey(context, ctx->auth_context,
+                                     &ctx->subkey);
 
          /* fill in the encryption descriptors */
 
index 0d46e8eca1c8b1926cc3aa9614558c0b1cfe404e..62e652d667c4193daf4502f1080f0c14c8a0610f 100644 (file)
@@ -1,3 +1,38 @@
+2003-05-09  Tom Yu  <tlyu@mit.edu>
+
+       * auth_con.c (krb5_auth_con_setsendsubkey) 
+       (krb5_auth_con_setrecvsubkey, krb5_auth_con_getsendsubkey) 
+       (krb5_auth_con_getrecvsubkey): New functions.  Set or retrieve
+       subkeys from an auth_context.
+       (krb5_auth_con_getlocalsubkey, krb5_auth_con_getremotesubkey):
+       Reimplement in terms of the above.
+
+       * auth_con.h, ser_actx.c: Rename {local,remote}_subkey ->
+       {send,recv}_subkey.
+
+       * chpw.c (krb5int_rd_chpw_rep): Save send_subkey prior to rd_rep;
+       use saved send_subkey to smash recv_subkey obtained from rd_rep.
+
+       * mk_req_ext.c (krb5_mk_req_extended): Rename
+       {local,remote}_subkey -> {send,recv}_subkey.  Set both subkeys if
+       subkey generation is requested.
+
+       * mk_cred.c, mk_priv.c, mk_safe.c: Rename {local,remote}_subkey ->
+       {send,recv}_subkey.  Use either send_subkey or keyblock, in that
+       order.
+
+       * rd_cred.c, rd_priv.c, rd_safe.c: Rename {local,remote}_subkey ->
+       {send,recv}_subkey.  Use either recv_subkey or keyblock, in that
+       order.
+
+       * rd_rep.c (krb5_rd_rep): Rename {local,remote}_subkey ->
+       {send,recv}_subkey.  Set both subkeys if a subkey is present in
+       the AP-REP message.
+
+       * rd_req_dec.c (krb5_rd_req_decoded_opt): Rename
+       {local,remote}_subkey -> {send,recv}_subkey.  Set both subkeys if
+       a subkey is present in the AP-REQ message.
+
 2003-05-06  Sam Hartman  <hartmans@mit.edu>
 
        * kfree.c (krb5_free_etype_info): Free s2kparams
index 09ccf9808efc524bcc50a78db26f89083002d8eb..bc26774a6c054789210bffd6b6b3c7ba5355023b 100644 (file)
@@ -59,10 +59,10 @@ krb5_auth_con_free(krb5_context context, krb5_auth_context auth_context)
        krb5_free_authenticator(context, auth_context->authentp);
     if (auth_context->keyblock) 
        krb5_free_keyblock(context, auth_context->keyblock);
-    if (auth_context->local_subkey) 
-       krb5_free_keyblock(context, auth_context->local_subkey);
-    if (auth_context->remote_subkey) 
-       krb5_free_keyblock(context, auth_context->remote_subkey);
+    if (auth_context->send_subkey) 
+       krb5_free_keyblock(context, auth_context->send_subkey);
+    if (auth_context->recv_subkey) 
+       krb5_free_keyblock(context, auth_context->recv_subkey);
     if (auth_context->rcache)
        krb5_rc_close(context, auth_context->rcache);
     if (auth_context->permitted_etypes)
@@ -176,17 +176,53 @@ krb5_auth_con_getkey(krb5_context context, krb5_auth_context auth_context, krb5_
 krb5_error_code KRB5_CALLCONV
 krb5_auth_con_getlocalsubkey(krb5_context context, krb5_auth_context auth_context, krb5_keyblock **keyblock)
 {
-    if (auth_context->local_subkey)
-       return krb5_copy_keyblock(context,auth_context->local_subkey,keyblock);
+    return krb5_auth_con_getsendsubkey(context, auth_context, keyblock);
+}
+
+krb5_error_code KRB5_CALLCONV
+krb5_auth_con_getremotesubkey(krb5_context context, krb5_auth_context auth_context, krb5_keyblock **keyblock)
+{
+    return krb5_auth_con_getrecvsubkey(context, auth_context, keyblock);
+}
+
+krb5_error_code KRB5_CALLCONV
+krb5_auth_con_setsendsubkey(krb5_context ctx, krb5_auth_context ac, krb5_keyblock *keyblock)
+{
+    if (ac->send_subkey != NULL)
+       krb5_free_keyblock(ctx, ac->send_subkey);
+    ac->send_subkey = NULL;
+    if (keyblock !=NULL)
+       return krb5_copy_keyblock(ctx, keyblock, &ac->send_subkey);
+    else
+       return 0;
+}
+
+krb5_error_code KRB5_CALLCONV
+krb5_auth_con_setrecvsubkey(krb5_context ctx, krb5_auth_context ac, krb5_keyblock *keyblock)
+{
+    if (ac->recv_subkey != NULL)
+       krb5_free_keyblock(ctx, ac->recv_subkey);
+    ac->recv_subkey = NULL;
+    if (keyblock != NULL)
+       return krb5_copy_keyblock(ctx, keyblock, &ac->recv_subkey);
+    else
+       return 0;
+}
+
+krb5_error_code KRB5_CALLCONV
+krb5_auth_con_getsendsubkey(krb5_context ctx, krb5_auth_context ac, krb5_keyblock **keyblock)
+{
+    if (ac->send_subkey != NULL)
+       return krb5_copy_keyblock(ctx, ac->send_subkey, keyblock);
     *keyblock = NULL;
     return 0;
 }
 
 krb5_error_code KRB5_CALLCONV
-krb5_auth_con_getremotesubkey(krb5_context context, krb5_auth_context auth_context, krb5_keyblock **keyblock)
+krb5_auth_con_getrecvsubkey(krb5_context ctx, krb5_auth_context ac, krb5_keyblock **keyblock)
 {
-    if (auth_context->remote_subkey)
-       return krb5_copy_keyblock(context,auth_context->remote_subkey,keyblock);
+    if (ac->recv_subkey != NULL)
+       return krb5_copy_keyblock(ctx, ac->recv_subkey, keyblock);
     *keyblock = NULL;
     return 0;
 }
index d83d6b86e87912b6cc4ff08c10232b6bf258704e..1dcfc89e7b170acbdfd24e929e3bb9bd002cba34 100644 (file)
@@ -9,8 +9,8 @@ struct _krb5_auth_context {
     krb5_address      *        local_addr;
     krb5_address      *        local_port;
     krb5_keyblock     * keyblock;
-    krb5_keyblock     * local_subkey;
-    krb5_keyblock     * remote_subkey;
+    krb5_keyblock     * send_subkey;
+    krb5_keyblock     * recv_subkey;
 
     krb5_int32         auth_context_flags;
     krb5_int32         remote_seq_number;
index 248c4c88c3a287a84a547dd5e0cb1e7f9ee1708b..f640ce66c60d83a76c555379d44e105e7215ea6c 100644 (file)
@@ -120,8 +120,18 @@ krb5int_rd_chpw_rep(krb5_context context, krb5_auth_context auth_context, krb5_d
        ap_rep.data = ptr;
        ptr += ap_rep.length;
 
-       if ((ret = krb5_rd_rep(context, auth_context, &ap_rep, &ap_rep_enc)))
+       /*
+        * Save send_subkey to later smash recv_subkey.
+        */
+       ret = krb5_auth_con_getsendsubkey(context, auth_context, &tmp);
+       if (ret)
+           return ret;
+
+       ret = krb5_rd_rep(context, auth_context, &ap_rep, &ap_rep_enc);
+       if (ret) {
+           krb5_free_keyblock(context, tmp);
            return(ret);
+       }
 
        krb5_free_ap_rep_enc_part(context, ap_rep_enc);
 
@@ -130,18 +140,17 @@ krb5int_rd_chpw_rep(krb5_context context, krb5_auth_context auth_context, krb5_d
        cipherresult.data = ptr;
        cipherresult.length = (packet->data + packet->length) - ptr;
 
-       /* XXX there's no api to do this right. The problem is that
-          if there's a remote subkey, it will be used.  This is
-          not what the spec requires */
-
-       tmp = auth_context->remote_subkey;
-       auth_context->remote_subkey = NULL;
+       /*
+        * Smash recv_subkey to be send_subkey, per spec.
+        */
+       ret = krb5_auth_con_setrecvsubkey(context, auth_context, tmp);
+       krb5_free_keyblock(context, tmp);
+       if (ret)
+           return ret;
 
        ret = krb5_rd_priv(context, auth_context, &cipherresult, &clearresult,
                           &replay);
 
-       auth_context->remote_subkey = tmp;
-
        if (ret)
            return(ret);
     } else {
@@ -310,6 +319,7 @@ krb5int_rd_setpw_rep( krb5_context context, krb5_auth_context auth_context, krb5
     krb5_data cipherresult;
     krb5_data clearresult;
     krb5_replay_data replay;
+    krb5_keyblock *tmpkey;
 /*
 ** validate the packet length -
 */
@@ -381,8 +391,18 @@ krb5int_rd_setpw_rep( krb5_context context, krb5_auth_context auth_context, krb5
            ap_rep.data = ptr;
            ptr += ap_rep.length;
 
-           if (ret = krb5_rd_rep(context, auth_context, &ap_rep, &ap_rep_enc))
+           /*
+            * Save send_subkey to later smash recv_subkey.
+            */
+           ret = krb5_auth_con_getsendsubkey(context, auth_context, &tmpkey);
+           if (ret)
+               return ret;
+
+           ret = krb5_rd_rep(context, auth_context, &ap_rep, &ap_rep_enc);
+           if (ret) {
+               krb5_free_keyblock(context, tmpkey);
                return(ret);
+           }
 
            krb5_free_ap_rep_enc_part(context, ap_rep_enc);
 /*
@@ -391,19 +411,16 @@ krb5int_rd_setpw_rep( krb5_context context, krb5_auth_context auth_context, krb5
            cipherresult.data = ptr;
            cipherresult.length = (packet->data + packet->length) - ptr;
 
-           {
-               krb5_keyblock *saved_remote_subkey;
-/*
-** save the remote_subkey, so it doesn't get used when decoding 
-*/
-               saved_remote_subkey      = auth_context->remote_subkey;
-               auth_context->remote_subkey = NULL;
-
-               ret = krb5_rd_priv(context, auth_context, &cipherresult, &clearresult,
-                                  NULL);
-               auth_context->remote_subkey = saved_remote_subkey;
-           }
+           /*
+            * Smash recv_subkey to be send_subkey, per spec.
+            */
+           ret = krb5_auth_con_setrecvsubkey(context, auth_context, tmpkey);
+           krb5_free_keyblock(context, tmpkey);
+           if (ret)
+               return ret;
 
+           ret = krb5_rd_priv(context, auth_context, &cipherresult, &clearresult,
+                              NULL);
            if (ret)
                return(ret);
        } /*We got an ap_rep*/
index 6389298610f0fa65f44888e5af1fad70d94c551f..04248c08d1ed09167e8cd18b2c8353e32e0f859c 100644 (file)
@@ -182,9 +182,8 @@ krb5_mk_ncred(krb5_context context, krb5_auth_context auth_context, krb5_creds *
     memset(pcred->tickets, 0, sizeof(krb5_ticket *) * (ncred +1));
 
     /* Get keyblock */
-    if ((keyblock = auth_context->local_subkey) == NULL) 
-       if ((keyblock = auth_context->remote_subkey) == NULL) 
-           keyblock = auth_context->keyblock;
+    if ((keyblock = auth_context->send_subkey) == NULL) 
+       keyblock = auth_context->keyblock;
 
     /* Get replay info */
     if ((auth_context->auth_context_flags & KRB5_AUTH_CONTEXT_DO_TIME) &&
index 196b6eea00293c7fe6ac96f4064eb35e56f7fbb0..efe254ac090ac2242be6f396111b2803fb1ae86b 100644 (file)
@@ -119,9 +119,8 @@ krb5_mk_priv(krb5_context context, krb5_auth_context auth_context,
     memset((char *) &replaydata, 0, sizeof(krb5_replay_data));
 
     /* Get keyblock */
-    if ((keyblock = auth_context->local_subkey) == NULL)
-        if ((keyblock = auth_context->remote_subkey) == NULL)
-            keyblock = auth_context->keyblock;
+    if ((keyblock = auth_context->send_subkey) == NULL)
+       keyblock = auth_context->keyblock;
 
     /* Get replay info */
     if ((auth_context->auth_context_flags & KRB5_AUTH_CONTEXT_DO_TIME) &&
index 1ed14a9226079fc56db723ccd02d4c8ef87c627e..91a4f3d1cff6fe6cc2553e9ee9852359a25a9450 100644 (file)
@@ -130,7 +130,7 @@ krb5_mk_req_extended(krb5_context context, krb5_auth_context *auth_context,
            goto cleanup;
     }
 
-    if ((ap_req_options & AP_OPTS_USE_SUBKEY)&&(!(*auth_context)->local_subkey)) {
+    if ((ap_req_options & AP_OPTS_USE_SUBKEY)&&(!(*auth_context)->send_subkey)) {
        /* Provide some more fodder for random number code.
           This isn't strong cryptographically; the point here is not
           to guarantee randomness, but to make it less likely that multiple
@@ -145,8 +145,15 @@ krb5_mk_req_extended(krb5_context context, krb5_auth_context *auth_context,
        (void) krb5_c_random_add_entropy (context, KRB5_C_RANDSOURCE_TIMING, &d);
 
        if ((retval = krb5_generate_subkey(context, &(in_creds)->keyblock, 
-                                          &(*auth_context)->local_subkey)))
+                                          &(*auth_context)->send_subkey)))
            goto cleanup;
+       retval = krb5_copy_keyblock(context, (*auth_context)->send_subkey,
+                                   &((*auth_context)->recv_subkey));
+       if (retval) {
+           krb5_free_keyblock(context, (*auth_context)->send_subkey);
+           (*auth_context)->send_subkey = NULL;
+           goto cleanup;
+       }
     }
 
 
@@ -178,7 +185,7 @@ krb5_mk_req_extended(krb5_context context, krb5_auth_context *auth_context,
     if ((retval = krb5_generate_authenticator(context,
                                              (*auth_context)->authentp,
                                              (in_creds)->client, checksump,
-                                             (*auth_context)->local_subkey,
+                                             (*auth_context)->send_subkey,
                                              (*auth_context)->local_seq_number,
                                              (in_creds)->authdata)))
        goto cleanup_cksum;
index 992a456a903646f389875a85517f73e3330d6de5..eefcab7cd473d2233b3ef0da6af6de511b469980 100644 (file)
@@ -120,9 +120,8 @@ krb5_mk_safe(krb5_context context, krb5_auth_context auth_context, const krb5_da
     memset((char *) &replaydata, 0, sizeof(krb5_replay_data));
 
     /* Get keyblock */
-    if ((keyblock = auth_context->local_subkey) == NULL)
-        if ((keyblock = auth_context->remote_subkey) == NULL)
-            keyblock = auth_context->keyblock;
+    if ((keyblock = auth_context->send_subkey) == NULL)
+       keyblock = auth_context->keyblock;
 
     /* Get replay info */
     if ((auth_context->auth_context_flags & KRB5_AUTH_CONTEXT_DO_TIME) &&
index 228219f765cb9fca628ba7b1e37250086f22cf20..0359d40c3c2e9fa041906f76fa4d46ef45b149e4 100644 (file)
@@ -169,9 +169,8 @@ krb5_rd_cred(krb5_context context, krb5_auth_context auth_context, krb5_data *pc
     krb5_replay_data      replaydata;
 
     /* Get keyblock */
-    if ((keyblock = auth_context->remote_subkey) == NULL)
-       if ((keyblock = auth_context->local_subkey) == NULL)
-            keyblock = auth_context->keyblock;
+    if ((keyblock = auth_context->recv_subkey) == NULL)
+       keyblock = auth_context->keyblock;
 
     if (((auth_context->auth_context_flags & KRB5_AUTH_CONTEXT_RET_TIME) ||
       (auth_context->auth_context_flags & KRB5_AUTH_CONTEXT_RET_SEQUENCE)) &&
index 813205662354f58118a3138b678123d2f892813e..180559cc230f8b4f0fa5703ee30070a9393e17f6 100644 (file)
@@ -156,9 +156,8 @@ krb5_rd_priv(krb5_context context, krb5_auth_context auth_context, const krb5_da
     krb5_replay_data     replaydata;
 
     /* Get keyblock */
-    if ((keyblock = auth_context->remote_subkey) == NULL)
-       if ((keyblock = auth_context->local_subkey) == NULL)
-            keyblock = auth_context->keyblock;
+    if ((keyblock = auth_context->recv_subkey) == NULL)
+       keyblock = auth_context->keyblock;
 
     if (((auth_context->auth_context_flags & KRB5_AUTH_CONTEXT_RET_TIME) ||
       (auth_context->auth_context_flags & KRB5_AUTH_CONTEXT_RET_SEQUENCE)) &&
index e35e43f5d2f838b5cfb4ca5184ea00fcd44c53c3..50ce51331efe5bc9c2fe9cd50ec8bb4cd8618c33 100644 (file)
@@ -82,7 +82,15 @@ krb5_rd_rep(krb5_context context, krb5_auth_context auth_context, const krb5_dat
     /* Set auth subkey */
     if ((*repl)->subkey) {
        retval = krb5_copy_keyblock(context, (*repl)->subkey,
-                                   &auth_context->remote_subkey);
+                                   &auth_context->recv_subkey);
+       if (retval)
+           goto clean_scratch;
+       retval = krb5_copy_keyblock(context, (*repl)->subkey,
+                                   &auth_context->send_subkey);
+       if (retval) {
+           krb5_free_keyblock(context, auth_context->send_subkey);
+           auth_context->send_subkey = NULL;
+       }
     }
 
     /* Get remote sequence number */
index fa126b4abd8509adf63e853b4220f43e41ecd5d2..3c398aed1a947addb1c4d6be0c083c265f0623a8 100644 (file)
@@ -290,10 +290,18 @@ krb5_rd_req_decoded_opt(krb5_context context, krb5_auth_context *auth_context, c
     if ((*auth_context)->authentp->subkey) {
        if ((retval = krb5_copy_keyblock(context,
                                         (*auth_context)->authentp->subkey,
-                                        &((*auth_context)->remote_subkey))))
+                                        &((*auth_context)->recv_subkey))))
            goto cleanup;
+       retval = krb5_copy_keyblock(context, (*auth_context)->authentp->subkey,
+                                   &((*auth_context)->send_subkey));
+       if (retval) {
+           krb5_free_keyblock(context, (*auth_context)->recv_subkey);
+           (*auth_context)->recv_subkey = NULL;
+           goto cleanup;
+       }
     } else {
-       (*auth_context)->remote_subkey = 0;
+       (*auth_context)->recv_subkey = 0;
+       (*auth_context)->send_subkey = 0;
     }
 
     if ((retval = krb5_copy_keyblock(context, req->ticket->enc_part2->session,
index 0f6cec27ff6ae73d4cac07e0de5179534a2d1c90..3194229a39995d519993b3380bdf1f537dadf40b 100644 (file)
@@ -161,9 +161,8 @@ krb5_rd_safe(krb5_context context, krb5_auth_context auth_context, const krb5_da
        return KRB5_RC_REQUIRED;
 
     /* Get keyblock */
-    if ((keyblock = auth_context->remote_subkey) == NULL)
-       if ((keyblock = auth_context->local_subkey) == NULL)
-            keyblock = auth_context->keyblock;
+    if ((keyblock = auth_context->recv_subkey) == NULL)
+       keyblock = auth_context->keyblock;
 
 {
     krb5_address * premote_fulladdr = NULL;
index a8ec90ee6fcd808e2a91338d87149a33b164e864..32519e19f00ea8119157f682a860b2f9ab9ebbc3 100644 (file)
@@ -151,21 +151,21 @@ krb5_auth_context_size(krb5_context kcontext, krb5_pointer arg, size_t *sizep)
                required += sizeof(krb5_int32);
        }
 
-       /* Calculate size required by local_subkey, if appropriate */
-       if (!kret && auth_context->local_subkey) {
+       /* Calculate size required by send_subkey, if appropriate */
+       if (!kret && auth_context->send_subkey) {
            kret = krb5_size_opaque(kcontext,
                                    KV5M_KEYBLOCK,
-                                   (krb5_pointer) auth_context->local_subkey,
+                                   (krb5_pointer) auth_context->send_subkey,
                                    &required);
            if (!kret)
                required += sizeof(krb5_int32);
        }
 
-       /* Calculate size required by remote_subkey, if appropriate */
-       if (!kret && auth_context->remote_subkey) {
+       /* Calculate size required by recv_subkey, if appropriate */
+       if (!kret && auth_context->recv_subkey) {
            kret = krb5_size_opaque(kcontext,
                                    KV5M_KEYBLOCK,
-                                   (krb5_pointer) auth_context->remote_subkey,
+                                   (krb5_pointer) auth_context->recv_subkey,
                                    &required);
            if (!kret)
                required += sizeof(krb5_int32);
@@ -300,23 +300,23 @@ krb5_auth_context_externalize(krb5_context kcontext, krb5_pointer arg, krb5_octe
            }
 
            /* Now handle subkey, if appropriate */
-           if (!kret && auth_context->local_subkey) {
+           if (!kret && auth_context->send_subkey) {
                (void) krb5_ser_pack_int32(TOKEN_LSKBLOCK, &bp, &remain);
                kret = krb5_externalize_opaque(kcontext,
                                               KV5M_KEYBLOCK,
                                               (krb5_pointer)
-                                              auth_context->local_subkey,
+                                              auth_context->send_subkey,
                                               &bp,
                                               &remain);
            }
 
            /* Now handle subkey, if appropriate */
-           if (!kret && auth_context->remote_subkey) {
+           if (!kret && auth_context->recv_subkey) {
                (void) krb5_ser_pack_int32(TOKEN_RSKBLOCK, &bp, &remain);
                kret = krb5_externalize_opaque(kcontext,
                                               KV5M_KEYBLOCK,
                                               (krb5_pointer)
-                                              auth_context->remote_subkey,
+                                              auth_context->recv_subkey,
                                               &bp,
                                               &remain);
            }
@@ -474,26 +474,26 @@ krb5_auth_context_internalize(krb5_context kcontext, krb5_pointer *argp, krb5_oc
                    kret = krb5_ser_unpack_int32(&tag, &bp, &remain);
            }
 
-           /* This is the local_subkey */
+           /* This is the send_subkey */
            if (!kret && (tag == TOKEN_LSKBLOCK)) {
                if (!(kret = krb5_internalize_opaque(kcontext,
                                                     KV5M_KEYBLOCK,
                                                     (krb5_pointer *)
                                                     &auth_context->
-                                                    local_subkey,
+                                                    send_subkey,
                                                     &bp,
                                                     &remain)))
                    kret = krb5_ser_unpack_int32(&tag, &bp, &remain);
            }
 
-           /* This is the remote_subkey */
+           /* This is the recv_subkey */
            if (!kret) {
                if (tag == TOKEN_RSKBLOCK) {
                    kret = krb5_internalize_opaque(kcontext,
                                                   KV5M_KEYBLOCK,
                                                   (krb5_pointer *)
                                                   &auth_context->
-                                                  remote_subkey,
+                                                  recv_subkey,
                                                   &bp,
                                                   &remain);
                }
index 0d4d5f24d18bbb874bdeca3397e7b0cfcafdd75f..257dd287e0ff28222c0f94b938efc7f994b53528 100644 (file)
@@ -36,8 +36,10 @@ EXPORTS
        krb5_auth_con_getlocalseqnumber
        krb5_auth_con_getlocalsubkey
        krb5_auth_con_getrcache                 ; KRB5_CALLCONV_WRONG
+       krb5_auth_con_getrecvsubkey
        krb5_auth_con_getremoteseqnumber
        krb5_auth_con_getremotesubkey
+       krb5_auth_con_getsendsubkey
        krb5_auth_con_init
        krb5_auth_con_initivector               ; DEPRECATED
        krb5_auth_con_setaddrs                  ; KRB5_CALLCONV_WRONG
@@ -45,6 +47,8 @@ EXPORTS
        krb5_auth_con_setflags
        krb5_auth_con_setports
        krb5_auth_con_setrcache
+       krb5_auth_con_setrecvsubkey
+       krb5_auth_con_setsendsubkey
        krb5_auth_con_setuseruserkey
        krb5_build_principal
        krb5_build_principal_ext
index 915cd1f7fd58ebdbac62c6451019c6d2cfc8a3e8..70dd599d2c12e8608a095f259211e4bc1fe93c90 100644 (file)
        _krb5_auth_con_getremotesubkey
        _krb5_auth_con_getlocalseqnumber
        _krb5_auth_con_getremoteseqnumber
+       _krb5_auth_con_getrecvsubkey
+       _krb5_auth_con_getsendsubkey
+       _krb5_auth_con_setrecvsubkey
+       _krb5_auth_con_setsendsubkey
        _krb5_auth_con_setrcache
        _krb5_auth_con_getrcache
        _krb5_auth_con_getauthenticator