[OpenAFS-devel] bg-fcrypt

Björn Grönvall bg@sics.se
Tue, 5 Dec 2006 11:57:11 +0100


On Tue, 05 Dec 2006 09:38:38 +0100 (MET)
Harald Barth <haba@pdc.kth.se> wrote:

> Du har kanske inte sett det här mailet ;-)

That's right, I'm not on the list and never saw this mail.

> From: Marcus Watts <mdw@umich.edu>
> To: openafs-devel@openafs.org
> Subject: [OpenAFS-devel] bg-fcrypt
> Date: Mon, 04 Dec 2006 23:20:18 -0500
> Sender: openafs-devel-admin@openafs.org

> around line 553 in bg-fcrypt.c that starts off with:
> 	#if ((1ul << 31) << 1) && defined(ULONG_MAX) && ((ULONG_MAX >> 55) !==
 0) && ((1ul << 55) != 0)

Absolutely horrible test! Must have been written by your truly ;-) !

> Fortunately, there's a simplier alternative
> 	#ifdef AFS_64BIT_ENV
> 	    afs_uint64 k;
> which should be safe because this also conditions other 64-bit logic
> inside of afs/stds.h .

Since you have a simple and reliable test in your build environment I
would suggest that you use that instead (i.e AFS_64BIT_ENV).

> Xeon 3.06 Ghz.  linux 2.4.24.  gcc 3.3.1
>         kernel fcrypt           0.07    0.56    3.39
>         "kernel" bg-fcrypt.o    0.20    0.08    0.52    
>         user fcrypt.o           0.07    0.59    3.67
>         user bg-fcrypt.o        0.20    0.08    0.54    
> 
> kernel/"kernel" means built with the same compiler options
> as the kernel module for that architecture--optimization, word
> size, & whatever.
> 
> Apparently bg-fcrypt key schedule loses on i386 because it does lots
> of "ntohl" byte swapping.

The code is designed to "lose" on key schedule calculations in order
to "win big" on encryption operations. The key schedule is only
calculated once and encryption is typically performed thousands of
times. In this case the effective speedup should be
significant. Thanks for verifying this (and for pointing out that
"bg-fcrypt" is in the AFS tree).

Cheers,
/b

-- 
  _     _                                           ,_______________.
Bjorn Gronvall (Björn Grönvall)                    /_______________/|
Swedish Institute of Computer Science              |               ||
PO Box 1263, S-164 29 Kista, Sweden                | Schroedingers ||
Email: bg@sics.se, Phone +46 -8 633 15 25          |      Cat      |/
Cellular +46 -70 768 06 35, Fax +46 -8 751 72 30   '---------------'