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