Go to the documentation of this file.
59 static const char *
now0key0 =
"SESS_ID_AT_0123456789abcdefAAAAAAAAAAAAAAAAAAAAAE5JsQJOVfo8jnI3RL3tBaR5NkE4yPfcylFUHmHSc5Bu";
61 static const char *
zeroinline =
"-----BEGIN OpenVPN auth-token server key-----\n"
62 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"
63 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"
64 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n"
65 "-----END OpenVPN auth-token server key-----";
67 static const char *
allx01inline =
"-----BEGIN OpenVPN auth-token server key-----\n"
68 "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB\n"
69 "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB\n"
70 "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=\n"
71 "-----END OpenVPN auth-token server key-----";
73 static const char *
random_key =
"-----BEGIN OpenVPN auth-token server key-----\n"
74 "+mmmf7IQ5cymtMVjKYTWk8IOcYanRlpQmV9Tb3EjkHYxueBVDg3yqRgzeBlVGzNLD//rAPiOVhau\n"
75 "3NDBjNOQB8951bfs7Cc2mYfay92Bh2gRJ5XEM/DMfzCWN+7uU6NWoTTHr4FuojnIQtjtqVAj/JS9\n"
76 "w+dTSp/vYHl+c7uHd19uVRu/qLqV85+rm4tUGIjO7FfYuwyPqwmhuIsi3hs9QkSimh888FmBpoKY\n"
77 "/tbKVTJZmSERKti9KEwtV2eVAR0znN5KW7lCB3mHVAhN7bUpcoDjfCzYIFARxwswTFu9gFkwqUMY\n"
78 "I1KUOgIsVNs4llACioeXplYekWETR+YkJwDc/A==\n"
79 "-----END OpenVPN auth-token server key-----";
81 static const char *
random_token =
"SESS_ID_AT_ThhRItzOKNKrh3dfAAAAAFwzHpwAAAAAXDMenDdrq0RoH3dkA1f7O3wO+7kZcx2DusVZrRmFlWQM9HOb";
152 memset(&
key,
'1',
sizeof(
key));
159 memset(&
key, 0,
sizeof(
key));
213 while (now < 100000 + ctx->
session->opt->auth_token_lifetime + 1)
237 memset(hmacstart, 0x8d, strlen(hmacstart));
265 if (
streq(name,
"session_state"))
300 free(token_sessiona);
412 const struct CMUnitTest tests[] = {
424 #if defined(ENABLE_CRYPTO_OPENSSL)
425 OpenSSL_add_all_algorithms();
428 int ret = cmocka_run_group_tests_name(
"auth-token tests", tests, NULL, NULL);
#define SESSION_ID_PREFIX
The prefix given to auth tokens start with, this prefix is special cased to not show up in log files ...
static const char * random_token
char * auth_token
If server sends a generated auth-token, this is the token to use for future user/pass authentications...
unsigned int auth_token_state_flags
The state of the auth-token sent from the client.
unsigned int verify_auth_token(struct user_pass *up, struct tls_multi *multi, struct tls_session *session)
Verifies the auth token to be in the format that generate_auth_token create and checks if the token i...
#define KS_PRIMARY
Primary key state index.
static const char * random_key
struct tls_session session[TM_SIZE]
Array of tls_session objects representing control channel sessions with the remote peer.
void add_session_token_env(struct tls_session *session, struct tls_multi *multi, const struct user_pass *up)
Put the session id, and auth token status into the environment if auth-token is enabled.
struct key_ctx auth_token_key
char username[USER_PASS_LEN]
static void auth_token_test_empty_user(void **state)
static int setup(void **state)
interval_t renegotiate_seconds
Security parameter state for a single VPN tunnel.
static void auth_token_test_env(void **state)
Security parameter state of one TLS and data channel key session.
Container for unidirectional cipher and HMAC key material.
unsigned int auth_token_renewal
static void auth_token_test_key_load(void **state)
bool auth_token_generate
Generate auth-tokens on successful user/pass auth,seet via options->auth_token_generate.
#define AUTH_TOKEN_VALID_EMPTYUSER
Auth-token is only valid for an empty username and not the username actually supplied from the client...
#define TM_ACTIVE
Active tls_session.
#define AUTH_TOKEN_SESSION_ID_LEN
static const char * allx01inline
static void auth_token_test_known_keys(void **state)
const char * digest
Message digest static parameters.
void auth_token_test_session_mismatch(void **state)
struct key_state key[KS_SIZE]
void init_key_ctx(struct key_ctx *ctx, const struct key *key, const struct key_type *kt, int enc, const char *prefix)
static const char * now0key0
#define AUTH_TOKEN_SESSION_ID_BASE64_LEN
void setenv_str(struct env_set *es, const char *name, const char *value)
void auth_token_init_secret(struct key_ctx *key_ctx, const char *key_file, bool key_inline)
Loads an HMAC secret from a file or if no file is present generates a epheremal secret for the run ti...
static struct key_type auth_token_kt(void)
Security parameter state of a single session within a VPN tunnel.
void generate_auth_token(const struct user_pass *up, struct tls_multi *multi)
Generate an auth token based on username and timestamp.
static void auth_token_test_random_keys(void **state)
void auth_set_client_reason(struct tls_multi *multi, const char *reason)
Sets the reason why authentication of a client failed.
static const char * zeroinline
static void openvpn_unit_test_setup(void)
Sets up the environment for unit tests like making both stderr and stdout non-buffered to avoid messa...
unsigned int auth_token_lifetime
static void zerohmac(char *token)
void free_key_ctx(struct key_ctx *ctx)
#define AUTH_TOKEN_HMAC_OK
Auth-token sent from client has valid hmac.
static void auth_token_test_timeout(void **state)
#define AUTH_TOKEN_EXPIRED
Auth-token sent from client has expired.
static int teardown(void **state)
static void auth_token_basic_test(void **state)
static void auth_token_fail_invalid_key(void **state)
void wipe_auth_token(struct tls_multi *multi)
Wipes the authentication token out of the memory, frees and cleans up related buffers and flags.
char password[USER_PASS_LEN]
struct tls_session * session
char * auth_token_initial
The first auth-token we sent to a client.
void send_push_reply_auth_token(struct tls_multi *multi)
Sends a push reply message only containin the auth-token to update the auth-token on the client.
static const char * lastsesion_statevalue