diff options
author | 1999-04-05 21:00:27 +0000 | |
---|---|---|
committer | 1999-04-05 21:00:27 +0000 | |
commit | 390fe947cf10a792c3640527f7c1b1d3bb1b5951 (patch) | |
tree | d46210752e35aac2efd905067fd50ebddbf6e95c | |
parent | Merge with EOM 1.34 (diff) | |
download | wireguard-openbsd-390fe947cf10a792c3640527f7c1b1d3bb1b5951.tar.xz wireguard-openbsd-390fe947cf10a792c3640527f7c1b1d3bb1b5951.zip |
Merge with EOM 1.24
Better error messages, style
1999 copyrights
-rw-r--r-- | sbin/isakmpd/crypto.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/sbin/isakmpd/crypto.c b/sbin/isakmpd/crypto.c index 0b878431a61..229756ef4b6 100644 --- a/sbin/isakmpd/crypto.c +++ b/sbin/isakmpd/crypto.c @@ -1,8 +1,9 @@ -/* $OpenBSD: crypto.c,v 1.4 1999/02/26 03:35:54 niklas Exp $ */ -/* $EOM: crypto.c,v 1.22 1999/02/25 11:38:50 niklas Exp $ */ +/* $OpenBSD: crypto.c,v 1.5 1999/04/05 21:00:27 niklas Exp $ */ +/* $EOM: crypto.c,v 1.24 1999/04/05 07:57:03 niklas Exp $ */ /* * Copyright (c) 1998 Niels Provos. All rights reserved. + * Copyright (c) 1999 Niklas Hallqvist. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -252,24 +253,26 @@ struct keystate * crypto_init (struct crypto_xf *xf, u_int8_t *key, u_int16_t len, enum cryptoerr *err) { - struct keystate *ks = NULL; + struct keystate *ks; if (len < xf->keymin || len > xf->keymax) { log_debug (LOG_CRYPTO, 10, "crypto_init: invalid key length %d", len); *err = EKEYLEN; - return NULL; + return 0; } - if ((ks = calloc (1, sizeof (struct keystate))) == NULL) + ks = calloc (1, sizeof *ks); + if (!ks) { + log_error ("crypto_init: calloc (1, %d) failed", sizeof *ks); *err = ENOCRYPTO; - return NULL; + return 0; } ks->xf = xf; - /* Set up the iv */ + /* Setup the IV. */ ks->riv = ks->iv; ks->liv = ks->iv2; @@ -281,7 +284,7 @@ crypto_init (struct crypto_xf *xf, u_int8_t *key, u_int16_t len, log_debug (LOG_CRYPTO, 30, "crypto_init: weak key found for %s", xf->name); free (ks); - return NULL; + return 0; } return ks; @@ -335,6 +338,7 @@ crypto_decrypt (struct keystate *ks, u_int8_t *buf, u_int16_t len) len); } +/* Make a copy of the keystate pointed to by OKS. */ struct keystate * crypto_clone_keystate (struct keystate *oks) { @@ -342,7 +346,10 @@ crypto_clone_keystate (struct keystate *oks) ks = malloc (sizeof *ks); if (!ks) - return 0; + { + log_error ("crypto_clone_keystate: malloc (%d) failed", sizeof *ks); + return 0; + } memcpy (ks, oks, sizeof *ks); if (oks->riv == oks->iv) { |