]> www.infradead.org Git - users/dhowells/kafs-utils.git/commitdiff
Add OpenAFS rxgk support to gssapi test and partially to gssapi aklog
authorDavid Howells <dhowells@redhat.com>
Wed, 30 Sep 2020 08:22:46 +0000 (09:22 +0100)
committerDavid Howells <dhowells@redhat.com>
Fri, 5 May 2023 10:53:26 +0000 (11:53 +0100)
For example:

# kafs gssapi test -server localhost -kvno 2 -enctype 26 -tenctype 25 -openafs
Success! 01020304 05060708 09101112 13141516
# kafs gssapi test -server localhost -kvno 2 -enctype 26 -tenctype 25 -yfs
Success! 01020304 05060708 09101112 13141516

kafs/gssapi_aklog.C
kafs/gssapi_test.C

index 5a43cdf915c380f47cb1a896b450d8076d2c3d16..8f64d5ab8e97c25f2538e14d985e886171b43cf2 100644 (file)
@@ -274,6 +274,20 @@ static void rxgk_add_key(kafs::Context *ctx,
                token.ygk.ticket        = client_info.token;
                token.ygk.ticket.del_buffer = false;
                break;
+
+       case kafs::afs::AFSTOKEN_UNION_GK:
+               token.gk.gk_viceid      = 0;
+               token.gk.gk_enctype     = client_info.enctype;
+               token.gk.gk_level       = client_info.level;
+               token.gk.gk_lifetime    = client_info.lifetime;
+               token.gk.gk_bytelife    = client_info.bytelife;
+               token.gk.gk_expiration  = client_info.expiration;
+               token.gk.gk_token       = client_info.token;
+               token.gk.gk_token.del_buffer = false;
+               token.gk.gk_k0          = K0;
+               token.gk.gk_k0.del_buffer = false;
+               break;
+
        default:
                throw std::runtime_error("Unknown security type");
        }
