diff options
Diffstat (limited to 'src/include/ipxe')
| -rw-r--r-- | src/include/ipxe/asn1.h | 18 | ||||
| -rw-r--r-- | src/include/ipxe/efi/efi.h | 32 | ||||
| -rw-r--r-- | src/include/ipxe/open.h | 2 | ||||
| -rw-r--r-- | src/include/ipxe/rotate.h | 34 |
4 files changed, 76 insertions, 10 deletions
diff --git a/src/include/ipxe/asn1.h b/src/include/ipxe/asn1.h index 24caecdc5..efc66631d 100644 --- a/src/include/ipxe/asn1.h +++ b/src/include/ipxe/asn1.h @@ -312,6 +312,24 @@ struct asn1_algorithm { /** Declare an ASN.1 OID-identified algorithm */ #define __asn1_algorithm __table_entry ( ASN1_ALGORITHMS, 01 ) +/* ASN.1 OID-identified algorithms */ +extern struct asn1_algorithm rsa_encryption_algorithm; +extern struct asn1_algorithm md5_with_rsa_encryption_algorithm; +extern struct asn1_algorithm sha1_with_rsa_encryption_algorithm; +extern struct asn1_algorithm sha256_with_rsa_encryption_algorithm; +extern struct asn1_algorithm sha384_with_rsa_encryption_algorithm; +extern struct asn1_algorithm sha512_with_rsa_encryption_algorithm; +extern struct asn1_algorithm sha224_with_rsa_encryption_algorithm; +extern struct asn1_algorithm oid_md4_algorithm; +extern struct asn1_algorithm oid_md5_algorithm; +extern struct asn1_algorithm oid_sha1_algorithm; +extern struct asn1_algorithm oid_sha256_algorithm; +extern struct asn1_algorithm oid_sha384_algorithm; +extern struct asn1_algorithm oid_sha512_algorithm; +extern struct asn1_algorithm oid_sha224_algorithm; +extern struct asn1_algorithm oid_sha512_224_algorithm; +extern struct asn1_algorithm oid_sha512_256_algorithm; + /** An ASN.1 bit string */ struct asn1_bit_string { /** Data */ diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 669e5364a..b8777ef47 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -65,6 +65,8 @@ typedef struct {} *EFI_HANDLE; #include <ipxe/tables.h> #include <ipxe/uuid.h> +#include <ipxe/version.h> +#include <ipxe/profile.h> /** An EFI protocol used by iPXE */ struct efi_protocol { @@ -272,6 +274,36 @@ extern void dbg_efi_protocols ( EFI_HANDLE handle ); #define DBGCP_EFI_PROTOCOLS( ... ) \ DBGC_EFI_PROTOCOLS_IF ( PROFILE, ##__VA_ARGS__ ) +extern unsigned long __stack_chk_guard; +extern unsigned long efi_stack_cookie ( EFI_HANDLE handle ); +extern void __stack_chk_fail ( void ); + +/** + * Initialise stack cookie + * + * @v handle Image handle + */ +static inline __attribute__ (( always_inline )) void +efi_init_stack_guard ( EFI_HANDLE handle ) { + + /* The calling function must not itself use stack protection, + * since the change in the stack guard value would trigger a + * false positive. + * + * There is unfortunately no way to annotate a function to + * exclude the use of stack protection. We must therefore + * rely on correctly anticipating the compiler's decision on + * the use of stack protection. + * + * The calculation of the stack cookie value deliberately + * takes the address of a stack variable (to provide an + * additional source of entropy). This operation would + * trigger the application of stack protection to the calling + * function, and so must be externalised. + */ + __stack_chk_guard = efi_stack_cookie ( handle ); +} + extern EFI_STATUS efi_init ( EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab ); diff --git a/src/include/ipxe/open.h b/src/include/ipxe/open.h index 43d4cdc66..64e12d177 100644 --- a/src/include/ipxe/open.h +++ b/src/include/ipxe/open.h @@ -70,8 +70,6 @@ struct uri_opener { struct socket_opener { /** Communication semantics (e.g. SOCK_STREAM) */ int semantics; - /** Address family (e.g. AF_INET) */ - int family; /** Open socket * * @v intf Object interface diff --git a/src/include/ipxe/rotate.h b/src/include/ipxe/rotate.h index b5693e3ca..4dea09aeb 100644 --- a/src/include/ipxe/rotate.h +++ b/src/include/ipxe/rotate.h @@ -10,44 +10,62 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <stdint.h> +#define ROLx( data, rotation ) \ + ( ( (data) << (rotation) ) | \ + ( (data) >> ( ( 8 * sizeof (data) ) - (rotation) ) ) ); + +#define RORx( data, rotation ) \ + ( ( (data) >> (rotation) ) | \ + ( (data) << ( ( 8 * sizeof (data) ) - (rotation) ) ) ); + static inline __attribute__ (( always_inline )) uint8_t rol8 ( uint8_t data, unsigned int rotation ) { - return ( ( data << rotation ) | ( data >> ( 8 - rotation ) ) ); + return ROLx ( data, rotation ); } static inline __attribute__ (( always_inline )) uint8_t ror8 ( uint8_t data, unsigned int rotation ) { - return ( ( data >> rotation ) | ( data << ( 8 - rotation ) ) ); + return RORx ( data, rotation ); } static inline __attribute__ (( always_inline )) uint16_t rol16 ( uint16_t data, unsigned int rotation ) { - return ( ( data << rotation ) | ( data >> ( 16 - rotation ) ) ); + return ROLx ( data, rotation ); } static inline __attribute__ (( always_inline )) uint16_t ror16 ( uint16_t data, unsigned int rotation ) { - return ( ( data >> rotation ) | ( data << ( 16 - rotation ) ) ); + return RORx ( data, rotation ); } static inline __attribute__ (( always_inline )) uint32_t rol32 ( uint32_t data, unsigned int rotation ) { - return ( ( data << rotation ) | ( data >> ( 32 - rotation ) ) ); + return ROLx ( data, rotation ); } static inline __attribute__ (( always_inline )) uint32_t ror32 ( uint32_t data, unsigned int rotation ) { - return ( ( data >> rotation ) | ( data << ( 32 - rotation ) ) ); + return RORx ( data, rotation ); } static inline __attribute__ (( always_inline )) uint64_t rol64 ( uint64_t data, unsigned int rotation ) { - return ( ( data << rotation ) | ( data >> ( 64 - rotation ) ) ); + return ROLx ( data, rotation ); } static inline __attribute__ (( always_inline )) uint64_t ror64 ( uint64_t data, unsigned int rotation ) { - return ( ( data >> rotation ) | ( data << ( 64 - rotation ) ) ); + return RORx ( data, rotation ); +} + +static inline __attribute__ (( always_inline )) unsigned long +roll ( unsigned long data, unsigned int rotation ) { + return ROLx ( data, rotation ); +} + +static inline __attribute__ (( always_inline )) unsigned long +rorl ( unsigned long data, unsigned int rotation ) { + return RORx ( data, rotation ); } #endif /* _IPXE_ROTATE_H */ |
