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

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