I2C toy code
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

46 řádky
1.3 KiB

  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. #include "tomcrypt.h"
  10. /**
  11. @file demo_crypt_sizes.c
  12. Demo how to get various sizes to dynamic languages
  13. like Python - Larry Bugbee, February 2013
  14. */
  15. int main(void) {
  16. /* given a specific size name, get and print its size */
  17. char name[] = "ecc_key";
  18. unsigned int size;
  19. char *sizes_list;
  20. unsigned int sizes_list_len;
  21. if(crypt_get_size(name, &size) != 0)
  22. exit(EXIT_FAILURE);
  23. printf("\n size of '%s' is %u \n\n", name, size);
  24. /* get and print the length of the names (and sizes) list */
  25. if(crypt_list_all_sizes(NULL, &sizes_list_len) != 0)
  26. exit(EXIT_FAILURE);
  27. printf(" need to allocate %u bytes \n\n", sizes_list_len);
  28. /* get and print the names (and sizes) list */
  29. sizes_list = malloc(sizes_list_len);
  30. if(crypt_list_all_sizes(sizes_list, &sizes_list_len) != 0)
  31. exit(EXIT_FAILURE);
  32. printf(" supported sizes:\n\n%s\n\n", sizes_list);
  33. return 0;
  34. }
  35. /* ref: $Format:%D$ */
  36. /* git commit: $Format:%H$ */
  37. /* commit time: $Format:%ai$ */