You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

os_port.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef AXTLS_OS_PORT_H
  2. #define AXTLS_OS_PORT_H
  3. /**
  4. * @file os_port.h
  5. *
  6. * Trick the axtls code into building within our build environment.
  7. */
  8. #include <stdint.h>
  9. #include <byteswap.h>
  10. /** All imported axTLS files are licensed using the three-clause BSD licence */
  11. FILE_LICENCE ( BSD3 );
  12. /** We can't actually abort, since we are effectively a kernel... */
  13. #define abort() assert ( 0 )
  14. /** rsa.c uses alloca() */
  15. #define alloca( size ) __builtin_alloca ( size )
  16. #include <ipxe/random_nz.h>
  17. static inline void get_random_NZ ( int num_rand_bytes, uint8_t *rand_data ) {
  18. /* AXTLS does not check for failures when generating random
  19. * data. Rely on the fact that get_random_nz() does not
  20. * request prediction resistance (and so cannot introduce new
  21. * failures) and therefore any potential failure must already
  22. * have been encountered by e.g. tls_generate_random(), which
  23. * does check for failures.
  24. */
  25. get_random_nz ( rand_data, num_rand_bytes );
  26. }
  27. /* Expose AES_encrypt() and AES_decrypt() in aes.o */
  28. #define aes 1
  29. #if OBJECT
  30. struct aes_key_st;
  31. static void AES_encrypt ( const struct aes_key_st *ctx, uint32_t *data );
  32. static void AES_decrypt ( const struct aes_key_st *ctx, uint32_t *data );
  33. void axtls_aes_encrypt ( void *ctx, uint32_t *data ) {
  34. AES_encrypt ( ctx, data );
  35. }
  36. void axtls_aes_decrypt ( void *ctx, uint32_t *data ) {
  37. AES_decrypt ( ctx, data );
  38. }
  39. #endif
  40. #undef aes
  41. #endif