I2C toy code
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

53 linhas
1.4 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_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$ */