+
+done:
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_GSSSessionData, &gsessdata);
+}
+
+static int mag_basic_hmac(struct seal_key *key, unsigned char *mac,
+ gss_buffer_desc user, gss_buffer_desc pwd)
+{
+ struct databuf hmacbuf = { mac, 0 };
+ int data_size = user.length + pwd.length + 1;
+ unsigned char data[data_size];
+ struct databuf databuf = { data, data_size };
+
+ memcpy(data, user.value, user.length);
+ data[user.length] = '\0';
+ memcpy(&data[user.length + 1], pwd.value, pwd.length);
+
+ 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);