1 #ifndef _MATRIXSSL_CRYPTOLAYER_H
2 #define _MATRIXSSL_CRYPTOLAYER_H
6 * Compatibility layer for MatrixSSL
17 #include <gpxe/rotate.h>
18 #include <gpxe/crypto.h>
20 /* Drag in pscrypto.h */
21 typedef uint64_t ulong64;
22 typedef void psPool_t;
26 #define USE_RSA_PUBLIC_ENCRYPT
28 #include "matrixssl/pscrypto.h"
32 #define sslAssert( ... ) assert ( __VA_ARGS__ )
34 static inline __attribute__ (( always_inline )) void * __malloc
35 psMalloc ( psPool_t *pool __unused, size_t len ) {
36 return malloc ( len );
39 static inline __attribute__ (( always_inline )) void *
40 psRealloc ( void *ptr, size_t len ) {
41 return realloc ( ptr, len );
44 static inline __attribute__ (( always_inline )) void psFree ( void *ptr ) {
48 #define matrixStrDebugMsg( ... ) DBG ( __VA_ARGS__ )
49 #define matrixIntDebugMsg( ... ) DBG ( __VA_ARGS__ )
51 /* Use our standard cpu_to_leXX etc. macros */
54 #define LOAD32L( cpu32, ptr ) do { \
55 uint32_t *le32 = ( ( uint32_t * ) ptr ); \
56 cpu32 = le32_to_cpu ( *le32 ); \
60 #define LOAD32H( cpu32, ptr ) do { \
61 uint32_t *be32 = ( ( uint32_t * ) ptr ); \
62 cpu32 = be32_to_cpu ( *be32 ); \
66 #define LOAD64L( cpu64, ptr ) do { \
67 uint64_t *le64 = ( ( uint64_t * ) ptr ); \
68 cpu64 = le64_to_cpu ( *le64 ); \
72 #define LOAD64H( cpu64, ptr ) do { \
73 uint64_t *be64 = ( ( uint64_t * ) ptr ); \
74 cpu64 = be64_to_cpu ( *be64 ); \
78 #define STORE32L( cpu32, ptr ) do { \
79 uint32_t *le32 = ( ( uint32_t * ) ptr ); \
80 *le32 = cpu_to_le32 ( cpu32 ); \
84 #define STORE32H( cpu32, ptr ) do { \
85 uint32_t *be32 = ( ( uint32_t * ) ptr ); \
86 *be32 = cpu_to_be32 ( cpu32 ); \
90 #define STORE64L( cpu64, ptr ) do { \
91 uint64_t *le64 = ( ( uint64_t * ) ptr ); \
92 *le64 = cpu_to_le64 ( cpu64 ); \
96 #define STORE64H( cpu64, ptr ) do { \
97 uint64_t *be64 = ( ( uint64_t * ) ptr ); \
98 *be64 = cpu_to_be64 ( cpu64 ); \
101 /* Use rolXX etc. from bitops.h */
104 #define ROL( data, rotation ) rol32 ( (data), (rotation) )
106 #define ROLc( data, rotation ) rol32 ( (data), (rotation) )
108 #define ROR( data, rotation ) ror32 ( (data), (rotation) )
110 #define RORc( data, rotation ) ror32 ( (data), (rotation) )
112 #define ROL64( data, rotation ) rol64 ( (data), (rotation) )
114 #define ROL64c( data, rotation ) rol64 ( (data), (rotation) )
116 #define ROR64( data, rotation ) ror64 ( (data), (rotation) )
118 #define ROR64c( data, rotation ) ror64 ( (data), (rotation) )
120 #endif /* _MATRIXSSL_CRYPTOLAYER_H */