demo_crypt_sizes.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* LibTomCrypt, modular cryptographic library -- Tom St Denis
  2. *
  3. * LibTomCrypt is a library that provides various cryptographic
  4. * algorithms in a highly modular and flexible manner.
  5. *
  6. * The library is free for all purposes without any express
  7. * guarantee it works.
  8. *
  9. * Tom St Denis, [email protected], http://libtom.org
  10. */
  11. #include "tomcrypt.h"
  12. /**
  13. @file demo_crypt_sizes.c
  14. Demo how to get various sizes to dynamic languages
  15. like Python - Larry Bugbee, February 2013
  16. */
  17. int main(void) {
  18. int rc;
  19. // given a specific size name, get and print its size
  20. char name[] = "ecc_key_struct_size";
  21. int size;
  22. rc = crypt_get_size(name, &size);
  23. printf("\n size of '%s' is %d \n\n", name, size);
  24. // get and print the length of the names (and sizes) list
  25. char *sizes_list;
  26. unsigned long sizes_list_len;
  27. rc = crypt_list_all_sizes(NULL, &sizes_list_len);
  28. printf(" need to allocate %lu bytes \n\n", sizes_list_len);
  29. // get and print the names (and sizes) list
  30. sizes_list = malloc(sizes_list_len);
  31. rc = crypt_list_all_sizes(sizes_list, &sizes_list_len);
  32. printf(" supported sizes:\n\n%s\n\n", sizes_list);
  33. }
  34. /* $Source: $ */
  35. /* $Revision: $ */
  36. /* $Date: $ */