Whamcloud - gitweb
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>