rc4.h 694 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the License); you may
  5. * not use this file except in compliance with the License.
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. */
  9. #ifndef GMSSL_RC4_H
  10. #define GMSSL_RC4_H
  11. #include <string.h>
  12. #include <stdint.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #define RC4_MIN_KEY_BITS 40
  17. #define RC4_STATE_NUM_WORDS 256
  18. typedef struct {
  19. uint8_t d[RC4_STATE_NUM_WORDS];
  20. } RC4_STATE;
  21. void rc4_init(RC4_STATE *state, const uint8_t *key, size_t keylen);
  22. void rc4_generate_keystream(RC4_STATE *state, size_t outlen, uint8_t *out);
  23. #ifdef __cplusplus
  24. }
  25. #endif
  26. #endif