2N/A/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2N/A/*
2N/A * lib/krb5/krb/encrypt_tk.c
2N/A *
2N/A * Copyright 1990 by the Massachusetts Institute of Technology.
2N/A * All Rights Reserved.
2N/A *
2N/A * Export of this software from the United States of America may
2N/A * require a specific license from the United States Government.
2N/A * It is the responsibility of any person or organization contemplating
2N/A * export to obtain such a license before exporting.
2N/A *
2N/A * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
2N/A * distribute this software and its documentation for any purpose and
2N/A * without fee is hereby granted, provided that the above copyright
2N/A * notice appear in all copies and that both that copyright notice and
2N/A * this permission notice appear in supporting documentation, and that
2N/A * the name of M.I.T. not be used in advertising or publicity pertaining
2N/A * to distribution of the software without specific, written prior
2N/A * permission. Furthermore if you modify this software you must label
2N/A * your software as modified software and not distribute it in such a
2N/A * fashion that it might be confused with the original M.I.T. software.
2N/A * M.I.T. makes no representations about the suitability of
2N/A * this software for any purpose. It is provided "as is" without express
2N/A * or implied warranty.
2N/A *
2N/A *
2N/A * krb5_encrypt_tkt_part() routine.
2N/A */
2N/A
2N/A#include "k5-int.h"
2N/A
2N/A/*
2N/A Takes unencrypted dec_ticket & dec_tkt_part, encrypts with
2N/A dec_ticket->enc_part.etype
2N/A using *srv_key, and places result in dec_ticket->enc_part.
2N/A The string dec_ticket->enc_part.ciphertext will be allocated before
2N/A formatting.
2N/A
2N/A returns errors from encryption routines, system errors
2N/A
2N/A enc_part->ciphertext.data allocated & filled in with encrypted stuff
2N/A*/
2N/A
2N/Akrb5_error_code
2N/Akrb5_encrypt_tkt_part(krb5_context context, const krb5_keyblock *srv_key, register krb5_ticket *dec_ticket)
2N/A{
2N/A krb5_data *scratch;
2N/A krb5_error_code retval;
2N/A register krb5_enc_tkt_part *dec_tkt_part = dec_ticket->enc_part2;
2N/A
2N/A /* start by encoding the to-be-encrypted part. */
2N/A if ((retval = encode_krb5_enc_tkt_part(dec_tkt_part, &scratch))) {
2N/A return retval;
2N/A }
2N/A
2N/A#define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); \
2N/A krb5_free_data(context, scratch); }
2N/A
2N/A /* call the encryption routine */
2N/A retval = krb5_encrypt_helper(context, srv_key,
2N/A KRB5_KEYUSAGE_KDC_REP_TICKET, scratch,
2N/A &dec_ticket->enc_part);
2N/A
2N/A cleanup_scratch();
2N/A
2N/A return(retval);
2N/A}