Author: rinrab
Date: Sun Jan 4 13:08:15 2026
New Revision: 1931095
Log:
bcrypt: Use Win32 API directly when computing checksum without a context
instead of creating a context on stack. It's more convenient and it feels
wrong to use our "public" API with additional custom manipulations here.
* subversion/libsvn_subr/checksum_bcrypt.c
(bcrypt_checksum): Replace bcrypt_ctx_t with a plain BCRYPT_HANDLE, use
BCryptHashData() and BCryptFinishHash() instead of bcrypt_ctx_update() and
bcrypt_ctx_final().
Modified:
subversion/trunk/subversion/libsvn_subr/checksum_bcrypt.c
Modified: subversion/trunk/subversion/libsvn_subr/checksum_bcrypt.c
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/checksum_bcrypt.c Sun Jan 4
12:48:14 2026 (r1931094)
+++ subversion/trunk/subversion/libsvn_subr/checksum_bcrypt.c Sun Jan 4
13:08:15 2026 (r1931095)
@@ -165,9 +165,11 @@ bcrypt_checksum(algorithm_state_t *algor
const void *data,
apr_size_t len)
{
- bcrypt_ctx_t bcrypt_ctx = { 0 };
+ BCRYPT_HANDLE handle;
void *object_buf;
+ SVN_ERR_ASSERT(len <= ULONG_MAX);
+
SVN_ERR(svn_atomic__init_once(&algorithm->initialized, algorithm_init,
algorithm, NULL));
@@ -175,17 +177,21 @@ bcrypt_checksum(algorithm_state_t *algor
object_buf = alloca(algorithm->object_length);
SVN_ERR(handle_error(BCryptCreateHash(algorithm->alg_handle,
- &bcrypt_ctx.handle,
+ &handle,
object_buf, algorithm->object_length,
/* pbSecret */ NULL,
/* cbSecret */ 0,
/* dwFlags */ 0)));
- SVN_ERR(bcrypt_ctx_update(algorithm, &bcrypt_ctx,
- data, len));
-
- SVN_ERR(bcrypt_ctx_final(algorithm, &bcrypt_ctx,
- digest));
+ SVN_ERR(handle_error(BCryptHashData(handle,
+ (PUCHAR) data,
+ (ULONG) len,
+ /* dwFlags */ 0)));
+
+ SVN_ERR(handle_error(BCryptFinishHash(handle,
+ (PUCHAR) digest,
+ algorithm->hash_length,
+ /* dwFlags */ 0)));
return SVN_NO_ERROR;
}