if (!valid_etype(etype))
return KRB5_PROG_ETYPE_NOSUPP;
- privmsg.etype = etype;
+ privmsg.enc_part.etype = etype;
+ privmsg.enc_part.kvno = 0; /* XXX allow user-set? */
privmsg_enc_part.user_data = *userdata;
privmsg_enc_part.s_address = sender_addr->address;
/* put together an eblock for this encryption */
eblock.crypto_entry = krb5_csarray[etype]->system;
- privmsg.enc_part.length = krb5_encrypt_size(scratch->length,
+ privmsg.enc_part.ciphertext.length = krb5_encrypt_size(scratch->length,
eblock.crypto_entry);
/* add padding area, and zero it */
- if (!(scratch->data = realloc(scratch->data, privmsg.enc_part.length))) {
+ if (!(scratch->data = realloc(scratch->data,
+ privmsg.enc_part.ciphertext.length))) {
/* may destroy scratch->data */
xfree(scratch);
return ENOMEM;
}
bzero(scratch->data + scratch->length,
- privmsg.enc_part.length - scratch->length);
- if (!(privmsg.enc_part.data = malloc(privmsg.enc_part.length))) {
+ privmsg.enc_part.ciphertext.length - scratch->length);
+ if (!(privmsg.enc_part.ciphertext.data =
+ malloc(privmsg.enc_part.ciphertext.length))) {
retval = ENOMEM;
goto clean_scratch;
}
-#define cleanup_encpart() {(void) bzero(privmsg.enc_part.data, privmsg.enc_part.length); free(privmsg.enc_part.data); privmsg.enc_part.length = 0; privmsg.enc_part.data = 0;}
+#define cleanup_encpart() {\
+(void) bzero(privmsg.enc_part.ciphertext.data, \
+ privmsg.enc_part.ciphertext.length); \
+free(privmsg.enc_part.ciphertext.data); \
+privmsg.enc_part.ciphertext.length = 0; privmsg.enc_part.ciphertext.data = 0;}
/* do any necessary key pre-processing */
if (retval = krb5_process_key(&eblock, key)) {
/* call the encryption routine */
if (retval = krb5_encrypt((krb5_pointer) scratch->data,
- (krb5_pointer) privmsg.enc_part.data,
+ (krb5_pointer) privmsg.enc_part.ciphertext.data,
scratch->length, &eblock,
i_vector)) {
goto clean_prockey;
/* put last block into the i_vector */
if (i_vector)
- bcopy(privmsg.enc_part.data +
- (privmsg.enc_part.length - eblock.crypto_entry->block_length),
+ bcopy(privmsg.enc_part.ciphertext.data +
+ (privmsg.enc_part.ciphertext.length -
+ eblock.crypto_entry->block_length),
i_vector,
eblock.crypto_entry->block_length);
/* put together an eblock for this encryption */
eblock.crypto_entry = krb5_csarray[etype]->system;
- reply.enc_part.length = krb5_encrypt_size(scratch->length,
- eblock.crypto_entry);
+ reply.enc_part.etype = etype;
+ reply.enc_part.kvno = 0; /* XXX user set? */
+
+ reply.enc_part.ciphertext.length = krb5_encrypt_size(scratch->length,
+ eblock.crypto_entry);
/* add padding area, and zero it */
- if (!(scratch->data = realloc(scratch->data, reply.enc_part.length))) {
+ if (!(scratch->data = realloc(scratch->data,
+ reply.enc_part.ciphertext.length))) {
/* may destroy scratch->data */
xfree(scratch);
return ENOMEM;
}
bzero(scratch->data + scratch->length,
- reply.enc_part.length - scratch->length);
- if (!(reply.enc_part.data = malloc(reply.enc_part.length))) {
+ reply.enc_part.ciphertext.length - scratch->length);
+ if (!(reply.enc_part.ciphertext.data =
+ malloc(reply.enc_part.ciphertext.length))) {
retval = ENOMEM;
goto clean_scratch;
}
-#define cleanup_encpart() {(void) bzero(reply.enc_part.data, reply.enc_part.length); free(reply.enc_part.data); reply.enc_part.length = 0; reply.enc_part.data = 0;}
+#define cleanup_encpart() {\
+(void) bzero(reply.enc_part.ciphertext.data, \
+ reply.enc_part.ciphertext.length); \
+free(reply.enc_part.ciphertext.data); \
+reply.enc_part.ciphertext.length = 0; reply.enc_part.ciphertext.data = 0;}
/* do any necessary key pre-processing */
if (retval = krb5_process_key(&eblock, kblock)) {
/* call the encryption routine */
if (retval = krb5_encrypt((krb5_pointer) scratch->data,
- (krb5_pointer) reply.enc_part.data,
+ (krb5_pointer) reply.enc_part.ciphertext.data,
scratch->length, &eblock, 0)) {
goto clean_prockey;
}
return retval;
}
-#define cleanup_privmsg() {(void)xfree(privmsg->enc_part.data); (void)xfree(privmsg);}
- if (!valid_etype(privmsg->etype)) {
+#define cleanup_privmsg() {(void)xfree(privmsg->enc_part.ciphertext.data); (void)xfree(privmsg);}
+ if (!valid_etype(privmsg->enc_part.etype)) {
cleanup_privmsg();
return KRB5_PROG_ETYPE_NOSUPP; /* XXX */
}
/* put together an eblock for this decryption */
- eblock.crypto_entry = krb5_csarray[privmsg->etype]->system;
- scratch.length = privmsg->enc_part.length;
+ eblock.crypto_entry = krb5_csarray[privmsg->enc_part.etype]->system;
+ scratch.length = privmsg->enc_part.ciphertext.length;
if (!(scratch.data = malloc(scratch.length))) {
cleanup_privmsg();
#define cleanup_prockey() {(void) krb5_finish_key(&eblock);}
/* call the decryption routine */
- if (retval = krb5_decrypt((krb5_pointer) privmsg->enc_part.data,
+ if (retval = krb5_decrypt((krb5_pointer) privmsg->enc_part.ciphertext.data,
(krb5_pointer) scratch.data,
scratch.length, &eblock,
i_vector)) {
input */
/* put last block into the i_vector */
if (i_vector)
- bcopy(privmsg->enc_part.data +
- (privmsg->enc_part.length - eblock.crypto_entry->block_length),
+ bcopy(privmsg->enc_part.ciphertext.data +
+ (privmsg->enc_part.ciphertext.length -
+ eblock.crypto_entry->block_length),
i_vector,
eblock.crypto_entry->block_length);
/* put together an eblock for this encryption */
- eblock.crypto_entry = krb5_keytype_array[kblock->keytype]->system;
+ if (!valid_etype(reply->enc_part.etype)) {
+ krb5_free_ap_rep(reply);
+ return KRB5_PROG_ETYPE_NOSUPP;
+ }
+ eblock.crypto_entry = krb5_csarray[reply->enc_part.etype]->system;
- scratch.length = reply->enc_part.length;
+ scratch.length = reply->enc_part.ciphertext.length;
if (!(scratch.data = malloc(scratch.length))) {
krb5_free_ap_rep(reply);
return(ENOMEM);
}
/* call the encryption routine */
- if (retval = krb5_decrypt((krb5_pointer) reply->enc_part.data,
+ if (retval = krb5_decrypt((krb5_pointer) reply->enc_part.ciphertext.data,
(krb5_pointer) scratch.data,
scratch.length, &eblock, 0)) {
(void) krb5_finish_key(&eblock);
/* fetch a server key */
if (keyproc) {
retval = (*keyproc)(keyprocarg, req->ticket->server,
- req->ticket->skvno, &tkt_key);
+ req->ticket->enc_part.kvno, &tkt_key);
} else {
krb5_keytab keytabid;
krb5_keytab_entry ktentry;
}
if (!retval) {
retval = krb5_kt_get_entry(keytabid, req->ticket->server,
- req->ticket->skvno, &ktentry);
+ req->ticket->enc_part.kvno, &ktentry);
(void) krb5_kt_close(keytabid);
if (!retval) {
retval = krb5_copy_keyblock(&ktentry.key, &tkt_key_real);
/* put together an eblock for this encryption */
- eblock.crypto_entry = krb5_keytype_array[sesskey->keytype]->system;
+ if (!valid_etype(request->authenticator.etype))
+ return KRB5_PROG_ETYPE_NOSUPP;
- scratch.length = request->authenticator.length;
+ eblock.crypto_entry = krb5_csarray[request->authenticator.etype]->system;
+
+ scratch.length = request->authenticator.ciphertext.length;
if (!(scratch.data = malloc(scratch.length)))
return(ENOMEM);
}
/* call the encryption routine */
- if (retval = krb5_decrypt((krb5_pointer) request->authenticator.data,
+ if (retval = krb5_decrypt((krb5_pointer) request->authenticator.ciphertext.data,
(krb5_pointer) scratch.data,
scratch.length, &eblock, 0)) {
(void) krb5_finish_key(&eblock);