Print this page
6717509 Need to use bswap/bswapq for byte swap of 64-bit integer on x32/x64 (fix lint)


 359  * This will decrypt the cipher text.  However, the plaintext won't be
 360  * returned to the caller.  It will be returned when decrypt_final() is
 361  * called if the MAC matches
 362  */
 363 /* ARGSUSED */
 364 int
 365 ccm_mode_decrypt_contiguous_blocks(ccm_ctx_t *ctx, char *data, size_t length,
 366     crypto_data_t *out, size_t block_size,
 367     int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
 368     void (*copy_block)(uint8_t *, uint8_t *),
 369     void (*xor_block)(uint8_t *, uint8_t *))
 370 {
 371         size_t remainder = length;
 372         size_t need;
 373         uint8_t *datap = (uint8_t *)data;
 374         uint8_t *blockp;
 375         uint8_t *cbp;
 376         uint64_t counter;
 377         size_t pt_len, total_decrypted_len, mac_len, pm_len, pd_len;
 378         uint8_t *resultp;
 379 #ifdef _LITTLE_ENDIAN
 380         uint8_t *p;
 381 #endif  /* _LITTLE_ENDIAN */
 382 
 383 
 384         pm_len = ctx->ccm_processed_mac_len;
 385 
 386         if (pm_len > 0) {
 387                 uint8_t *tmp;
 388                 /*
 389                  * all ciphertext has been processed, just waiting for
 390                  * part of the value of the mac
 391                  */
 392                 if ((pm_len + length) > ctx->ccm_mac_len) {
 393                         return (CRYPTO_ENCRYPTED_DATA_LEN_RANGE);
 394                 }
 395                 tmp = (uint8_t *)ctx->ccm_mac_input_buf;
 396 
 397                 bcopy(datap, tmp + pm_len, length);
 398 
 399                 ctx->ccm_processed_mac_len += length;
 400                 return (CRYPTO_SUCCESS);
 401         }




 359  * This will decrypt the cipher text.  However, the plaintext won't be
 360  * returned to the caller.  It will be returned when decrypt_final() is
 361  * called if the MAC matches
 362  */
 363 /* ARGSUSED */
 364 int
 365 ccm_mode_decrypt_contiguous_blocks(ccm_ctx_t *ctx, char *data, size_t length,
 366     crypto_data_t *out, size_t block_size,
 367     int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
 368     void (*copy_block)(uint8_t *, uint8_t *),
 369     void (*xor_block)(uint8_t *, uint8_t *))
 370 {
 371         size_t remainder = length;
 372         size_t need;
 373         uint8_t *datap = (uint8_t *)data;
 374         uint8_t *blockp;
 375         uint8_t *cbp;
 376         uint64_t counter;
 377         size_t pt_len, total_decrypted_len, mac_len, pm_len, pd_len;
 378         uint8_t *resultp;



 379 
 380 
 381         pm_len = ctx->ccm_processed_mac_len;
 382 
 383         if (pm_len > 0) {
 384                 uint8_t *tmp;
 385                 /*
 386                  * all ciphertext has been processed, just waiting for
 387                  * part of the value of the mac
 388                  */
 389                 if ((pm_len + length) > ctx->ccm_mac_len) {
 390                         return (CRYPTO_ENCRYPTED_DATA_LEN_RANGE);
 391                 }
 392                 tmp = (uint8_t *)ctx->ccm_mac_input_buf;
 393 
 394                 bcopy(datap, tmp + pm_len, length);
 395 
 396                 ctx->ccm_processed_mac_len += length;
 397                 return (CRYPTO_SUCCESS);
 398         }