mc = *conn;
if (!mc) {
- mc = apr_pcalloc(req->pool, sizeof(struct mag_conn));
- if (!mc) return;
-
- mc->parent = req->pool;
- *conn = mc;
+ *conn = mc = mag_new_conn_ctx(req->pool);
}
rc = mag_session_get(req, sess, MAG_BEARER_KEY, &sessval);
}
/* user name */
- mc->user_name = apr_pstrndup(mc->parent,
+ mc->user_name = apr_pstrndup(mc->pool,
(char *)gsessdata->username.buf,
gsessdata->username.size);
if (!mc->user_name) goto done;
/* gssapi name */
- mc->gss_name = apr_pstrndup(mc->parent,
+ mc->gss_name = apr_pstrndup(mc->pool,
(char *)gsessdata->gssname.buf,
gsessdata->gssname.size);
if (!mc->gss_name) goto done;
mc->basic_hash.length = gsessdata->basichash.size;
- mc->basic_hash.value = apr_palloc(mc->parent, mc->basic_hash.length);
+ mc->basic_hash.value = apr_palloc(mc->pool, mc->basic_hash.length);
memcpy(mc->basic_hash.value,
gsessdata->basichash.buf, gsessdata->basichash.size);
return HMAC_BUFFER(key, &databuf, &hmacbuf);
}
+static int mag_get_mac_size(struct mag_config *cfg)
+{
+ apr_status_t rc;
+
+ if (!cfg->mag_skey) {
+ ap_log_perror(APLOG_MARK, APLOG_INFO, 0, cfg->pool,
+ "Session key not available, generating new one.");
+ rc = SEAL_KEY_CREATE(cfg->pool, &cfg->mag_skey, NULL);
+ if (rc != OK) {
+ ap_log_perror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, cfg->pool,
+ "Failed to create sealing key!");
+ return 0;
+ }
+ }
+
+ return get_mac_size(cfg->mag_skey);
+}
+
bool mag_basic_check(struct mag_config *cfg, struct mag_conn *mc,
gss_buffer_desc user, gss_buffer_desc pwd)
{
- int mac_size = get_mac_size(cfg->mag_skey);
+ int mac_size = mag_get_mac_size(cfg);
unsigned char mac[mac_size];
int ret, i, j;
bool res = false;
void mag_basic_cache(struct mag_config *cfg, struct mag_conn *mc,
gss_buffer_desc user, gss_buffer_desc pwd)
{
- int mac_size = get_mac_size(cfg->mag_skey);
+ int mac_size = mag_get_mac_size(cfg);
unsigned char mac[mac_size];
int ret;
if (ret != 0) return;
mc->basic_hash.length = mac_size;
- mc->basic_hash.value = apr_palloc(mc->parent, mac_size);
+ mc->basic_hash.value = apr_palloc(mc->pool, mac_size);
memcpy(mc->basic_hash.value, mac, mac_size);
}