003 File Manager
Current Path:
/usr/src/contrib/wpa/src/crypto
usr
/
src
/
contrib
/
wpa
/
src
/
crypto
/
📁
..
📄
aes-cbc.c
(1.93 KB)
📄
aes-ccm.c
(4.92 KB)
📄
aes-ctr.c
(1.64 KB)
📄
aes-eax.c
(3.24 KB)
📄
aes-encblock.c
(704 B)
📄
aes-gcm.c
(6.47 KB)
📄
aes-internal-dec.c
(3.64 KB)
📄
aes-internal-enc.c
(2.66 KB)
📄
aes-internal.c
(41.23 KB)
📄
aes-omac1.c
(4.46 KB)
📄
aes-siv.c
(4.06 KB)
📄
aes-unwrap.c
(1.78 KB)
📄
aes-wrap.c
(1.62 KB)
📄
aes.h
(548 B)
📄
aes_i.h
(4.16 KB)
📄
aes_siv.h
(565 B)
📄
aes_wrap.h
(2.91 KB)
📄
crypto.h
(28.61 KB)
📄
crypto_gnutls.c
(11.42 KB)
📄
crypto_internal-cipher.c
(5.08 KB)
📄
crypto_internal-modexp.c
(2.95 KB)
📄
crypto_internal-rsa.c
(2.81 KB)
📄
crypto_internal.c
(6.84 KB)
📄
crypto_libtomcrypt.c
(15.07 KB)
📄
crypto_linux.c
(21.77 KB)
📄
crypto_module_tests.c
(61.19 KB)
📄
crypto_nettle.c
(9.7 KB)
📄
crypto_none.c
(461 B)
📄
crypto_openssl.c
(44.34 KB)
📄
crypto_wolfssl.c
(33.91 KB)
📄
des-internal.c
(14.83 KB)
📄
des_i.h
(709 B)
📄
dh_group5.c
(806 B)
📄
dh_group5.h
(556 B)
📄
dh_groups.c
(54.26 KB)
📄
dh_groups.h
(692 B)
📄
fips_prf_internal.c
(1.37 KB)
📄
fips_prf_openssl.c
(2.05 KB)
📄
fips_prf_wolfssl.c
(1.75 KB)
📄
md4-internal.c
(7.91 KB)
📄
md5-internal.c
(8.79 KB)
📄
md5.c
(2.64 KB)
📄
md5.h
(505 B)
📄
md5_i.h
(516 B)
📄
milenage.c
(9.5 KB)
📄
milenage.h
(1019 B)
📄
ms_funcs.c
(16.16 KB)
📄
ms_funcs.h
(2.41 KB)
📄
random.c
(11.66 KB)
📄
random.h
(855 B)
📄
rc4.c
(1009 B)
📄
sha1-internal.c
(8.93 KB)
📄
sha1-pbkdf2.c
(2.34 KB)
📄
sha1-prf.c
(1.58 KB)
📄
sha1-tlsprf.c
(2.69 KB)
📄
sha1-tprf.c
(1.75 KB)
📄
sha1.c
(2.69 KB)
📄
sha1.h
(1.03 KB)
📄
sha1_i.h
(590 B)
📄
sha256-internal.c
(6 KB)
📄
sha256-kdf.c
(2.08 KB)
📄
sha256-prf.c
(2.84 KB)
📄
sha256-tlsprf.c
(1.81 KB)
📄
sha256.c
(2.64 KB)
📄
sha256.h
(1.07 KB)
📄
sha256_i.h
(584 B)
📄
sha384-internal.c
(2.17 KB)
📄
sha384-kdf.c
(2.08 KB)
📄
sha384-prf.c
(2.85 KB)
📄
sha384.c
(2.63 KB)
📄
sha384.h
(949 B)
📄
sha384_i.h
(573 B)
📄
sha512-internal.c
(7.71 KB)
📄
sha512-kdf.c
(2.08 KB)
📄
sha512-prf.c
(2.85 KB)
📄
sha512.c
(2.63 KB)
📄
sha512.h
(949 B)
📄
sha512_i.h
(591 B)
📄
tls.h
(23.71 KB)
📄
tls_gnutls.c
(44.97 KB)
📄
tls_internal.c
(18.93 KB)
📄
tls_none.c
(3.9 KB)
📄
tls_openssl.c
(137.99 KB)
📄
tls_openssl.h
(477 B)
📄
tls_openssl_ocsp.c
(20.52 KB)
📄
tls_wolfssl.c
(51.88 KB)
Editing: crypto_internal-modexp.c
/* * Crypto wrapper for internal crypto implementation - modexp * Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi> * * This software may be distributed under the terms of the BSD license. * See README for more details. */ #include "includes.h" #include "common.h" #include "tls/bignum.h" #include "crypto.h" int crypto_dh_init(u8 generator, const u8 *prime, size_t prime_len, u8 *privkey, u8 *pubkey) { size_t pubkey_len, pad; if (os_get_random(privkey, prime_len) < 0) return -1; if (os_memcmp(privkey, prime, prime_len) > 0) { /* Make sure private value is smaller than prime */ privkey[0] = 0; } pubkey_len = prime_len; if (crypto_mod_exp(&generator, 1, privkey, prime_len, prime, prime_len, pubkey, &pubkey_len) < 0) return -1; if (pubkey_len < prime_len) { pad = prime_len - pubkey_len; os_memmove(pubkey + pad, pubkey, pubkey_len); os_memset(pubkey, 0, pad); } return 0; } int crypto_dh_derive_secret(u8 generator, const u8 *prime, size_t prime_len, const u8 *order, size_t order_len, const u8 *privkey, size_t privkey_len, const u8 *pubkey, size_t pubkey_len, u8 *secret, size_t *len) { struct bignum *pub; int res = -1; if (pubkey_len > prime_len || (pubkey_len == prime_len && os_memcmp(pubkey, prime, prime_len) >= 0)) return -1; pub = bignum_init(); if (!pub || bignum_set_unsigned_bin(pub, pubkey, pubkey_len) < 0 || bignum_cmp_d(pub, 1) <= 0) goto fail; if (order) { struct bignum *p, *q, *tmp; int failed; /* verify: pubkey^q == 1 mod p */ p = bignum_init(); q = bignum_init(); tmp = bignum_init(); failed = !p || !q || !tmp || bignum_set_unsigned_bin(p, prime, prime_len) < 0 || bignum_set_unsigned_bin(q, order, order_len) < 0 || bignum_exptmod(pub, q, p, tmp) < 0 || bignum_cmp_d(tmp, 1) != 0; bignum_deinit(p); bignum_deinit(q); bignum_deinit(tmp); if (failed) goto fail; } res = crypto_mod_exp(pubkey, pubkey_len, privkey, privkey_len, prime, prime_len, secret, len); fail: bignum_deinit(pub); return res; } int crypto_mod_exp(const u8 *base, size_t base_len, const u8 *power, size_t power_len, const u8 *modulus, size_t modulus_len, u8 *result, size_t *result_len) { struct bignum *bn_base, *bn_exp, *bn_modulus, *bn_result; int ret = -1; bn_base = bignum_init(); bn_exp = bignum_init(); bn_modulus = bignum_init(); bn_result = bignum_init(); if (bn_base == NULL || bn_exp == NULL || bn_modulus == NULL || bn_result == NULL) goto error; if (bignum_set_unsigned_bin(bn_base, base, base_len) < 0 || bignum_set_unsigned_bin(bn_exp, power, power_len) < 0 || bignum_set_unsigned_bin(bn_modulus, modulus, modulus_len) < 0) goto error; if (bignum_exptmod(bn_base, bn_exp, bn_modulus, bn_result) < 0) goto error; ret = bignum_get_unsigned_bin(bn_result, result, result_len); error: bignum_deinit(bn_base); bignum_deinit(bn_exp); bignum_deinit(bn_modulus); bignum_deinit(bn_result); return ret; }
Upload File
Create Folder