summaryrefslogtreecommitdiffstats
path: root/Documentation/admin-guide
AgeCommit message (Expand)Author
2018-09-14xen/balloon: add runtime control for scrubbing ballooned out pagesMarek Marczykowski-Górecki
2018-09-09Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/...Linus Torvalds
2018-09-01random: make CPU trust a boot parameterKees Cook
2018-08-24Merge tag 'iommu-updates-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/...Linus Torvalds
2018-08-22mm, oom: introduce memory.oom.groupRoman Gushchin
2018-08-22mm: clarify CONFIG_PAGE_POISONING and usageKees Cook
2018-08-18Merge tag 'driver-core-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel...Linus Torvalds
2018-08-18Merge tag 'tty-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gre...Linus Torvalds
2018-08-17Merge branch 'akpm' (patches from Andrew)Linus Torvalds
2018-08-17tools/vm/page-types.c: add support for idle page trackingChristian Hansen
2018-08-17tools/vm/page-types.c: include shared map countsChristian Hansen
2018-08-17Merge tag 'powerpc-4.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/p...Linus Torvalds
2018-08-16Merge tag 'pci-v4.19-changes' of git://git.kernel.org/pub/scm/linux/kernel/gi...Linus Torvalds
2018-08-15Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git...Linus Torvalds
2018-08-15Merge branch 'pci/resource'Bjorn Helgaas
2018-08-15Merge tag 'hardened-usercopy-v4.19-rc1' of git://git.kernel.org/pub/scm/linux...Linus Torvalds
2018-08-14Merge tag 'docs-4.19' of git://git.lwn.net/linuxLinus Torvalds
2018-08-14Merge tag 'for-4.19/block-20180812' of git://git.kernel.dk/linux-blockLinus Torvalds
2018-08-14Merge branch 'l1tf-final' of git://git.kernel.org/pub/scm/linux/kernel/git/ti...Linus Torvalds
2018-08-13Merge branch 'x86-timers-for-linus' of git://git.kernel.org/pub/scm/linux/ker...Linus Torvalds
2018-08-09PCI: Add "pci=disable_acs_redir=" parameter for peer-to-peer supportLogan Gunthorpe
2018-08-09PCI: Allow specifying devices using a base bus and path of devfnsLogan Gunthorpe
2018-08-09PCI: Make specifying PCI devices in kernel parameters reusableLogan Gunthorpe
2018-08-08Merge branches 'arm/shmobile', 'arm/renesas', 'arm/msm', 'arm/smmu', 'arm/oma...Joerg Roedel
2018-08-08Documentation: Add nospectre_v1 parameterDiana Craciun
2018-08-05Merge tag 'v4.18-rc6' into for-4.19/block2Jens Axboe
2018-08-05KVM: VMX: Tell the nested hypervisor to skip L1D flush on vmentryPaolo Bonzini
2018-08-05Documentation/l1tf: Remove Yonah processors from not vulnerable listThomas Gleixner
2018-08-05Merge 4.18-rc7 into master to pick up the KVM dependcyThomas Gleixner
2018-08-02block: make iolatency avg_lat exponentially decayDennis Zhou (Facebook)
2018-07-30Merge 4.18-rc7 into driver-core-nextGreg Kroah-Hartman
2018-07-27iommu: Add config option to set passthrough as defaultOlof Johansson
2018-07-21vt: add /dev/vcsu* to devices.txtNicolas Pitre
2018-07-20Documentation/l1tf: Fix typosTony Luck
2018-07-20x86/tsc: Redefine notsc to behave as tsc=unstablePavel Tatashin
2018-07-18blkcg: Track DISCARD statistics and output them in cgroup io.statTejun Heo
2018-07-17vsprintf: Add command line option debug_boot_weak_hashTobin C. Harding
2018-07-17Merge branch 'for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/pau...Ingo Molnar
2018-07-13Documentation: Add section about CPU vulnerabilitiesThomas Gleixner
2018-07-13x86/bugs, kvm: Introduce boot-time control of L1TF mitigationsJiri Kosina
2018-07-12rcutorture: Change units of onoff_interval to jiffiesPaul E. McKenney
2018-07-10Documentation: Add powerpc options for spec_store_bypass_disableMichael Ellerman
2018-07-10docs: kernel-parameters.txt: document xhci-hcd.quirks parameterLaurentiu Tudor
2018-07-10driver core: allow stopping deferred probe after initRob Herring
2018-07-09Documentation: add a doc for blk-iolatencyJosef Bacik
2018-07-06docs: kernel-parameters.txt: document xhci-hcd.quirks parameterLaurentiu Tudor
2018-07-04x86/KVM/VMX: Add module argument for L1TF mitigationKonrad Rzeszutek Wilk
2018-07-04x86/KVM: Warn user if KVM is loaded SMT and L1TF CPU bug being presentKonrad Rzeszutek Wilk
2018-07-04usercopy: Allow boot cmdline disabling of hardeningChris von Recklinghausen
2018-07-02Merge tag 'v4.18-rc3' into docs-nextJonathan Corbet
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
/*
 * The MORUS-640 Authenticated-Encryption Algorithm
 *
 * Copyright (c) 2016-2018 Ondrej Mosnacek <omosnacek@gmail.com>
 * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 */

#include <asm/unaligned.h>
#include <crypto/algapi.h>
#include <crypto/internal/aead.h>
#include <crypto/internal/skcipher.h>
#include <crypto/morus_common.h>
#include <crypto/scatterwalk.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/scatterlist.h>

#define MORUS640_WORD_SIZE 4
#define MORUS640_BLOCK_SIZE (MORUS_BLOCK_WORDS * MORUS640_WORD_SIZE)
#define MORUS640_BLOCK_ALIGN (__alignof__(__le32))
#define MORUS640_ALIGNED(p) IS_ALIGNED((uintptr_t)p, MORUS640_BLOCK_ALIGN)

