Deleted Added
full compact
crypto.h (189261) crypto.h (214734)
1/*
2 * WPA Supplicant / wrapper functions for crypto libraries
1/*
2 * WPA Supplicant / wrapper functions for crypto libraries
3 * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
3 * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
11 *

--- 16 unchanged lines hidden (view full) ---

28#define CRYPTO_H
29
30/**
31 * md4_vector - MD4 hash for data vector
32 * @num_elem: Number of elements in the data vector
33 * @addr: Pointers to the data areas
34 * @len: Lengths of the data blocks
35 * @mac: Buffer for the hash
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
11 *

--- 16 unchanged lines hidden (view full) ---

28#define CRYPTO_H
29
30/**
31 * md4_vector - MD4 hash for data vector
32 * @num_elem: Number of elements in the data vector
33 * @addr: Pointers to the data areas
34 * @len: Lengths of the data blocks
35 * @mac: Buffer for the hash
36 * Returns: 0 on success, -1 on failure
36 */
37 */
37void md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
38int md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
38
39/**
40 * md5_vector - MD5 hash for data vector
41 * @num_elem: Number of elements in the data vector
42 * @addr: Pointers to the data areas
43 * @len: Lengths of the data blocks
44 * @mac: Buffer for the hash
39
40/**
41 * md5_vector - MD5 hash for data vector
42 * @num_elem: Number of elements in the data vector
43 * @addr: Pointers to the data areas
44 * @len: Lengths of the data blocks
45 * @mac: Buffer for the hash
46 * Returns: 0 on success, -1 on failure
45 */
47 */
46void md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
48int md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
47
49
50#ifdef CONFIG_FIPS
48/**
51/**
52 * md5_vector_non_fips_allow - MD5 hash for data vector (non-FIPS use allowed)
53 * @num_elem: Number of elements in the data vector
54 * @addr: Pointers to the data areas
55 * @len: Lengths of the data blocks
56 * @mac: Buffer for the hash
57 * Returns: 0 on success, -1 on failure
58 */
59int md5_vector_non_fips_allow(size_t num_elem, const u8 *addr[],
60 const size_t *len, u8 *mac);
61#else /* CONFIG_FIPS */
62#define md5_vector_non_fips_allow md5_vector
63#endif /* CONFIG_FIPS */
64
65
66/**
49 * sha1_vector - SHA-1 hash for data vector
50 * @num_elem: Number of elements in the data vector
51 * @addr: Pointers to the data areas
52 * @len: Lengths of the data blocks
53 * @mac: Buffer for the hash
67 * sha1_vector - SHA-1 hash for data vector
68 * @num_elem: Number of elements in the data vector
69 * @addr: Pointers to the data areas
70 * @len: Lengths of the data blocks
71 * @mac: Buffer for the hash
72 * Returns: 0 on success, -1 on failure
54 */
73 */
55void sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len,
56 u8 *mac);
74int sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len,
75 u8 *mac);
57
58/**
59 * fips186_2-prf - NIST FIPS Publication 186-2 change notice 1 PRF
60 * @seed: Seed/key for the PRF
61 * @seed_len: Seed length in bytes
62 * @x: Buffer for PRF output
63 * @xlen: Output length in bytes
64 * Returns: 0 on success, -1 on failure

--- 6 unchanged lines hidden (view full) ---

71 size_t xlen);
72
73/**
74 * sha256_vector - SHA256 hash for data vector
75 * @num_elem: Number of elements in the data vector
76 * @addr: Pointers to the data areas
77 * @len: Lengths of the data blocks
78 * @mac: Buffer for the hash
76
77/**
78 * fips186_2-prf - NIST FIPS Publication 186-2 change notice 1 PRF
79 * @seed: Seed/key for the PRF
80 * @seed_len: Seed length in bytes
81 * @x: Buffer for PRF output
82 * @xlen: Output length in bytes
83 * Returns: 0 on success, -1 on failure

--- 6 unchanged lines hidden (view full) ---

90 size_t xlen);
91
92/**
93 * sha256_vector - SHA256 hash for data vector
94 * @num_elem: Number of elements in the data vector
95 * @addr: Pointers to the data areas
96 * @len: Lengths of the data blocks
97 * @mac: Buffer for the hash
98 * Returns: 0 on success, -1 on failure
79 */
99 */
80void sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
81 u8 *mac);
100int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
101 u8 *mac);
82
83/**
84 * des_encrypt - Encrypt one block with DES
85 * @clear: 8 octets (in)
86 * @key: 7 octets (in) (no parity bits included)
87 * @cypher: 8 octets (out)
88 */
89void des_encrypt(const u8 *clear, const u8 *key, u8 *cypher);

