Bug 1639033 - Change +sftk_xcbc_mac_pad's block-size argument to be unsigned int to avoid sign-comparison warnings. r=kjacobs
authorJeff Walden <jwalden@mit.edu>
Thu, 21 May 2020 19:57:07 +0000
changeset 15626 a5f80d0805caeda11968611221ffd48f62334680
parent 15625 e65dd5c2cf86c36d414fa99986e49e9b1bd97aa0
child 15627 563a7cd7484bde21b387dda2b0b7e4e5a049f7cf
push id3751
push userkjacobs@mozilla.com
push dateFri, 22 May 2020 20:56:57 +0000
reviewerskjacobs
bugs1639033
Bug 1639033 - Change +sftk_xcbc_mac_pad's block-size argument to be unsigned int to avoid sign-comparison warnings. r=kjacobs Depends on D75842 Differential Revision: https://phabricator.services.mozilla.com/D75843
lib/softoken/pkcs11i.h
lib/softoken/sftkike.c
--- a/lib/softoken/pkcs11i.h
+++ b/lib/softoken/pkcs11i.h
@@ -823,17 +823,17 @@ extern CK_RV sftk_ike1_appendix_b_prf(CK
 extern CK_RV sftk_ike_prf_plus(CK_SESSION_HANDLE hSession,
                                const SFTKAttribute *inKey,
                                const CK_NSS_IKE_PRF_PLUS_DERIVE_PARAMS *params, SFTKObject *outKey,
                                unsigned int keySize);
 extern CK_RV sftk_aes_xcbc_new_keys(CK_SESSION_HANDLE hSession,
                                     CK_OBJECT_HANDLE hKey, CK_OBJECT_HANDLE_PTR phKey,
                                     unsigned char *k2, unsigned char *k3);
 extern CK_RV sftk_xcbc_mac_pad(unsigned char *padBuf, unsigned int bufLen,
-                               int blockSize, const unsigned char *k2,
+                               unsigned int blockSize, const unsigned char *k2,
                                const unsigned char *k3);
 extern SECStatus sftk_fips_IKE_PowerUpSelfTests(void);
 
 /* mechanism allows this operation */
 extern CK_RV sftk_MechAllowsOperation(CK_MECHANISM_TYPE type, CK_ATTRIBUTE_TYPE op);
 
 /* helper function which calls nsslowkey_FindKeyByPublicKey after safely
  * acquiring a reference to the keydb from the slot */
--- a/lib/softoken/sftkike.c
+++ b/lib/softoken/sftkike.c
@@ -184,20 +184,21 @@ fail:
     PORT_Memset(k2, 0, AES_BLOCK_SIZE);
     PORT_Memset(k3, 0, AES_BLOCK_SIZE);
     PORT_Memset(newKey, 0, AES_BLOCK_SIZE);
     return crv;
 }
 
 /* encode the final pad block of aes xcbc, padBuf is modified */
 CK_RV
-sftk_xcbc_mac_pad(unsigned char *padBuf, unsigned int bufLen, int blockSize,
-                  const unsigned char *k2, const unsigned char *k3)
+sftk_xcbc_mac_pad(unsigned char *padBuf, unsigned int bufLen,
+                  unsigned int blockSize, const unsigned char *k2,
+                  const unsigned char *k3)
 {
-    int i;
+    unsigned int i;
     if (bufLen == blockSize) {
         for (i = 0; i < blockSize; i++) {
             padBuf[i] ^= k2[i];
         }
     } else {
         padBuf[bufLen++] = 0x80;
         for (i = bufLen; i < blockSize; i++) {
             padBuf[i] = 0x00;