Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

asn1_test.h 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _ASN1_TEST_H
  2. #define _ASN1_TEST_H
  3. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  4. #include <stdint.h>
  5. #include <ipxe/image.h>
  6. #include <ipxe/sha1.h>
  7. #include <ipxe/test.h>
  8. /** Digest algorithm used for ASN.1 tests */
  9. #define asn1_test_digest_algorithm sha1_algorithm
  10. /** Digest size used for ASN.1 tests */
  11. #define ASN1_TEST_DIGEST_SIZE SHA1_DIGEST_SIZE
  12. /** An ASN.1 test digest */
  13. struct asn1_test_digest {
  14. /** Digest value */
  15. uint8_t digest[ASN1_TEST_DIGEST_SIZE];
  16. };
  17. /** An ASN.1 test */
  18. struct asn1_test {
  19. /** Image type */
  20. struct image_type *type;
  21. /** Source image */
  22. struct image *image;
  23. /** Expected digests of ASN.1 objects */
  24. struct asn1_test_digest *expected;
  25. /** Number of ASN.1 objects */
  26. unsigned int count;
  27. };
  28. /**
  29. * Define an ASN.1 test
  30. *
  31. * @v _name Test name
  32. * @v _type Test image file type
  33. * @v _file Test image file data
  34. * @v ... Expected ASN.1 object digests
  35. * @ret test ASN.1 test
  36. */
  37. #define ASN1( _name, _type, _file, ... ) \
  38. static const char _name ## __file[] = _file; \
  39. static struct image _name ## __image = { \
  40. .refcnt = REF_INIT ( ref_no_free ), \
  41. .name = #_name, \
  42. .data = ( userptr_t ) ( _name ## __file ), \
  43. .len = sizeof ( _name ## __file ), \
  44. }; \
  45. static struct asn1_test_digest _name ## _expected[] = { \
  46. __VA_ARGS__ \
  47. }; \
  48. static struct asn1_test _name = { \
  49. .type = _type, \
  50. .image = & _name ## __image, \
  51. .expected = _name ## _expected, \
  52. .count = ( sizeof ( _name ## _expected ) / \
  53. sizeof ( _name ## _expected[0] ) ), \
  54. };
  55. extern void asn1_okx ( struct asn1_test *test, const char *file,
  56. unsigned int line );
  57. /**
  58. * Report ASN.1 test result
  59. *
  60. * @v test ASN.1 test
  61. */
  62. #define asn1_ok( test ) asn1_okx ( test, __FILE__, __LINE__ )
  63. #endif /* _ASN1_TEST_H */