apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Reid" <da...@jetnet.co.uk>
Subject [PATCH] apr_md5 changes
Date Tue, 15 Jun 2004 15:13:17 GMT
As discussed...

This changes the api to return void for most of the md5 operations (which
seems better for code that doesn't fail).

david

Index: include/apr_md5.h
===================================================================
RCS file: /home/cvs/apr-util/include/apr_md5.h,v
retrieving revision 1.10
diff -u -r1.10 apr_md5.h
--- include/apr_md5.h 28 May 2004 00:48:54 -0000 1.10
+++ include/apr_md5.h 15 Jun 2004 15:08:34 -0000
@@ -87,7 +87,7 @@
  * MD5 Initialize.  Begins an MD5 operation, writing a new context.
  * @param context The MD5 context to initialize.
  */
-APU_DECLARE(apr_status_t) apr_md5_init(apr_md5_ctx_t *context);
+APU_DECLARE(void) apr_md5_init(apr_md5_ctx_t *context);

 /**
  * MD5 translation setup.  Provides the APR translation handle to be used
@@ -105,9 +105,9 @@
  * @param input next message block to update
  * @param inputLen The length of the next message block
  */
-APU_DECLARE(apr_status_t) apr_md5_update(apr_md5_ctx_t *context,
-                                         const void *input,
-                                         apr_size_t inputLen);
+APU_DECLARE(void) apr_md5_update(apr_md5_ctx_t *context,
+                                 const void *input,
+                                 apr_size_t inputLen);

 /**
  * MD5 finalization.  Ends an MD5 message-digest operation, writing the
@@ -115,8 +115,8 @@
  * @param digest The final MD5 digest
  * @param context The MD5 content we are finalizing.
  */
-APU_DECLARE(apr_status_t) apr_md5_final(unsigned char
digest[APR_MD5_DIGESTSIZE],
-                                        apr_md5_ctx_t *context);
+APU_DECLARE(void) apr_md5_final(unsigned char digest[APR_MD5_DIGESTSIZE],
+                                apr_md5_ctx_t *context);

 /**
  * MD5 in one step
@@ -124,9 +124,9 @@
  * @param input The message block to use
  * @param inputLen The length of the message block
  */
-APU_DECLARE(apr_status_t) apr_md5(unsigned char digest[APR_MD5_DIGESTSIZE],
-                                  const void *input,
-                                  apr_size_t inputLen);
+APU_DECLARE(void) apr_md5(unsigned char digest[APR_MD5_DIGESTSIZE],
+                          const void *input,
+                          apr_size_t inputLen);

 /**
  * Encode a password using an MD5 algorithm
@@ -135,8 +135,8 @@
  * @param result The string to store the encoded password in
  * @param nbytes The length of the string
  */
-APU_DECLARE(apr_status_t) apr_md5_encode(const char *password, const char
*salt,
-                                         char *result, apr_size_t nbytes);
+APU_DECLARE(void) apr_md5_encode(const char *password, const char *salt,
+                                 char *result, apr_size_t nbytes);


 /**
Index: crypto/apr_md5.c
===================================================================
RCS file: /home/cvs/apr-util/crypto/apr_md5.c,v
retrieving revision 1.11
diff -u -r1.11 apr_md5.c
--- crypto/apr_md5.c 28 May 2004 00:22:02 -0000 1.11
+++ crypto/apr_md5.c 15 Jun 2004 15:08:35 -0000
@@ -149,7 +149,7 @@

 /* MD5 initialization. Begins an MD5 operation, writing a new context.
  */
-APU_DECLARE(apr_status_t) apr_md5_init(apr_md5_ctx_t *context)
+APU_DECLARE(void) apr_md5_init(apr_md5_ctx_t *context)
 {
     context->count[0] = context->count[1] = 0;

@@ -159,8 +159,6 @@
     context->state[2] = 0x98badcfe;
     context->state[3] = 0x10325476;
     context->xlate = NULL;
-
-    return APR_SUCCESS;
 }

 /* MD5 translation setup.  Provides the APR translation handle
@@ -194,8 +192,8 @@
  * operation, processing another message block, and updating the
  * context.
  */
-APU_DECLARE(apr_status_t) apr_md5_update(apr_md5_ctx_t *context,
-                                         const void *_input,
+APU_DECLARE(void) apr_md5_update(apr_md5_ctx_t *context,
+                                 const void *_input,
                                          apr_size_t inputLen)
 {
     const unsigned char *input = _input;
@@ -275,14 +273,13 @@
         memcpy(&context->buffer[idx], &input[i], inputLen - i);
     }
 #endif /*APR_HAS_XLATE*/
-    return APR_SUCCESS;
 }

 /* MD5 finalization. Ends an MD5 message-digest operation, writing the
  * the message digest and zeroizing the context.
  */
-APU_DECLARE(apr_status_t) apr_md5_final(unsigned char
digest[APR_MD5_DIGESTSIZE],
-                                        apr_md5_ctx_t *context)
+APU_DECLARE(void) apr_md5_final(unsigned char digest[APR_MD5_DIGESTSIZE],
+                                apr_md5_ctx_t *context)
 {
     unsigned char bits[8];
     unsigned int idx, padLen;
@@ -308,15 +305,13 @@

     /* Zeroize sensitive information. */
     memset(context, 0, sizeof(*context));
-
-    return APR_SUCCESS;
 }

 /* MD5 in one step (init, update, final)
  */
-APU_DECLARE(apr_status_t) apr_md5(unsigned char digest[APR_MD5_DIGESTSIZE],
-                                  const void *_input,
-                                  apr_size_t inputLen)
+APU_DECLARE(void) apr_md5(unsigned char digest[APR_MD5_DIGESTSIZE],
+                          const void *_input,
+                          apr_size_t inputLen)
 {
     const unsigned char *input = _input;
     apr_md5_ctx_t ctx;
@@ -324,10 +319,9 @@

     apr_md5_init(&ctx);

-    if ((rv = apr_md5_update(&ctx, input, inputLen)) != APR_SUCCESS)
-        return rv;
+    apr_md5_update(&ctx, input, inputLen);

-    return apr_md5_final(digest, &ctx);
+    apr_md5_final(digest, &ctx);
 }

 /* MD5 basic transformation. Transforms state based on block. */
@@ -483,8 +477,8 @@
     }
 }

-APU_DECLARE(apr_status_t) apr_md5_encode(const char *pw, const char *salt,
-                             char *result, apr_size_t nbytes)
+APU_DECLARE(void) apr_md5_encode(const char *pw, const char *salt,
+                                 char *result, apr_size_t nbytes)
 {
     /*
      * Minimum size is 8 bytes for salt, plus 1 for the trailing NUL,
@@ -634,7 +628,6 @@
     memset(final, 0, sizeof(final));

     apr_cpystrn(result, passwd, nbytes - 1);
-    return APR_SUCCESS;
 }

 #if !defined(WIN32) && !defined(BEOS) && !defined(NETWARE)


Mime
View raw message