I2C toy code
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

constants.c 1.4 KiB

vor 5 Jahren
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_constants.c
  12. Demo how to get various constants to dynamic languages
  13. like Python
  14. Larry Bugbee, February 2013
  15. */
  16. int main(void) {
  17. /* given a specific constant name, get and print its value */
  18. char name[] = "CTR_COUNTER_BIG_ENDIAN";
  19. int value;
  20. char *names_list;
  21. unsigned int names_list_len;
  22. if (crypt_get_constant(name, &value) != 0)
  23. exit(EXIT_FAILURE);
  24. printf("\n %s is %d \n\n", name, value);
  25. /* get and print the length of the names (and values) list */
  26. if (crypt_list_all_constants(NULL, &names_list_len) != 0)
  27. exit(EXIT_FAILURE);
  28. printf(" need to allocate %u bytes \n\n", names_list_len);
  29. /* get and print the names (and values) list */
  30. if ((names_list = malloc(names_list_len)) == NULL)
  31. exit(EXIT_FAILURE);
  32. if (crypt_list_all_constants(names_list, &names_list_len) != 0)
  33. exit(EXIT_FAILURE);
  34. printf(" supported constants:\n\n%s\n\n", names_list);
  35. free(names_list);
  36. return 0;
  37. }
  38. /* ref: $Format:%D$ */
  39. /* git commit: $Format:%H$ */
  40. /* commit time: $Format:%ai$ */