@@ -35,15 +35,15 @@ auth_token_kt(void)
3535}
3636
3737void
38- add_session_token_env (struct tls_session * session , struct tls_multi * multi ,
39- const struct user_pass * up )
38+ add_session_token_env (struct tls_session * session , struct tls_multi * multi , const struct user_pass * up )
4039{
4140 if (!multi -> opt .auth_token_generate )
4241 {
4342 return ;
4443 }
4544
46- int auth_token_state_flags = session -> key [KS_PRIMARY ].auth_token_state_flags ;
45+ struct key_state * ks = tls_select_encryption_key_init (multi );
46+ int auth_token_state_flags = ks -> auth_token_state_flags ;
4747
4848 const char * state ;
4949
@@ -81,7 +81,7 @@ add_session_token_env(struct tls_session *session, struct tls_multi *multi,
8181 state = "Invalid" ;
8282 }
8383
84- setenv_str (session -> opt -> es , "session_state" , state );
84+ setenv_str (multi -> opt . es , "session_state" , state );
8585
8686 /* We had a valid session id before */
8787 const char * session_id_source ;
@@ -111,7 +111,7 @@ add_session_token_env(struct tls_session *session, struct tls_multi *multi,
111111 memcpy (session_id , session_id_source + strlen (SESSION_ID_PREFIX ),
112112 AUTH_TOKEN_SESSION_ID_LEN * 8 / 6 );
113113
114- setenv_str (session -> opt -> es , "session_id" , session_id );
114+ setenv_str (multi -> opt . es , "session_id" , session_id );
115115}
116116
117117void
@@ -217,8 +217,8 @@ generate_auth_token(const struct user_pass *up, struct tls_multi *multi)
217217 * a new token with the empty username since we do not want to loose
218218 * the information that the username cannot be trusted
219219 */
220- struct key_state * ks = & multi -> session [ TM_ACTIVE ]. key [ KS_PRIMARY ] ;
221- if (ks -> auth_token_state_flags & AUTH_TOKEN_VALID_EMPTYUSER )
220+ struct key_state * ks = tls_select_encryption_key_init ( multi ) ;
221+ if (ks && ks -> auth_token_state_flags & AUTH_TOKEN_VALID_EMPTYUSER )
222222 {
223223 hmac_ctx_update (ctx , (const uint8_t * )"" , 0 );
224224 }
@@ -415,10 +415,15 @@ void
415415check_send_auth_token (struct context * c )
416416{
417417 struct tls_multi * multi = c -> c2 .tls_multi ;
418- struct tls_session * session = & multi -> session [TM_ACTIVE ];
419418
420- if (get_primary_key (multi )-> state < S_GENERATED_KEYS
421- || get_primary_key (multi )-> authenticated != KS_AUTH_TRUE )
419+ if (!multi )
420+ {
421+ return ;
422+ }
423+
424+ struct key_state * ks = tls_select_encryption_key_init (multi );
425+
426+ if (ks -> state < S_GENERATED_KEYS || ks -> authenticated != KS_AUTH_TRUE )
422427 {
423428 /* the currently active session is still in renegotiation or another
424429 * not fully authorized state. We are either very close to a
@@ -447,11 +452,11 @@ check_send_auth_token(struct context *c)
447452
448453 generate_auth_token (& up , multi );
449454
450- resend_auth_token_renegotiation (multi , session );
455+ resend_auth_token_renegotiation (multi );
451456}
452457
453458void
454- resend_auth_token_renegotiation (struct tls_multi * multi , struct tls_session * session )
459+ resend_auth_token_renegotiation (struct tls_multi * multi )
455460{
456461 /*
457462 * Auth token already sent to client, update auth-token on client.
0 commit comments