|
OpenVPN
|
#include "syshead.h"#include "manage.h"#include "base64.h"#include "run_command.h"#include "xkey_common.h"#include "cert_data.h"#include "pkcs11.h"#include "ssl.h"#include <setjmp.h>#include <cmocka.h>#include "test_common.h"
Go to the source code of this file.
Data Structures | |
| struct | test_cert |
Macros | |
| #define | token_name "Test Token" |
| #define | PIN "12345" |
| #define | HASHSIZE 20 |
Functions | |
| void | crypto_print_openssl_errors (const unsigned int flags) |
| Retrieve any occurred OpenSSL errors and print those errors. | |
| int | parse_line (const char *line, char **p, const int n, const char *file, const int line_num, msglvl_t msglevel, struct gc_arena *gc) |
| char * | x509_get_subject (openvpn_x509_cert_t *cert, struct gc_arena *gc) |
| void | query_user_clear (void) |
| Wipes all data put into all of the query_user structs. | |
| bool | query_user_exec_builtin (void) |
| Loop through configured query_user slots, using the built-in method for querying the user. | |
| void | query_user_add (char *prompt, size_t prompt_len, char *resp, size_t resp_len, bool echo) |
| void | purge_user_pass (struct user_pass *up, const bool force) |
| char * | management_query_pk_sig (struct management *man, const char *b64_data, const char *algorithm) |
| int | digest_sign_verify (EVP_PKEY *privkey, EVP_PKEY *pubkey) |
| void | init_cert_data (void) |
| bool | get_user_pass_cr (struct user_pass *up, const char *auth_file, const char *prefix, const unsigned int flags, const char *unused) |
| Retrieves the user credentials from various sources depending on the flags. | |
| static void | sha1_fingerprint (X509 *x509, uint8_t *hash, int capacity) |
| static int | init (void **state) |
| static int | cleanup (void **state) |
| static int | setup_pkcs11 (void **state) |
| static int | teardown_pkcs11 (void **state) |
| static struct test_cert * | lookup_cert_byhash (uint8_t *sha1) |
| static void | test_pkcs11_ids (void **state) |
| static void | test_tls_ctx_use_pkcs11 (void **state) |
| static void | test_tls_ctx_use_pkcs11__management (void **state) |
| int | main (void) |
Variables | |
| struct management * | management |
| static struct test_cert | certs [5] |
| static bool | pkcs11_id_management |
| static char | softhsm2_tokens_path [] = "softhsm2_tokens_XXXXXX" |
| static char | softhsm2_conf_path [] = "softhsm2_conf_XXXXXX" |
| int | num_certs |
| static const char * | pkcs11_id_current |
| struct env_set * | test_set |
| #define HASHSIZE 20 |
Definition at line 43 of file test_pkcs11.c.
| #define PIN "12345" |
Definition at line 42 of file test_pkcs11.c.
| #define token_name "Test Token" |
Definition at line 41 of file test_pkcs11.c.
|
static |
Definition at line 291 of file test_pkcs11.c.
References argv_free(), argv_new(), argv_printf(), test_cert::cert, certs, env_set_destroy(), openvpn_execve_check(), softhsm2_conf_path, softhsm2_tokens_path, test_set, and token_name.
Referenced by ApplyGpolSettings32(), ApplyGpolSettings64(), buffer_read_from_file(), buffer_write_file(), cipher_kt_block_size(), command_create(), crypto_pem_decode(), crypto_pem_encode(), incoming_push_message(), main(), multi_client_connect_call_plugin_v1(), multi_client_connect_call_script(), ProcessDeferredAction(), read_control_auth(), read_pem_key_file(), socks_username_password_auth(), tls_crypt_v2_verify_metadata(), tls_crypt_v2_write_client_key_file(), tls_ctx_use_management_external_key(), tls_session_generate_data_channel_keys(), verify_callback(), verify_cert(), verify_check_crl_dir(), and write_pem_key_file().
| void crypto_print_openssl_errors | ( | const unsigned int | flags | ) |
Retrieve any occurred OpenSSL errors and print those errors.
Note that this function uses the not thread-safe OpenSSL error API.
| flags | Flags to indicate error type and priority. |
Definition at line 51 of file test_pkcs11.c.
References msg.
| int digest_sign_verify | ( | EVP_PKEY * | privkey, |
| EVP_PKEY * | pubkey | ||
| ) |
Referenced by test_tls_ctx_use_pkcs11().
| bool get_user_pass_cr | ( | struct user_pass * | up, |
| const char * | auth_file, | ||
| const char * | prefix, | ||
| const unsigned int | flags, | ||
| const char * | auth_challenge | ||
| ) |
Retrieves the user credentials from various sources depending on the flags.
| up | The user_pass structure to store the retrieved credentials. |
| auth_file | The path to the authentication file. Might be NULL. |
| prefix | The prefix to prepend to user prompts. |
| flags | Additional flags to control the behavior of the function. |
| auth_challenge | The authentication challenge string. |
Definition at line 159 of file test_pkcs11.c.
References GET_USER_PASS_NEED_STR, GET_USER_PASS_PASSWORD_ONLY, M_NONFATAL, msg, user_pass::password, PIN, pkcs11_id_current, pkcs11_id_management, and strncpynt().
|
static |
Definition at line 196 of file test_pkcs11.c.
References argv_free(), argv_new(), argv_printf(), test_cert::cert, certs, env_set_create(), HASHSIZE, init_cert_data(), num_certs, openvpn_execve_check(), PIN, setenv_str(), sha1_fingerprint(), softhsm2_conf_path, softhsm2_tokens_path, test_set, token_name, and write.
Referenced by main().
| void init_cert_data | ( | void | ) |
|
static |
Definition at line 349 of file test_pkcs11.c.
References test_cert::cert, certs, test_cert::hash, and HASHSIZE.
Referenced by test_pkcs11_ids().
| int main | ( | void | ) |
Definition at line 474 of file test_pkcs11.c.
References cleanup(), init(), openvpn_unit_test_setup(), setup_pkcs11(), teardown_pkcs11(), test_pkcs11_ids(), test_tls_ctx_use_pkcs11(), and test_tls_ctx_use_pkcs11__management().
| char * management_query_pk_sig | ( | struct management * | man, |
| const char * | b64_data, | ||
| const char * | algorithm | ||
| ) |
Definition at line 111 of file test_pkcs11.c.
| int parse_line | ( | const char * | line, |
| char ** | p, | ||
| const int | n, | ||
| const char * | file, | ||
| const int | line_num, | ||
| msglvl_t | msglevel, | ||
| struct gc_arena * | gc | ||
| ) |
Definition at line 63 of file test_pkcs11.c.
| void purge_user_pass | ( | struct user_pass * | up, |
| const bool | force | ||
| ) |
Definition at line 104 of file test_pkcs11.c.
References secure_memzero().
| void query_user_add | ( | char * | prompt, |
| size_t | prompt_len, | ||
| char * | resp, | ||
| size_t | resp_len, | ||
| bool | echo | ||
| ) |
Definition at line 94 of file test_pkcs11.c.
| void query_user_clear | ( | void | ) |
Wipes all data put into all of the query_user structs.
Definition at line 75 of file test_pkcs11.c.
Referenced by query_user_SINGLE().
| bool query_user_exec_builtin | ( | void | ) |
Loop through configured query_user slots, using the built-in method for querying the user.
This method uses the console/TTY directly.
Loop through configured query_user slots, using the built-in method for querying the user.
Default method for querying user using default stdin/stdout on a console. This needs to be available as a backup interface for the alternative implementations in case they cannot query through their implementation specific methods.
If no alternative implementation is declared, a wrapper in console.h will ensure query_user_exec() will call this function instead.
Definition at line 88 of file test_pkcs11.c.
|
static |
|
static |
Definition at line 184 of file test_pkcs11.c.
Referenced by init(), test_pkcs11_ids(), and test_tls_ctx_use_pkcs11().
|
static |
Definition at line 331 of file test_pkcs11.c.
References SIZE, and tls_libctx.
Referenced by main().
|
static |
Definition at line 361 of file test_pkcs11.c.
References test_cert::cert, certs, test_cert::hash, HASHSIZE, lookup_cert_byhash(), num_certs, openvpn_base64_decode(), test_cert::p11_id, and sha1_fingerprint().
Referenced by main().
|
static |
Definition at line 413 of file test_pkcs11.c.
References test_cert::cert, certs, tls_root_ctx::ctx, digest_sign_verify(), HASHSIZE, pkcs11_id_current, pkcs11_id_management, sha1_fingerprint(), SSL_CTX_new_ex, and tls_libctx.
Referenced by main(), and test_tls_ctx_use_pkcs11__management().
|
static |
Definition at line 467 of file test_pkcs11.c.
References pkcs11_id_management, and test_tls_ctx_use_pkcs11().
Referenced by main().
| char * x509_get_subject | ( | openvpn_x509_cert_t * | cert, |
| struct gc_arena * | gc | ||
| ) |
Definition at line 70 of file test_pkcs11.c.
Referenced by ssl_test_escape_rfc_2253_chars_in_subject(), ssl_test_reject_null_in_cert_subject(), and verify_cert().
|
static |
Referenced by cleanup(), init(), init_cert_data(), lookup_cert_byhash(), test_pkcs11_ids(), and test_tls_ctx_use_pkcs11().
| struct management* management |
Definition at line 46 of file test_pkcs11.c.
| int num_certs |
Definition at line 138 of file test_pkcs11.c.
Referenced by init(), and test_pkcs11_ids().
|
static |
Definition at line 139 of file test_pkcs11.c.
Referenced by get_user_pass_cr(), and test_tls_ctx_use_pkcs11().
|
static |
Definition at line 135 of file test_pkcs11.c.
Referenced by get_user_pass_cr(), options_postprocess_verify_ce(), show_settings(), test_tls_ctx_use_pkcs11(), and test_tls_ctx_use_pkcs11__management().
|
static |
Definition at line 137 of file test_pkcs11.c.
|
static |
Definition at line 136 of file test_pkcs11.c.
| struct env_set* test_set |
Definition at line 140 of file test_pkcs11.c.