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

Split Close
Expand all
Collapse all
          --- old/usr/src/common/crypto/aes/aes_impl.c
          +++ new/usr/src/common/crypto/aes/aes_impl.c
↓ open down ↓ 1480 lines elided ↑ open up ↑
1481 1481                  for (i = 0, j = 0; j < keysize; i++, j += 8) {
1482 1482                          /* LINTED: pointer alignment */
1483 1483                          keyarr.ka64[i] = *((uint64_t *)&cipherKey[j]);
1484 1484                  }
1485 1485          } else {
1486 1486                  bcopy(cipherKey, keyarr.ka32, keysize);
1487 1487          }
1488 1488  
1489 1489  #else   /* byte swap */
1490 1490          for (i = 0, j = 0; j < keysize; i++, j += 4) {
1491      -                keyarr.ka32[i] = htonl(*(uint32_t *)&cipherKey[j]);
     1491 +                keyarr.ka32[i] = htonl(*(uint32_t *)(void *)&cipherKey[j]);
1492 1492          }
1493 1493  #endif
1494 1494  
1495 1495          aes_setupkeys(newbie, keyarr.ka32, keyBits);
1496 1496  /* EXPORT DELETE END */
1497 1497  }
1498 1498  
1499 1499  /*
1500 1500   * Encrypt one block using AES.
1501 1501   * Align if needed and (for x86 32-bit only) byte-swap.
↓ open down ↓ 16 lines elided ↑ open up ↑
1518 1518                      (uint32_t *)pt, (uint32_t *)ct);
1519 1519          } else {
1520 1520  #endif
1521 1521                  uint32_t buffer[AES_BLOCK_LEN / sizeof (uint32_t)];
1522 1522  
1523 1523                  /* Copy input block into buffer */
1524 1524  #ifndef AES_BYTE_SWAP
1525 1525                  bcopy(pt, &buffer, AES_BLOCK_LEN);
1526 1526  
1527 1527  #else   /* byte swap */
1528      -                buffer[0] = htonl(*(uint32_t *)&pt[0]);
1529      -                buffer[1] = htonl(*(uint32_t *)&pt[4]);
1530      -                buffer[2] = htonl(*(uint32_t *)&pt[8]);
1531      -                buffer[3] = htonl(*(uint32_t *)&pt[12]);
     1528 +                buffer[0] = htonl(*(uint32_t *)(void *)&pt[0]);
     1529 +                buffer[1] = htonl(*(uint32_t *)(void *)&pt[4]);
     1530 +                buffer[2] = htonl(*(uint32_t *)(void *)&pt[8]);
     1531 +                buffer[3] = htonl(*(uint32_t *)(void *)&pt[12]);
1532 1532  #endif
1533 1533  
1534 1534                  AES_ENCRYPT_IMPL(&ksch->encr_ks.ks32[0], ksch->nr,
1535 1535                      buffer, buffer);
1536 1536  
1537 1537                  /* Copy result from buffer to output block */
1538 1538  #ifndef AES_BYTE_SWAP
1539 1539                  bcopy(&buffer, ct, AES_BLOCK_LEN);
1540 1540          }
1541 1541  
1542 1542  #else   /* byte swap */
1543      -                *(uint32_t *)&ct[0] = htonl(buffer[0]);
1544      -                *(uint32_t *)&ct[4] = htonl(buffer[1]);
1545      -                *(uint32_t *)&ct[8] = htonl(buffer[2]);
1546      -                *(uint32_t *)&ct[12] = htonl(buffer[3]);
     1543 +                *(uint32_t *)(void *)&ct[0] = htonl(buffer[0]);
     1544 +                *(uint32_t *)(void *)&ct[4] = htonl(buffer[1]);
     1545 +                *(uint32_t *)(void *)&ct[8] = htonl(buffer[2]);
     1546 +                *(uint32_t *)(void *)&ct[12] = htonl(buffer[3]);
1547 1547  #endif
1548 1548  /* EXPORT DELETE END */
1549 1549          return (CRYPTO_SUCCESS);
1550 1550  }
1551 1551  
1552 1552  /*
1553 1553   * Decrypt one block using AES.
1554 1554   * Align and byte-swap if needed.
1555 1555   *
1556 1556   * Parameters:
↓ open down ↓ 14 lines elided ↑ open up ↑
1571 1571                      (uint32_t *)ct, (uint32_t *)pt);
1572 1572          } else {
1573 1573  #endif
1574 1574                  uint32_t buffer[AES_BLOCK_LEN / sizeof (uint32_t)];
1575 1575  
1576 1576                  /* Copy input block into buffer */
1577 1577  #ifndef AES_BYTE_SWAP
1578 1578                  bcopy(ct, &buffer, AES_BLOCK_LEN);
1579 1579  
1580 1580  #else   /* byte swap */
1581      -                buffer[0] = htonl(*(uint32_t *)&ct[0]);
1582      -                buffer[1] = htonl(*(uint32_t *)&ct[4]);
1583      -                buffer[2] = htonl(*(uint32_t *)&ct[8]);
1584      -                buffer[3] = htonl(*(uint32_t *)&ct[12]);
     1581 +                buffer[0] = htonl(*(uint32_t *)(void *)&ct[0]);
     1582 +                buffer[1] = htonl(*(uint32_t *)(void *)&ct[4]);
     1583 +                buffer[2] = htonl(*(uint32_t *)(void *)&ct[8]);
     1584 +                buffer[3] = htonl(*(uint32_t *)(void *)&ct[12]);
1585 1585  #endif
1586 1586  
1587 1587                  AES_DECRYPT_IMPL(&ksch->decr_ks.ks32[0], ksch->nr,
1588 1588                      buffer, buffer);
1589 1589  
1590 1590                  /* Copy result from buffer to output block */
1591 1591  #ifndef AES_BYTE_SWAP
1592 1592                  bcopy(&buffer, pt, AES_BLOCK_LEN);
1593 1593          }
1594 1594  
1595 1595  #else   /* byte swap */
1596      -        *(uint32_t *)&pt[0] = htonl(buffer[0]);
1597      -        *(uint32_t *)&pt[4] = htonl(buffer[1]);
1598      -        *(uint32_t *)&pt[8] = htonl(buffer[2]);
1599      -        *(uint32_t *)&pt[12] = htonl(buffer[3]);
     1596 +        *(uint32_t *)(void *)&pt[0] = htonl(buffer[0]);
     1597 +        *(uint32_t *)(void *)&pt[4] = htonl(buffer[1]);
     1598 +        *(uint32_t *)(void *)&pt[8] = htonl(buffer[2]);
     1599 +        *(uint32_t *)(void *)&pt[12] = htonl(buffer[3]);
1600 1600  #endif
1601 1601  
1602 1602  /* EXPORT DELETE END */
1603 1603          return (CRYPTO_SUCCESS);
1604 1604  }
1605 1605  
1606 1606  
1607 1607  /*
1608 1608   * Allocate key schedule for AES.
1609 1609   *
↓ open down ↓ 129 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX