Move RC4 into crypto.h as a replaceable crypto function
[libeap.git] / src / crypto / crypto.h
index be3609e..44d0fb8 100644 (file)
@@ -448,4 +448,20 @@ int __must_check crypto_mod_exp(const u8 *base, size_t base_len,
                                const u8 *modulus, size_t modulus_len,
                                u8 *result, size_t *result_len);
 
+/**
+ * rc4_skip - XOR RC4 stream to given data with skip-stream-start
+ * @key: RC4 key
+ * @keylen: RC4 key length
+ * @skip: number of bytes to skip from the beginning of the RC4 stream
+ * @data: data to be XOR'ed with RC4 stream
+ * @data_len: buf length
+ * Returns: 0 on success, -1 on failure
+ *
+ * Generate RC4 pseudo random stream for the given key, skip beginning of the
+ * stream, and XOR the end result with the data buffer to perform RC4
+ * encryption/decryption.
+ */
+int rc4_skip(const u8 *key, size_t keylen, size_t skip,
+            u8 *data, size_t data_len);
+
 #endif /* CRYPTO_H */