Пример #1
0
mit_krb5_error_code KRB5_CALLCONV
mit_krb5_copy_data(mit_krb5_context context,
                   const mit_krb5_data *from,
                   mit_krb5_data **to)
{
    *to = mshim_malloc(sizeof(**to));
    (*to)->magic = MIT_KV5M_DATA;
    (*to)->length = from->length;
    (*to)->data = mshim_malloc(from->length);
    memcpy((*to)->data, from->data, from->length);
    return 0;
}
Пример #2
0
mit_krb5_error_code KRB5_CALLCONV
mit_krb5_os_localaddr(mit_krb5_context context, mit_krb5_address ***addresses)
{
    mit_krb5_address **a;
    krb5_addresses addrs;
    krb5_error_code ret;
    unsigned i;

    LOG_ENTRY();
    
    *addresses = NULL;

    addrs.len = 0;
    addrs.val = NULL;

    ret = heim_krb5_get_all_client_addrs(HC(context), &addrs);
    if (ret)
	return ret;

    a = calloc(addrs.len + 1, sizeof(a[0]));
    for (i = 0; i < addrs.len; i++) {
	a[i] = calloc(1, sizeof(mit_krb5_address));
	a[i]->addrtype = addrs.val[i].addr_type;
	a[i]->length = addrs.val[i].address.length;
	a[i]->contents = mshim_malloc(addrs.val[i].address.length);
	memcpy(a[i]->contents, addrs.val[i].address.data, addrs.val[i].address.length);
    }
    a[i] = NULL;

    return 0;
}
Пример #3
0
krb5_error_code
mshim_mdata2hdata(const mit_krb5_data *m, krb5_data *h)
{
    h->length = m->length;
    h->data = mshim_malloc(m->length);
    memcpy(h->data, m->data, m->length);
    return 0;
}
Пример #4
0
static cc_string_t
create_string(const char *string)
{
    cc_string_t s;
    s = mshim_malloc(sizeof(*s));
    s->functions = &string_functions;
    s->data = strdup(string);
    return s;
}
Пример #5
0
void
mshim_hkeyblock2mkeyblock(const krb5_keyblock *h, mit_krb5_keyblock *m)
{
    m->magic = MIT_KV5M_KEYBLOCK;
    m->enctype = h->keytype;
    m->length = h->keyvalue.length;
    m->contents = mshim_malloc(h->keyvalue.length);
    memcpy(m->contents, h->keyvalue.data, h->keyvalue.length);
}
Пример #6
0
krb5_error_code
mshim_hdata2mdata(const krb5_data *h, mit_krb5_data *m)
{
    m->magic = MIT_KV5M_DATA;
    m->length = h->length;
    m->data = mshim_malloc(h->length);
    memcpy(m->data, h->data, h->length);
    return 0;
}
Пример #7
0
mit_krb5_error_code KRB5_CALLCONV
mit_krb5_copy_keyblock(mit_krb5_context context,
                       const mit_krb5_keyblock *from,
                       mit_krb5_keyblock **to)
{
    LOG_ENTRY();
    *to = mshim_malloc(sizeof(**to));
    return mit_krb5_copy_keyblock_contents(context, from, *to);
}
Пример #8
0
static cc_ccache_t
create_ccache(krb5_ccache id)
{
    struct cc_ccache *c;

    c = mshim_malloc(sizeof(*c));
    c->ccache.functions = &ccache_functions;
    c->id = id;
    update_time(&c->change_time);
    return (cc_ccache_t)c;
}
Пример #9
0
mit_krb5_error_code KRB5_CALLCONV
mit_krb5_copy_keyblock_contents(mit_krb5_context context,
                                const mit_krb5_keyblock *from,
                                mit_krb5_keyblock *to)
{
    LOG_ENTRY();
    to->magic = MIT_KV5M_KEYBLOCK;
    to->enctype = from->enctype;
    to->length = from->length;
    to->contents = mshim_malloc(from->length);
    memcpy(to->contents, from->contents, from->length);
    return 0;
}
Пример #10
0
void
mshim_haprepencpart2maprepencpart(const krb5_ap_rep_enc_part *h,
				  mit_krb5_ap_rep_enc_part *m)
{
    m->magic = MIT_KV5M_AP_REP_ENC_PART;
    m->ctime = h->ctime;
    m->cusec = h->cusec;

    if (h->subkey) {
	m->subkey = mshim_malloc(sizeof(*m->subkey));
	mshim_hkeyblock2mkeyblock(h->subkey, m->subkey);
    } else
	m->subkey = NULL;

    if (h->seq_number) {
	m->seq_number = *h->seq_number;
    } else 
	m->seq_number = 0;
}
mit_krb5_error_code KRB5_CALLCONV
krb5_auth_con_getlocalsubkey(mit_krb5_context context,
			     mit_krb5_auth_context ac,
			     mit_krb5_keyblock **key)
{
    LOG_ENTRY();
    krb5_keyblock *hkey = NULL;
    krb5_error_code ret;

    *key = NULL;

    ret = heim_krb5_auth_con_getlocalsubkey(HC(context),
					    (krb5_auth_context)ac,
					    &hkey);
    if (ret)
	return ret;
    if (hkey) {
	*key = mshim_malloc(sizeof(**key));
	mshim_hkeyblock2mkeyblock(hkey, *key);
	heim_krb5_free_keyblock(HC(context), hkey);
    }
    return 0;
}