--- 180 unchanged lines hidden (view full) ---

270 * to implement this.
271 */
272struct crypto_public_key * crypto_public_key_import(const u8 *key, size_t len);
273
274/**
275 * crypto_private_key_import - Import an RSA private key
276 * @key: Key buffer (DER encoded RSA private key)
277 * @len: Key buffer length in bytes
102
103/**
104 * des_encrypt - Encrypt one block with DES
105 * @clear: 8 octets (in)
106 * @key: 7 octets (in) (no parity bits included)
107 * @cypher: 8 octets (out)
108 */
109void des_encrypt(const u8 *clear, const u8 *key, u8 *cypher);

--- 180 unchanged lines hidden (view full) ---

290 * to implement this.
291 */
292struct crypto_public_key * crypto_public_key_import(const u8 *key, size_t len);
293
294/**
295 * crypto_private_key_import - Import an RSA private key
296 * @key: Key buffer (DER encoded RSA private key)
297 * @len: Key buffer length in bytes
298 * @passwd: Key encryption password or %NULL if key is not encrypted
278 * Returns: Pointer to the private key or %NULL on failure
279 *
280 * This function is only used with internal TLSv1 implementation
281 * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
282 * to implement this.
283 */
284struct crypto_private_key * crypto_private_key_import(const u8 *key,
299 * Returns: Pointer to the private key or %NULL on failure
300 *
301 * This function is only used with internal TLSv1 implementation
302 * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
303 * to implement this.
304 */
305struct crypto_private_key * crypto_private_key_import(const u8 *key,
285 size_t len);
306 size_t len,
307 const char *passwd);
286
287/**
288 * crypto_public_key_from_cert - Import an RSA public key from a certificate
289 * @buf: DER encoded X.509 certificate
290 * @len: Certificate buffer length in bytes
291 * Returns: Pointer to public key or %NULL on failure
292 *
293 * This function can just return %NULL if the crypto library does not support

--- 129 unchanged lines hidden (view full) ---

423 * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
424 * to implement this.
425 */
426int __must_check crypto_mod_exp(const u8 *base, size_t base_len,
427 const u8 *power, size_t power_len,
428 const u8 *modulus, size_t modulus_len,
429 u8 *result, size_t *result_len);
430
308
309/**
310 * crypto_public_key_from_cert - Import an RSA public key from a certificate
311 * @buf: DER encoded X.509 certificate
312 * @len: Certificate buffer length in bytes
313 * Returns: Pointer to public key or %NULL on failure
314 *
315 * This function can just return %NULL if the crypto library does not support

--- 129 unchanged lines hidden (view full) ---

445 * (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need
446 * to implement this.
447 */
448int __must_check crypto_mod_exp(const u8 *base, size_t base_len,
449 const u8 *power, size_t power_len,
450 const u8 *modulus, size_t modulus_len,
451 u8 *result, size_t *result_len);
452
453/**
454 * rc4_skip - XOR RC4 stream to given data with skip-stream-start
455 * @key: RC4 key
456 * @keylen: RC4 key length
457 * @skip: number of bytes to skip from the beginning of the RC4 stream
458 * @data: data to be XOR'ed with RC4 stream
459 * @data_len: buf length
460 * Returns: 0 on success, -1 on failure
461 *
462 * Generate RC4 pseudo random stream for the given key, skip beginning of the
463 * stream, and XOR the end result with the data buffer to perform RC4
464 * encryption/decryption.
465 */
466int rc4_skip(const u8 *key, size_t keylen, size_t skip,
467 u8 *data, size_t data_len);
468
431#endif /* CRYPTO_H */
469#endif /* CRYPTO_H */