cipher_rc4_hw.c 1020 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright 2019 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. #include "cipher_rc4.h"
  10. static int cipher_hw_rc4_initkey(PROV_CIPHER_CTX *ctx,
  11. const unsigned char *key, size_t keylen)
  12. {
  13. PROV_RC4_CTX *rctx = (PROV_RC4_CTX *)ctx;
  14. RC4_set_key(&rctx->ks.ks, keylen, key);
  15. return 1;
  16. }
  17. static int cipher_hw_rc4_cipher(PROV_CIPHER_CTX *ctx, unsigned char *out,
  18. const unsigned char *in, size_t len)
  19. {
  20. PROV_RC4_CTX *rctx = (PROV_RC4_CTX *)ctx;
  21. RC4(&rctx->ks.ks, len, in, out);
  22. return 1;
  23. }
  24. static const PROV_CIPHER_HW rc4_hw = {
  25. cipher_hw_rc4_initkey,
  26. cipher_hw_rc4_cipher
  27. };
  28. const PROV_CIPHER_HW *PROV_CIPHER_HW_rc4(size_t keybits)
  29. {
  30. return &rc4_hw;
  31. }