Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/opencrypto simplify, no functional change
details: https://anonhg.NetBSD.org/src/rev/189f92d4fb73
branches: trunk
changeset: 334040:189f92d4fb73
user: christos <christos%NetBSD.org@localhost>
date: Thu Nov 27 20:30:21 2014 +0000
description:
simplify, no functional change
diffstat:
sys/opencrypto/cryptosoft_xform.c | 102 +++++++++++++++----------------------
1 files changed, 41 insertions(+), 61 deletions(-)
diffs (197 lines):
diff -r f959e02482ff -r 189f92d4fb73 sys/opencrypto/cryptosoft_xform.c
--- a/sys/opencrypto/cryptosoft_xform.c Thu Nov 27 20:30:05 2014 +0000
+++ b/sys/opencrypto/cryptosoft_xform.c Thu Nov 27 20:30:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cryptosoft_xform.c,v 1.26 2013/02/02 21:06:31 christos Exp $ */
+/* $NetBSD: cryptosoft_xform.c,v 1.27 2014/11/27 20:30:21 christos Exp $ */
/* $FreeBSD: src/sys/opencrypto/xform.c,v 1.1.2.1 2002/11/21 23:34:23 sam Exp $ */
/* $OpenBSD: xform.c,v 1.19 2002/08/16 22:47:25 dhartmei Exp $ */
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: cryptosoft_xform.c,v 1.26 2013/02/02 21:06:31 christos Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cryptosoft_xform.c,v 1.27 2014/11/27 20:30:21 christos Exp $");
#include <crypto/blowfish/blowfish.h>
#include <crypto/cast128/cast128.h>
@@ -427,17 +427,14 @@
des1_setkey(u_int8_t **sched, const u_int8_t *key, int len)
{
des_key_schedule *p;
- int err;
p = malloc(sizeof (des_key_schedule),
- M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
- if (p != NULL) {
- des_set_key((des_cblock *)__UNCONST(key), p[0]);
- err = 0;
- } else
- err = ENOMEM;
+ M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
*sched = (u_int8_t *) p;
- return err;
+ if (p == NULL)
+ return ENOMEM;
+ des_set_key((des_cblock *)__UNCONST(key), p[0]);
+ return 0;
}
static void
@@ -470,19 +467,16 @@
des3_setkey(u_int8_t **sched, const u_int8_t *key, int len)
{
des_key_schedule *p;
- int err;
p = malloc(3*sizeof (des_key_schedule),
M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
- if (p != NULL) {
- des_set_key((des_cblock *)__UNCONST(key + 0), p[0]);
- des_set_key((des_cblock *)__UNCONST(key + 8), p[1]);
- des_set_key((des_cblock *)__UNCONST(key + 16), p[2]);
- err = 0;
- } else
- err = ENOMEM;
*sched = (u_int8_t *) p;
- return err;
+ if (p == NULL)
+ return ENOMEM;
+ des_set_key((des_cblock *)__UNCONST(key + 0), p[0]);
+ des_set_key((des_cblock *)__UNCONST(key + 8), p[1]);
+ des_set_key((des_cblock *)__UNCONST(key + 16), p[2]);
+ return 0;
}
static void
@@ -510,16 +504,13 @@
static int
blf_setkey(u_int8_t **sched, const u_int8_t *key, int len)
{
- int err;
*sched = malloc(sizeof(BF_KEY),
M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
- if (*sched != NULL) {
- BF_set_key((BF_KEY *) *sched, len, key);
- err = 0;
- } else
- err = ENOMEM;
- return err;
+ if (*sched == NULL)
+ return ENOMEM;
+ BF_set_key((BF_KEY *) *sched, len, key);
+ return 0;
}
static void
@@ -545,16 +536,13 @@
static int
cast5_setkey(u_int8_t **sched, const u_int8_t *key, int len)
{
- int err;
*sched = malloc(sizeof(cast128_key), M_CRYPTO_DATA,
M_NOWAIT|M_ZERO);
- if (*sched != NULL) {
- cast128_setkey((cast128_key *)*sched, key, len);
- err = 0;
- } else
- err = ENOMEM;
- return err;
+ if (*sched == NULL)
+ return ENOMEM;
+ cast128_setkey((cast128_key *)*sched, key, len);
+ return 0;
}
static void
@@ -580,7 +568,6 @@
static int
skipjack_setkey(u_int8_t **sched, const u_int8_t *key, int len)
{
- int err;
/* NB: allocate all the memory that's needed at once */
/* XXX assumes bytes are aligned on sizeof(u_char) == 1 boundaries.
@@ -589,21 +576,19 @@
*sched = malloc(10 * (sizeof(u_int8_t *) + 0x100),
M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
- if (*sched != NULL) {
+ if (*sched == NULL)
+ return ENOMEM;
- u_int8_t** key_tables = (u_int8_t**) *sched;
- u_int8_t* table = (u_int8_t*) &key_tables[10];
- int k;
+ u_int8_t** key_tables = (u_int8_t**) *sched;
+ u_int8_t* table = (u_int8_t*) &key_tables[10];
+ int k;
- for (k = 0; k < 10; k++) {
- key_tables[k] = table;
- table += 0x100;
- }
- subkey_table_gen(key, (u_int8_t **) *sched);
- err = 0;
- } else
- err = ENOMEM;
- return err;
+ for (k = 0; k < 10; k++) {
+ key_tables[k] = table;
+ table += 0x100;
+ }
+ subkey_table_gen(key, (u_int8_t **) *sched);
+ return 0;
}
static void
@@ -630,18 +615,15 @@
static int
rijndael128_setkey(u_int8_t **sched, const u_int8_t *key, int len)
{
- int err;
if (len != 16 && len != 24 && len != 32)
return EINVAL;
*sched = malloc(sizeof(rijndael_ctx), M_CRYPTO_DATA,
M_NOWAIT|M_ZERO);
- if (*sched != NULL) {
- rijndael_set_key((rijndael_ctx *) *sched, key, len * 8);
- err = 0;
- } else
- err = ENOMEM;
- return err;
+ if (*sched == NULL)
+ return ENOMEM;
+ rijndael_set_key((rijndael_ctx *) *sched, key, len * 8);
+ return 0;
}
static void
@@ -669,18 +651,16 @@
static int
cml_setkey(u_int8_t **sched, const u_int8_t *key, int len)
{
- int err;
if (len != 16 && len != 24 && len != 32)
return (EINVAL);
*sched = malloc(sizeof(camellia_ctx), M_CRYPTO_DATA,
M_NOWAIT|M_ZERO);
- if (*sched != NULL) {
- camellia_set_key((camellia_ctx *) *sched, key, len * 8);
- err = 0;
- } else
- err = ENOMEM;
- return err;
+ if (*sched == NULL)
+ return ENOMEM;
+
+ camellia_set_key((camellia_ctx *) *sched, key, len * 8);
+ return 0;
}
static void
Home |
Main Index |
Thread Index |
Old Index