(krb5_build_authenticator): if the local sequence number is non-zero,

don't generate a new one


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12143 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2003-04-25 18:10:29 +00:00
parent 0b41135c1f
commit 10617940f1

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997 - 2002 Kungliga Tekniska H<>gskolan * Copyright (c) 1997 - 2003 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -45,86 +45,86 @@ krb5_build_authenticator (krb5_context context,
krb5_data *result, krb5_data *result,
krb5_key_usage usage) krb5_key_usage usage)
{ {
Authenticator *auth; Authenticator *auth;
u_char *buf = NULL; u_char *buf = NULL;
size_t buf_size; size_t buf_size;
size_t len; size_t len;
krb5_error_code ret; krb5_error_code ret;
krb5_crypto crypto; krb5_crypto crypto;
auth = malloc(sizeof(*auth)); auth = malloc(sizeof(*auth));
if (auth == NULL) { if (auth == NULL) {
krb5_set_error_string(context, "malloc: out of memory"); krb5_set_error_string(context, "malloc: out of memory");
return ENOMEM; return ENOMEM;
} }
memset (auth, 0, sizeof(*auth)); memset (auth, 0, sizeof(*auth));
auth->authenticator_vno = 5; auth->authenticator_vno = 5;
copy_Realm(&cred->client->realm, &auth->crealm); copy_Realm(&cred->client->realm, &auth->crealm);
copy_PrincipalName(&cred->client->name, &auth->cname); copy_PrincipalName(&cred->client->name, &auth->cname);
{ krb5_us_timeofday (context, &auth->ctime, &auth->cusec);
int32_t sec, usec;
ret = krb5_auth_con_getlocalsubkey(context, auth_context, &auth->subkey);
if(ret)
goto fail;
krb5_us_timeofday (context, &sec, &usec); if (auth_context->flags & KRB5_AUTH_CONTEXT_DO_SEQUENCE) {
auth->ctime = sec; if(auth_context->local_seqnumber == 0)
auth->cusec = usec; krb5_generate_seq_number (context,
} &cred->session,
ret = krb5_auth_con_getlocalsubkey(context, auth_context, &auth->subkey); &auth_context->local_seqnumber);
if(ret) ALLOC(auth->seq_number, 1);
goto fail; if(auth->seq_number == NULL) {
ret = ENOMEM;
goto fail;
}
*auth->seq_number = auth_context->local_seqnumber;
} else
auth->seq_number = NULL;
auth->authorization_data = NULL;
auth->cksum = cksum;
if (auth_context->flags & KRB5_AUTH_CONTEXT_DO_SEQUENCE) { /* XXX - Copy more to auth_context? */
krb5_generate_seq_number (context,
&cred->session,
&auth_context->local_seqnumber);
ALLOC(auth->seq_number, 1);
*auth->seq_number = auth_context->local_seqnumber;
} else
auth->seq_number = NULL;
auth->authorization_data = NULL;
auth->cksum = cksum;
/* XXX - Copy more to auth_context? */ if (auth_context) {
auth_context->authenticator->ctime = auth->ctime;
auth_context->authenticator->cusec = auth->cusec;
}
if (auth_context) { ASN1_MALLOC_ENCODE(Authenticator, buf, buf_size, auth, &len, ret);
auth_context->authenticator->ctime = auth->ctime;
auth_context->authenticator->cusec = auth->cusec;
}
ASN1_MALLOC_ENCODE(Authenticator, buf, buf_size, auth, &len, ret); if (ret)
goto fail;
if (ret) ret = krb5_crypto_init(context, &cred->session, enctype, &crypto);
goto fail; if (ret)
goto fail;
ret = krb5_encrypt (context,
crypto,
usage /* KRB5_KU_AP_REQ_AUTH */,
buf + buf_size - len,
len,
result);
krb5_crypto_destroy(context, crypto);
ret = krb5_crypto_init(context, &cred->session, enctype, &crypto); if (ret)
if (ret) goto fail;
goto fail;
ret = krb5_encrypt (context,
crypto,
usage /* KRB5_KU_AP_REQ_AUTH */,
buf + buf_size - len,
len,
result);
krb5_crypto_destroy(context, crypto);
if (ret) free (buf);
goto fail;
free (buf); if (auth_result)
*auth_result = auth;
if (auth_result) else {
*auth_result = auth; /* Don't free the `cksum', it's allocated by the caller */
else { auth->cksum = NULL;
/* Don't free the `cksum', it's allocated by the caller */ free_Authenticator (auth);
auth->cksum = NULL; free (auth);
}
return ret;
fail:
free_Authenticator (auth); free_Authenticator (auth);
free (auth); free (auth);
} free (buf);
return ret; return ret;
fail:
free_Authenticator (auth);
free (auth);
free (buf);
return ret;
} }