mod_auth_pubtkt icon indicating copy to clipboard operation
mod_auth_pubtkt copied to clipboard

[Improvement] Accept TKTAuthPassthruBasicKey in hexadecimal form in apache module

Open ggramaize opened this issue 6 years ago • 0 comments

Hi,

We can't easily install a TKTAuthPassthruBasicKey with bytes containing non-printable/extended ASCII characters in the apache configuration. This reduces the effective key space from 128 bits to at most 104 bits (optimistic estimation).

I think such an improvement could be performed using something similar to the following code block, the difficulty being we don't have built-in/standard is_hex() and hex2bin() primitives in C:

static const char *setup_passthru_basic_key(cmd_parms *cmd, void *cfg, const char *param) {

	if (strlen(param) == PASSTHRU_AUTH_KEY_SIZE*2) {
		if( is_hex(param) ) {
			conf->passthru_basic_key = new char[PASSTHRU_AUTH_KEY_SIZE];
			memcpy( hex2bin(param, PASSTHRU_AUTH_KEY_SIZE*2), conf->passthru_basic_key, PASSTHRU_AUTH_KEY_SIZE);
			return NULL
		}
		return apr_psprintf(cmd->pool, "wrong format of passthru basic auth key");
	}

	if (strlen(param) != PASSTHRU_AUTH_KEY_SIZE)
		return apr_psprintf(cmd->pool, "wrong length of passthru basic auth key");

	conf->passthru_basic_key = param;
	
	return NULL;
}

In the PHP module, we can currently circumvent the issue using the \xHH escape sequence, but native support can be implemented since we already have hex2bin() beginning with PHP 5.4.0, and ctype_xdigit() since 4.0.4.

Kind regards

ggramaize avatar Jan 21 '19 13:01 ggramaize