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


  42 /*
  43  * Encrypt and decrypt multiple blocks of data in counter mode.
  44  */
  45 int
  46 ctr_mode_contiguous_blocks(ctr_ctx_t *ctx, char *data, size_t length,
  47     crypto_data_t *out, size_t block_size,
  48     int (*cipher)(const void *ks, const uint8_t *pt, uint8_t *ct),
  49     void (*xor_block)(uint8_t *, uint8_t *))
  50 {
  51         size_t remainder = length;
  52         size_t need;
  53         uint8_t *datap = (uint8_t *)data;
  54         uint8_t *blockp;
  55         uint8_t *lastp;
  56         void *iov_or_mp;
  57         offset_t offset;
  58         uint8_t *out_data_1;
  59         uint8_t *out_data_2;
  60         size_t out_data_1_len;
  61         uint64_t counter;
  62 #ifdef _LITTLE_ENDIAN
  63         uint8_t *p;
  64 #endif
  65 
  66         if (length + ctx->ctr_remainder_len < block_size) {
  67                 /* accumulate bytes here and return */
  68                 bcopy(datap,
  69                     (uint8_t *)ctx->ctr_remainder + ctx->ctr_remainder_len,
  70                     length);
  71                 ctx->ctr_remainder_len += length;
  72                 ctx->ctr_copy_to = datap;
  73                 return (CRYPTO_SUCCESS);
  74         }
  75 
  76         lastp = (uint8_t *)ctx->ctr_cb;
  77         if (out != NULL)
  78                 crypto_init_ptrs(out, &iov_or_mp, &offset);
  79 
  80         do {
  81                 /* Unprocessed data from last call. */
  82                 if (ctx->ctr_remainder_len > 0) {
  83                         need = block_size - ctx->ctr_remainder_len;
  84 




  42 /*
  43  * Encrypt and decrypt multiple blocks of data in counter mode.
  44  */
  45 int
  46 ctr_mode_contiguous_blocks(ctr_ctx_t *ctx, char *data, size_t length,
  47     crypto_data_t *out, size_t block_size,
  48     int (*cipher)(const void *ks, const uint8_t *pt, uint8_t *ct),
  49     void (*xor_block)(uint8_t *, uint8_t *))
  50 {
  51         size_t remainder = length;
  52         size_t need;
  53         uint8_t *datap = (uint8_t *)data;
  54         uint8_t *blockp;
  55         uint8_t *lastp;
  56         void *iov_or_mp;
  57         offset_t offset;
  58         uint8_t *out_data_1;
  59         uint8_t *out_data_2;
  60         size_t out_data_1_len;
  61         uint64_t counter;



  62 
  63         if (length + ctx->ctr_remainder_len < block_size) {
  64                 /* accumulate bytes here and return */
  65                 bcopy(datap,
  66                     (uint8_t *)ctx->ctr_remainder + ctx->ctr_remainder_len,
  67                     length);
  68                 ctx->ctr_remainder_len += length;
  69                 ctx->ctr_copy_to = datap;
  70                 return (CRYPTO_SUCCESS);
  71         }
  72 
  73         lastp = (uint8_t *)ctx->ctr_cb;
  74         if (out != NULL)
  75                 crypto_init_ptrs(out, &iov_or_mp, &offset);
  76 
  77         do {
  78                 /* Unprocessed data from last call. */
  79                 if (ctx->ctr_remainder_len > 0) {
  80                         need = block_size - ctx->ctr_remainder_len;
  81