for (int i = 0; i < KEY_SCAN_SIZE; ++i)
{
- struct key_state *ks = multi->key_scan[i];
+ struct key_state *ks = get_key_scan(multi, i);
buf_printf(&out, " [key#%d state=%s id=%d sid=%s]", i,
state_name(ks->state), ks->key_id,
session_id_print(&ks->session_id_remote, gc));
/* get command line derived options */
ret->opt = *tls_options;
- /* set up list of keys to be scanned by data channel encrypt and decrypt routines */
- ASSERT(SIZE(ret->key_scan) == 3);
- ret->key_scan[0] = &ret->session[TM_ACTIVE].key[KS_PRIMARY];
- ret->key_scan[1] = &ret->session[TM_ACTIVE].key[KS_LAME_DUCK];
- ret->key_scan[2] = &ret->session[TM_LAME_DUCK].key[KS_LAME_DUCK];
-
return ret;
}
*/
if (error)
{
- for (int i = 0; i < (int) SIZE(multi->key_scan); ++i)
+ for (int i = 0; i < KEY_SCAN_SIZE; ++i)
{
- if (multi->key_scan[i]->state >= S_ACTIVE)
+ if (get_key_scan(multi, i)->state >= S_ACTIVE)
{
goto nohard;
}
const int throw_level = GREMLIN_CONNECTION_FLOOD_LEVEL(multi->opt.gremlin);
if (throw_level)
{
- for (int i = 0; i < (int) SIZE(multi->key_scan); ++i)
+ for (int i = 0; i < KEY_SCAN_SIZE; ++i)
{
- if (multi->key_scan[i]->state >= throw_level)
+ if (get_key_scan(multi, i)->state >= throw_level)
{
++multi->n_hard_errors;
++multi->n_soft_errors;
/* data channel packet */
for (int i = 0; i < KEY_SCAN_SIZE; ++i)
{
- struct key_state *ks = multi->key_scan[i];
+ struct key_state *ks = get_key_scan(multi, i);
/*
* This is the basic test of TLS state compatibility between a local OpenVPN
struct key_state *ks_select = NULL;
for (int i = 0; i < KEY_SCAN_SIZE; ++i)
{
- struct key_state *ks = multi->key_scan[i];
+ struct key_state *ks = get_key_scan(multi, i);
if (ks->state >= S_ACTIVE
&& (ks->authenticated == KS_AUTH_TRUE)
&& ks->crypto_options.key_ctx_bi.initialized
/* const options and config info */
struct tls_options opt;
- struct key_state *key_scan[KEY_SCAN_SIZE];
- /**< List of \c key_state objects in the
- * order they should be scanned by data
- * channel modules. */
-
/*
* used by tls_pre_encrypt to communicate the encrypt key
* to tls_post_encrypt()
* sessions with the remote peer. */
};
+/** gets an item of \c key_state objects in the
+ * order they should be scanned by data
+ * channel modules. */
+static inline struct key_state *
+get_key_scan(struct tls_multi *multi, int index)
+{
+ switch (index)
+ {
+ case 0:
+ return &multi->session[TM_ACTIVE].key[KS_PRIMARY];
+ case 1:
+ return &multi->session[TM_ACTIVE].key[KS_LAME_DUCK];
+ case 2:
+ return &multi->session[TM_LAME_DUCK].key[KS_LAME_DUCK];
+ default:
+ ASSERT(false);
+ }
+}
+
#endif /* SSL_COMMON_H_ */
for (i = 0; i < KEY_SCAN_SIZE; ++i)
{
- struct key_state *ks = multi->key_scan[i];
+ struct key_state *ks = get_key_scan(multi, i);
if (DECRYPT_KEY_ENABLED(multi, ks))
{
active = true;
auth_set_client_reason(multi, client_reason);
for (i = 0; i < KEY_SCAN_SIZE; ++i)
{
- struct key_state *ks = multi->key_scan[i];
+ struct key_state *ks = get_key_scan(multi, i);
if (ks->mda_key_id == mda_key_id)
{
ks->mda_status = auth ? ACF_SUCCEEDED : ACF_FAILED;