cipher_rc4_hw.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. /*
  10. * RC4 low level APIs are deprecated for public use, but still ok for internal
  11. * use.
  12. */
  13. #include "internal/deprecated.h"
  14. #include "cipher_rc4.h"
  15. static int cipher_hw_rc4_initkey(PROV_CIPHER_CTX *ctx,
  16. const unsigned char *key, size_t keylen)
  17. {
  18. PROV_RC4_CTX *rctx = (PROV_RC4_CTX *)ctx;
  19. RC4_set_key(&rctx->ks.ks, keylen, key);
  20. return 1;
  21. }
  22. static int cipher_hw_rc4_cipher(PROV_CIPHER_CTX *ctx, unsigned char *out,
  23. const unsigned char *in, size_t len)
  24. {
  25. PROV_RC4_CTX *rctx = (PROV_RC4_CTX *)ctx;
  26. RC4(&rctx->ks.ks, len, in, out);
  27. return 1;
  28. }
  29. static const PROV_CIPHER_HW rc4_hw = {
  30. cipher_hw_rc4_initkey,
  31. cipher_hw_rc4_cipher
  32. };
  33. const PROV_CIPHER_HW *ossl_prov_cipher_hw_rc4(size_t keybits)
  34. {
  35. return &rc4_hw;
  36. }