linux/net/sunrpc/auth_gss/gss_krb5_test.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2022 Oracle and/or its affiliates.
 *
 * KUnit test of SunRPC's GSS Kerberos mechanism. Subsystem
 * name is "rpcsec_gss_krb5".
 */

#include <kunit/test.h>
#include <kunit/visibility.h>

#include <linux/kernel.h>
#include <crypto/hash.h>

#include <linux/sunrpc/xdr.h>
#include <linux/sunrpc/gss_krb5.h>

#include "gss_krb5_internal.h"

MODULE_IMPORT_NS();

struct gss_krb5_test_param {};

static inline void gss_krb5_get_desc(const struct gss_krb5_test_param *param,
				     char *desc)
{}

static void kdf_case(struct kunit *test)
{}

static void checksum_case(struct kunit *test)
{}

#define DEFINE_HEX_XDR_NETOBJ(name, hex_array...)

#define DEFINE_STR_XDR_NETOBJ(name, string)

/*
 * RFC 3961 Appendix A.1.  n-fold
 *
 * The n-fold function is defined in section 5.1 of RFC 3961.
 *
 * This test material is copyright (C) The Internet Society (2005).
 */

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

static const struct gss_krb5_test_param rfc3961_nfold_test_params[] =;

/* Creates the function rfc3961_nfold_gen_params */
KUNIT_ARRAY_PARAM(rfc3961_nfold, rfc3961_nfold_test_params, gss_krb5_get_desc);

static void rfc3961_nfold_case(struct kunit *test)
{}

static struct kunit_case rfc3961_test_cases[] =;

static struct kunit_suite rfc3961_suite =;

/*
 * From RFC 3962 Appendix B:   Sample Test Vectors
 *
 * Some test vectors for CBC with ciphertext stealing, using an
 * initial vector of all-zero.
 *
 * This test material is copyright (C) The Internet Society (2005).
 */

DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

static const struct gss_krb5_test_param rfc3962_encrypt_test_params[] =;

/* Creates the function rfc3962_encrypt_gen_params */
KUNIT_ARRAY_PARAM(rfc3962_encrypt, rfc3962_encrypt_test_params,
		  gss_krb5_get_desc);

/*
 * This tests the implementation of the encryption part of the mechanism.
 * It does not apply a confounder or test the result of HMAC over the
 * plaintext.
 */
static void rfc3962_encrypt_case(struct kunit *test)
{}

static struct kunit_case rfc3962_test_cases[] =;

static struct kunit_suite rfc3962_suite =;

/*
 * From RFC 6803 Section 10.  Test vectors
 *
 * Sample results for key derivation
 *
 * Copyright (c) 2012 IETF Trust and the persons identified as the
 * document authors.  All rights reserved.
 */

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

static const struct gss_krb5_test_param rfc6803_kdf_test_params[] =;

/* Creates the function rfc6803_kdf_gen_params */
KUNIT_ARRAY_PARAM(rfc6803_kdf, rfc6803_kdf_test_params, gss_krb5_get_desc);

/*
 * From RFC 6803 Section 10.  Test vectors
 *
 * Sample checksums.
 *
 * Copyright (c) 2012 IETF Trust and the persons identified as the
 * document authors.  All rights reserved.
 *
 * XXX: These tests are likely to fail on EBCDIC or Unicode platforms.
 */
DEFINE_STR_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_STR_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_STR_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_STR_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

static const struct gss_krb5_test_param rfc6803_checksum_test_params[] =;

/* Creates the function rfc6803_checksum_gen_params */
KUNIT_ARRAY_PARAM(rfc6803_checksum, rfc6803_checksum_test_params,
		  gss_krb5_get_desc);

/*
 * From RFC 6803 Section 10.  Test vectors
 *
 * Sample encryptions (all using the default cipher state)
 *
 * Copyright (c) 2012 IETF Trust and the persons identified as the
 * document authors.  All rights reserved.
 *
 * Key usage values are from errata 4326 against RFC 6803.
 */

static const struct xdr_netobj rfc6803_enc_empty_plaintext =;

DEFINE_STR_XDR_NETOBJ();
DEFINE_STR_XDR_NETOBJ();
DEFINE_STR_XDR_NETOBJ();
DEFINE_STR_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

static const struct gss_krb5_test_param rfc6803_encrypt_test_params[] =;

/* Creates the function rfc6803_encrypt_gen_params */
KUNIT_ARRAY_PARAM(rfc6803_encrypt, rfc6803_encrypt_test_params,
		  gss_krb5_get_desc);

static void rfc6803_encrypt_case(struct kunit *test)
{}

static struct kunit_case rfc6803_test_cases[] =;

static struct kunit_suite rfc6803_suite =;

/*
 * From RFC 8009 Appendix A.  Test Vectors
 *
 * Sample results for SHA-2 enctype key derivation
 *
 * This test material is copyright (c) 2016 IETF Trust and the
 * persons identified as the document authors.  All rights reserved.
 */

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

static const struct gss_krb5_test_param rfc8009_kdf_test_params[] =;

/* Creates the function rfc8009_kdf_gen_params */
KUNIT_ARRAY_PARAM(rfc8009_kdf, rfc8009_kdf_test_params, gss_krb5_get_desc);

/*
 * From RFC 8009 Appendix A.  Test Vectors
 *
 * These sample checksums use the above sample key derivation results,
 * including use of the same base-key and key usage values.
 *
 * This test material is copyright (c) 2016 IETF Trust and the
 * persons identified as the document authors.  All rights reserved.
 */

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

static const struct gss_krb5_test_param rfc8009_checksum_test_params[] =;

/* Creates the function rfc8009_checksum_gen_params */
KUNIT_ARRAY_PARAM(rfc8009_checksum, rfc8009_checksum_test_params,
		  gss_krb5_get_desc);

/*
 * From RFC 8009 Appendix A.  Test Vectors
 *
 * Sample encryptions (all using the default cipher state):
 * --------------------------------------------------------
 *
 * These sample encryptions use the above sample key derivation results,
 * including use of the same base-key and key usage values.
 *
 * This test material is copyright (c) 2016 IETF Trust and the
 * persons identified as the document authors.  All rights reserved.
 */

static const struct xdr_netobj rfc8009_enc_empty_plaintext =;
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();
DEFINE_HEX_XDR_NETOBJ();

static const struct gss_krb5_test_param rfc8009_encrypt_test_params[] =;

/* Creates the function rfc8009_encrypt_gen_params */
KUNIT_ARRAY_PARAM(rfc8009_encrypt, rfc8009_encrypt_test_params,
		  gss_krb5_get_desc);

static void rfc8009_encrypt_case(struct kunit *test)
{}

static struct kunit_case rfc8009_test_cases[] =;

static struct kunit_suite rfc8009_suite =;

/*
 * Encryption self-tests
 */

DEFINE_STR_XDR_NETOBJ();

static const struct gss_krb5_test_param encrypt_selftest_params[] =;

/* Creates the function encrypt_selftest_gen_params */
KUNIT_ARRAY_PARAM(encrypt_selftest, encrypt_selftest_params,
		  gss_krb5_get_desc);

/*
 * Encrypt and decrypt plaintext, and ensure the input plaintext
 * matches the output plaintext. A confounder is not added in this
 * case.
 */
static void encrypt_selftest_case(struct kunit *test)
{}

static struct kunit_case encryption_test_cases[] =;

static struct kunit_suite encryption_test_suite =;

kunit_test_suites();

MODULE_DESCRIPTION();
MODULE_LICENSE();