Harmony in digest API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greeting,

I've completed the harmonized digest interface for cryptoapi.  I
really think people should start moving to something like this, make
life easier to deal with when new algorithms come along.  Or when old
ones are broken!

I haven't made it kernel-friendly yet any pointers would be appreciated.

Summary:
 At compile time you can specify 3 levels of optimization:
  1. Small footprint (sha1 < 2k!)
  2. Reasonable optimization
  3. Fully optimized (make very large code >100K)

 Each algorithm comes with a test bench console application to make
sure porting was successful.
 The C-struct hasher_t contains both data and function pointers to the
appropriate hash algorithm.  The example below should make it clear
how to use this, a complete example exists in hasher_test.c.

int main() {
  hasher_t H;
  u8 D[HASHER_MAX_DIGEST_SIZE];

  if (hasher_setup(&H, "md5") != HASHER_OK) {
    printf("Error: %d/%s\n", H.err, HasherErrorMsg(H.err));
    return 1;
  }
  
  H.Init(&H);
  H.Update(&H, "h", 1):
  H.Update(&H, "ello", 4);
  H.Update(&H, " there", 6);
  H.Final(&H, D);

  for (i=0; i<H.len; i++)
    printf("%.2x ", D[i]);
  printf("\n");
  
  H.Init(&H);
  H.Update(&H, "h", 1):
  H.Update(&H, "ello", 4);
  H.Update(&H, " THERE", 6);
  H.Final(&H, D);

  for (i=0; i<H.len; i++)
    printf("%.2x ", D[i]);
  printf("\n");
  
  HasherTeardown(&H); // cleanse hasher_t

  return 0;
}

I've used Doxygen to generate some purrty docs...

HTML API docs:
  http://www.certainkey.com/~jlcooke/linux-crypto/digest/hasher_docs/html/
PDF API docs:
  http://www.certainkey.com/~jlcooke/linux-crypto/digest/hasher_docs/latex/refman.pdf

Source code tar ball:
  http://www.certainkey.com/~jlcooke/linux-crypto/digest/TAR_BALLS/hasher_src.tar.gz
API docs tar ball:
  http://www.certainkey.com/~jlcooke/linux-crypto/digest/TAR_BALLS/hasher_docs.tar.gz

Cheers,

JLC
-- 
http://www.certainkey.com
Suite 4560 CTTC
1125 Colonel By Dr.
Ottawa ON, K1S 5B6
C: 613.263.2983
-
Linux-crypto:  cryptography in and on the Linux system
Archive:       http://mail.nl.linux.org/linux-crypto/


[Index of Archives]     [Kernel]     [Linux Crypto]     [Gnu Crypto]     [Gnu Classpath]     [Netfilter]     [Bugtraq]
  Powered by Linux