@Brief Initialization of pseudo random keystream with key. @param key IN argument. Used to create keystream. @param len IN argument. Size of key in bytes. @param keystream OUT argument. Generated keystream.
| 17 | /// @param len IN argument. Size of key in bytes. |
| 18 | /// @param keystream OUT argument. Generated keystream. |
| 19 | void KeySchedulingAlgorithm(const char* key, size_t len, unsigned char* keystream) |
| 20 | { |
| 21 | for (auto i = 0u; i < N; i++) |
| 22 | keystream[i] = static_cast<unsigned char>(i); |
| 23 | |
| 24 | for (auto i = 0u, j = 0u; i < N; i++) |
| 25 | { |
| 26 | j = (j + keystream[i] + key[i % len]) % N; |
| 27 | std::swap(keystream[i], keystream[j]); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | /// @brief Encrypting data with usage of keystream. |
| 32 | /// |