]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blobdiff - crypto/morus640.c
Merge tag 'kbuild-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
[mirror_ubuntu-eoan-kernel.git] / crypto / morus640.c
index da06ec2f6a807ae6e1a8290d3178b726a38b9866..1617a1eb8be13137007e043a38da34e9c6574105 100644 (file)
@@ -1,13 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * 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>
@@ -365,18 +361,19 @@ static void crypto_morus640_process_crypt(struct morus640_state *state,
                                          const struct morus640_ops *ops)
 {
        struct skcipher_walk walk;
-       u8 *dst;
-       const u8 *src;
 
        ops->skcipher_walk_init(&walk, req, false);
 
        while (walk.nbytes) {
-               src = walk.src.virt.addr;
-               dst = walk.dst.virt.addr;
+               unsigned int nbytes = walk.nbytes;
+
+               if (nbytes < walk.total)
+                       nbytes = round_down(nbytes, walk.stride);
 
-               ops->crypt_chunk(state, dst, src, walk.nbytes);
+               ops->crypt_chunk(state, walk.dst.virt.addr, walk.src.virt.addr,
+                                nbytes);
 
-               skcipher_walk_done(&walk, 0);
+               skcipher_walk_done(&walk, walk.nbytes - nbytes);
        }
 }