crypto.h revision 214734
1189251Ssam/*
2189251Ssam * WPA Supplicant / wrapper functions for crypto libraries
3214734Srpaulo * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
4189251Ssam *
5189251Ssam * This program is free software; you can redistribute it and/or modify
6189251Ssam * it under the terms of the GNU General Public License version 2 as
7189251Ssam * published by the Free Software Foundation.
8189251Ssam *
9189251Ssam * Alternatively, this software may be distributed under the terms of BSD
10189251Ssam * license.
11189251Ssam *
12189251Ssam * See README and COPYING for more details.
13189251Ssam *
14189251Ssam * This file defines the cryptographic functions that need to be implemented
15189251Ssam * for wpa_supplicant and hostapd. When TLS is not used, internal
16189251Ssam * implementation of MD5, SHA1, and AES is used and no external libraries are
17189251Ssam * required. When TLS is enabled (e.g., by enabling EAP-TLS or EAP-PEAP), the
18189251Ssam * crypto library used by the TLS implementation is expected to be used for
19189251Ssam * non-TLS needs, too, in order to save space by not implementing these
20189251Ssam * functions twice.
21189251Ssam *
22189251Ssam * Wrapper code for using each crypto library is in its own file (crypto*.c)
23189251Ssam * and one of these files is build and linked in to provide the functions
24189251Ssam * defined here.
25189251Ssam */
26214734Srpaulo
27214734Srpaulo#ifndef CRYPTO_H
28214734Srpaulo#define CRYPTO_H
29189251Ssam
30214734Srpaulo/**
31189251Ssam * md4_vector - MD4 hash for data vector
32214734Srpaulo * @num_elem: Number of elements in the data vector
33189251Ssam * @addr: Pointers to the data areas
34189251Ssam * @len: Lengths of the data blocks
35189251Ssam * @mac: Buffer for the hash
36189251Ssam * Returns: 0 on success, -1 on failure
37214734Srpaulo */
38189251Ssamint md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
39189251Ssam
40189251Ssam/**
41189251Ssam * md5_vector - MD5 hash for data vector
42189251Ssam * @num_elem: Number of elements in the data vector
43189251Ssam * @addr: Pointers to the data areas
44189251Ssam * @len: Lengths of the data blocks
45189251Ssam * @mac: Buffer for the hash
46189251Ssam * Returns: 0 on success, -1 on failure
47189251Ssam */
48189251Ssamint md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
49189251Ssam
50189251Ssam#ifdef CONFIG_FIPS
51189251Ssam/**
52189251Ssam * md5_vector_non_fips_allow - MD5 hash for data vector (non-FIPS use allowed)
53189251Ssam * @num_elem: Number of elements in the data vector
54189251Ssam * @addr: Pointers to the data areas
55189251Ssam * @len: Lengths of the data blocks
56189251Ssam * @mac: Buffer for the hash
57189251Ssam * Returns: 0 on success, -1 on failure
58189251Ssam */
59189251Ssamint md5_vector_non_fips_allow(size_t num_elem, const u8 *addr[],
60189251Ssam			      const size_t *len, u8 *mac);
61189251Ssam#else /* CONFIG_FIPS */
62189251Ssam#define md5_vector_non_fips_allow md5_vector
63189251Ssam#endif /* CONFIG_FIPS */
64189251Ssam
65189251Ssam
66189251Ssam/**
67189251Ssam * sha1_vector - SHA-1 hash for data vector
68189251Ssam * @num_elem: Number of elements in the data vector
69189251Ssam * @addr: Pointers to the data areas
70189251Ssam * @len: Lengths of the data blocks
71189251Ssam * @mac: Buffer for the hash
72189251Ssam * Returns: 0 on success, -1 on failure
73189251Ssam */
74189251Ssamint sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len,
75189251Ssam		u8 *mac);
76189251Ssam
77189251Ssam/**
78189251Ssam * fips186_2-prf - NIST FIPS Publication 186-2 change notice 1 PRF
79189251Ssam * @seed: Seed/key for the PRF
80189251Ssam * @seed_len: Seed length in bytes
81189251Ssam * @x: Buffer for PRF output
82189251Ssam * @xlen: Output length in bytes
83189251Ssam * Returns: 0 on success, -1 on failure
84189251Ssam *
85189251Ssam * This function implements random number generation specified in NIST FIPS
86189251Ssam * Publication 186-2 for EAP-SIM. This PRF uses a function that is similar to
87189251Ssam * SHA-1, but has different message padding.
88189251Ssam */
89189251Ssamint __must_check fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x,
90189251Ssam			       size_t xlen);
91189251Ssam
92189251Ssam/**
93214734Srpaulo * sha256_vector - SHA256 hash for data vector
94214734Srpaulo * @num_elem: Number of elements in the data vector
95214734Srpaulo * @addr: Pointers to the data areas
96214734Srpaulo * @len: Lengths of the data blocks
97189251Ssam * @mac: Buffer for the hash
98189251Ssam * Returns: 0 on success, -1 on failure
99189251Ssam */
100189251Ssamint sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
101189251Ssam		  u8 *mac);
102189251Ssam
103189251Ssam/**
104189251Ssam * des_encrypt - Encrypt one block with DES
105189251Ssam * @clear: 8 octets (in)
106214734Srpaulo * @key: 7 octets (in) (no parity bits included)
107189251Ssam * @cypher: 8 octets (out)
108189251Ssam */
109189251Ssamvoid des_encrypt(const u8 *clear, const u8 *key, u8 *cypher);
110189251Ssam
111189251Ssam/**
112189251Ssam * aes_encrypt_init - Initialize AES for encryption
113189251Ssam * @key: Encryption key
114189251Ssam * @len: Key length in bytes (usually 16, i.e., 128 bits)
115189251Ssam * Returns: Pointer to context data or %NULL on failure
116189251Ssam */
117189251Ssamvoid * aes_encrypt_init(const u8 *key, size_t len);
118189251Ssam
119189251Ssam/**
120189251Ssam * aes_encrypt - Encrypt one AES block
121189251Ssam * @ctx: Context pointer from aes_encrypt_init()
122189251Ssam * @plain: Plaintext data to be encrypted (16 bytes)
123189251Ssam * @crypt: Buffer for the encrypted data (16 bytes)
124189251Ssam */
125189251Ssamvoid aes_encrypt(void *ctx, const u8 *plain, u8 *crypt);
126189251Ssam
127189251Ssam/**
128189251Ssam * aes_encrypt_deinit - Deinitialize AES encryption
129189251Ssam * @ctx: Context pointer from aes_encrypt_init()
130214734Srpaulo */
131214734Srpaulovoid aes_encrypt_deinit(void *ctx);
132214734Srpaulo
133214734Srpaulo/**
134189251Ssam * aes_decrypt_init - Initialize AES for decryption
135214734Srpaulo * @key: Decryption key
136214734Srpaulo * @len: Key length in bytes (usually 16, i.e., 128 bits)
137214734Srpaulo * Returns: Pointer to context data or %NULL on failure
138214734Srpaulo */
139214734Srpaulovoid * aes_decrypt_init(const u8 *key, size_t len);
140214734Srpaulo
141214734Srpaulo/**
142214734Srpaulo * aes_decrypt - Decrypt one AES block
143214734Srpaulo * @ctx: Context pointer from aes_encrypt_init()
144214734Srpaulo * @crypt: Encrypted data (16 bytes)
145214734Srpaulo * @plain: Buffer for the decrypted data (16 bytes)
146214734Srpaulo */
147214734Srpaulovoid aes_decrypt(void *ctx, const u8 *crypt, u8 *plain);
148214734Srpaulo
149214734Srpaulo/**
150214734Srpaulo * aes_decrypt_deinit - Deinitialize AES decryption
151214734Srpaulo * @ctx: Context pointer from aes_encrypt_init()
152214734Srpaulo */
153214734Srpaulovoid aes_decrypt_deinit(void *ctx);
154214734Srpaulo
155214734Srpaulo
156214734Srpauloenum crypto_hash_alg {
157214734Srpaulo	CRYPTO_HASH_ALG_MD5, CRYPTO_HASH_ALG_SHA1,
158214734Srpaulo	CRYPTO_HASH_ALG_HMAC_MD5, CRYPTO_HASH_ALG_HMAC_SHA1
159214734Srpaulo};
160214734Srpaulo
161214734Srpaulostruct crypto_hash;
162214734Srpaulo
163214734Srpaulo/**
164214734Srpaulo * crypto_hash_init - Initialize hash/HMAC function
165214734Srpaulo * @alg: Hash algorithm
166214734Srpaulo * @key: Key for keyed hash (e.g., HMAC) or %NULL if not needed
167214734Srpaulo * @key_len: Length of the key in bytes
168214734Srpaulo * Returns: Pointer to hash context to use with other hash functions or %NULL
169214734Srpaulo * on failure
170214734Srpaulo *
171214734Srpaulo * This function is only used with internal TLSv1 implementation
172214734Srpaulo * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
173214734Srpaulo * to implement this.
174214734Srpaulo */
175214734Srpaulostruct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
176214734Srpaulo				      size_t key_len);
177214734Srpaulo
178214734Srpaulo/**
179214734Srpaulo * crypto_hash_update - Add data to hash calculation
180214734Srpaulo * @ctx: Context pointer from crypto_hash_init()
181214734Srpaulo * @data: Data buffer to add
182214734Srpaulo * @len: Length of the buffer
183214734Srpaulo *
184214734Srpaulo * This function is only used with internal TLSv1 implementation
185189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
186189251Ssam * to implement this.
187214734Srpaulo */
188214734Srpaulovoid crypto_hash_update(struct crypto_hash *ctx, const u8 *data, size_t len);
189214734Srpaulo
190214734Srpaulo/**
191214734Srpaulo * crypto_hash_finish - Complete hash calculation
192214734Srpaulo * @ctx: Context pointer from crypto_hash_init()
193214734Srpaulo * @hash: Buffer for hash value or %NULL if caller is just freeing the hash
194189251Ssam * context
195189251Ssam * @len: Pointer to length of the buffer or %NULL if caller is just freeing the
196189251Ssam * hash context; on return, this is set to the actual length of the hash value
197189251Ssam * Returns: 0 on success, -1 if buffer is too small (len set to needed length),
198189251Ssam * or -2 on other failures (including failed crypto_hash_update() operations)
199214734Srpaulo *
200189251Ssam * This function calculates the hash value and frees the context buffer that
201189251Ssam * was used for hash calculation.
202189251Ssam *
203189251Ssam * This function is only used with internal TLSv1 implementation
204214734Srpaulo * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
205189251Ssam * to implement this.
206189251Ssam */
207189251Ssamint crypto_hash_finish(struct crypto_hash *ctx, u8 *hash, size_t *len);
208214734Srpaulo
209189251Ssam
210189251Ssamenum crypto_cipher_alg {
211189251Ssam	CRYPTO_CIPHER_NULL = 0, CRYPTO_CIPHER_ALG_AES, CRYPTO_CIPHER_ALG_3DES,
212214734Srpaulo	CRYPTO_CIPHER_ALG_DES, CRYPTO_CIPHER_ALG_RC2, CRYPTO_CIPHER_ALG_RC4
213214734Srpaulo};
214214734Srpaulo
215214734Srpaulostruct crypto_cipher;
216214734Srpaulo
217214734Srpaulo/**
218214734Srpaulo * crypto_cipher_init - Initialize block/stream cipher function
219214734Srpaulo * @alg: Cipher algorithm
220214734Srpaulo * @iv: Initialization vector for block ciphers or %NULL for stream ciphers
221189251Ssam * @key: Cipher key
222189251Ssam * @key_len: Length of key in bytes
223214734Srpaulo * Returns: Pointer to cipher context to use with other cipher functions or
224214734Srpaulo * %NULL on failure
225214734Srpaulo *
226214734Srpaulo * This function is only used with internal TLSv1 implementation
227214734Srpaulo * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
228214734Srpaulo * to implement this.
229214734Srpaulo */
230214734Srpaulostruct crypto_cipher * crypto_cipher_init(enum crypto_cipher_alg alg,
231214734Srpaulo					  const u8 *iv, const u8 *key,
232214734Srpaulo					  size_t key_len);
233214734Srpaulo
234214734Srpaulo/**
235214734Srpaulo * crypto_cipher_encrypt - Cipher encrypt
236214734Srpaulo * @ctx: Context pointer from crypto_cipher_init()
237214734Srpaulo * @plain: Plaintext to cipher
238214734Srpaulo * @crypt: Resulting ciphertext
239214734Srpaulo * @len: Length of the plaintext
240214734Srpaulo * Returns: 0 on success, -1 on failure
241214734Srpaulo *
242214734Srpaulo * This function is only used with internal TLSv1 implementation
243214734Srpaulo * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
244214734Srpaulo * to implement this.
245214734Srpaulo */
246214734Srpauloint __must_check crypto_cipher_encrypt(struct crypto_cipher *ctx,
247214734Srpaulo				       const u8 *plain, u8 *crypt, size_t len);
248214734Srpaulo
249214734Srpaulo/**
250189251Ssam * crypto_cipher_decrypt - Cipher decrypt
251189251Ssam * @ctx: Context pointer from crypto_cipher_init()
252189251Ssam * @crypt: Ciphertext to decrypt
253189251Ssam * @plain: Resulting plaintext
254189251Ssam * @len: Length of the cipher text
255189251Ssam * Returns: 0 on success, -1 on failure
256189251Ssam *
257189251Ssam * This function is only used with internal TLSv1 implementation
258214734Srpaulo * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
259214734Srpaulo * to implement this.
260214734Srpaulo */
261214734Srpauloint __must_check crypto_cipher_decrypt(struct crypto_cipher *ctx,
262214734Srpaulo				       const u8 *crypt, u8 *plain, size_t len);
263214734Srpaulo
264214734Srpaulo/**
265214734Srpaulo * crypto_cipher_decrypt - Free cipher context
266214734Srpaulo * @ctx: Context pointer from crypto_cipher_init()
267189251Ssam *
268214734Srpaulo * This function is only used with internal TLSv1 implementation
269189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
270189251Ssam * to implement this.
271189251Ssam */
272189251Ssamvoid crypto_cipher_deinit(struct crypto_cipher *ctx);
273214734Srpaulo
274214734Srpaulo
275214734Srpaulostruct crypto_public_key;
276214734Srpaulostruct crypto_private_key;
277189251Ssam
278189251Ssam/**
279189251Ssam * crypto_public_key_import - Import an RSA public key
280189251Ssam * @key: Key buffer (DER encoded RSA public key)
281189251Ssam * @len: Key buffer length in bytes
282189251Ssam * Returns: Pointer to the public key or %NULL on failure
283189251Ssam *
284189251Ssam * This function can just return %NULL if the crypto library supports X.509
285189251Ssam * parsing. In that case, crypto_public_key_from_cert() is used to import the
286189251Ssam * public key from a certificate.
287189251Ssam *
288189251Ssam * This function is only used with internal TLSv1 implementation
289189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
290189251Ssam * to implement this.
291189251Ssam */
292189251Ssamstruct crypto_public_key * crypto_public_key_import(const u8 *key, size_t len);
293189251Ssam
294189251Ssam/**
295189251Ssam * crypto_private_key_import - Import an RSA private key
296189251Ssam * @key: Key buffer (DER encoded RSA private key)
297189251Ssam * @len: Key buffer length in bytes
298189251Ssam * @passwd: Key encryption password or %NULL if key is not encrypted
299189251Ssam * Returns: Pointer to the private key or %NULL on failure
300189251Ssam *
301189251Ssam * This function is only used with internal TLSv1 implementation
302189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
303189251Ssam * to implement this.
304189251Ssam */
305189251Ssamstruct crypto_private_key * crypto_private_key_import(const u8 *key,
306189251Ssam						      size_t len,
307189251Ssam						      const char *passwd);
308189251Ssam
309189251Ssam/**
310189251Ssam * crypto_public_key_from_cert - Import an RSA public key from a certificate
311189251Ssam * @buf: DER encoded X.509 certificate
312189251Ssam * @len: Certificate buffer length in bytes
313189251Ssam * Returns: Pointer to public key or %NULL on failure
314189251Ssam *
315189251Ssam * This function can just return %NULL if the crypto library does not support
316189251Ssam * X.509 parsing. In that case, internal code will be used to parse the
317189251Ssam * certificate and public key is imported using crypto_public_key_import().
318189251Ssam *
319189251Ssam * This function is only used with internal TLSv1 implementation
320189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
321189251Ssam * to implement this.
322189251Ssam */
323189251Ssamstruct crypto_public_key * crypto_public_key_from_cert(const u8 *buf,
324189251Ssam						       size_t len);
325189251Ssam
326189251Ssam/**
327189251Ssam * crypto_public_key_encrypt_pkcs1_v15 - Public key encryption (PKCS #1 v1.5)
328189251Ssam * @key: Public key
329189251Ssam * @in: Plaintext buffer
330189251Ssam * @inlen: Length of plaintext buffer in bytes
331189251Ssam * @out: Output buffer for encrypted data
332189251Ssam * @outlen: Length of output buffer in bytes; set to used length on success
333189251Ssam * Returns: 0 on success, -1 on failure
334189251Ssam *
335189251Ssam * This function is only used with internal TLSv1 implementation
336189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
337189251Ssam * to implement this.
338189251Ssam */
339189251Ssamint __must_check crypto_public_key_encrypt_pkcs1_v15(
340189251Ssam	struct crypto_public_key *key, const u8 *in, size_t inlen,
341189251Ssam	u8 *out, size_t *outlen);
342189251Ssam
343189251Ssam/**
344189251Ssam * crypto_private_key_decrypt_pkcs1_v15 - Private key decryption (PKCS #1 v1.5)
345189251Ssam * @key: Private key
346189251Ssam * @in: Encrypted buffer
347189251Ssam * @inlen: Length of encrypted buffer in bytes
348189251Ssam * @out: Output buffer for encrypted data
349189251Ssam * @outlen: Length of output buffer in bytes; set to used length on success
350189251Ssam * Returns: 0 on success, -1 on failure
351189251Ssam *
352189251Ssam * This function is only used with internal TLSv1 implementation
353189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
354189251Ssam * to implement this.
355189251Ssam */
356189251Ssamint __must_check crypto_private_key_decrypt_pkcs1_v15(
357189251Ssam	struct crypto_private_key *key, const u8 *in, size_t inlen,
358189251Ssam	u8 *out, size_t *outlen);
359189251Ssam
360189251Ssam/**
361189251Ssam * crypto_private_key_sign_pkcs1 - Sign with private key (PKCS #1)
362189251Ssam * @key: Private key from crypto_private_key_import()
363189251Ssam * @in: Plaintext buffer
364189251Ssam * @inlen: Length of plaintext buffer in bytes
365189251Ssam * @out: Output buffer for encrypted (signed) data
366189251Ssam * @outlen: Length of output buffer in bytes; set to used length on success
367189251Ssam * Returns: 0 on success, -1 on failure
368189251Ssam *
369189251Ssam * This function is only used with internal TLSv1 implementation
370189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
371189251Ssam * to implement this.
372189251Ssam */
373189251Ssamint __must_check crypto_private_key_sign_pkcs1(struct crypto_private_key *key,
374189251Ssam					       const u8 *in, size_t inlen,
375189251Ssam					       u8 *out, size_t *outlen);
376189251Ssam
377189251Ssam/**
378189251Ssam * crypto_public_key_free - Free public key
379189251Ssam * @key: Public key
380189251Ssam *
381189251Ssam * This function is only used with internal TLSv1 implementation
382189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
383189251Ssam * to implement this.
384189251Ssam */
385189251Ssamvoid crypto_public_key_free(struct crypto_public_key *key);
386189251Ssam
387189251Ssam/**
388189251Ssam * crypto_private_key_free - Free private key
389189251Ssam * @key: Private key from crypto_private_key_import()
390189251Ssam *
391189251Ssam * This function is only used with internal TLSv1 implementation
392189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
393189251Ssam * to implement this.
394189251Ssam */
395189251Ssamvoid crypto_private_key_free(struct crypto_private_key *key);
396189251Ssam
397189251Ssam/**
398189251Ssam * crypto_public_key_decrypt_pkcs1 - Decrypt PKCS #1 signature
399189251Ssam * @key: Public key
400189251Ssam * @crypt: Encrypted signature data (using the private key)
401189251Ssam * @crypt_len: Encrypted signature data length
402189251Ssam * @plain: Buffer for plaintext (at least crypt_len bytes)
403189251Ssam * @plain_len: Plaintext length (max buffer size on input, real len on output);
404189251Ssam * Returns: 0 on success, -1 on failure
405189251Ssam */
406189251Ssamint __must_check crypto_public_key_decrypt_pkcs1(
407189251Ssam	struct crypto_public_key *key, const u8 *crypt, size_t crypt_len,
408189251Ssam	u8 *plain, size_t *plain_len);
409189251Ssam
410189251Ssam/**
411189251Ssam * crypto_global_init - Initialize crypto wrapper
412189251Ssam *
413189251Ssam * This function is only used with internal TLSv1 implementation
414189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
415189251Ssam * to implement this.
416189251Ssam */
417189251Ssamint __must_check crypto_global_init(void);
418189251Ssam
419189251Ssam/**
420189251Ssam * crypto_global_deinit - Deinitialize crypto wrapper
421189251Ssam *
422189251Ssam * This function is only used with internal TLSv1 implementation
423189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
424189251Ssam * to implement this.
425189251Ssam */
426189251Ssamvoid crypto_global_deinit(void);
427189251Ssam
428189251Ssam/**
429189251Ssam * crypto_mod_exp - Modular exponentiation of large integers
430189251Ssam * @base: Base integer (big endian byte array)
431189251Ssam * @base_len: Length of base integer in bytes
432189251Ssam * @power: Power integer (big endian byte array)
433189251Ssam * @power_len: Length of power integer in bytes
434189251Ssam * @modulus: Modulus integer (big endian byte array)
435189251Ssam * @modulus_len: Length of modulus integer in bytes
436189251Ssam * @result: Buffer for the result
437189251Ssam * @result_len: Result length (max buffer size on input, real len on output)
438189251Ssam * Returns: 0 on success, -1 on failure
439189251Ssam *
440189251Ssam * This function calculates result = base ^ power mod modulus. modules_len is
441189251Ssam * used as the maximum size of modulus buffer. It is set to the used size on
442189251Ssam * success.
443189251Ssam *
444189251Ssam * This function is only used with internal TLSv1 implementation
445189251Ssam * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
446189251Ssam * to implement this.
447189251Ssam */
448189251Ssamint __must_check crypto_mod_exp(const u8 *base, size_t base_len,
449189251Ssam				const u8 *power, size_t power_len,
450189251Ssam				const u8 *modulus, size_t modulus_len,
451189251Ssam				u8 *result, size_t *result_len);
452189251Ssam
453189251Ssam/**
454189251Ssam * rc4_skip - XOR RC4 stream to given data with skip-stream-start
455189251Ssam * @key: RC4 key
456189251Ssam * @keylen: RC4 key length
457189251Ssam * @skip: number of bytes to skip from the beginning of the RC4 stream
458189251Ssam * @data: data to be XOR'ed with RC4 stream
459189251Ssam * @data_len: buf length
460189251Ssam * Returns: 0 on success, -1 on failure
461189251Ssam *
462189251Ssam * Generate RC4 pseudo random stream for the given key, skip beginning of the
463189251Ssam * stream, and XOR the end result with the data buffer to perform RC4
464189251Ssam * encryption/decryption.
465189251Ssam */
466189251Ssamint rc4_skip(const u8 *key, size_t keylen, size_t skip,
467189251Ssam	     u8 *data, size_t data_len);
468189251Ssam
469189251Ssam#endif /* CRYPTO_H */
470189251Ssam