Print this page
5007142 Add ntohll and htonll to sys/byteorder.h
6717509 Need to use bswap/bswapq for byte swap of 64-bit integer on x32/x64
PSARC 2008/474

Split Close
Expand all
Collapse all
          --- old/usr/src/common/crypto/aes/amd64/aesopt.h
          +++ new/usr/src/common/crypto/aes/amd64/aesopt.h
↓ open down ↓ 46 lines elided ↑ open up ↑
  47   47  
  48   48  /*
  49   49   * OpenSolaris changes
  50   50   * 1. Added __cplusplus and _AESTAB_H header guards
  51   51   * 2. Added header files sys/types.h and aes_impl.h
  52   52   * 3. Added defines for AES_ENCRYPT, AES_DECRYPT, AES_REV_DKS, and ASM_AMD64_C
  53   53   * 4. Moved defines for IS_BIG_ENDIAN, IS_LITTLE_ENDIAN, PLATFORM_BYTE_ORDER
  54   54   *    from brg_endian.h
  55   55   * 5. Undefined VIA_ACE_POSSIBLE and ASSUME_VIA_ACE_PRESENT
  56   56   * 6. Changed uint_8t and uint_32t to uint8_t and uint32_t
  57      - * 7. cstyled and hdrchk code
       57 + * 7. Defined aes_sw32 as htonl() for byte swapping
       58 + * 8. Cstyled and hdrchk code
  58   59   *
  59   60   */
  60   61  
  61   62  #ifndef _AESOPT_H
  62   63  #define _AESOPT_H
  63   64  
  64      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  65      -
  66   65  #ifdef  __cplusplus
  67   66  extern "C" {
  68   67  #endif
  69   68  
  70   69  #include <sys/types.h>
       70 +#include <sys/byteorder.h>
  71   71  #include <aes_impl.h>
  72   72  
  73   73  /*  SUPPORT FEATURES */
  74   74  #define AES_ENCRYPT /* if support for encryption is needed */
  75   75  #define AES_DECRYPT /* if support for decryption is needed */
  76   76  
  77   77  /*  PLATFORM-SPECIFIC FEATURES */
  78   78  #define IS_BIG_ENDIAN           4321 /* byte 0 is most significant (mc68k) */
  79   79  #define IS_LITTLE_ENDIAN        1234 /* byte 0 is least significant (i386) */
  80   80  #define PLATFORM_BYTE_ORDER     IS_LITTLE_ENDIAN
↓ open down ↓ 433 lines elided ↑ open up ↑
 514  514  #elif DEC_ROUND == ONE_TABLE && LAST_DEC_ROUND == FOUR_TABLES
 515  515  #undef  LAST_DEC_ROUND
 516  516  #define LAST_DEC_ROUND  ONE_TABLE
 517  517  #endif
 518  518  
 519  519  #if DEC_ROUND == NO_TABLES && DEC_UNROLL != NONE
 520  520  #undef  DEC_UNROLL
 521  521  #define DEC_UNROLL  NONE
 522  522  #endif
 523  523  
 524      -#if defined(bswap32)
      524 +#if (ALGORITHM_BYTE_ORDER == IS_LITTLE_ENDIAN)
      525 +#define aes_sw32        htonl
      526 +#elif defined(bswap32)
 525  527  #define aes_sw32        bswap32
 526  528  #elif defined(bswap_32)
 527  529  #define aes_sw32        bswap_32
 528  530  #else
 529      -#define brot(x, n)   (((uint32_t)(x) <<  n) | ((uint32_t)(x) >> (32 - n)))
      531 +#define brot(x, n)  (((uint32_t)(x) << (n)) | ((uint32_t)(x) >> (32 - (n))))
 530  532  #define aes_sw32(x) ((brot((x), 8) & 0x00ff00ff) | (brot((x), 24) & 0xff00ff00))
 531  533  #endif
 532  534  
      535 +
 533  536  /*
 534      - *  upr(x, n):  rotates bytes within words by n positions, moving bytes to
      537 + *      upr(x, n):  rotates bytes within words by n positions, moving bytes to
 535  538   *              higher index positions with wrap around into low positions
 536  539   *      ups(x, n):  moves bytes by n positions to higher index positions in
 537  540   *              words but without wrap around
 538  541   *      bval(x, n): extracts a byte from a word
 539  542   *
 540  543   *      WARNING:   The definitions given here are intended only for use with
 541  544   *              unsigned variables and with shift counts that are compile
 542  545   *              time constants
 543  546   */
 544  547  
↓ open down ↓ 224 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX