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

Packit fd8b60
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
Packit fd8b60
/*
Packit fd8b60
 * COPYRIGHT (c) 2006
Packit fd8b60
 * The Regents of the University of Michigan
Packit fd8b60
 * ALL RIGHTS RESERVED
Packit fd8b60
 *
Packit fd8b60
 * Permission is granted to use, copy, create derivative works
Packit fd8b60
 * and redistribute this software and such derivative works
Packit fd8b60
 * for any purpose, so long as the name of The University of
Packit fd8b60
 * Michigan is not used in any advertising or publicity
Packit fd8b60
 * pertaining to the use of distribution of this software
Packit fd8b60
 * without specific, written prior authorization.  If the
Packit fd8b60
 * above copyright notice or any other identification of the
Packit fd8b60
 * University of Michigan is included in any copy of any
Packit fd8b60
 * portion of this software, then the disclaimer below must
Packit fd8b60
 * also be included.
Packit fd8b60
 *
Packit fd8b60
 * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION
Packit fd8b60
 * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY
Packit fd8b60
 * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF
Packit fd8b60
 * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
Packit fd8b60
 * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
Packit fd8b60
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
Packit fd8b60
 * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE
Packit fd8b60
 * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR
Packit fd8b60
 * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING
Packit fd8b60
 * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN
Packit fd8b60
 * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF
Packit fd8b60
 * SUCH DAMAGES.
Packit fd8b60
 */
Packit fd8b60
Packit fd8b60
#include "crypto_int.h"
Packit fd8b60
Packit fd8b60
/*
Packit fd8b60
 * keybytes is the number of bytes required as input to make a key,
Packit fd8b60
 * keylength is the length of the final key in bytes
Packit fd8b60
 */
Packit fd8b60
krb5_error_code KRB5_CALLCONV
Packit fd8b60
krb5_c_keylengths(krb5_context context, krb5_enctype enctype,
Packit fd8b60
                  size_t *keybytes, size_t *keylength)
Packit fd8b60
{
Packit fd8b60
    const struct krb5_keytypes *ktp;
Packit fd8b60
Packit fd8b60
    if (keybytes == NULL && keylength == NULL)
Packit fd8b60
        return EINVAL;
Packit fd8b60
Packit fd8b60
    ktp = find_enctype(enctype);
Packit fd8b60
    if (ktp == NULL)
Packit fd8b60
        return KRB5_BAD_ENCTYPE;
Packit fd8b60
Packit fd8b60
    if (keybytes)
Packit fd8b60
        *keybytes = ktp->enc->keybytes;
Packit fd8b60
    if (keylength)
Packit fd8b60
        *keylength = ktp->enc->keylength;
Packit fd8b60
Packit fd8b60
    return 0;
Packit fd8b60
}