这篇教程C++ wpabuf_mhead函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wpabuf_mhead函数的典型用法代码示例。如果您正苦于以下问题:C++ wpabuf_mhead函数的具体用法?C++ wpabuf_mhead怎么用?C++ wpabuf_mhead使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wpabuf_mhead函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: eap_sim_msg_finishstruct wpabuf * eap_sim_msg_finish(struct eap_sim_msg *msg, const u8 *k_aut, const u8 *extra, size_t extra_len){ struct eap_hdr *eap; struct wpabuf *buf; if (msg == NULL) return NULL; eap = wpabuf_mhead(msg->buf); eap->length = host_to_be16(wpabuf_len(msg->buf));#if defined(EAP_AKA_PRIME) || defined(EAP_SERVER_AKA_PRIME) if (k_aut && msg->mac && msg->type == EAP_TYPE_AKA_PRIME) { eap_sim_add_mac_sha256(k_aut, (u8 *) wpabuf_head(msg->buf), wpabuf_len(msg->buf), (u8 *) wpabuf_mhead(msg->buf) + msg->mac, extra, extra_len); } else#endif /* EAP_AKA_PRIME || EAP_SERVER_AKA_PRIME */ if (k_aut && msg->mac) { eap_sim_add_mac(k_aut, (u8 *) wpabuf_head(msg->buf), wpabuf_len(msg->buf), (u8 *) wpabuf_mhead(msg->buf) + msg->mac, extra, extra_len); } buf = msg->buf; os_free(msg); return buf;}
开发者ID:sevennothing,项目名称:lros,代码行数:31,
示例2: dh_derive_shared/** * dh_derive_shared - Derive shared Diffie-Hellman key * @peer_public: Diffie-Hellman public value from peer * @own_private: Diffie-Hellman private key from dh_init() * @dh: Selected Diffie-Hellman group * Returns: Diffie-Hellman shared key */struct wpabuf * dh_derive_shared(const struct wpabuf *peer_public, const struct wpabuf *own_private, const struct dh_group *dh){ struct wpabuf *shared; size_t shared_len; if (dh == NULL || peer_public == NULL || own_private == NULL) return NULL; shared_len = dh->prime_len; shared = wpabuf_alloc(shared_len); if (shared == NULL) return NULL; if (crypto_mod_exp(wpabuf_head(peer_public), wpabuf_len(peer_public), wpabuf_head(own_private), wpabuf_len(own_private), dh->prime, dh->prime_len, wpabuf_mhead(shared), &shared_len) < 0) { wpabuf_free(shared); wpa_printf(MSG_INFO, "DH: crypto_mod_exp failed"); return NULL; } wpabuf_put(shared, shared_len); wpa_hexdump_buf_key(MSG_DEBUG, "DH: shared key", shared); return shared;}
开发者ID:ArnoNuehm,项目名称:reaver-script,代码行数:34,
示例3: eap_fast_encrypt_phase2static int eap_fast_encrypt_phase2(struct eap_sm *sm, struct eap_fast_data *data, struct wpabuf *plain, int piggyback){ struct wpabuf *encr; wpa_hexdump_buf_key(MSG_DEBUG, "EAP-FAST: Encrypting Phase 2 TLVs", plain); encr = eap_server_tls_encrypt(sm, &data->ssl, wpabuf_mhead(plain), wpabuf_len(plain)); wpabuf_free(plain); if (data->ssl.out_buf && piggyback) { wpa_printf(MSG_DEBUG, "EAP-FAST: Piggyback Phase 2 data " "(len=%d) with last Phase 1 Message (len=%d " "used=%d)", (int) wpabuf_len(encr), (int) wpabuf_len(data->ssl.out_buf), (int) data->ssl.out_used); if (wpabuf_resize(&data->ssl.out_buf, wpabuf_len(encr)) < 0) { wpa_printf(MSG_WARNING, "EAP-FAST: Failed to resize " "output buffer"); wpabuf_free(encr); return -1; } wpabuf_put_buf(data->ssl.out_buf, encr); wpabuf_free(encr); } else { wpabuf_free(data->ssl.out_buf); data->ssl.out_used = 0; data->ssl.out_buf = encr; } return 0;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:35,
示例4: ndef_build_wifistruct wpabuf * ndef_build_wifi(struct wpabuf *buf){ return ndef_build_record(FLAG_MESSAGE_BEGIN | FLAG_MESSAGE_END | FLAG_TNF_RFC2046, wifi_handover_type, os_strlen(wifi_handover_type), NULL, 0, wpabuf_mhead(buf), wpabuf_len(buf));}
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:7,
示例5: read_ufdstatic struct wpabuf * read_ufd(void *priv){ struct wps_ufd_data *data = priv; struct wpabuf *buf; struct stat s; size_t file_size; if (fstat(data->ufd_fd, &s) < 0) { wpa_printf(MSG_ERROR, "WPS (UFD): Failed to get file size"); return NULL; } file_size = s.st_size; buf = wpabuf_alloc(file_size); if (buf == NULL) { wpa_printf(MSG_ERROR, "WPS (UFD): Failed to alloc read " "buffer"); return NULL; } if (read(data->ufd_fd, wpabuf_mhead(buf), file_size) != (int) file_size) { wpabuf_free(buf); wpa_printf(MSG_ERROR, "WPS (UFD): Failed to read"); return NULL; } wpabuf_put(buf, file_size); return buf;}
开发者ID:TeamNyx,项目名称:external_wpa_supplicant_8,代码行数:29,
示例6: wpabuf_clear_freevoid wpabuf_clear_free(struct wpabuf *buf){ if (buf) { os_memset(wpabuf_mhead(buf), 0, wpabuf_len(buf)); wpabuf_free(buf); }}
开发者ID:RTEMS,项目名称:rtems-libbsd,代码行数:7,
示例7: printfstruct radius_attr_hdr *radius_msg_add_attr(struct radius_msg *msg, u8 type, const u8 *data, size_t data_len){ size_t buf_needed; struct radius_attr_hdr *attr; if (data_len > RADIUS_MAX_ATTR_LEN) { printf("radius_msg_add_attr: too long attribute (%lu bytes)/n", (unsigned long) data_len); return NULL; } buf_needed = sizeof(*attr) + data_len; if (wpabuf_tailroom(msg->buf) < buf_needed) { /* allocate more space for message buffer */ if (wpabuf_resize(&msg->buf, buf_needed) < 0) return NULL; msg->hdr = wpabuf_mhead(msg->buf); } attr = wpabuf_put(msg->buf, sizeof(struct radius_attr_hdr)); attr->type = type; attr->length = sizeof(*attr) + data_len; wpabuf_put_data(msg->buf, data, data_len); if (radius_msg_add_attr_to_array(msg, attr)) return NULL; return attr;}
开发者ID:sevennothing,项目名称:lros,代码行数:31,
示例8: gnutls_get_appl_datastatic struct wpabuf * gnutls_get_appl_data(struct tls_connection *conn){ int res; struct wpabuf *ad; wpa_printf(MSG_DEBUG, "GnuTLS: Check for possible Application Data"); ad = wpabuf_alloc((wpabuf_len(conn->pull_buf) + 500) * 3); if (ad == NULL) return NULL; res = gnutls_record_recv(conn->session, wpabuf_mhead(ad), wpabuf_size(ad)); wpa_printf(MSG_DEBUG, "GnuTLS: gnutls_record_recv: %d", res); if (res < 0) { wpa_printf(MSG_DEBUG, "%s - gnutls_record_recv failed: %d " "(%s)", __func__, (int) res, gnutls_strerror(res)); wpabuf_free(ad); return NULL; } wpabuf_put(ad, res); wpa_printf(MSG_DEBUG, "GnuTLS: Received %d bytes of Application Data", res); return ad;}
开发者ID:samm-git,项目名称:e3372h-vendor-src,代码行数:25,
示例9: eap_update_lenvoid eap_update_len(struct wpabuf *msg){ struct eap_hdr *hdr; hdr = wpabuf_mhead(msg); if (wpabuf_len(msg) < sizeof(*hdr)) return; hdr->length = host_to_be16(wpabuf_len(msg));}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:8,
示例10: ikev2_update_hdrvoid ikev2_update_hdr(struct wpabuf *msg){ struct ikev2_hdr *hdr; /* Update lenth field in HDR */ hdr = wpabuf_mhead(msg); WPA_PUT_BE32(hdr->length, wpabuf_len(msg));}
开发者ID:yhpan0613,项目名称:hostap,代码行数:8,
示例11: tls_connection_encryptstruct wpabuf * tls_connection_encrypt(void *tls_ctx, struct tls_connection *conn, const struct wpabuf *in_data){#ifdef CONFIG_TLS_INTERNAL_CLIENT if (conn->client) { struct wpabuf *buf; int res; buf = wpabuf_alloc(wpabuf_len(in_data) + 300); if (buf == NULL) return NULL; res = tlsv1_client_encrypt(conn->client, wpabuf_head(in_data), wpabuf_len(in_data), wpabuf_mhead(buf), wpabuf_size(buf)); if (res < 0) { wpabuf_free(buf); return NULL; } wpabuf_put(buf, res); return buf; }#endif /* CONFIG_TLS_INTERNAL_CLIENT */#ifdef CONFIG_TLS_INTERNAL_SERVER if (conn->server) { struct wpabuf *buf; int res; buf = wpabuf_alloc(wpabuf_len(in_data) + 300); if (buf == NULL) return NULL; res = tlsv1_server_encrypt(conn->server, wpabuf_head(in_data), wpabuf_len(in_data), wpabuf_mhead(buf), wpabuf_size(buf)); if (res < 0) { wpabuf_free(buf); return NULL; } wpabuf_put(buf, res); return buf; }#endif /* CONFIG_TLS_INTERNAL_SERVER */ return NULL;}
开发者ID:2asoft,项目名称:freebsd,代码行数:44,
示例12: dh_init/** * dh_init - Initialize Diffie-Hellman handshake * @dh: Selected Diffie-Hellman group * @priv: Pointer for returning Diffie-Hellman private key * Returns: Diffie-Hellman public value */struct wpabuf * dh_init(const struct dh_group *dh, struct wpabuf **priv){ struct wpabuf *pv; size_t pv_len; int retval = 1; if (dh == NULL) return NULL; wpabuf_free(*priv); *priv = wpabuf_alloc(dh->prime_len); if (*priv == NULL) return NULL; if(get_dh_small()) { /* Use small DH secret (1) to reduce calculation time on AP */ if(!memset(wpabuf_put(*priv, 1), 1, 1)) retval = 0; } else { if(os_get_random(wpabuf_put(*priv, dh->prime_len), dh->prime_len)) retval = 0; } if(!retval) { wpabuf_free(*priv); *priv = NULL; return NULL; } if (os_memcmp(wpabuf_head(*priv), dh->prime, dh->prime_len) > 0) { /* Make sure private value is smaller than prime */ *(wpabuf_mhead_u8(*priv)) = 0; } wpa_hexdump_buf_key(/*MSG_INFO*/ MSG_DEBUG, "DH: private value", *priv); pv_len = dh->prime_len; pv = wpabuf_alloc(pv_len); if (pv == NULL) return NULL; if (crypto_mod_exp(dh->generator, dh->generator_len, wpabuf_head(*priv), wpabuf_len(*priv), dh->prime, dh->prime_len, wpabuf_mhead(pv), &pv_len) < 0) { wpabuf_free(pv); wpa_printf(MSG_INFO, "DH: crypto_mod_exp failed"); return NULL; } wpabuf_put(pv, pv_len); wpa_hexdump_buf(MSG_DEBUG, "DH: public value", pv); return pv;}
开发者ID:ArnoNuehm,项目名称:reaver-script,代码行数:62,
示例13: write_ufdstatic int write_ufd(void *priv, struct wpabuf *buf){ struct wps_ufd_data *data = priv; if (write(data->ufd_fd, wpabuf_mhead(buf), wpabuf_len(buf)) != (int) wpabuf_len(buf)) { wpa_printf(MSG_ERROR, "WPS (UFD): Failed to write"); return -1; } return 0;}
开发者ID:TeamNyx,项目名称:external_wpa_supplicant_8,代码行数:11,
示例14: ext_password_freevoid ext_password_free(struct wpabuf *pw){ if (pw == NULL) { return; } os_memset(wpabuf_mhead(pw), 0, wpabuf_len(pw));#ifdef __linux__ if (munlock(wpabuf_head(pw), wpabuf_len(pw)) < 0) { wpa_printf(MSG_ERROR, "EXT PW: munlock failed: %s", strerror(errno)); }#endif /* __linux__ */ wpabuf_free(pw);}
开发者ID:drashti304,项目名称:TizenRT,代码行数:13,
示例15: eap_sim_msg_finishstruct wpabuf * eap_sim_msg_finish(struct eap_sim_msg *msg, const u8 *k_aut, const u8 *extra, size_t extra_len){ struct eap_hdr *eap; struct wpabuf *buf; if (msg == NULL) return NULL; eap = wpabuf_mhead(msg->buf); eap->length = host_to_be16(wpabuf_len(msg->buf)); if (k_aut && msg->mac) { eap_sim_add_mac(k_aut, (u8 *) wpabuf_head(msg->buf), wpabuf_len(msg->buf), (u8 *) wpabuf_mhead(msg->buf) + msg->mac, extra, extra_len); } buf = msg->buf; os_free(msg); return buf;}
开发者ID:tcdog001,项目名称:apv5sdk-v15,代码行数:23,
示例16: wps_decrypt_encr_settingsstruct wpabuf * wps_decrypt_encr_settings(struct wps_data *wps, const u8 *encr, size_t encr_len){ struct wpabuf *decrypted; const size_t block_size = 16; size_t i; u8 pad; const u8 *pos; /* AES-128-CBC */ if (encr == NULL || encr_len < 2 * block_size || encr_len % block_size) { wpa_printf(MSG_DEBUG, "WPS: No Encrypted Settings received"); return NULL; } decrypted = wpabuf_alloc(encr_len - block_size); if (decrypted == NULL) return NULL; wpa_hexdump(MSG_MSGDUMP, "WPS: Encrypted Settings", encr, encr_len); wpabuf_put_data(decrypted, encr + block_size, encr_len - block_size); if (aes_128_cbc_decrypt(wps->keywrapkey, encr, wpabuf_mhead(decrypted), wpabuf_len(decrypted))) { wpabuf_free(decrypted); return NULL; } wpa_hexdump_buf_key(MSG_MSGDUMP, "WPS: Decrypted Encrypted Settings", decrypted); pos = wpabuf_head_u8(decrypted) + wpabuf_len(decrypted) - 1; pad = *pos; if (pad > wpabuf_len(decrypted)) { wpa_printf(MSG_DEBUG, "WPS: Invalid PKCS#5 v2.0 pad value"); wpabuf_free(decrypted); return NULL; } for (i = 0; i < pad; i++) { if (*pos-- != pad) { wpa_printf(MSG_DEBUG, "WPS: Invalid PKCS#5 v2.0 pad " "string"); wpabuf_free(decrypted); return NULL; } } decrypted->used -= pad; return decrypted;}
开发者ID:springware,项目名称:92u10,代码行数:50,
示例17: eap_fast_parse_decryptedstatic int eap_fast_parse_decrypted(struct wpabuf *decrypted, struct eap_fast_tlv_parse *tlv, struct wpabuf **resp){ int mandatory, tlv_type, res; size_t len; u8 *pos, *end; os_memset(tlv, 0, sizeof(*tlv)); /* Parse TLVs from the decrypted Phase 2 data */ pos = wpabuf_mhead(decrypted); end = pos + wpabuf_len(decrypted); while (end - pos > 4) { mandatory = pos[0] & 0x80; tlv_type = WPA_GET_BE16(pos) & 0x3fff; pos += 2; len = WPA_GET_BE16(pos); pos += 2; if (len > (size_t) (end - pos)) { wpa_printf(MSG_INFO, "EAP-FAST: TLV overflow"); return -1; } wpa_printf(MSG_DEBUG, "EAP-FAST: Received Phase 2: " "TLV type %d length %u%s", tlv_type, (unsigned int) len, mandatory ? " (mandatory)" : ""); res = eap_fast_parse_tlv(tlv, tlv_type, pos, len); if (res == -2) break; if (res < 0) { if (mandatory) { wpa_printf(MSG_DEBUG, "EAP-FAST: Nak unknown " "mandatory TLV type %d", tlv_type); *resp = eap_fast_tlv_nak(0, tlv_type); break; } else { wpa_printf(MSG_DEBUG, "EAP-FAST: ignored " "unknown optional TLV type %d", tlv_type); } } pos += len; } return 0;}
开发者ID:gxk,项目名称:hostap,代码行数:49,
示例18: eap_pax_build_std_1static struct wpabuf * eap_pax_build_std_1(struct eap_sm *sm, struct eap_pax_data *data, u8 id){ struct wpabuf *req; struct eap_pax_hdr *pax; u8 *pos; wpa_printf(MSG_DEBUG, "EAP-PAX: PAX_STD-1 (sending)"); if (random_get_bytes(data->rand.r.x, EAP_PAX_RAND_LEN)) { wpa_printf(MSG_ERROR, "EAP-PAX: Failed to get random data"); data->state = FAILURE; return NULL; } req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_PAX, sizeof(*pax) + 2 + EAP_PAX_RAND_LEN + EAP_PAX_ICV_LEN, EAP_CODE_REQUEST, id); if (req == NULL) { wpa_printf(MSG_ERROR, "EAP-PAX: Failed to allocate memory " "request"); data->state = FAILURE; return NULL; } pax = wpabuf_put(req, sizeof(*pax)); pax->op_code = EAP_PAX_OP_STD_1; pax->flags = 0; pax->mac_id = data->mac_id; pax->dh_group_id = EAP_PAX_DH_GROUP_NONE; pax->public_key_id = EAP_PAX_PUBLIC_KEY_NONE; wpabuf_put_be16(req, EAP_PAX_RAND_LEN); wpabuf_put_data(req, data->rand.r.x, EAP_PAX_RAND_LEN); wpa_hexdump(MSG_MSGDUMP, "EAP-PAX: A = X (server rand)", data->rand.r.x, EAP_PAX_RAND_LEN); pos = wpabuf_put(req, EAP_PAX_MAC_LEN); eap_pax_mac(data->mac_id, (u8 *) "", 0, wpabuf_mhead(req), wpabuf_len(req) - EAP_PAX_ICV_LEN, NULL, 0, NULL, 0, pos); wpa_hexdump(MSG_MSGDUMP, "EAP-PAX: ICV", pos, EAP_PAX_ICV_LEN); return req;}
开发者ID:bartve-enovation,项目名称:hostap,代码行数:45,
示例19: eap_pax_build_std_3static struct wpabuf * eap_pax_build_std_3(struct eap_sm *sm, struct eap_pax_data *data, u8 id){ struct wpabuf *req; struct eap_pax_hdr *pax; u8 *pos; wpa_printf(MSG_DEBUG, "EAP-PAX: PAX_STD-3 (sending)"); req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_PAX, sizeof(*pax) + 2 + EAP_PAX_MAC_LEN + EAP_PAX_ICV_LEN, EAP_CODE_REQUEST, id); if (req == NULL) { wpa_printf(MSG_ERROR, "EAP-PAX: Failed to allocate memory " "request"); data->state = FAILURE; return NULL; } pax = wpabuf_put(req, sizeof(*pax)); pax->op_code = EAP_PAX_OP_STD_3; pax->flags = 0; pax->mac_id = data->mac_id; pax->dh_group_id = EAP_PAX_DH_GROUP_NONE; pax->public_key_id = EAP_PAX_PUBLIC_KEY_NONE; wpabuf_put_be16(req, EAP_PAX_MAC_LEN); pos = wpabuf_put(req, EAP_PAX_MAC_LEN); eap_pax_mac(data->mac_id, data->ck, EAP_PAX_CK_LEN, data->rand.r.y, EAP_PAX_RAND_LEN, (u8 *) data->cid, data->cid_len, NULL, 0, pos); wpa_hexdump(MSG_MSGDUMP, "EAP-PAX: MAC_CK(B, CID)", pos, EAP_PAX_MAC_LEN); pos += EAP_PAX_MAC_LEN; /* Optional ADE could be added here, if needed */ pos = wpabuf_put(req, EAP_PAX_MAC_LEN); eap_pax_mac(data->mac_id, data->ick, EAP_PAX_ICK_LEN, wpabuf_mhead(req), wpabuf_len(req) - EAP_PAX_ICV_LEN, NULL, 0, NULL, 0, pos); wpa_hexdump(MSG_MSGDUMP, "EAP-PAX: ICV", pos, EAP_PAX_ICV_LEN); return req;}
开发者ID:bartve-enovation,项目名称:hostap,代码行数:45,
示例20: eap_fast_parse_tlvsstatic int eap_fast_parse_tlvs(struct wpabuf *data, struct eap_fast_tlv_parse *tlv){ int mandatory, tlv_type, len, res; u8 *pos, *end; os_memset(tlv, 0, sizeof(*tlv)); pos = wpabuf_mhead(data); end = pos + wpabuf_len(data); while (pos + 4 < end) { mandatory = pos[0] & 0x80; tlv_type = WPA_GET_BE16(pos) & 0x3fff; pos += 2; len = WPA_GET_BE16(pos); pos += 2; if (pos + len > end) { wpa_printf(MSG_INFO, "EAP-FAST: TLV overflow"); return -1; } wpa_printf(MSG_DEBUG, "EAP-FAST: Received Phase 2: " "TLV type %d length %d%s", tlv_type, len, mandatory ? " (mandatory)" : ""); res = eap_fast_parse_tlv(tlv, tlv_type, pos, len); if (res == -2) break; if (res < 0) { if (mandatory) { wpa_printf(MSG_DEBUG, "EAP-FAST: Nak unknown " "mandatory TLV type %d", tlv_type); /* TODO: generate Nak TLV */ break; } else { wpa_printf(MSG_DEBUG, "EAP-FAST: Ignored " "unknown optional TLV type %d", tlv_type); } } pos += len; } return 0;}
开发者ID:0x000000FF,项目名称:wpa_supplicant_for_edison,代码行数:45,
示例21: eap_peer_tls_decrypt/** * eap_peer_tls_decrypt - Decrypt received phase 2 TLS message * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() * @data: Data for TLS processing * @in_data: Message received from the server * @in_decrypted: Buffer for returning a pointer to the decrypted message * Returns: 0 on success, 1 if more input data is needed, or -1 on failure */int eap_peer_tls_decrypt(struct eap_sm *sm, struct eap_ssl_data *data, const struct wpabuf *in_data, struct wpabuf **in_decrypted){ int res; const u8 *msg; size_t msg_len, buf_len; int need_more_input; msg = eap_peer_tls_data_reassemble(data, wpabuf_head(in_data), wpabuf_len(in_data), &msg_len, &need_more_input); if (msg == NULL) return need_more_input ? 1 : -1; buf_len = wpabuf_len(in_data); if (data->tls_in_total > buf_len) buf_len = data->tls_in_total; /* * Even though we try to disable TLS compression, it is possible that * this cannot be done with all TLS libraries. Add extra buffer space * to handle the possibility of the decrypted data being longer than * input data. */ buf_len += 500; buf_len *= 3; *in_decrypted = wpabuf_alloc(buf_len ? buf_len : 1); if (*in_decrypted == NULL) { eap_peer_tls_reset_input(data); wpa_printf(MSG_WARNING, "SSL: Failed to allocate memory for " "decryption"); return -1; } res = tls_connection_decrypt(sm->ssl_ctx, data->conn, msg, msg_len, wpabuf_mhead(*in_decrypted), buf_len); eap_peer_tls_reset_input(data); if (res < 0) { wpa_printf(MSG_INFO, "SSL: Failed to decrypt Phase 2 data"); return -1; } wpabuf_put(*in_decrypted, res); return 0;}
开发者ID:Austrie,项目名称:android_external_hostapd,代码行数:52,
示例22: dh_init/** * dh_init - Initialize Diffie-Hellman handshake * @dh: Selected Diffie-Hellman group * @priv: Pointer for returning Diffie-Hellman private key * Returns: Diffie-Hellman public value */struct wpabuf * dh_init(const struct dh_group *dh, struct wpabuf **priv){ struct wpabuf *pv; size_t pv_len; if (dh == NULL) return NULL; wpabuf_free(*priv); *priv = wpabuf_alloc(dh->prime_len); if (*priv == NULL) return NULL; if (random_get_bytes(wpabuf_put(*priv, dh->prime_len), dh->prime_len)) { wpabuf_free(*priv); *priv = NULL; return NULL; } if (os_memcmp(wpabuf_head(*priv), dh->prime, dh->prime_len) > 0) { /* Make sure private value is smaller than prime */ *(wpabuf_mhead_u8(*priv)) = 0; } wpa_hexdump_buf_key(MSG_DEBUG, "DH: private value", *priv); pv_len = dh->prime_len; pv = wpabuf_alloc(pv_len); if (pv == NULL) return NULL; if (crypto_mod_exp(dh->generator, dh->generator_len, wpabuf_head(*priv), wpabuf_len(*priv), dh->prime, dh->prime_len, wpabuf_mhead(pv), &pv_len) < 0) { wpabuf_free(pv); wpa_printf(MSG_INFO, "DH: crypto_mod_exp failed"); return NULL; } wpabuf_put(pv, pv_len); wpa_hexdump_buf(MSG_DEBUG, "DH: public value", pv); return pv;}
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:49,
示例23: tls_connection_decryptstruct wpabuf * tls_connection_decrypt(void *tls_ctx, struct tls_connection *conn, const struct wpabuf *in_data) { PRInt32 res; struct wpabuf *out; wpa_printf(MSG_DEBUG, "NSS: decrypt %d bytes", (int) wpabuf_len(in_data)); if (conn->pull_buf) { wpa_printf(MSG_DEBUG, "%s - %lu bytes remaining in " "pull_buf", __func__, (unsigned long) conn->pull_buf_len); os_free(conn->pull_buf); } conn->pull_buf = os_malloc(wpabuf_len(in_data)); if (conn->pull_buf == NULL) return NULL; os_memcpy(conn->pull_buf, wpabuf_head(in_data), wpabuf_len(in_data)); conn->pull_buf_offset = conn->pull_buf; conn->pull_buf_len = wpabuf_len(in_data); /* * Even though we try to disable TLS compression, it is possible that * this cannot be done with all TLS libraries. Add extra buffer space * to handle the possibility of the decrypted data being longer than * input data. */ out = wpabuf_alloc((wpabuf_len(in_data) + 500) * 3); if (out == NULL) return NULL; res = PR_Recv(conn->fd, wpabuf_mhead(out), wpabuf_size(out), 0, 0); wpa_printf(MSG_DEBUG, "NSS: PR_Recv: %d", res); if (res < 0) { wpabuf_free(out); return NULL; } wpabuf_put(out, res); return out;}
开发者ID:vk496,项目名称:reaver-wps-fork-t6x,代码行数:41,
示例24: eap_ttls_avp_encapsulatestatic struct wpabuf * eap_ttls_avp_encapsulate(struct wpabuf *resp, u32 avp_code, int mandatory){ struct wpabuf *avp; u8 *pos; avp = wpabuf_alloc(sizeof(struct ttls_avp) + wpabuf_len(resp) + 4); if (avp == NULL) { wpabuf_free(resp); return NULL; } pos = eap_ttls_avp_hdr(wpabuf_mhead(avp), avp_code, 0, mandatory, wpabuf_len(resp)); os_memcpy(pos, wpabuf_head(resp), wpabuf_len(resp)); pos += wpabuf_len(resp); AVP_PAD((const u8 *) wpabuf_head(avp), pos); wpabuf_free(resp); wpabuf_put(avp, pos - (u8 *) wpabuf_head(avp)); return avp;}
开发者ID:Bebooo43,项目名称:android_hardware_mediatek,代码行数:21,
示例25: ndef_parse_recordsstatic struct wpabuf * ndef_parse_records(struct wpabuf *buf, int (*filter)(struct ndef_record *)){ struct ndef_record record; int len = wpabuf_len(buf); u8 *data = wpabuf_mhead(buf); while (len > 0) { if (ndef_parse_record(data, len, &record) < 0) { wpa_printf(MSG_ERROR, "NDEF : Failed to parse"); return NULL; } if (filter == NULL || filter(&record)) return wpabuf_alloc_copy(record.payload, record.payload_length); data += record.total_length; len -= record.total_length; } wpa_printf(MSG_ERROR, "NDEF : Record not found"); return NULL;}
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:21,
示例26: tls_connection_decryptstruct wpabuf * tls_connection_decrypt(void *tls_ctx, struct tls_connection *conn, const struct wpabuf *in_data){ ssize_t res; struct wpabuf *out; if (conn->pull_buf) { wpa_printf(MSG_DEBUG, "%s - %lu bytes remaining in " "pull_buf", __func__, (unsigned long) wpabuf_len(conn->pull_buf)); wpabuf_free(conn->pull_buf); } conn->pull_buf = wpabuf_dup(in_data); if (conn->pull_buf == NULL) return NULL; conn->pull_buf_offset = wpabuf_head(conn->pull_buf); /* * Even though we try to disable TLS compression, it is possible that * this cannot be done with all TLS libraries. Add extra buffer space * to handle the possibility of the decrypted data being longer than * input data. */ out = wpabuf_alloc((wpabuf_len(in_data) + 500) * 3); if (out == NULL) return NULL; res = gnutls_record_recv(conn->session, wpabuf_mhead(out), wpabuf_size(out)); if (res < 0) { wpa_printf(MSG_DEBUG, "%s - gnutls_record_recv failed: %d " "(%s)", __func__, (int) res, gnutls_strerror(res)); wpabuf_free(out); return NULL; } wpabuf_put(out, res); return out;}
开发者ID:samm-git,项目名称:e3372h-vendor-src,代码行数:40,
示例27: wps_er_process_wlaneventstatic void wps_er_process_wlanevent(struct wps_er_ap *ap, struct wpabuf *event){ u8 *data; u8 wlan_event_type; u8 wlan_event_mac[ETH_ALEN]; struct wpabuf msg; wpa_hexdump(MSG_MSGDUMP, "WPS ER: Received WLANEvent", wpabuf_head(event), wpabuf_len(event)); if (wpabuf_len(event) < 1 + 17) { wpa_printf(MSG_DEBUG, "WPS ER: Too short WLANEvent"); return; } data = wpabuf_mhead(event); wlan_event_type = data[0]; if (hwaddr_aton((char *) data + 1, wlan_event_mac) < 0) { wpa_printf(MSG_DEBUG, "WPS ER: Invalid WLANEventMAC in " "WLANEvent"); return; } wpabuf_set(&msg, data + 1 + 17, wpabuf_len(event) - (1 + 17)); switch (wlan_event_type) { case 1: wps_er_process_wlanevent_probe_req(ap, wlan_event_mac, &msg); break; case 2: wps_er_process_wlanevent_eap(ap, wlan_event_mac, &msg); break; default: wpa_printf(MSG_DEBUG, "WPS ER: Unknown WLANEventType %d", wlan_event_type); break; }}
开发者ID:DentonGentry,项目名称:gfiber-gfrg100,代码行数:38,
注:本文中的wpabuf_mhead函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wpabuf_put函数代码示例 C++ wpabuf_head_u8函数代码示例 |