DPP: Move crypto routines into a separate source code file
This is an initial step in splitting the overly long dpp.c into smaller pieces. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
parent
6eb03715e3
commit
87b6572616
8 changed files with 2662 additions and 2548 deletions
|
@ -537,6 +537,7 @@ endif
|
||||||
ifdef CONFIG_DPP
|
ifdef CONFIG_DPP
|
||||||
L_CFLAGS += -DCONFIG_DPP
|
L_CFLAGS += -DCONFIG_DPP
|
||||||
OBJS += src/common/dpp.c
|
OBJS += src/common/dpp.c
|
||||||
|
OBJS += src/common/dpp_crypto.c
|
||||||
OBJS += src/ap/dpp_hostapd.c
|
OBJS += src/ap/dpp_hostapd.c
|
||||||
OBJS += src/ap/gas_query_ap.c
|
OBJS += src/ap/gas_query_ap.c
|
||||||
NEED_AES_SIV=y
|
NEED_AES_SIV=y
|
||||||
|
|
|
@ -568,6 +568,7 @@ endif
|
||||||
ifdef CONFIG_DPP
|
ifdef CONFIG_DPP
|
||||||
CFLAGS += -DCONFIG_DPP
|
CFLAGS += -DCONFIG_DPP
|
||||||
OBJS += ../src/common/dpp.o
|
OBJS += ../src/common/dpp.o
|
||||||
|
OBJS += ../src/common/dpp_crypto.o
|
||||||
OBJS += ../src/ap/dpp_hostapd.o
|
OBJS += ../src/ap/dpp_hostapd.o
|
||||||
OBJS += ../src/ap/gas_query_ap.o
|
OBJS += ../src/ap/gas_query_ap.o
|
||||||
NEED_AES_SIV=y
|
NEED_AES_SIV=y
|
||||||
|
|
2563
src/common/dpp.c
2563
src/common/dpp.c
File diff suppressed because it is too large
Load diff
2551
src/common/dpp_crypto.c
Normal file
2551
src/common/dpp_crypto.c
Normal file
File diff suppressed because it is too large
Load diff
91
src/common/dpp_i.h
Normal file
91
src/common/dpp_i.h
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* DPP module internal definitions
|
||||||
|
* Copyright (c) 2017, Qualcomm Atheros, Inc.
|
||||||
|
* Copyright (c) 2018-2020, The Linux Foundation
|
||||||
|
*
|
||||||
|
* This software may be distributed under the terms of the BSD license.
|
||||||
|
* See README for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DPP_I_H
|
||||||
|
#define DPP_I_H
|
||||||
|
|
||||||
|
#ifdef CONFIG_DPP
|
||||||
|
|
||||||
|
/* dpp_crypto.c */
|
||||||
|
|
||||||
|
struct dpp_signed_connector_info {
|
||||||
|
unsigned char *payload;
|
||||||
|
size_t payload_len;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum dpp_status_error
|
||||||
|
dpp_process_signed_connector(struct dpp_signed_connector_info *info,
|
||||||
|
EVP_PKEY *csign_pub, const char *connector);
|
||||||
|
const struct dpp_curve_params * dpp_get_curve_name(const char *name);
|
||||||
|
const struct dpp_curve_params * dpp_get_curve_jwk_crv(const char *name);
|
||||||
|
const struct dpp_curve_params * dpp_get_curve_oid(const ASN1_OBJECT *poid);
|
||||||
|
const struct dpp_curve_params * dpp_get_curve_nid(int nid);
|
||||||
|
int dpp_bi_pubkey_hash(struct dpp_bootstrap_info *bi,
|
||||||
|
const u8 *data, size_t data_len);
|
||||||
|
struct wpabuf * dpp_get_pubkey_point(EVP_PKEY *pkey, int prefix);
|
||||||
|
EVP_PKEY * dpp_set_pubkey_point_group(const EC_GROUP *group,
|
||||||
|
const u8 *buf_x, const u8 *buf_y,
|
||||||
|
size_t len);
|
||||||
|
EVP_PKEY * dpp_set_pubkey_point(EVP_PKEY *group_key, const u8 *buf, size_t len);
|
||||||
|
int dpp_bn2bin_pad(const BIGNUM *bn, u8 *pos, size_t len);
|
||||||
|
int dpp_hash_vector(const struct dpp_curve_params *curve, size_t num_elem,
|
||||||
|
const u8 *addr[], const size_t *len, u8 *mac);
|
||||||
|
int dpp_hkdf_expand(size_t hash_len, const u8 *secret, size_t secret_len,
|
||||||
|
const char *label, u8 *out, size_t outlen);
|
||||||
|
int dpp_hmac(size_t hash_len, const u8 *key, size_t key_len,
|
||||||
|
const u8 *data, size_t data_len, u8 *mac);
|
||||||
|
int dpp_hmac_vector(size_t hash_len, const u8 *key, size_t key_len,
|
||||||
|
size_t num_elem, const u8 *addr[], const size_t *len,
|
||||||
|
u8 *mac);
|
||||||
|
int dpp_ecdh(EVP_PKEY *own, EVP_PKEY *peer, u8 *secret, size_t *secret_len);
|
||||||
|
void dpp_debug_print_point(const char *title, const EC_GROUP *group,
|
||||||
|
const EC_POINT *point);
|
||||||
|
void dpp_debug_print_key(const char *title, EVP_PKEY *key);
|
||||||
|
int dpp_pbkdf2(size_t hash_len, const u8 *password, size_t password_len,
|
||||||
|
const u8 *salt, size_t salt_len, unsigned int iterations,
|
||||||
|
u8 *buf, size_t buflen);
|
||||||
|
int dpp_get_subject_public_key(struct dpp_bootstrap_info *bi,
|
||||||
|
const u8 *data, size_t data_len);
|
||||||
|
int dpp_bootstrap_key_hash(struct dpp_bootstrap_info *bi);
|
||||||
|
int dpp_keygen(struct dpp_bootstrap_info *bi, const char *curve,
|
||||||
|
const u8 *privkey, size_t privkey_len);
|
||||||
|
EVP_PKEY * dpp_set_keypair(const struct dpp_curve_params **curve,
|
||||||
|
const u8 *privkey, size_t privkey_len);
|
||||||
|
EVP_PKEY * dpp_gen_keypair(const struct dpp_curve_params *curve);
|
||||||
|
int dpp_derive_k1(const u8 *Mx, size_t Mx_len, u8 *k1, unsigned int hash_len);
|
||||||
|
int dpp_derive_k2(const u8 *Nx, size_t Nx_len, u8 *k2, unsigned int hash_len);
|
||||||
|
int dpp_derive_bk_ke(struct dpp_authentication *auth);
|
||||||
|
int dpp_gen_r_auth(struct dpp_authentication *auth, u8 *r_auth);
|
||||||
|
int dpp_gen_i_auth(struct dpp_authentication *auth, u8 *i_auth);
|
||||||
|
int dpp_auth_derive_l_responder(struct dpp_authentication *auth);
|
||||||
|
int dpp_auth_derive_l_initiator(struct dpp_authentication *auth);
|
||||||
|
int dpp_derive_pmk(const u8 *Nx, size_t Nx_len, u8 *pmk, unsigned int hash_len);
|
||||||
|
int dpp_derive_pmkid(const struct dpp_curve_params *curve,
|
||||||
|
EVP_PKEY *own_key, EVP_PKEY *peer_key, u8 *pmkid);
|
||||||
|
EC_POINT * dpp_pkex_derive_Qi(const struct dpp_curve_params *curve,
|
||||||
|
const u8 *mac_init, const char *code,
|
||||||
|
const char *identifier, BN_CTX *bnctx,
|
||||||
|
EC_GROUP **ret_group);
|
||||||
|
EC_POINT * dpp_pkex_derive_Qr(const struct dpp_curve_params *curve,
|
||||||
|
const u8 *mac_resp, const char *code,
|
||||||
|
const char *identifier, BN_CTX *bnctx,
|
||||||
|
EC_GROUP **ret_group);
|
||||||
|
int dpp_pkex_derive_z(const u8 *mac_init, const u8 *mac_resp,
|
||||||
|
const u8 *Mx, size_t Mx_len,
|
||||||
|
const u8 *Nx, size_t Nx_len,
|
||||||
|
const char *code,
|
||||||
|
const u8 *Kx, size_t Kx_len,
|
||||||
|
u8 *z, unsigned int hash_len);
|
||||||
|
char * dpp_sign_connector(struct dpp_configurator *conf,
|
||||||
|
const struct wpabuf *dppcon);
|
||||||
|
int dpp_test_gen_invalid_key(struct wpabuf *msg,
|
||||||
|
const struct dpp_curve_params *curve);
|
||||||
|
|
||||||
|
#endif /* CONFIG_DPP */
|
||||||
|
#endif /* DPP_I_H */
|
|
@ -21,6 +21,7 @@ OBJS += $(SRC)/crypto/sha384-kdf.o
|
||||||
OBJS += $(SRC)/crypto/sha512-kdf.o
|
OBJS += $(SRC)/crypto/sha512-kdf.o
|
||||||
OBJS += $(SRC)/tls/asn1.o
|
OBJS += $(SRC)/tls/asn1.o
|
||||||
OBJS += $(SRC)/common/dpp.o
|
OBJS += $(SRC)/common/dpp.o
|
||||||
|
OBJS += $(SRC)/common/dpp_crypto.o
|
||||||
|
|
||||||
dpp-uri: dpp-uri.o $(OBJS) $(LIBS)
|
dpp-uri: dpp-uri.o $(OBJS) $(LIBS)
|
||||||
$(LDO) $(LDFLAGS) -o $@ $^ -lcrypto
|
$(LDO) $(LDFLAGS) -o $@ $^ -lcrypto
|
||||||
|
|
|
@ -247,6 +247,7 @@ endif
|
||||||
ifdef CONFIG_DPP
|
ifdef CONFIG_DPP
|
||||||
L_CFLAGS += -DCONFIG_DPP
|
L_CFLAGS += -DCONFIG_DPP
|
||||||
OBJS += src/common/dpp.c
|
OBJS += src/common/dpp.c
|
||||||
|
OBJS += src/common/dpp_crypto.c
|
||||||
OBJS += dpp_supplicant.c
|
OBJS += dpp_supplicant.c
|
||||||
NEED_AES_SIV=y
|
NEED_AES_SIV=y
|
||||||
NEED_HMAC_SHA256_KDF=y
|
NEED_HMAC_SHA256_KDF=y
|
||||||
|
|
|
@ -279,6 +279,7 @@ endif
|
||||||
ifdef CONFIG_DPP
|
ifdef CONFIG_DPP
|
||||||
CFLAGS += -DCONFIG_DPP
|
CFLAGS += -DCONFIG_DPP
|
||||||
OBJS += ../src/common/dpp.o
|
OBJS += ../src/common/dpp.o
|
||||||
|
OBJS += ../src/common/dpp_crypto.o
|
||||||
OBJS += dpp_supplicant.o
|
OBJS += dpp_supplicant.o
|
||||||
NEED_AES_SIV=y
|
NEED_AES_SIV=y
|
||||||
NEED_HMAC_SHA256_KDF=y
|
NEED_HMAC_SHA256_KDF=y
|
||||||
|
|
Loading…
Reference in a new issue