2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/net/sunrpc/gss_krb5_seal.c
|
|
|
|
*
|
|
|
|
* Adapted from MIT Kerberos 5-1.2.1 lib/gssapi/krb5/k5seal.c
|
|
|
|
*
|
2010-03-18 01:02:51 +08:00
|
|
|
* Copyright (c) 2000-2008 The Regents of the University of Michigan.
|
2005-04-17 06:20:36 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Andy Adamson <andros@umich.edu>
|
|
|
|
* J. Bruce Fields <bfields@umich.edu>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1993 by OpenVision Technologies, Inc.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software
|
|
|
|
* and its documentation for any purpose is hereby granted without fee,
|
|
|
|
* provided that the above copyright notice appears in all copies and
|
|
|
|
* that both that copyright notice and this permission notice appear in
|
|
|
|
* supporting documentation, and that the name of OpenVision not be used
|
|
|
|
* in advertising or publicity pertaining to distribution of the software
|
|
|
|
* without specific, written prior permission. OpenVision makes no
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
|
|
|
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 1998 by the FundsXpress, INC.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Export of this software from the United States of America may require
|
|
|
|
* a specific license from the United States Government. It is the
|
|
|
|
* responsibility of any person or organization contemplating export to
|
|
|
|
* obtain such a license before exporting.
|
|
|
|
*
|
|
|
|
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
|
|
|
|
* distribute this software and its documentation for any purpose and
|
|
|
|
* without fee is hereby granted, provided that the above copyright
|
|
|
|
* notice appear in all copies and that both that copyright notice and
|
|
|
|
* this permission notice appear in supporting documentation, and that
|
|
|
|
* the name of FundsXpress. not be used in advertising or publicity pertaining
|
|
|
|
* to distribution of the software without specific, written prior
|
|
|
|
* permission. FundsXpress makes no representations about the suitability of
|
|
|
|
* this software for any purpose. It is provided "as is" without express
|
|
|
|
* or implied warranty.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/jiffies.h>
|
|
|
|
#include <linux/sunrpc/gss_krb5.h>
|
|
|
|
#include <linux/random.h>
|
|
|
|
#include <linux/crypto.h>
|
2018-10-19 05:03:56 +08:00
|
|
|
#include <linux/atomic.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2023-01-16 01:21:07 +08:00
|
|
|
#include "gss_krb5_internal.h"
|
|
|
|
|
2014-11-18 05:58:04 +08:00
|
|
|
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
|
2005-04-17 06:20:36 +08:00
|
|
|
# define RPCDBG_FACILITY RPCDBG_AUTH
|
|
|
|
#endif
|
|
|
|
|
SUNRPC: Enable rpcsec_gss_krb5.ko to be built without CRYPTO_DES
Because the DES block cipher has been deprecated by Internet
standard, highly secure configurations might require that DES
support be blacklisted or not installed. NFS Kerberos should still
be able to work correctly with only the AES-based enctypes in that
situation.
Also note that MIT Kerberos has begun a deprecation process for DES
encryption types. Their README for 1.19.3 states:
> Beginning with the krb5-1.19 release, a warning will be issued
> if initial credentials are acquired using the des3-cbc-sha1
> encryption type. In future releases, this encryption type will
> be disabled by default and eventually removed.
>
> Beginning with the krb5-1.18 release, single-DES encryption
> types have been removed.
Aside from the CONFIG option name change, there are two important
policy changes:
1. The 'insecure enctype' group is now disabled by default.
Distributors have to take action to enable support for deprecated
enctypes. Implementation of these enctypes will be removed in a
future kernel release.
2. des3-cbc-sha1 is now considered part of the 'insecure enctype'
group, having been deprecated by RFC 8429, and is thus disabled
by default
After this patch is applied, SunRPC support can be built with
Kerberos 5 support but without CRYPTO_DES enabled in the kernel.
And, when these enctypes are disabled, the Linux kernel's SunRPC
RPCSEC GSS implementation fully complies with BCP 179 / RFC 6649
and BCP 218 / RFC 8429.
Tested-by: Scott Mayhew <smayhew@redhat.com>
Reviewed-by: Simo Sorce <simo@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2023-01-16 01:21:52 +08:00
|
|
|
static void *
|
|
|
|
setup_token_v2(struct krb5_ctx *ctx, struct xdr_netobj *token)
|
|
|
|
{
|
|
|
|
u16 *ptr;
|
|
|
|
void *krb5_hdr;
|
|
|
|
u8 *p, flags = 0x00;
|
|
|
|
|
|
|
|
if ((ctx->flags & KRB5_CTX_FLAG_INITIATOR) == 0)
|
|
|
|
flags |= 0x01;
|
|
|
|
if (ctx->flags & KRB5_CTX_FLAG_ACCEPTOR_SUBKEY)
|
|
|
|
flags |= 0x04;
|
|
|
|
|
|
|
|
/* Per rfc 4121, sec 4.2.6.1, there is no header,
|
|
|
|
* just start the token.
|
|
|
|
*/
|
|
|
|
krb5_hdr = (u16 *)token->data;
|
|
|
|
ptr = krb5_hdr;
|
|
|
|
|
|
|
|
*ptr++ = KG2_TOK_MIC;
|
|
|
|
p = (u8 *)ptr;
|
|
|
|
*p++ = flags;
|
|
|
|
*p++ = 0xff;
|
|
|
|
ptr = (u16 *)p;
|
|
|
|
*ptr++ = 0xffff;
|
|
|
|
*ptr = 0xffff;
|
|
|
|
|
|
|
|
token->len = GSS_KRB5_TOK_HDR_LEN + ctx->gk5e->cksumlength;
|
|
|
|
return krb5_hdr;
|
|
|
|
}
|
|
|
|
|
2023-01-16 01:21:20 +08:00
|
|
|
u32
|
|
|
|
gss_krb5_get_mic_v2(struct krb5_ctx *ctx, struct xdr_buf *text,
|
|
|
|
struct xdr_netobj *token)
|
2010-03-18 01:02:59 +08:00
|
|
|
{
|
2023-01-16 01:21:07 +08:00
|
|
|
struct crypto_ahash *tfm = ctx->initiate ?
|
|
|
|
ctx->initiator_sign : ctx->acceptor_sign;
|
|
|
|
struct xdr_netobj cksumobj = {
|
|
|
|
.len = ctx->gk5e->cksumlength,
|
|
|
|
};
|
|
|
|
__be64 seq_send_be64;
|
2010-03-18 01:02:59 +08:00
|
|
|
void *krb5_hdr;
|
2018-06-07 23:02:50 +08:00
|
|
|
time64_t now;
|
2010-03-18 01:02:59 +08:00
|
|
|
|
|
|
|
dprintk("RPC: %s\n", __func__);
|
|
|
|
|
|
|
|
krb5_hdr = setup_token_v2(ctx, token);
|
|
|
|
|
|
|
|
/* Set up the sequence number. Now 64-bits in clear
|
|
|
|
* text and w/o direction indicator */
|
2018-11-02 01:51:34 +08:00
|
|
|
seq_send_be64 = cpu_to_be64(atomic64_fetch_inc(&ctx->seq_send64));
|
2018-01-29 04:34:16 +08:00
|
|
|
memcpy(krb5_hdr + 8, (char *) &seq_send_be64, 8);
|
2010-03-18 01:02:59 +08:00
|
|
|
|
2023-01-16 01:21:07 +08:00
|
|
|
cksumobj.data = krb5_hdr + GSS_KRB5_TOK_HDR_LEN;
|
|
|
|
if (gss_krb5_checksum(tfm, krb5_hdr, GSS_KRB5_TOK_HDR_LEN,
|
|
|
|
text, 0, &cksumobj))
|
2010-03-18 01:02:59 +08:00
|
|
|
return GSS_S_FAILURE;
|
|
|
|
|
2018-06-07 23:02:50 +08:00
|
|
|
now = ktime_get_real_seconds();
|
2010-03-18 01:02:59 +08:00
|
|
|
return (ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE;
|
|
|
|
}
|