int tls_connection_prf(void *tls_ctx, struct tls_connection *conn, const char *label, int server_random_first, u8 *out, size_t out_len) { return tlsv1_client_prf(conn->client, label, server_random_first, out, out_len); }
int tls_connection_prf(void *tls_ctx, struct tls_connection *conn, const char *label, int server_random_first, int skip_keyblock, u8 *out, size_t out_len) { int ret = -1, skip = 0; u8 *tmp_out = NULL; u8 *_out = out; if (skip_keyblock) { skip = tls_get_keyblock_size(conn); if (skip < 0) return -1; tmp_out = os_malloc(skip + out_len); if (!tmp_out) return -1; _out = tmp_out; } #ifdef CONFIG_TLS_INTERNAL_CLIENT if (conn->client) { ret = tlsv1_client_prf(conn->client, label, server_random_first, _out, out_len); } #endif /* CONFIG_TLS_INTERNAL_CLIENT */ #ifdef CONFIG_TLS_INTERNAL_SERVER if (conn->server) { ret = tlsv1_server_prf(conn->server, label, server_random_first, _out, out_len); } #endif /* CONFIG_TLS_INTERNAL_SERVER */ if (ret == 0 && skip_keyblock) os_memcpy(out, _out + skip, out_len); bin_clear_free(tmp_out, skip); return ret; }