Whamcloud - gitweb
LU-5053 libcfs: clean up cfs_crypto_hash code 90/9990/4
authorAndreas Dilger <andreas.dilger@intel.com>
Mon, 18 Nov 2013 08:47:44 +0000 (01:47 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 1 Jul 2014 04:37:35 +0000 (04:37 +0000)
commit0723b8be34503b31dbfc6c877d7a855091c625b4
tree88a14a2f71b0173a6d1fcf1220b9644403363ab1
parent893b677180ae0ee36008522540c3ce743bade48d
LU-5053 libcfs: clean up cfs_crypto_hash code

Remove <libcfs/libcfs_crypto.h> from <libcfs/libcfs.h> and only
include it into the places where it is actually needed.  This
works out to be the same places as <obd_cksum.h>, so put it there.

Fix the cfs_crypto_hash_* functions to take enum cfs_crypto_hash_alg
as the algorithm type, instead of an unsigned char.  Return
CFS_HASH_ALG_UNKOWN for unknown hash names instead of "0xFF".

Rename some variables to be consistent across functions.

Add comment blocks for cfs_crypto_hash_*() in linux-crypto.c.  Some
of these functions could be shared with user-crypto.c in a common
crypto.c file, but the code shuffling should be done separately.

Change cfs_crypto_hash_final() to always clean up the hash descrptor
instead of not doing this in error cases.  All of the callers were
just calling cfs_crypto_hash_final() immediately to clean up the
descriptor anyway, and the old behaviour is unlike other init/fini
functions, and prone to memory leaks and other incorrect usage.  The
callers can call cfs_crypto_digest_size() to determine the hash size
in advance if needed, and avoid complexity in cfs_crypto_hash_final().

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I79884eb2ee31a2b375420cf62af5ce8ff22e0e75
Reviewed-on: http://review.whamcloud.com/9990
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/libcfs_crypto.h
libcfs/libcfs/linux/linux-crypto.c
libcfs/libcfs/user-crypto.c
lustre/include/obd_cksum.h
lustre/osc/osc_request.c
lustre/ptlrpc/sec_bulk.c
lustre/target/tgt_handler.c