You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2012/07/20 17:17:25 UTC

svn commit: r1363831 - in /subversion/branches/master-passphrase/subversion: libsvn_subr/auth_store.h libsvn_subr/pathetic_auth_store.c tests/libsvn_subr/crypto-test.c

Author: cmpilato
Date: Fri Jul 20 15:17:25 2012
New Revision: 1363831

URL: http://svn.apache.org/viewvc?rev=1363831&view=rev
Log:
On the 'master-passphrase' branch: Tweak the pathetic auth store
factory function to accept a callback for fetching secrets rather than
requiring the secret up front.  In subsequent commit, we'll delay the
fetch of the secret until it is first needed.

* subversion/libsvn_subr/auth_store.h
  (svn_auth__master_passphrase_fetch_t): New callback type.
  (svn_auth__pathetic_store_get): Now accept 'secret_func' and
    'secret_baton' instead of 'secret'.

* subversion/libsvn_subr/pathetic_auth_store.c
  (svn_auth__pathetic_store_get): Now accept 'secret_func' and
    'secret_baton' instead of 'secret'.

* subversion/tests/libsvn_subr/crypto-test.c
  (fetch_secret): Super-simple callback implementation for fetching secrets.
  (create_ephemeral_auth_store, test_auth_store_basic): Update calls
    to svn_auth__pathetic_store_get(), using fetch_secret as the secret-
    fetching callback function.

