return(GSS_S_FAILURE);
}
+ ctx->context = context;
ctx->initiate = 0;
ctx->mutual = gss_flags & GSS_C_MUTUAL_FLAG;
ctx->seed_init = 0;
/* generate an AP_REP if necessary */
if (ctx->mutual) {
- if (code = make_ap_rep(authdat, ctx->subkey, &ctx->seq_send, &token)) {
+ if (code = make_ap_rep(context, authdat, ctx->subkey, &ctx->seq_send,
+ &token)) {
(void)krb5_gss_delete_sec_context(context, minor_status,
(gss_ctx_id_t *) &ctx, NULL);
krb5_free_tkt_authent(context, authdat);
if ((cred_usage == GSS_C_ACCEPT) ||
(cred_usage == GSS_C_BOTH))
- if ((ret = acquire_accept_cred(minor_status, desired_name,
+ if ((ret = acquire_accept_cred(context, minor_status, desired_name,
&(cred->princ), cred))
!= GSS_S_COMPLETE) {
if (cred->princ)
if ((cred_usage == GSS_C_INITIATE) ||
(cred_usage == GSS_C_BOTH))
if ((ret =
- acquire_init_cred(minor_status,
+ acquire_init_cred(context, minor_status,
cred->princ?(gss_name_t)cred->princ:desired_name,
&(cred->princ), cred))
!= GSS_S_COMPLETE) {
extern void *kg_vdb;
+extern krb5_context kg_context;
+
/* helper macros */
#define kg_save_name(name) g_save_name(&kg_vdb,name)
int* /* locally_initiated */
));
+OM_uint32 kg_get_context();
+
#endif /* _GSSAPIP_KRB5_H_ */
if (defcred == GSS_C_NO_CREDENTIAL) {
OM_uint32 major;
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
if ((major = krb5_gss_acquire_cred(kg_context, minor_status,
GSS_C_NO_NAME, GSS_C_INDEFINITE,
GSS_C_NULL_OID_SET, GSS_C_INITIATE,
return(GSS_S_COMPLETE);
}
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_release_cred(kg_context, minor_status, &defcred));
}
+
+OM_uint32
+kg_get_context()
+{
+ if (kg_context)
+ return GSS_S_COMPLETE;
+ if (krb5_init_context(&kg_context))
+ return GSS_S_FAILURE;
+ return GSS_S_COMPLETE;
+}
/* fill in the ctx */
+ ctx->context = context;
ctx->initiate = 1;
ctx->mutual = req_flags & GSS_C_MUTUAL_FLAG;
ctx->seed_init = 0;
return(GSS_S_FAILURE);
}
- if (code = make_ap_req(ctx->cred, ctx->there, &ctx->endtime,
+ if (code = make_ap_req(context, ctx->cred, ctx->there, &ctx->endtime,
input_chan_bindings, ctx->mutual,
&ctx->subkey, &ctx->flags,
&ctx->seq_send, &token)) {
return(GSS_S_FAILURE);
}
- if (code = make_seal_token(&ctx->enc, &ctx->seq, &ctx->seq_send,
- ctx->initiate,
+ if (code = make_seal_token(ctx->context, &ctx->enc, &ctx->seq,
+ &ctx->seq_send, ctx->initiate,
input_message_buffer, output_message_buffer,
conf_req_flag, toktype, ctx->big_endian)) {
*minor_status = code;
#include "gssapiP_krb5.h"
-extern krb5_context kg_context;
-
OM_uint32
gss_accept_sec_context(minor_status, context_handle, verifier_cred_handle,
input_token, input_chan_bindings, src_name, mech_type,
ctx = (krb5_gss_ctx_id_rec *) context_handle;
- return(krb5_gss_accept_sec_context(ctx->context, minor_status,
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
+ return(krb5_gss_accept_sec_context(kg_context, minor_status,
context_handle,
verifier_cred_handle,
input_token,
gss_OID_set *actual_mechs;
OM_uint32 *time_rec;
{
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_acquire_cred(kg_context, minor_status,
desired_name,
time_req,
gss_name_t name2;
int *name_equal;
{
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_compare_name(kg_context, minor_status, name1,
name2, name_equal));
}
gss_buffer_t output_name_buffer;
gss_OID *output_name_type;
{
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_display_name(kg_context, minor_status, input_name,
output_name_buffer, output_name_type));
}
int *message_context;
gss_buffer_t status_string;
{
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_display_status(kg_context, minor_status, status_value,
status_type, mech_type, message_context,
status_string));
const_gss_OID input_name_type;
gss_name_t *output_name;
{
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_import_name(kg_context, minor_status, input_name_buffer,
input_name_type, output_name));
}
OM_uint32 *minor_status;
gss_OID_set *mech_set;
{
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_indicate_mechs(kg_context, minor_status, mech_set));
}
int *ret_flags;
OM_uint32 *time_rec;
{
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_init_sec_context(kg_context, minor_status,
claimant_cred_handle, context_handle,
target_name, mech_type, req_flags,
int *cred_usage;
gss_OID_set *mechanisms;
{
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_inquire_cred(kg_context, minor_status, cred_handle,
name, lifetime_ret, cred_usage, mechanisms));
}
OM_uint32 *minor_status;
gss_cred_id_t *cred_handle;
{
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_release_cred(kg_context, minor_status, cred_handle));
}
OM_uint32 *minor_status;
gss_name_t *input_name;
{
+ if (!kg_context && kg_get_context())
+ return GSS_S_FAILURE;
+
return(krb5_gss_release_name(kg_context, minor_status, input_name));
}
long tmp;
krb5_error_code code;
+ if (!kg_context && (code=kg_get_context()))
+ return code;
+
/* generate a buffer full of zeros if no cb specified */
if (cb == GSS_C_NO_CHANNEL_BINDINGS) {
cksum->checksum_type = CKSUMTYPE_RSA_MD5;
memset(cksum->contents, '\0',
- (cksum->length = krb5_checksum_size(global_context, CKSUMTYPE_RSA_MD5)));
+ (cksum->length = krb5_checksum_size(kg_context, CKSUMTYPE_RSA_MD5)));
return(0);
}
/* checksum the data */
- if (code = krb5_calculate_checksum(global_context, CKSUMTYPE_RSA_MD5,
+ if (code = krb5_calculate_checksum(kg_context, CKSUMTYPE_RSA_MD5,
buf, len, NULL, 0, cksum)) {
xfree(cksum->contents);
xfree(buf);
static unsigned char zeros[8] = {0,0,0,0,0,0,0,0};
-extern krb5_context kg_context;
-
int kg_confounder_size(ed)
krb5_gss_enc_desc *ed;
{
krb5_gss_enc_desc *ed;
unsigned char *buf;
{
- return(krb5_random_confounder(kg_context,
- ed->eblock.crypto_entry->block_length, buf));
+ krb5_error_code code;
+
+ return(krb5_random_confounder( ed->eblock.crypto_entry->block_length, buf));
}
int kg_encrypt_size(ed, n)
{
krb5_error_code code;
+ if (!kg_context && (code=kg_get_context()))
+ return code;
+
if (! ed->processed) {
if (code = krb5_process_key(kg_context, &ed->eblock, ed->key))
return(code);
int elen;
char *buf;
+ if (!kg_context && (code=kg_get_context()))
+ return code;
+
if (! ed->processed) {
if (code = krb5_process_key(kg_context, &ed->eblock, ed->key))
return(code);
static unsigned char zeros[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
-extern krb5_context kg_context;
-
krb5_error_code
kg_make_seed(key, seed)
krb5_keyblock *key;
krb5_gss_enc_desc ed;
int i;
+ if (!kg_context && (code=kg_get_context()))
+ return code;
+
if (code = krb5_copy_keyblock(kg_context, key, &ed.key))
return(code);