From 4f9e24f88dd23955ab117b7b28d3b8fa3330c240 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Fri, 6 Jan 2012 22:39:37 +0100 Subject: [PATCH] updated copyright information --- Makefile | 2 +- authenc.c | 59 ++++------------------------------------------ util.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ util.h | 2 ++ zc.c | 1 + 5 files changed, 88 insertions(+), 56 deletions(-) create mode 100644 util.c create mode 100644 util.h diff --git a/Makefile b/Makefile index 67895d8..e0c005a 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ KBUILD_CFLAGS += -I$(src) KERNEL_DIR = /lib/modules/$(shell uname -r)/build VERSION = 1.0 -cryptodev-objs = ioctl.o main.o cryptlib.o authenc.o zc.o +cryptodev-objs = ioctl.o main.o cryptlib.o authenc.o zc.o util.o obj-m += cryptodev.o diff --git a/authenc.c b/authenc.c index 2ad0daa..9b2ce09 100644 --- a/authenc.c +++ b/authenc.c @@ -1,7 +1,9 @@ /* * Driver for /dev/crypto device (aka CryptoDev) * - * Copyright (c) 2011 Nikos Mavrogiannopoulos + * Copyright (c) 2011, 2012 OpenSSL Software Foundation, Inc. + * + * Author: Nikos Mavrogiannopoulos * * This file is part of linux cryptodev. * @@ -41,6 +43,7 @@ #include #include "cryptodev_int.h" #include "zc.h" +#include "util.h" #include "cryptlib.h" #include "version.h" @@ -91,60 +94,6 @@ static int get_userbuf_tls(struct csession *ses, struct kernel_crypt_auth_op *kc return 0; } -/* Taken from Maxim Levitsky's patch - */ -static struct scatterlist *sg_advance(struct scatterlist *sg, int consumed) -{ - while (consumed >= sg->length) { - consumed -= sg->length; - - sg = sg_next(sg); - if (!sg) - break; - } - - WARN_ON(!sg && consumed); - - if (!sg) - return NULL; - - sg->offset += consumed; - sg->length -= consumed; - - if (sg->offset >= PAGE_SIZE) { - struct page *page = - nth_page(sg_page(sg), sg->offset / PAGE_SIZE); - sg_set_page(sg, page, sg->length, sg->offset % PAGE_SIZE); - } - - return sg; -} - -/** - * sg_copy - copies sg entries from sg_from to sg_to, such - * as sg_to covers first 'len' bytes from sg_from. - */ -static int sg_copy(struct scatterlist *sg_from, struct scatterlist *sg_to, int len) -{ - while (len > sg_from->length) { - len -= sg_from->length; - - sg_set_page(sg_to, sg_page(sg_from), - sg_from->length, sg_from->offset); - - sg_to = sg_next(sg_to); - sg_from = sg_next(sg_from); - - if (len && (!sg_from || !sg_to)) - return -ENOMEM; - } - - if (len) - sg_set_page(sg_to, sg_page(sg_from), - len, sg_from->offset); - sg_mark_end(sg_to); - return 0; -} #define MAX_SRTP_AUTH_DATA_DIFF 256 diff --git a/util.c b/util.c new file mode 100644 index 0000000..9eba483 --- /dev/null +++ b/util.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2011 Maxim Levitsky + * + * This file is part of linux cryptodev. + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include "util.h" + +/* These were taken from Maxim Levitsky's patch to lkml. + */ +struct scatterlist *sg_advance(struct scatterlist *sg, int consumed) +{ + while (consumed >= sg->length) { + consumed -= sg->length; + + sg = sg_next(sg); + if (!sg) + break; + } + + WARN_ON(!sg && consumed); + + if (!sg) + return NULL; + + sg->offset += consumed; + sg->length -= consumed; + + if (sg->offset >= PAGE_SIZE) { + struct page *page = + nth_page(sg_page(sg), sg->offset / PAGE_SIZE); + sg_set_page(sg, page, sg->length, sg->offset % PAGE_SIZE); + } + + return sg; +} + +/** + * sg_copy - copies sg entries from sg_from to sg_to, such + * as sg_to covers first 'len' bytes from sg_from. + */ +int sg_copy(struct scatterlist *sg_from, struct scatterlist *sg_to, int len) +{ + while (len > sg_from->length) { + len -= sg_from->length; + + sg_set_page(sg_to, sg_page(sg_from), + sg_from->length, sg_from->offset); + + sg_to = sg_next(sg_to); + sg_from = sg_next(sg_from); + + if (len && (!sg_from || !sg_to)) + return -ENOMEM; + } + + if (len) + sg_set_page(sg_to, sg_page(sg_from), + len, sg_from->offset); + sg_mark_end(sg_to); + return 0; +} + diff --git a/util.h b/util.h new file mode 100644 index 0000000..204de75 --- /dev/null +++ b/util.h @@ -0,0 +1,2 @@ +int sg_copy(struct scatterlist *sg_from, struct scatterlist *sg_to, int len); +struct scatterlist *sg_advance(struct scatterlist *sg, int consumed); diff --git a/zc.c b/zc.c index cf1aa25..778593f 100644 --- a/zc.c +++ b/zc.c @@ -3,6 +3,7 @@ * * Copyright (c) 2009-2011 Nikos Mavrogiannopoulos * Copyright (c) 2010 Phil Sutter + * Copyright (c) 2011, 2012 OpenSSL Software Foundation, Inc. * * This file is part of linux cryptodev. * -- 2.11.4.GIT