Modified:
    subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h
    subversion/branches/master-passphrase/subversion/libsvn_subr/pathetic_auth_store.c
    subversion/branches/master-passphrase/subversion/tests/libsvn_subr/crypto-test.c

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h?rev=1363831&r1=1363830&r2=1363831&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/auth_store.h Fri Jul 20 15:17:25 2012
@@ -198,18 +198,29 @@ svn_auth__store_iterate_creds(svn_auth__
 
 
 
+/*** Pathetic Encrypted Authentication Store ***/
+
+/* Callback type used to fetch a master passphrase for unlocking an
+   encrypted auth store. */
+typedef svn_error_t *(*svn_auth__master_passphrase_fetch_t)(
+  const svn_string_t **secret,
+  void *baton, 
+  apr_pool_t *result_pool,
+  apr_pool_t *scratch_pool);
+
 /* Set *AUTH_STORE_P to an object which describes the encrypted
    authentication credential store located at AUTH_STORE_PATH.
 
    CRYPTO_CTX is the cryptographic context which the store will use
    for related functionality.
 
-   SECRET is the master passphrase used to encrypt the sensitive
-   contents of the store.  When creating the store it is registered
-   with the store as-is, but when opening a previously existing store,
-   it is validated against the passphrase self-checking information in
-   the store itself.  SVN_ERR_AUTHN_FAILED will be returned if SECRET
-   does not validate against an existing store's checktext.
+   Use SECRET_FUNC/SECRET_BATON to acquire the master passphrase used
+   to encrypt the sensitive contents of the store.  When creating the
+   store it is registered with the store as-is, but when opening a
+   previously existing store, it is validated against the passphrase
+   self-checking information in the store itself.  Return
+   SVN_ERR_AUTHN_FAILED if the secret provided by SECRET_FUNC does not
+   validate against an existing store's checktext.
 
    ### TODO:  This is expected to be experimental code! ###
 */
@@ -217,10 +228,15 @@ svn_error_t *
 svn_auth__pathetic_store_get(svn_auth__store_t **auth_store_p,
                              const char *auth_store_path,
                              svn_crypto__ctx_t *crypto_ctx,
-                             const svn_string_t *secret,
+                             svn_auth__master_passphrase_fetch_t secret_func,
+                             void *secret_baton,
                              apr_pool_t *result_pool,
                              apr_pool_t *scratch_pool);
 
+
+
+/*** Runtime-config-based Authentication Store (aka, "the old way") ***/
+
 /* Set *AUTH_STORE_P to an object which describes the
    runtime-config-based authentication credential store located at
    AUTH_STORE_PATH.  CFG is the configuration object with which the

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/pathetic_auth_store.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/pathetic_auth_store.c?rev=1363831&r1=1363830&r2=1363831&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/pathetic_auth_store.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/pathetic_auth_store.c Fri Jul 20 15:17:25 2012
@@ -463,17 +463,23 @@ svn_error_t *
 svn_auth__pathetic_store_get(svn_auth__store_t **auth_store_p,
                              const char *auth_store_path,
                              svn_crypto__ctx_t *crypto_ctx,
-                             const svn_string_t *secret,
+                             svn_auth__master_passphrase_fetch_t secret_func,
+                             void *secret_baton,
                              apr_pool_t *result_pool,
                              apr_pool_t *scratch_pool)
 {
+  const svn_string_t *secret;
   svn_auth__store_t *auth_store;
   pathetic_auth_store_baton_t *pathetic_store;
 
+  SVN_ERR_ASSERT(secret_func);
+
   if (! svn_crypto__is_available())
     return svn_error_create(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
                             _("Encrypted auth store feature not available"));
 
+  SVN_ERR(secret_func(&secret, secret_baton, result_pool, scratch_pool));
+    
   pathetic_store = apr_pcalloc(result_pool, sizeof(*pathetic_store));
   pathetic_store->pool = result_pool;
   pathetic_store->path = apr_pstrdup(result_pool, auth_store_path);

Modified: subversion/branches/master-passphrase/subversion/tests/libsvn_subr/crypto-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/tests/libsvn_subr/crypto-test.c?rev=1363831&r1=1363830&r2=1363831&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/tests/libsvn_subr/crypto-test.c (original)
+++ subversion/branches/master-passphrase/subversion/tests/libsvn_subr/crypto-test.c Fri Jul 20 15:17:25 2012
@@ -78,6 +78,18 @@ encrypt_decrypt(svn_crypto__ctx_t *ctx,
 }
 
 
+/* Implements `svn_auth__master_passphrase_fetch_t' */
+static svn_error_t *
+fetch_secret(const svn_string_t **secret,
+             void *baton,
+             apr_pool_t *result_pool,
+             apr_pool_t *scratch_pool)
+{
+  *secret = svn_string_dup(baton, result_pool);
+  return SVN_NO_ERROR;
+}
+
+
 /* Create and open an auth store within CONFIG_DIR, deleting any
    previous auth store at that location, and using CRYPTO_CTX and the
    master passphrase SECRET.  Set *AUTH_STORE_P to the resulting store
@@ -95,7 +107,8 @@ create_ephemeral_auth_store(svn_auth__st
                                      pool, pool));
   SVN_ERR(svn_io_remove_file2(*auth_store_path, TRUE, pool));
   SVN_ERR(svn_auth__pathetic_store_get(auth_store_p, *auth_store_path,
-                                       crypto_ctx, secret, pool, pool));
+                                       crypto_ctx, fetch_secret, 
+                                       (void *)secret, pool, pool));
   SVN_ERR(svn_auth__store_open(*auth_store_p, TRUE, pool));
   return SVN_NO_ERROR;
 }
@@ -219,13 +232,15 @@ test_auth_store_basic(apr_pool_t *pool)
   /* Close and reopen the auth store. */
   SVN_ERR(svn_auth__store_close(auth_store, pool));
   SVN_ERR(svn_auth__pathetic_store_get(&auth_store, auth_store_path, ctx,
-                                       secret, pool, pool));
+                                       fetch_secret, (void *)secret,
+                                       pool, pool));
   SVN_ERR(svn_auth__store_open(auth_store, FALSE, pool));
 
   /* Close and reopen the auth store with a bogus secret. */
   SVN_ERR(svn_auth__store_close(auth_store, pool));
   SVN_ERR(svn_auth__pathetic_store_get(&auth_store, auth_store_path, ctx,
-                                       bad_secret, pool, pool));
+                                       fetch_secret, (void *)bad_secret,
+                                       pool, pool));
   err = svn_auth__store_open(auth_store, FALSE, pool);
   if (! err)
     return svn_error_create(SVN_ERR_TEST_FAILED, NULL,