@@ -179,10 +179,10 @@ int gcm_encrypt(const uint8_t* plaintext, int plaintext_len, uint8_t* key, int k
179179
180180 // Copying the buffer size, nonce and tag to ciphertext
181181 int bufferSize = nonce_len + ciphertext_len + gcmTagLen;
182- ciphertext[3 ] = 0xff & (bufferSize >> 24 );
183- ciphertext[2 ] = 0xff & (bufferSize >> 16 );
184- ciphertext[1 ] = 0xff & (bufferSize >> 8 );
185- ciphertext[0 ] = 0xff & (bufferSize);
182+ ciphertext[3 ] = ( uint8_t )( 0xff & (bufferSize >> 24 ) );
183+ ciphertext[2 ] = ( uint8_t )( 0xff & (bufferSize >> 16 ) );
184+ ciphertext[1 ] = ( uint8_t )( 0xff & (bufferSize >> 8 ) );
185+ ciphertext[0 ] = ( uint8_t )( 0xff & (bufferSize) );
186186 std::copy (nonce, nonce + nonce_len, ciphertext + bufferSizeLen);
187187 std::copy (tag, tag + gcmTagLen, ciphertext + bufferSizeLen + nonce_len + ciphertext_len);
188188
@@ -233,10 +233,10 @@ int ctr_encrypt(const uint8_t* plaintext, int plaintext_len, uint8_t* key, int k
233233
234234 // Copying the buffer size and nonce to ciphertext
235235 int bufferSize = nonceLen + ciphertext_len;
236- ciphertext[3 ] = 0xff & (bufferSize >> 24 );
237- ciphertext[2 ] = 0xff & (bufferSize >> 16 );
238- ciphertext[1 ] = 0xff & (bufferSize >> 8 );
239- ciphertext[0 ] = 0xff & (bufferSize);
236+ ciphertext[3 ] = ( uint8_t )( 0xff & (bufferSize >> 24 ) );
237+ ciphertext[2 ] = ( uint8_t )( 0xff & (bufferSize >> 16 ) );
238+ ciphertext[1 ] = ( uint8_t )( 0xff & (bufferSize >> 8 ) );
239+ ciphertext[0 ] = ( uint8_t )( 0xff & (bufferSize) );
240240 std::copy (nonce, nonce + nonceLen, ciphertext + bufferSizeLen);
241241
242242 return bufferSizeLen + bufferSize;
0 commit comments