struct morus640_block {
	u32 words[MORUS_BLOCK_WORDS];
};

union morus640_block_in {
	__le32 words[MORUS_BLOCK_WORDS];
	u8 bytes[MORUS640_BLOCK_SIZE];
};

struct morus640_state {
	struct morus640_block s[MORUS_STATE_BLOCKS];
};

struct morus640_ctx {
	struct morus640_block key;
};

struct morus640_ops {
	int (*skcipher_walk_init)(struct skcipher_walk *walk,
				  struct aead_request *req, bool atomic);

	void (*crypt_chunk)(struct morus640_state *state,
			    u8 *dst, const u8 *src, unsigned int size);
};

static const struct morus640_block crypto_morus640_const[2] = {
	{ .words = {
		U32_C(0x02010100),
		U32_C(0x0d080503),
		U32_C(0x59372215),
		U32_C(0x6279e990),
	} },
	{ .words = {
		U32_C(0x55183ddb),
		U32_C(0xf12fc26d),
		U32_C(0x42311120),
		U32_C(0xdd28b573),
	} },
};

static void crypto_morus640_round(struct morus640_block *b0,
				  struct morus640_block *b1,
				  struct morus640_block *b2,
				  struct morus640_block *b3,
				  struct morus640_block *b4,
				  const struct morus640_block *m,
				  unsigned int b, unsigned int w)
{
	unsigned int i;
	struct morus640_block tmp;

	for (i = 0; i < MORUS_BLOCK_WORDS; i++) {
		b0->words[i] ^= b1->words[i] & b2->words[i];
		b0->words[i] ^= b3->words[i];
		b0->words[i] ^= m->words[i];
		b0->words[i] = rol32(b0->words[i], b);
	}

	tmp = *b3;
	for (i = 0; i < MORUS_BLOCK_WORDS; i++)
		b3->words[(i + w) % MORUS_BLOCK_WORDS] = tmp.words[i];
}

static void crypto_morus640_update(struct morus640_state *state,
				   const struct morus640_block *m)
{
	static const struct morus640_block z = {};

	struct morus640_block *s = state->s;

	crypto_morus640_round(&s[0], &s[1], &s[2], &s[3], &s[4], &z,  5, 1);
	crypto_morus640_round(&s[1], &s[2], &s[3], &s[4], &s[0], m,  31, 2);
	crypto_morus640_round(&s[2], &s[3], &s[4], &s[0], &s[1], m,   7, 3);
	crypto_morus640_round(&s[3], &s[4], &s[0], &s[1], &s[2], m,  22, 2);
	crypto_morus640_round(&s[4], &s[0], &s[1], &s[2], &s[3], m,  13, 1);
}

static void crypto_morus640_load_a(struct morus640_block *dst, const u8 *src)
{
	unsigned int i;
	for (i = 0; i < MORUS_BLOCK_WORDS; i++) {
		dst->words[i] = le32_to_cpu(*(const __le32 *)src);
		src += MORUS640_WORD_SIZE;
	}
}

static void crypto_morus640_load_u(struct morus640_block *dst, const u8 *src)
{
	unsigned int i;
	for (i = 0; i < MORUS_BLOCK_WORDS; i++) {
		dst->words[i] = get_unaligned_le32(src);
		src += MORUS640_WORD_SIZE;
	}
}

static void crypto_morus640_load(struct morus640_block *dst, const u8 *src)
{
	if (MORUS640_ALIGNED(src))
		crypto_morus640_load_a(dst, src);
	else
		crypto_morus640_load_u(dst, src);
}

static void crypto_morus640_store_a(u8 *dst, const struct morus640_block *src)
{
	unsigned int i;
	for (i = 0; i < MORUS_BLOCK_WORDS; i++) {
		*(__le32 *)dst = cpu_to_le32(src->words[i]);
		dst += MORUS640_WORD_SIZE;
	}
}

static void crypto_morus640_store_u(u8 *dst, const struct morus640_block *src)
{
	unsigned int i;
	for (i = 0; i < MORUS_BLOCK_WORDS; i++) {
		put_unaligned_le32(src->words[i], dst);
		dst += MORUS640_WORD_SIZE;
	}
}

static void crypto_morus640_store(u8 *dst, const struct morus640_block *src)
{
	if (MORUS640_ALIGNED(dst))
		crypto_morus640_store_a(dst, src);
	else
		crypto_morus640_store_u(dst, src);
}

static void crypto_morus640_ad(struct morus640_state *state, const u8 *src,
			       unsigned int size)
{
	struct morus640_block m;

	if (MORUS640_ALIGNED(src)) {
		while (size >= MORUS640_BLOCK_SIZE) {
			crypto_morus640_load_a(&m, src);
			crypto_morus640_update(state, &m);

			size -= MORUS640_BLOCK_SIZE;
			src += MORUS640_BLOCK_SIZE;
		}
	} else {
		while (size >= MORUS640_BLOCK_SIZE) {
			crypto_morus640_load_u(&m, src);
			crypto_morus640_update(state, &m);

			size -= MORUS640_BLOCK_SIZE;
			src += MORUS640_BLOCK_SIZE;
		}
	}
}

static void crypto_morus640_core(const struct morus640_state *state,
				 struct morus640_block *blk)
{
	unsigned int i;

	for (i = 0; i < MORUS_BLOCK_WORDS; i++)
		blk->words[(i + 3) % MORUS_BLOCK_WORDS] ^= state->s[1].words[i];

	for (i = 0; i < MORUS_BLOCK_WORDS; i++) {
		blk->words[i] ^= state->s[0].words[