Blame src/lib/crypto/krb/encrypt_iov.c

Packit Service 99d1c0
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
Packit Service 99d1c0
/* lib/crypto/krb/encrypt_iov.c */
Packit Service 99d1c0
/*
Packit Service 99d1c0
 * Copyright 2008 by the Massachusetts Institute of Technology.
Packit Service 99d1c0
 * All Rights Reserved.
Packit Service 99d1c0
 *
Packit Service 99d1c0
 * Export of this software from the United States of America may
Packit Service 99d1c0
 *   require a specific license from the United States Government.
Packit Service 99d1c0
 *   It is the responsibility of any person or organization contemplating
Packit Service 99d1c0
 *   export to obtain such a license before exporting.
Packit Service 99d1c0
 *
Packit Service 99d1c0
 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
Packit Service 99d1c0
 * distribute this software and its documentation for any purpose and
Packit Service 99d1c0
 * without fee is hereby granted, provided that the above copyright
Packit Service 99d1c0
 * notice appear in all copies and that both that copyright notice and
Packit Service 99d1c0
 * this permission notice appear in supporting documentation, and that
Packit Service 99d1c0
 * the name of M.I.T. not be used in advertising or publicity pertaining
Packit Service 99d1c0
 * to distribution of the software without specific, written prior
Packit Service 99d1c0
 * permission.  Furthermore if you modify this software you must label
Packit Service 99d1c0
 * your software as modified software and not distribute it in such a
Packit Service 99d1c0
 * fashion that it might be confused with the original M.I.T. software.
Packit Service 99d1c0
 * M.I.T. makes no representations about the suitability of
Packit Service 99d1c0
 * this software for any purpose.  It is provided "as is" without express
Packit Service 99d1c0
 * or implied warranty.
Packit Service 99d1c0
 */
Packit Service 99d1c0
Packit Service 99d1c0
#include "crypto_int.h"
Packit Service 99d1c0
Packit Service 99d1c0
krb5_error_code KRB5_CALLCONV
Packit Service 99d1c0
krb5_k_encrypt_iov(krb5_context context, krb5_key key, krb5_keyusage usage,
Packit Service 99d1c0
                   const krb5_data *cipher_state, krb5_crypto_iov *data,
Packit Service 99d1c0
                   size_t num_data)
Packit Service 99d1c0
{
Packit Service 99d1c0
    const struct krb5_keytypes *ktp;
Packit Service 99d1c0
Packit Service 99d1c0
    ktp = find_enctype(key->keyblock.enctype);
Packit Service 99d1c0
    if (ktp == NULL)
Packit Service 99d1c0
        return KRB5_BAD_ENCTYPE;
Packit Service 99d1c0
Packit Service 99d1c0
    return ktp->encrypt(ktp, key, usage, cipher_state, data, num_data);
Packit Service 99d1c0
}
Packit Service 99d1c0
Packit Service 99d1c0
krb5_error_code KRB5_CALLCONV
Packit Service 99d1c0
krb5_c_encrypt_iov(krb5_context context, const krb5_keyblock *keyblock,
Packit Service 99d1c0
                   krb5_keyusage usage, const krb5_data *cipher_state,
Packit Service 99d1c0
                   krb5_crypto_iov *data, size_t num_data)
Packit Service 99d1c0
{
Packit Service 99d1c0
    krb5_key key;
Packit Service 99d1c0
    krb5_error_code ret;
Packit Service 99d1c0
Packit Service 99d1c0
    ret = krb5_k_create_key(context, keyblock, &key);
Packit Service 99d1c0
    if (ret != 0)
Packit Service 99d1c0
        return ret;
Packit Service 99d1c0
    ret = krb5_k_encrypt_iov(context, key, usage, cipher_state, data,
Packit Service 99d1c0
                             num_data);
Packit Service 99d1c0
    krb5_k_free_key(context, key);
Packit Service 99d1c0
    return ret;
Packit Service 99d1c0
}