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