On Tue, Sep 25, 2012 at 8:04 PM, Shane Hansen <
shanem...@gmail.com> wrote:
> Using the existing registry seemed like a great way to accomplish that, but
> if violates some design principle of the standard libraries then it's a
> no-go.
Although it's not the intended use, that doesn't mean that it
shouldn't change. However, overriding the registry of hash functions
does often leave you with both the generic and platform-specific
versions linked in, right? It's just that the generic version would be
idle.
(It's also important to note that math/big is not constant time at the
moment so it may be possible to extract key material via timing side
channels. Also, the Go crypto code has not received anything like the
sort of review that more common crypto libraries have. For these
reasons alone you may wish to use something like OpenSSL.)
Are you sure that using the hardware support is actually faster than a
good software implementation? TLS is often going to be dealing with
~1400 byte chunks. (crypto/tls probably doesn't do a good job of
fragmentation at the moment, but that has other performance
implications.) I assume that the overhead of a kernel call every 1400
bytes is going to be significant, and possibly might overwhelm the
benefits.
But, if the benefits are clear then I think the design that would most
closely gel with the current code would be a package that implements
the kernel calls and then code in crypto/aes, crypto/sha1 etc that
figures out whether to call it at run time. (That code would have to
include suitable build tags, of course.)
Cheers
AGL