]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
crypto/gc: Simplify the previous change.
authorCollin Funk <collin.funk1@gmail.com>
Mon, 26 May 2025 19:56:22 +0000 (12:56 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Mon, 26 May 2025 19:56:22 +0000 (12:56 -0700)
Suggested by Bruno Haible in:
<https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00249.html>.

* lib/gc-gnulib.c (gc_cipher_setkey, gc_cipher_setiv): Remove cast and
perform a bitwise AND with an unsigned constant.

ChangeLog
lib/gc-gnulib.c

index a6728386acedc166c06134d60abbf2c334bbd78b..9351692a281349c39d11e74f0fa335d36760aeec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2025-05-26  Collin Funk  <collin.funk1@gmail.com>
 
+       crypto/gc: Simplify the previous change.
+       Suggested by Bruno Haible in:
+       <https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00249.html>.
+       * lib/gc-gnulib.c (gc_cipher_setkey, gc_cipher_setiv): Remove cast and
+       perform a bitwise AND with an unsigned constant.
+
        crypto/gc: Pacify -Wformat warnings.
        * lib/gc-gnulib.c (gc_cipher_setkey, gc_cipher_setiv): Cast the argument
        since "%02x" expects the argument to be unsigned.
index 85b7a62b741218b0450d1958f513798ad117b71e..9b53feb88675ba48cd42e7d122d5c5b0ad09905c 100644 (file)
@@ -290,8 +290,7 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
         char keyMaterial[RIJNDAEL_MAX_KEY_SIZE + 1];
 
         for (i = 0; i < keylen; i++)
-          sprintf (&keyMaterial[2 * i], "%02x",
-                   (unsigned int) (key[i] & 0xFF));
+          sprintf (&keyMaterial[2 * i], "%02x", key[i] & 0xFFU);
 
         rc = rijndaelMakeKey (&ctx->aesEncKey, RIJNDAEL_DIR_ENCRYPT,
                               keylen * 8, keyMaterial);
@@ -349,8 +348,7 @@ gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
             char ivMaterial[2 * RIJNDAEL_MAX_IV_SIZE + 1];
 
             for (i = 0; i < ivlen; i++)
-              sprintf (&ivMaterial[2 * i], "%02x",
-                       (unsigned int) (iv[i] & 0xFF));
+              sprintf (&ivMaterial[2 * i], "%02x", iv[i] & 0xFFU);
 
             rc = rijndaelCipherInit (&ctx->aesContext, RIJNDAEL_MODE_CBC,
                                      ivMaterial);