@@ -324,7 +338,10 @@ static void rxgk_add_key(kafs::Context *ctx,
  * ARG: "[-noauth]"                            - Auth
  * ARG: "[-localauth]"                         - Auth
  * ARG: "[-verbose]"
+ * ARG: "[-openafs]"
+ * ARG: "[-yfs]"
  * ARG: "[-encrypt]"                           - Auth
+ * NOCOMBINE: openafs, yfs
  *
  * Authenticate via GSSAPI to get tokens for the RxGK security class.
  */
@@ -333,7 +350,9 @@ void COMMAND_gssapi_aklog(
        std::string                     &a_principal,
        std::vector<std::string>        &a_enctypes,
        std::vector<std::string>        &a_levels,
-       bool                            a_verbose)
+       bool                            a_verbose,
+       bool                            a_openafs,
+       bool                            a_yfs)
 {
        gss_buffer_desc token_for_gssapi = GSS_C_EMPTY_BUFFER;
        gss_buffer_desc token_for_rxgk = GSS_C_EMPTY_BUFFER;
@@ -343,6 +362,12 @@ void COMMAND_gssapi_aklog(
        gss_OID actual_mech = GSS_C_NO_OID;
        OM_uint32 major, minor, req_flags, ret_flags;
        bool anon = false;
+       unsigned int sec_type = kafs::afs::AFSTOKEN_UNION_YFSGK;
+
+       if (a_yfs)
+               sec_type = kafs::afs::AFSTOKEN_UNION_YFSGK;
+       else if (a_openafs)
+               sec_type = kafs::afs::AFSTOKEN_UNION_GK;
 
        ref<kafs::VL_service> vlservice = new kafs::VL_service(ctx);
        rxrpc::Opaque opaque_cache, rxgk_info, K0;
@@ -482,8 +507,7 @@ void COMMAND_gssapi_aklog(
                rxgk_check_mic(gssctx, rxgk_params, client_info, a_verbose);
                rxgk_derive_K0(gssctx, rxgk_params, client_info, K0, a_verbose);
 
-               rxgk_add_key(ctx, client_info, K0, a_verbose,
-                            kafs::afs::AFSTOKEN_UNION_YFSGK);
+               rxgk_add_key(ctx, client_info, K0, a_verbose, sec_type);
 
                verbose_gss("Negotiation successful\n");
        } catch (...) {
index 76f1ed2e8ec39181c6e3bfb51c0c90831e685c83..0a7cd05bca3e6c03dd579565f4e0ec1e11bf2508 100644 (file)
@@ -200,6 +200,20 @@ static void rxgk_add_key(kafs::Context *ctx,
                token.ygk.ticket        = client_info.token;
                token.ygk.ticket.del_buffer = false;
                break;
+
+       case kafs::afs::AFSTOKEN_UNION_GK:
+               token.gk.gk_viceid      = 0;
+               token.gk.gk_enctype     = client_info.enctype;
+               token.gk.gk_level       = client_info.level;
+               token.gk.gk_lifetime    = client_info.lifetime;
+               token.gk.gk_bytelife    = client_info.bytelife;
+               token.gk.gk_expiration  = client_info.expiration;
+               token.gk.gk_token       = client_info.token;
+               token.gk.gk_token.del_buffer = false;
+               token.gk.gk_k0          = K0;
+               token.gk.gk_k0.del_buffer = false;
+               break;
+
        default:
                throw std::runtime_error("Unknown security type");
        }
@@ -250,7 +264,10 @@ static void rxgk_add_key(kafs::Context *ctx,
  * ARG: "[-tenctype <enc>]"
  * ARG: "[-kvno <kvno>]"
  * ARG: "[-verbose]"
+ * ARG: "[-openafs]"
+ * ARG: "[-yfs]"
  * ARG: "[-encrypt]"                           - Auth
+ * NOCOMBINE: openafs, yfs
  *
  * Forge a ticket and poke the server by RxGK.
  */
@@ -261,15 +278,23 @@ void COMMAND_gssapi_test(
        std::string                     &a_level,
        std::string                     &a_tenctype,
        std::string                     &a_kvno,
-       bool                            a_verbose)
+       bool                            a_verbose,
+       bool                            a_openafs,
+       bool                            a_yfs)
 {
        rxrpc::security_auth_level rxlevel = rxrpc::security_encrypt;
        RXGK_ClientInfo client_info;
        rxrpc::Opaque ticket_key, K0;
+       unsigned int sec_type = kafs::afs::AFSTOKEN_UNION_YFSGK;
        unsigned int kvno = 1;
        int tenctype = ENCTYPE_AES128_CTS_HMAC_SHA1_96;
        int tklen, k0len, i;
 
+       if (a_yfs)
+               sec_type = kafs::afs::AFSTOKEN_UNION_YFSGK;
+       else if (a_openafs)
+               sec_type = kafs::afs::AFSTOKEN_UNION_GK;
+
        client_info.expiration  = 0;
        client_info.level       = kafs::afs::RXGK_LEVEL_CRYPT;
        client_info.lifetime    = 0;
@@ -335,7 +360,7 @@ void COMMAND_gssapi_test(
                kvno = stoi(a_kvno);
 
        forge_rxgk_ticket(ctx, client_info, ticket_key, K0, tenctype, kvno, client_info.token);
-       rxgk_add_key(ctx, client_info, K0, a_verbose, kafs::afs::AFSTOKEN_UNION_YFSGK);
+       rxgk_add_key(ctx, client_info, K0, a_verbose, sec_type);
 
        rxrpc::find_transport();
 
@@ -345,7 +370,7 @@ void COMMAND_gssapi_test(
 
        rxrpc::Call_params params;
        params.endpoint = ctx->endpoint;
-       
+
        ref<kafs::FS_site> site = kafs::resolve_server_spec(ctx, a_server);
        params.peer = site->vs_addrs[0];
        params.peer.srx_service = RX_PERF_SERVICE;