Print this page
6189743 Need an ARCFOUR implementation optimized for AMD64

Split Close
Expand all
Collapse all
          --- old/usr/src/common/crypto/arcfour/arcfour_crypt.c
          +++ new/usr/src/common/crypto/arcfour/arcfour_crypt.c
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5      - * Common Development and Distribution License, Version 1.0 only
   6      - * (the "License").  You may not use this file except in compliance
   7      - * with the License.
        5 + * Common Development and Distribution License (the "License").
        6 + * You may not use this file except in compliance with the License.
   8    7   *
   9    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10    9   * or http://www.opensolaris.org/os/licensing.
  11   10   * See the License for the specific language governing permissions
  12   11   * and limitations under the License.
  13   12   *
  14   13   * When distributing Covered Code, include this CDDL HEADER in each
  15   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   15   * If applicable, add the following below this CDDL HEADER, with the
  17   16   * fields enclosed by brackets "[]" replaced with your own identifying
  18   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   18   *
  20   19   * CDDL HEADER END
  21   20   */
  22   21  /*
  23      - * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
       22 + * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24   23   * Use is subject to license terms.
  25   24   */
  26   25  
  27      -#pragma ident   "@(#)arcfour_crypt.c    1.5     05/08/23 SMI"
       26 +#pragma ident   "@(#)arcfour_crypt.c    1.6     08/01/02 SMI"
  28   27  
  29   28  #include "arcfour.h"
  30   29  
       30 +#if defined(__amd64)
       31 +/*
       32 + * Use hand-tuned, processor-specific assembly version of arcfour_crypt()
       33 + * for 64-bit x86:
       34 + */
       35 +#define USE_PSR_VERSION_OF_ARCFOUR_CRYPT
       36 +#endif /* __amd64 */
       37 +
  31   38  /* Initialize the key stream 'key' using the key value */
  32   39  void
  33   40  arcfour_key_init(ARCFour_key *key, uchar_t *keyval, int keyvallen)
  34   41  {
  35   42  /* EXPORT DELETE START */
  36   43  
  37   44          uchar_t ext_keyval[256];
  38   45          uchar_t tmp;
  39   46          int i, j;
  40   47  
↓ open down ↓ 13 lines elided ↑ open up ↑
  54   61                  key->arr[i] = key->arr[j];
  55   62                  key->arr[j] = tmp;
  56   63          }
  57   64          key->i = 0;
  58   65          key->j = 0;
  59   66  
  60   67  /* EXPORT DELETE END */
  61   68  }
  62   69  
  63   70  
       71 +#if !defined(USE_PSR_VERSION_OF_ARCFOUR_CRYPT)
  64   72  /*
  65      - * Encipher 'in' using 'key.
       73 + * Encipher 'in' using 'key'.
  66   74   * in and out can point to the same location
  67   75   */
  68   76  void
  69   77  arcfour_crypt(ARCFour_key *key, uchar_t *in, uchar_t *out, size_t len)
  70   78  {
  71   79          size_t ii;
  72   80          uchar_t tmp, i, j;
  73   81  
  74   82  /* EXPORT DELETE START */
  75   83  
↓ open down ↓ 47 lines elided ↑ open up ↑
 123  131                  key->i = i;
 124  132                  key->j = j;
 125  133  #ifdef  sun4u
 126  134          } else {
 127  135                  arcfour_crypt_aligned(key, len, in, out);
 128  136          }
 129  137  #endif  /* sun4u */
 130  138  
 131  139  /* EXPORT DELETE END */
 132  140  }
      141 +#endif  /* !USE_PSR_VERSION_OF_ARCFOUR_CRYPT */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX