26 #elif defined(_MSC_VER) 63 static const char *
now0key0 =
"SESS_ID_AT_0123456789abcdefAAAAAAAAAAAAAAAAAAAAAE5JsQJOVfo8jnI3RL3tBaR5NkE4yPfcylFUHmHSc5Bu";
65 static const char *
zeroinline =
"-----BEGIN OpenVPN auth-token server key-----\n" 66 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" 67 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" 68 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n" 69 "-----END OpenVPN auth-token server key-----";
71 static const char *
allx01inline =
"-----BEGIN OpenVPN auth-token server key-----\n" 72 "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB\n" 73 "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB\n" 74 "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=\n" 75 "-----END OpenVPN auth-token server key-----";
77 static const char *
random_key =
"-----BEGIN OpenVPN auth-token server key-----\n" 78 "+mmmf7IQ5cymtMVjKYTWk8IOcYanRlpQmV9Tb3EjkHYxueBVDg3yqRgzeBlVGzNLD//rAPiOVhau\n" 79 "3NDBjNOQB8951bfs7Cc2mYfay92Bh2gRJ5XEM/DMfzCWN+7uU6NWoTTHr4FuojnIQtjtqVAj/JS9\n" 80 "w+dTSp/vYHl+c7uHd19uVRu/qLqV85+rm4tUGIjO7FfYuwyPqwmhuIsi3hs9QkSimh888FmBpoKY\n" 81 "/tbKVTJZmSERKti9KEwtV2eVAR0znN5KW7lCB3mHVAhN7bUpcoDjfCzYIFARxwswTFu9gFkwqUMY\n" 82 "I1KUOgIsVNs4llACioeXplYekWETR+YkJwDc/A==\n" 83 "-----END OpenVPN auth-token server key-----";
85 static const char *
random_token =
"SESS_ID_AT_ThhRItzOKNKrh3dfAAAAAFwzHpwAAAAAXDMenDdrq0RoH3dkA1f7O3wO+7kZcx2DusVZrRmFlWQM9HOb";
94 struct key key = { 0 };
154 memset(&key,
'1',
sizeof(key));
161 memset(&key, 0,
sizeof(key));
236 memset(hmacstart, 0x8d, strlen(hmacstart));
264 if (
streq(name,
"session_state"))
387 #if defined(ENABLE_CRYPTO_OPENSSL) 388 OpenSSL_add_all_algorithms();
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.
int auth_token_state_flags
The state of the auth-token sent from the client last time.
void free_key_ctx(struct key_ctx *ctx)
void generate_auth_token(const struct user_pass *up, struct tls_multi *multi)
Generate an auth token based on username and timestamp.
static const char * lastsesion_statevalue
void init_key_ctx(struct key_ctx *ctx, const struct key *key, const struct key_type *kt, int enc, const char *prefix)
unsigned int auth_token_lifetime
static void auth_token_fail_invalid_key(void **state)
#define AUTH_TOKEN_EXPIRED
Auth-token sent from client has expired.
#define SESSION_ID_PREFIX
The prefix given to auth tokens start with, this prefix is special cased to not show up in log files ...
char * auth_token_initial
The first auth-token we sent to a client, for clients that do not update their auth-token (older Open...
Security parameter state for a single VPN tunnel.
static void auth_token_test_key_load(void **state)
static void zerohmac(char *token)
struct tls_session session
static const char * now0key0
#define AUTH_TOKEN_SESSION_ID_LEN
static int setup(void **state)
bool auth_token_generate
Generate auth-tokens on successful user/pass auth,seet via options->auth_token_generate.
void auth_set_client_reason(struct tls_multi *multi, const char *reason)
Sets the reason why authentication of a client failed.
char username[USER_PASS_LEN]
static struct key_type auth_token_kt(void)
static const char * allx01inline
static void auth_token_basic_test(void **state)
#define AUTH_TOKEN_HMAC_OK
Auth-token sent from client has valid hmac.
#define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown)
#define assert_string_equal(a, b)
void setenv_str(struct env_set *es, const char *name, const char *value)
interval_t renegotiate_seconds
#define AUTH_TOKEN_VALID_EMPTYUSER
Auth-token is only valid for an empty username and not the username actually supplied from the client...
static void auth_token_test_timeout(void **state)
static void auth_token_test_empty_user(void **state)
static const char * random_token
void wipe_auth_token(struct tls_multi *multi)
Wipes the authentication token out of the memory, frees and cleans up related buffers and flags...
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...
static void auth_token_test_random_keys(void **state)
static void auth_token_test_env(void **state)
static const char * zeroinline
unsigned __int64 uint64_t
static int teardown(void **state)
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...
#define cmocka_unit_test_setup_teardown(f, setup, teardown)
Initialize an array of CMUnitTest structures with a setup function for a test and a teardown function...
struct key_ctx auth_token_key
static void auth_token_test_known_keys(void **state)
char * auth_token
If server sends a generated auth-token, this is the token to use for future user/pass authentications...
const md_kt_t * digest
Message digest static parameters.
Security parameter state of a single session within a VPN tunnel.
static const char * random_key
char password[USER_PASS_LEN]
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...
#define assert_int_equal(a, b)
Container for unidirectional cipher and HMAC key material.