MCPcopy Create free account
hub / github.com/ReversecLabs/C3 / KeySchedulingAlgorithm

Function KeySchedulingAlgorithm

Src/Common/FSecure/CppTools/Encryption.cpp:19–29  ·  view source on GitHub ↗

@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.

Source from the content-addressed store, hash-verified

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 ///

Callers 1

RC4Function · 0.85

Calls 1

swapFunction · 0.85

Tested by

no test coverage detected