components/krb5/Solaris/ucrypto/hash_provider/hash_md4.c
author Will Fiveash <will.fiveash@oracle.com>
Fri, 24 Mar 2017 12:29:03 -0500
changeset 7950 50d75ee82dad
permissions -rw-r--r--
25114734 Userland krb should use libucrypto
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7950
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
     1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
     2
/*
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
     3
 * Copyright (C) 1998 by the FundsXpress, INC.
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
     4
 *
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
     5
 * All rights reserved.
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
     6
 *
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
     7
 * Export of this software from the United States of America may require
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
     8
 * a specific license from the United States Government.  It is the
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
     9
 * responsibility of any person or organization contemplating export to
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    10
 * obtain such a license before exporting.
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    11
 *
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    12
 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    13
 * distribute this software and its documentation for any purpose and
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    14
 * without fee is hereby granted, provided that the above copyright
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    15
 * notice appear in all copies and that both that copyright notice and
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    16
 * this permission notice appear in supporting documentation, and that
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    17
 * the name of FundsXpress. not be used in advertising or publicity pertaining
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    18
 * to distribution of the software without specific, written prior
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    19
 * permission.  FundsXpress makes no representations about the suitability of
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    20
 * this software for any purpose.  It is provided "as is" without express
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    21
 * or implied warranty.
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    22
 *
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    23
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    24
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    25
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    26
 */
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    27
/*
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    28
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    29
 */
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    30
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    31
#include "crypto_int.h"
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    32
#include <md4.h>
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    33
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    34
static krb5_error_code
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    35
k5_md4_hash(const krb5_crypto_iov *data, size_t num_data, krb5_data *output)
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    36
{
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    37
    MD4_CTX md4ctx;
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    38
    size_t i;
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    39
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    40
    if (output->length != MD4_DIGEST_LENGTH)
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    41
        return KRB5_CRYPTO_INTERNAL;
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    42
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    43
    MD4Init(&md4ctx);
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    44
    for (i = 0; i < num_data; i++) {
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    45
        const krb5_data *d = &data[i].data;
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    46
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    47
        if (SIGN_IOV(&data[i]))
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    48
            MD4Update(&md4ctx, d->data, (size_t)d->length);
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    49
    }
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    50
    MD4Final(output->data, &md4ctx);
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    51
    return 0;
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    52
}
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    53
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    54
const struct krb5_hash_provider krb5int_hash_md4 = {
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    55
    "MD4",
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    56
    MD4_DIGEST_LENGTH,
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    57
    MD4_HMAC_BLOCK_SIZE,
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    58
    k5_md4_hash
50d75ee82dad 25114734 Userland krb should use libucrypto
Will Fiveash <will.fiveash@oracle.com>
parents:
diff changeset
    59
};