Print this page
first pass

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/crypto/io/arcfour.c
          +++ new/usr/src/uts/common/crypto/io/arcfour.c
↓ open down ↓ 193 lines elided ↑ open up ↑
 194  194  {
 195  195          *status = CRYPTO_PROVIDER_READY;
 196  196  }
 197  197  
 198  198  /* ARGSUSED */
 199  199  static int
 200  200  rc4_common_init(crypto_ctx_t *ctx, crypto_mechanism_t *mechanism,
 201  201      crypto_key_t *key, crypto_spi_ctx_template_t template,
 202  202      crypto_req_handle_t req)
 203  203  {
 204      -
 205      -/* EXPORT DELETE START */
 206      -
 207  204          ARCFour_key *keystream;
 208  205  
 209  206          if ((mechanism)->cm_type != RC4_MECH_INFO_TYPE)
 210  207                  return (CRYPTO_MECHANISM_INVALID);
 211  208  
 212  209          if (key->ck_format != CRYPTO_KEY_RAW)
 213  210                  return (CRYPTO_KEY_TYPE_INCONSISTENT);
 214  211  
 215  212          if (key->ck_length < ARCFOUR_MIN_KEY_BITS ||
 216  213              key->ck_length > ARCFOUR_MAX_KEY_BITS) {
↓ open down ↓ 5 lines elided ↑ open up ↑
 222  219           */
 223  220          if ((keystream = kmem_alloc(sizeof (ARCFour_key),
 224  221              crypto_kmflag(req))) == NULL)
 225  222                  return (CRYPTO_HOST_MEMORY);
 226  223  
 227  224          arcfour_key_init(keystream, key->ck_data,
 228  225              CRYPTO_BITS2BYTES(key->ck_length));
 229  226  
 230  227          ctx->cc_provider_private = keystream;
 231  228  
 232      -/* EXPORT DELETE END */
 233      -
 234  229          return (CRYPTO_SUCCESS);
 235  230  }
 236  231  
 237  232  static int
 238  233  rc4_crypt(crypto_ctx_t *ctx, crypto_data_t *input, crypto_data_t *output,
 239  234      crypto_req_handle_t req)
 240  235  {
 241  236          int ret;
 242  237  
 243  238          ret = rc4_crypt_update(ctx, input, output, req);
↓ open down ↓ 4 lines elided ↑ open up ↑
 248  243          return (ret);
 249  244  }
 250  245  
 251  246  /* ARGSUSED */
 252  247  static int
 253  248  rc4_crypt_update(crypto_ctx_t *ctx, crypto_data_t *input, crypto_data_t *output,
 254  249      crypto_req_handle_t req)
 255  250  {
 256  251          int ret = CRYPTO_SUCCESS;
 257  252  
 258      -/* EXPORT DELETE START */
 259      -
 260  253          ARCFour_key *key;
 261  254          off_t saveoffset;
 262  255  
 263  256          ASSERT(ctx->cc_provider_private != NULL);
 264  257  
 265  258          if ((ctx->cc_flags & CRYPTO_USE_OPSTATE) && ctx->cc_opstate != NULL)
 266  259                  key = ctx->cc_opstate;
 267  260          else
 268  261                  key = ctx->cc_provider_private;
 269  262  
↓ open down ↓ 207 lines elided ↑ open up ↑
 477  470                  if (vec_idx == uiop->uio_iovcnt && length > 0) {
 478  471  
 479  472                          return (CRYPTO_DATA_LEN_RANGE);
 480  473                  }
 481  474          }
 482  475          }
 483  476  
 484  477          output->cd_offset = saveoffset;
 485  478          output->cd_length = input->cd_length;
 486  479  
 487      -/* EXPORT DELETE END */
 488      -
 489  480          return (ret);
 490  481  }
 491  482  
 492  483  /* ARGSUSED */
 493  484  static int rc4_crypt_final(crypto_ctx_t *ctx, crypto_data_t *data,
 494  485      crypto_req_handle_t req)
 495  486  {
 496  487          /* No final part for streams ciphers. Just free the context */
 497  488          if (data != NULL)
 498  489                  data->cd_length = 0;
↓ open down ↓ 21 lines elided ↑ open up ↑
 520  511  
 521  512          (void) rc4_free_context(&ctx);
 522  513  
 523  514          return (ret);
 524  515  }
 525  516  
 526  517  /* ARGSUSED */
 527  518  static int
 528  519  rc4_free_context(crypto_ctx_t *ctx)
 529  520  {
 530      -
 531      -/* EXPORT DELETE START */
 532      -
 533  521          ARCFour_key *keystream = ctx->cc_provider_private;
 534  522  
 535  523          if (keystream != NULL) {
 536  524                  bzero(keystream, sizeof (ARCFour_key));
 537  525                  kmem_free(keystream, sizeof (ARCFour_key));
 538  526                  ctx->cc_provider_private = NULL;
 539  527          }
 540  528  
 541      -/* EXPORT DELETE END */
 542      -
 543  529          return (CRYPTO_SUCCESS);
 544  530  }
 545  531  
 546  532  /* Encrypts a contiguous input 'in' into the 'out' crypto_data_t */
 547  533  
 548  534  static int
 549  535  crypto_arcfour_crypt(ARCFour_key *key, uchar_t *in, crypto_data_t *out,
 550  536      int length)
 551  537  {
 552  538          switch (out->cd_format) {
↓ open down ↓ 122 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX