mirror of
https://gitlab.com/qemu-project/ipxe.git
synced 2025-11-03 07:59:06 +08:00
Compare commits
101 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 94b39fbe92 | |||
| 0f5abd8b11 | |||
| a846c4ccfc | |||
| e7ae51b0d7 | |||
| af4583b214 | |||
| 36a27b22b1 | |||
| 0cc0f47443 | |||
| 65d69d33da | |||
| 963ec1c4f3 | |||
| 8f6a9399b3 | |||
| a881a26061 | |||
| b234226dbc | |||
| 8e2469c861 | |||
| 989dbe0bc4 | |||
| 6f70e8be83 | |||
| 17135c83fb | |||
| 27398f1360 | |||
| de8a0821c7 | |||
| 2eea04c02c | |||
| 908174ec7e | |||
| bac13ba1f6 | |||
| 13e390d54e | |||
| 26d3ef062b | |||
| 4b7d9a6af0 | |||
| 6d29415c89 | |||
| 6ca597eee9 | |||
| e66552eeed | |||
| 08fcb0e8fb | |||
| c6226f104e | |||
| 0abb3e85e5 | |||
| 4ed7a5718f | |||
| fa62213231 | |||
| 119c415ee4 | |||
| 9e92c39894 | |||
| 3fc1b407d2 | |||
| 0958e01463 | |||
| 337880deaa | |||
| f22879ca99 | |||
| 98dd25a3bb | |||
| a147245f1a | |||
| c3dd3168c9 | |||
| b829b1750d | |||
| 03ff1bb99a | |||
| 18582a05fc | |||
| 6714b20ea2 | |||
| b37d89db90 | |||
| cc858acd32 | |||
| b30a0987e2 | |||
| 3d8a614657 | |||
| a9e89787d0 | |||
| 678a60f61d | |||
| 8c8ead2530 | |||
| 77b07ea4fd | |||
| d8f9c221ed | |||
| 595b1796f6 | |||
| 1bd01b761f | |||
| 5524bb9832 | |||
| 36e1a559a2 | |||
| 1f3a37e342 | |||
| 74ec00a9f3 | |||
| f883203132 | |||
| 115707c0ed | |||
| ff0f860483 | |||
| 8b14652e50 | |||
| 56cc61a168 | |||
| cac3a584dc | |||
| 8cbf248198 | |||
| 8b1d34badf | |||
| cc1e27e525 | |||
| ae4e85bde9 | |||
| eeb7cd56e5 | |||
| 0aa2e4ec96 | |||
| 9e99a55b31 | |||
| c1834f323f | |||
| d5c08f78bd | |||
| c30b71ee9c | |||
| f3036fc213 | |||
| 59d065c9ac | |||
| 48ae5d5361 | |||
| 6701d91c50 | |||
| b5b60ea33d | |||
| 8244410690 | |||
| daa9e54ab8 | |||
| 3ef4f7e2ef | |||
| cc07ed7c7e | |||
| 6f57d91935 | |||
| e17568ad06 | |||
| 2524a60550 | |||
| 280942a92a | |||
| 6d98e0ca47 | |||
| 0c67a3632d | |||
| c57887bfc8 | |||
| 18af669701 | |||
| cfe65aa826 | |||
| ae435cb4cc | |||
| f8a0d1c0b8 | |||
| f0b1025503 | |||
| c832580f19 | |||
| 9a118322a0 | |||
| 2689a6e776 | |||
| 4fa4052c7e |
@ -46,11 +46,19 @@ def create_snapshot(region, description, image):
|
||||
return snapshot_id
|
||||
|
||||
|
||||
def import_image(region, name, architecture, image, public):
|
||||
def import_image(region, name, architecture, image, public, overwrite):
|
||||
"""Import an AMI image"""
|
||||
client = boto3.client('ec2', region_name=region)
|
||||
resource = boto3.resource('ec2', region_name=region)
|
||||
description = '%s (%s)' % (name, architecture)
|
||||
images = client.describe_images(Filters=[{'Name': 'name',
|
||||
'Values': [description]}])
|
||||
if overwrite and images['Images']:
|
||||
images = images['Images'][0]
|
||||
image_id = images['ImageId']
|
||||
snapshot_id = images['BlockDeviceMappings'][0]['Ebs']['SnapshotId']
|
||||
resource.Image(image_id).deregister()
|
||||
resource.Snapshot(snapshot_id).delete()
|
||||
snapshot_id = create_snapshot(region=region, description=description,
|
||||
image=image)
|
||||
client.get_waiter('snapshot_completed').wait(SnapshotIds=[snapshot_id])
|
||||
@ -88,6 +96,8 @@ parser.add_argument('--name', '-n',
|
||||
help="Image name")
|
||||
parser.add_argument('--public', '-p', action='store_true',
|
||||
help="Make image public")
|
||||
parser.add_argument('--overwrite', action='store_true',
|
||||
help="Overwrite any existing image with same name")
|
||||
parser.add_argument('--region', '-r', action='append',
|
||||
help="AWS region(s)")
|
||||
parser.add_argument('--wiki', '-w', metavar='FILE',
|
||||
@ -115,7 +125,8 @@ with ThreadPoolExecutor(max_workers=len(imports)) as executor:
|
||||
name=args.name,
|
||||
architecture=architectures[image],
|
||||
image=image,
|
||||
public=args.public): (region, image)
|
||||
public=args.public,
|
||||
overwrite=args.overwrite): (region, image)
|
||||
for region, image in imports}
|
||||
results = {futures[future]: future.result()
|
||||
for future in as_completed(futures)}
|
||||
|
||||
68
contrib/cloud/aws-int13con
Executable file
68
contrib/cloud/aws-int13con
Executable file
@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
|
||||
import boto3
|
||||
|
||||
BLOCKSIZE = 512 * 1024
|
||||
|
||||
IPXELOG_OFFSET = 16 * 1024
|
||||
|
||||
IPXELOG_MAGIC = b'iPXE LOG'
|
||||
|
||||
|
||||
def create_snapshot(region, instance_id):
|
||||
"""Create root volume snapshot"""
|
||||
client = boto3.client('ec2', region_name=region)
|
||||
resource = boto3.resource('ec2', region_name=region)
|
||||
instance = resource.Instance(instance_id)
|
||||
volumes = list(instance.volumes.all())
|
||||
snapshot = volumes[0].create_snapshot()
|
||||
snapshot.wait_until_completed()
|
||||
return snapshot.id
|
||||
|
||||
|
||||
def get_snapshot_block(region, snapshot_id, index):
|
||||
"""Get block content from snapshot"""
|
||||
client = boto3.client('ebs', region_name=region)
|
||||
blocks = client.list_snapshot_blocks(SnapshotId=snapshot_id,
|
||||
StartingBlockIndex=index)
|
||||
token = blocks['Blocks'][0]['BlockToken']
|
||||
block = client.get_snapshot_block(SnapshotId=snapshot_id,
|
||||
BlockIndex=index,
|
||||
BlockToken=token)
|
||||
return block['BlockData'].read()
|
||||
|
||||
|
||||
def get_block0_content(region, instance_id):
|
||||
"""Get content of root volume block zero from instance"""
|
||||
client = boto3.client('ec2', region_name=region)
|
||||
resource = boto3.resource('ec2', region_name=region)
|
||||
snapshot_id = create_snapshot(region, instance_id)
|
||||
block = get_snapshot_block(region, snapshot_id, 0)
|
||||
resource.Snapshot(snapshot_id).delete()
|
||||
return block
|
||||
|
||||
|
||||
def get_int13con_output(region, instance_id):
|
||||
"""Get INT13 console output"""
|
||||
block = get_block0_content(region, instance_id)
|
||||
logpart = block[IPXELOG_OFFSET:]
|
||||
magic = logpart[:len(IPXELOG_MAGIC)]
|
||||
if magic != IPXELOG_MAGIC:
|
||||
raise ValueError("Invalid log magic signature")
|
||||
log = logpart[len(IPXELOG_MAGIC):].split(b'\0')[0]
|
||||
return log.decode()
|
||||
|
||||
|
||||
# Parse command-line arguments
|
||||
parser = argparse.ArgumentParser(description="Get AWS INT13 console output")
|
||||
parser.add_argument('--region', '-r', help="AWS region")
|
||||
parser.add_argument('id', help="Instance ID")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Get console output from INT13CON partition
|
||||
output = get_int13con_output(args.region, args.id)
|
||||
|
||||
# Print console output
|
||||
print(output)
|
||||
2
src/.gitignore
vendored
2
src/.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
.toolcheck
|
||||
.echocheck
|
||||
TAGS*
|
||||
bin*
|
||||
bin-*
|
||||
|
||||
@ -50,6 +50,10 @@ $(BIN)/efidrv.cab : $(BIN)/alldrv.efis # $(ALL_drv.efi) is not yet defined
|
||||
$(QM)$(ECHO) " [CAB] $@"
|
||||
$(Q)$(LCAB) -n -q $(ALL_drv.efi) $@
|
||||
|
||||
$(BIN)/%.iso $(BIN)/%.usb : $(BIN)/%.efi util/genfsimg
|
||||
$(BIN)/%.iso : $(BIN)/%.efi util/genfsimg
|
||||
$(QM)$(ECHO) " [GENFSIMG] $@"
|
||||
$(Q)util/genfsimg -o $@ $<
|
||||
|
||||
$(BIN)/%.usb : $(BIN)/%.efi util/genfsimg
|
||||
$(QM)$(ECHO) " [GENFSIMG] $@"
|
||||
$(Q)util/genfsimg -o $@ $<
|
||||
|
||||
@ -502,6 +502,13 @@ LDFLAGS += --gc-sections
|
||||
#
|
||||
LDFLAGS += -static
|
||||
|
||||
# Use separate code segment if supported by linker
|
||||
#
|
||||
ZSC_TEST = $(LD) -z separate-code --version 2>&1 > /dev/null
|
||||
ZSC_FLAGS := $(shell [ -z "`$(ZSC_TEST)`" ] && \
|
||||
$(ECHO) '-z separate-code -z max-page-size=4096')
|
||||
LDFLAGS += $(ZSC_FLAGS)
|
||||
|
||||
# compiler.h is needed for our linking and debugging system
|
||||
#
|
||||
CFLAGS += -include include/compiler.h
|
||||
@ -1002,6 +1009,7 @@ endif
|
||||
# Device ID tables (using IDs from ROM definition file)
|
||||
#
|
||||
define obj_pci_id_asm
|
||||
.section ".note.GNU-stack", "", $(ASM_TCHAR)progbits
|
||||
.section ".pci_devlist.$(1)", "a", $(ASM_TCHAR)progbits
|
||||
.globl pci_devlist_$(1)
|
||||
pci_devlist_$(1):
|
||||
@ -1171,7 +1179,7 @@ BLIB = $(BIN)/blib.a
|
||||
$(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS)
|
||||
$(Q)$(RM) $(BLIB)
|
||||
$(QM)$(ECHO) " [AR] $@"
|
||||
$(Q)$(AR) rD $@ $(sort $(BLIB_OBJS))
|
||||
$(Q)$(AR) rcD $@ $(sort $(BLIB_OBJS))
|
||||
$(Q)$(OBJCOPY) --enable-deterministic-archives \
|
||||
--prefix-symbols=$(SYMBOL_PREFIX) $@
|
||||
$(Q)$(RANLIB) -D $@
|
||||
|
||||
@ -9,4 +9,5 @@ INCDIRS += arch/arm/include
|
||||
|
||||
# ARM-specific directories containing source files
|
||||
#
|
||||
SRCDIRS += arch/arm/core
|
||||
SRCDIRS += arch/arm/interface/efi
|
||||
|
||||
@ -46,7 +46,7 @@ union arm32_io_qword {
|
||||
*
|
||||
* This is not atomic for ARM32.
|
||||
*/
|
||||
static uint64_t arm32_readq ( volatile uint64_t *io_addr ) {
|
||||
static __unused uint64_t arm32_readq ( volatile uint64_t *io_addr ) {
|
||||
volatile union arm32_io_qword *ptr =
|
||||
container_of ( io_addr, union arm32_io_qword, qword );
|
||||
union arm32_io_qword tmp;
|
||||
@ -64,7 +64,8 @@ static uint64_t arm32_readq ( volatile uint64_t *io_addr ) {
|
||||
*
|
||||
* This is not atomic for ARM32.
|
||||
*/
|
||||
static void arm32_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
|
||||
static __unused void arm32_writeq ( uint64_t data,
|
||||
volatile uint64_t *io_addr ) {
|
||||
volatile union arm32_io_qword *ptr =
|
||||
container_of ( io_addr, union arm32_io_qword, qword );
|
||||
union arm32_io_qword tmp;
|
||||
@ -82,7 +83,6 @@ PROVIDE_IOAPI_INLINE ( arm, readl );
|
||||
PROVIDE_IOAPI_INLINE ( arm, writeb );
|
||||
PROVIDE_IOAPI_INLINE ( arm, writew );
|
||||
PROVIDE_IOAPI_INLINE ( arm, writel );
|
||||
PROVIDE_IOAPI_INLINE ( arm, iodelay );
|
||||
PROVIDE_IOAPI_INLINE ( arm, mb );
|
||||
#ifdef __aarch64__
|
||||
PROVIDE_IOAPI_INLINE ( arm, readq );
|
||||
@ -91,3 +91,4 @@ PROVIDE_IOAPI_INLINE ( arm, writeq );
|
||||
PROVIDE_IOAPI ( arm, readq, arm32_readq );
|
||||
PROVIDE_IOAPI ( arm, writeq, arm32_writeq );
|
||||
#endif
|
||||
PROVIDE_DUMMY_PIO ( arm );
|
||||
|
||||
@ -9,6 +9,4 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/io.h>
|
||||
|
||||
#endif /* _BITS_PCI_IO_H */
|
||||
|
||||
@ -15,6 +15,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define IOAPI_PREFIX_arm __arm_
|
||||
#endif
|
||||
|
||||
#include <ipxe/dummy_pio.h>
|
||||
|
||||
/*
|
||||
* Memory space mappings
|
||||
*
|
||||
@ -77,55 +79,6 @@ ARM_WRITEX ( w, uint16_t, "h", "" );
|
||||
ARM_WRITEX ( l, uint32_t, "", "" );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy PIO reads and writes up to 32 bits
|
||||
*
|
||||
* There is no common standard for I/O-space access for ARM, and
|
||||
* non-MMIO peripherals are vanishingly rare. Provide dummy
|
||||
* implementations that will allow code to link and should cause
|
||||
* drivers to simply fail to detect hardware at runtime.
|
||||
*
|
||||
*/
|
||||
|
||||
#define ARM_INX( _suffix, _type ) \
|
||||
static inline __always_inline _type \
|
||||
IOAPI_INLINE ( arm, in ## _suffix ) ( volatile _type *io_addr __unused) { \
|
||||
return ~( (_type) 0 ); \
|
||||
} \
|
||||
static inline __always_inline void \
|
||||
IOAPI_INLINE ( arm, ins ## _suffix ) ( volatile _type *io_addr __unused, \
|
||||
_type *data, unsigned int count ) { \
|
||||
memset ( data, 0xff, count * sizeof ( *data ) ); \
|
||||
}
|
||||
ARM_INX ( b, uint8_t );
|
||||
ARM_INX ( w, uint16_t );
|
||||
ARM_INX ( l, uint32_t );
|
||||
|
||||
#define ARM_OUTX( _suffix, _type ) \
|
||||
static inline __always_inline void \
|
||||
IOAPI_INLINE ( arm, out ## _suffix ) ( _type data __unused, \
|
||||
volatile _type *io_addr __unused ) { \
|
||||
/* Do nothing */ \
|
||||
} \
|
||||
static inline __always_inline void \
|
||||
IOAPI_INLINE ( arm, outs ## _suffix ) ( volatile _type *io_addr __unused, \
|
||||
const _type *data __unused, \
|
||||
unsigned int count __unused ) { \
|
||||
/* Do nothing */ \
|
||||
}
|
||||
ARM_OUTX ( b, uint8_t );
|
||||
ARM_OUTX ( w, uint16_t );
|
||||
ARM_OUTX ( l, uint32_t );
|
||||
|
||||
/*
|
||||
* Slow down I/O
|
||||
*
|
||||
*/
|
||||
static inline __always_inline void
|
||||
IOAPI_INLINE ( arm, iodelay ) ( void ) {
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
/*
|
||||
* Memory barrier
|
||||
*
|
||||
@ -140,4 +93,7 @@ IOAPI_INLINE ( arm, mb ) ( void ) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Dummy PIO */
|
||||
DUMMY_PIO ( arm );
|
||||
|
||||
#endif /* _IPXE_ARM_IO_H */
|
||||
|
||||
@ -46,8 +46,12 @@ static void efiarm_cpu_nap ( void ) {
|
||||
* The EFI shell doesn't seem to bother sleeping the CPU; it
|
||||
* just sits there idly burning power.
|
||||
*
|
||||
* If a shutdown is in progess, there may be nothing to
|
||||
* generate an interrupt since the timer is disabled in the
|
||||
* first step of ExitBootServices().
|
||||
*/
|
||||
__asm__ __volatile__ ( "wfi" );
|
||||
if ( ! efi_shutdown_in_progress )
|
||||
__asm__ __volatile__ ( "wfi" );
|
||||
}
|
||||
|
||||
PROVIDE_NAP ( efiarm, cpu_nap, efiarm_cpu_nap );
|
||||
|
||||
@ -36,19 +36,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* Multiply big integers
|
||||
*
|
||||
* @v multiplicand0 Element 0 of big integer to be multiplied
|
||||
* @v multiplicand_size Number of elements in multiplicand
|
||||
* @v multiplier0 Element 0 of big integer to be multiplied
|
||||
* @v multiplier_size Number of elements in multiplier
|
||||
* @v result0 Element 0 of big integer to hold result
|
||||
* @v size Number of elements
|
||||
*/
|
||||
void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint32_t *multiplier0,
|
||||
uint32_t *result0, unsigned int size ) {
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplicand =
|
||||
( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplier =
|
||||
( ( const void * ) multiplier0 );
|
||||
bigint_t ( size * 2 ) __attribute__ (( may_alias )) *result =
|
||||
( ( void * ) result0 );
|
||||
unsigned int multiplier_size,
|
||||
uint32_t *result0 ) {
|
||||
unsigned int result_size = ( multiplicand_size + multiplier_size );
|
||||
const bigint_t ( multiplicand_size ) __attribute__ (( may_alias ))
|
||||
*multiplicand = ( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( multiplier_size ) __attribute__ (( may_alias ))
|
||||
*multiplier = ( ( const void * ) multiplier0 );
|
||||
bigint_t ( result_size ) __attribute__ (( may_alias ))
|
||||
*result = ( ( void * ) result0 );
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
uint32_t multiplicand_element;
|
||||
@ -62,9 +66,9 @@ void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
memset ( result, 0, sizeof ( *result ) );
|
||||
|
||||
/* Multiply integers one element at a time */
|
||||
for ( i = 0 ; i < size ; i++ ) {
|
||||
for ( i = 0 ; i < multiplicand_size ; i++ ) {
|
||||
multiplicand_element = multiplicand->element[i];
|
||||
for ( j = 0 ; j < size ; j++ ) {
|
||||
for ( j = 0 ; j < multiplier_size ; j++ ) {
|
||||
multiplier_element = multiplier->element[j];
|
||||
result_elements = &result->element[ i + j ];
|
||||
/* Perform a single multiply, and add the
|
||||
@ -73,7 +77,7 @@ void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
* never overflow beyond the end of the
|
||||
* result, since:
|
||||
*
|
||||
* a < 2^{n}, b < 2^{n} => ab < 2^{2n}
|
||||
* a < 2^{n}, b < 2^{m} => ab < 2^{n+m}
|
||||
*/
|
||||
__asm__ __volatile__ ( "umull %1, %2, %5, %6\n\t"
|
||||
"ldr %3, [%0]\n\t"
|
||||
|
||||
@ -310,7 +310,9 @@ bigint_done_raw ( const uint32_t *value0, unsigned int size __unused,
|
||||
}
|
||||
|
||||
extern void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint32_t *multiplier0,
|
||||
uint32_t *value0, unsigned int size );
|
||||
unsigned int multiplier_size,
|
||||
uint32_t *value0 );
|
||||
|
||||
#endif /* _BITS_BIGINT_H */
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", %progbits
|
||||
.text
|
||||
.thumb
|
||||
|
||||
/**
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", %progbits
|
||||
.text
|
||||
.arm
|
||||
|
||||
/**
|
||||
|
||||
@ -36,19 +36,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* Multiply big integers
|
||||
*
|
||||
* @v multiplicand0 Element 0 of big integer to be multiplied
|
||||
* @v multiplicand_size Number of elements in multiplicand
|
||||
* @v multiplier0 Element 0 of big integer to be multiplied
|
||||
* @v multiplier_size Number of elements in multiplier
|
||||
* @v result0 Element 0 of big integer to hold result
|
||||
* @v size Number of elements
|
||||
*/
|
||||
void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint64_t *multiplier0,
|
||||
uint64_t *result0, unsigned int size ) {
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplicand =
|
||||
( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplier =
|
||||
( ( const void * ) multiplier0 );
|
||||
bigint_t ( size * 2 ) __attribute__ (( may_alias )) *result =
|
||||
( ( void * ) result0 );
|
||||
unsigned int multiplier_size,
|
||||
uint64_t *result0 ) {
|
||||
unsigned int result_size = ( multiplicand_size + multiplier_size );
|
||||
const bigint_t ( multiplicand_size ) __attribute__ (( may_alias ))
|
||||
*multiplicand = ( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( multiplier_size ) __attribute__ (( may_alias ))
|
||||
*multiplier = ( ( const void * ) multiplier0 );
|
||||
bigint_t ( result_size ) __attribute__ (( may_alias ))
|
||||
*result = ( ( void * ) result0 );
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
uint64_t multiplicand_element;
|
||||
@ -63,9 +67,9 @@ void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
memset ( result, 0, sizeof ( *result ) );
|
||||
|
||||
/* Multiply integers one element at a time */
|
||||
for ( i = 0 ; i < size ; i++ ) {
|
||||
for ( i = 0 ; i < multiplicand_size ; i++ ) {
|
||||
multiplicand_element = multiplicand->element[i];
|
||||
for ( j = 0 ; j < size ; j++ ) {
|
||||
for ( j = 0 ; j < multiplier_size ; j++ ) {
|
||||
multiplier_element = multiplier->element[j];
|
||||
result_elements = &result->element[ i + j ];
|
||||
/* Perform a single multiply, and add the
|
||||
@ -74,7 +78,7 @@ void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
* never overflow beyond the end of the
|
||||
* result, since:
|
||||
*
|
||||
* a < 2^{n}, b < 2^{n} => ab < 2^{2n}
|
||||
* a < 2^{n}, b < 2^{m} => ab < 2^{n+m}
|
||||
*/
|
||||
__asm__ __volatile__ ( "mul %1, %6, %7\n\t"
|
||||
"umulh %2, %6, %7\n\t"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", %progbits
|
||||
.text
|
||||
|
||||
/* Must match jmp_buf structure layout */
|
||||
|
||||
@ -311,7 +311,9 @@ bigint_done_raw ( const uint64_t *value0, unsigned int size __unused,
|
||||
}
|
||||
|
||||
extern void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint64_t *multiplier0,
|
||||
uint64_t *value0, unsigned int size );
|
||||
unsigned int multiplier_size,
|
||||
uint64_t *value0 );
|
||||
|
||||
#endif /* _BITS_BIGINT_H */
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
* Interrupt handlers
|
||||
****************************************************************************
|
||||
*/
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.section ".text", "ax", @progbits
|
||||
.code32
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.arch i386
|
||||
.code32
|
||||
.arch i386
|
||||
|
||||
/* Must match jmp_buf structure layout */
|
||||
.struct 0
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code32
|
||||
.arch i386
|
||||
|
||||
.section ".data", "aw", @progbits
|
||||
|
||||
@ -20,6 +20,7 @@ CFLAGS += -fshort-wchar
|
||||
|
||||
# LoongArch64-specific directories containing source files
|
||||
SRCDIRS += arch/loong64/core
|
||||
SRCDIRS += arch/loong64/interface/efi
|
||||
|
||||
# Include platform-specific Makefile
|
||||
MAKEDEPS += arch/loong64/Makefile.$(PLATFORM)
|
||||
|
||||
14
src/arch/loong64/Makefile.efi
Normal file
14
src/arch/loong64/Makefile.efi
Normal file
@ -0,0 +1,14 @@
|
||||
# -*- makefile -*- : Force emacs to use Makefile mode
|
||||
|
||||
# Specify EFI image builder
|
||||
#
|
||||
ELF2EFI = $(ELF2EFI64)
|
||||
|
||||
# Specify EFI boot file
|
||||
#
|
||||
EFI_BOOT_FILE = bootloongarch64.efi
|
||||
|
||||
# Include generic EFI Makefile
|
||||
#
|
||||
MAKEDEPS += Makefile.efi
|
||||
include Makefile.efi
|
||||
@ -37,19 +37,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* Multiply big integers
|
||||
*
|
||||
* @v multiplicand0 Element 0 of big integer to be multiplied
|
||||
* @v multiplicand_size Number of elements in multiplicand
|
||||
* @v multiplier0 Element 0 of big integer to be multiplied
|
||||
* @v multiplier_size Number of elements in multiplier
|
||||
* @v result0 Element 0 of big integer to hold result
|
||||
* @v size Number of elements
|
||||
*/
|
||||
void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint64_t *multiplier0,
|
||||
uint64_t *result0, unsigned int size ) {
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplicand =
|
||||
( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplier =
|
||||
( ( const void * ) multiplier0 );
|
||||
bigint_t ( size * 2 ) __attribute__ (( may_alias )) *result =
|
||||
( ( void * ) result0 );
|
||||
unsigned int multiplier_size,
|
||||
uint64_t *result0 ) {
|
||||
unsigned int result_size = ( multiplicand_size + multiplier_size );
|
||||
const bigint_t ( multiplicand_size ) __attribute__ (( may_alias ))
|
||||
*multiplicand = ( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( multiplier_size ) __attribute__ (( may_alias ))
|
||||
*multiplier = ( ( const void * ) multiplier0 );
|
||||
bigint_t ( result_size ) __attribute__ (( may_alias ))
|
||||
*result = ( ( void * ) result0 );
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
uint64_t multiplicand_element;
|
||||
@ -64,9 +68,9 @@ void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
memset ( result, 0, sizeof ( *result ) );
|
||||
|
||||
/* Multiply integers one element at a time */
|
||||
for ( i = 0 ; i < size ; i++ ) {
|
||||
for ( i = 0 ; i < multiplicand_size ; i++ ) {
|
||||
multiplicand_element = multiplicand->element[i];
|
||||
for ( j = 0 ; j < size ; j++ ) {
|
||||
for ( j = 0 ; j < multiplier_size ; j++ ) {
|
||||
multiplier_element = multiplier->element[j];
|
||||
result_elements = &result->element[ i + j ];
|
||||
/* Perform a single multiply, and add the
|
||||
@ -75,7 +79,7 @@ void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
* never overflow beyond the end of the
|
||||
* result, since:
|
||||
*
|
||||
* a < 2^{n}, b < 2^{n} => ab < 2^{2n}
|
||||
* a < 2^{n}, b < 2^{m} => ab < 2^{n+m}
|
||||
*/
|
||||
__asm__ __volatile__ ( "mul.d %1, %6, %7\n\t"
|
||||
"mulh.du %2, %6, %7\n\t"
|
||||
|
||||
46
src/arch/loong64/core/loong64_io.c
Normal file
46
src/arch/loong64/core/loong64_io.c
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Xiaotian Wu <wuxiaotian@loongson.cn>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/io.h>
|
||||
#include <ipxe/loong64_io.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
* iPXE I/O API for LoongArch64
|
||||
*
|
||||
*/
|
||||
|
||||
PROVIDE_IOAPI_INLINE ( loong64, phys_to_bus );
|
||||
PROVIDE_IOAPI_INLINE ( loong64, bus_to_phys );
|
||||
PROVIDE_IOAPI_INLINE ( loong64, readb );
|
||||
PROVIDE_IOAPI_INLINE ( loong64, readw );
|
||||
PROVIDE_IOAPI_INLINE ( loong64, readl );
|
||||
PROVIDE_IOAPI_INLINE ( loong64, readq );
|
||||
PROVIDE_IOAPI_INLINE ( loong64, writeb );
|
||||
PROVIDE_IOAPI_INLINE ( loong64, writew );
|
||||
PROVIDE_IOAPI_INLINE ( loong64, writel );
|
||||
PROVIDE_IOAPI_INLINE ( loong64, writeq );
|
||||
PROVIDE_IOAPI_INLINE ( loong64, mb );
|
||||
PROVIDE_DUMMY_PIO ( loong64 );
|
||||
@ -53,34 +53,37 @@ bigint_add_raw ( const uint64_t *addend0, uint64_t *value0,
|
||||
uint64_t *discard_value;
|
||||
uint64_t discard_addend_i;
|
||||
uint64_t discard_value_i;
|
||||
uint64_t discard_carry;
|
||||
uint64_t discard_temp;
|
||||
unsigned int discard_size;
|
||||
__asm__ __volatile__ ( "move $t0, $zero\n"
|
||||
"1:\n\t"
|
||||
"ld.d %3, %0, 0\n\t"
|
||||
|
||||
__asm__ __volatile__ ( "\n1:\n\t"
|
||||
/* Load addend[i] and value[i] */
|
||||
"ld.d %3, %0, 0\n\t"
|
||||
"ld.d %4, %1, 0\n\t"
|
||||
/* Add carry flag and addend */
|
||||
"add.d %4, %4, %5\n\t"
|
||||
"sltu %6, %4, %5\n\t"
|
||||
"add.d %4, %4, %3\n\t"
|
||||
"sltu %5, %4, %3\n\t"
|
||||
"or %5, %5, %6\n\t"
|
||||
/* Store value[i] */
|
||||
"st.d %4, %1, 0\n\t"
|
||||
/* Loop */
|
||||
"addi.d %0, %0, 8\n\t"
|
||||
"ld.d %4, %1, 0\n\t"
|
||||
|
||||
"add.d %4, %4, $t0\n\t"
|
||||
"sltu $t0, %4, $t0\n\t"
|
||||
|
||||
"add.d %4, %4, %3\n\t"
|
||||
"sltu $t1, %4, %3\n\t"
|
||||
|
||||
"or $t0, $t0, $t1\n\t"
|
||||
"st.d %4, %1, 0\n\t"
|
||||
"addi.d %1, %1, 8\n\t"
|
||||
"addi.w %2, %2, -1\n\t"
|
||||
"bnez %2, 1b"
|
||||
"bnez %2, 1b\n\t"
|
||||
: "=r" ( discard_addend ),
|
||||
"=r" ( discard_value ),
|
||||
"=r" ( discard_size ),
|
||||
"=r" ( discard_addend_i ),
|
||||
"=r" ( discard_value_i ),
|
||||
"=r" ( discard_carry ),
|
||||
"=r" ( discard_temp ),
|
||||
"+m" ( *value )
|
||||
: "0" ( addend0 ),
|
||||
"1" ( value0 ),
|
||||
"2" ( size )
|
||||
: "t0", "t1" );
|
||||
: "0" ( addend0 ), "1" ( value0 ),
|
||||
"2" ( size ), "5" ( 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,35 +96,43 @@ bigint_add_raw ( const uint64_t *addend0, uint64_t *value0,
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
bigint_subtract_raw ( const uint64_t *subtrahend0, uint64_t *value0,
|
||||
unsigned int size ) {
|
||||
bigint_t ( size ) __attribute__ (( may_alias )) *value =
|
||||
( ( void * ) value0 );
|
||||
uint64_t *discard_subtrahend;
|
||||
uint64_t *discard_value;
|
||||
uint64_t discard_subtrahend_i;
|
||||
uint64_t discard_value_i;
|
||||
uint64_t discard_carry;
|
||||
uint64_t discard_temp;
|
||||
unsigned int discard_size;
|
||||
unsigned int flag = 0;
|
||||
|
||||
discard_subtrahend = (uint64_t*) subtrahend0;
|
||||
discard_value = value0;
|
||||
discard_size = size;
|
||||
|
||||
do {
|
||||
discard_subtrahend_i = *discard_subtrahend;
|
||||
discard_subtrahend++;
|
||||
discard_value_i = *discard_value;
|
||||
|
||||
discard_value_i = discard_value_i - discard_subtrahend_i - flag;
|
||||
|
||||
if ( *discard_value < (discard_subtrahend_i + flag)) {
|
||||
flag = 1;
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
|
||||
*discard_value = discard_value_i;
|
||||
|
||||
discard_value++;
|
||||
discard_size -= 1;
|
||||
} while (discard_size != 0);
|
||||
__asm__ __volatile__ ( "\n1:\n\t"
|
||||
/* Load subtrahend[i] and value[i] */
|
||||
"ld.d %3, %0, 0\n\t"
|
||||
"ld.d %4, %1, 0\n\t"
|
||||
/* Subtract carry flag and subtrahend */
|
||||
"sltu %6, %4, %5\n\t"
|
||||
"sub.d %4, %4, %5\n\t"
|
||||
"sltu %5, %4, %3\n\t"
|
||||
"sub.d %4, %4, %3\n\t"
|
||||
"or %5, %5, %6\n\t"
|
||||
/* Store value[i] */
|
||||
"st.d %4, %1, 0\n\t"
|
||||
/* Loop */
|
||||
"addi.d %0, %0, 8\n\t"
|
||||
"addi.d %1, %1, 8\n\t"
|
||||
"addi.w %2, %2, -1\n\t"
|
||||
"bnez %2, 1b\n\t"
|
||||
: "=r" ( discard_subtrahend ),
|
||||
"=r" ( discard_value ),
|
||||
"=r" ( discard_size ),
|
||||
"=r" ( discard_subtrahend_i ),
|
||||
"=r" ( discard_value_i ),
|
||||
"=r" ( discard_carry ),
|
||||
"=r" ( discard_temp ),
|
||||
"+m" ( *value )
|
||||
: "0" ( subtrahend0 ), "1" ( value0 ),
|
||||
"2" ( size ), "5" ( 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,30 +143,37 @@ bigint_subtract_raw ( const uint64_t *subtrahend0, uint64_t *value0,
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
bigint_rol_raw ( uint64_t *value0, unsigned int size ) {
|
||||
bigint_t ( size ) __attribute__ (( may_alias )) *value =
|
||||
( ( void * ) value0 );
|
||||
uint64_t *discard_value;
|
||||
uint64_t discard_value_i;
|
||||
uint64_t discard_carry;
|
||||
uint64_t discard_temp;
|
||||
unsigned int discard_size;
|
||||
uint64_t current_value_i;
|
||||
unsigned int flag = 0;
|
||||
|
||||
discard_value = value0;
|
||||
discard_size = size;
|
||||
do {
|
||||
discard_value_i = *discard_value;
|
||||
current_value_i = discard_value_i;
|
||||
|
||||
discard_value_i += discard_value_i + flag;
|
||||
|
||||
if (discard_value_i < current_value_i) {
|
||||
flag = 1;
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
|
||||
*discard_value = discard_value_i;
|
||||
discard_value++;
|
||||
discard_size -= 1;
|
||||
} while ( discard_size != 0 );
|
||||
__asm__ __volatile__ ( "\n1:\n\t"
|
||||
/* Load value[i] */
|
||||
"ld.d %2, %0, 0\n\t"
|
||||
/* Shift left */
|
||||
"rotri.d %2, %2, 63\n\t"
|
||||
"andi %4, %2, 1\n\t"
|
||||
"xor %2, %2, %4\n\t"
|
||||
"or %2, %2, %3\n\t"
|
||||
"move %3, %4\n\t"
|
||||
/* Store value[i] */
|
||||
"st.d %2, %0, 0\n\t"
|
||||
/* Loop */
|
||||
"addi.d %0, %0, 8\n\t"
|
||||
"addi.w %1, %1, -1\n\t"
|
||||
"bnez %1, 1b\n\t"
|
||||
: "=r" ( discard_value ),
|
||||
"=r" ( discard_size ),
|
||||
"=r" ( discard_value_i ),
|
||||
"=r" ( discard_carry ),
|
||||
"=r" ( discard_temp ),
|
||||
"+m" ( *value )
|
||||
: "0" ( value0 ), "1" ( size ), "3" ( 0 )
|
||||
: "cc" );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,27 +184,37 @@ bigint_rol_raw ( uint64_t *value0, unsigned int size ) {
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
bigint_ror_raw ( uint64_t *value0, unsigned int size ) {
|
||||
bigint_t ( size ) __attribute__ (( may_alias )) *value =
|
||||
( ( void * ) value0 );
|
||||
uint64_t *discard_value;
|
||||
uint64_t discard_value_i;
|
||||
uint64_t discard_value_j;
|
||||
uint64_t discard_carry;
|
||||
uint64_t discard_temp;
|
||||
unsigned int discard_size;
|
||||
|
||||
discard_value = value0;
|
||||
discard_size = size;
|
||||
|
||||
discard_value_j = 0;
|
||||
|
||||
do {
|
||||
discard_size -= 1;
|
||||
|
||||
discard_value_i = *(discard_value + discard_size);
|
||||
|
||||
discard_value_j = (discard_value_j << 63) | (discard_value_i >> 1);
|
||||
|
||||
*(discard_value + discard_size) = discard_value_j;
|
||||
|
||||
discard_value_j = discard_value_i;
|
||||
} while ( discard_size > 0 );
|
||||
__asm__ __volatile__ ( "\n1:\n\t"
|
||||
/* Load value[i] */
|
||||
"ld.d %2, %0, -8\n\t"
|
||||
/* Shift right */
|
||||
"andi %4, %2, 1\n\t"
|
||||
"xor %2, %2, %4\n\t"
|
||||
"or %2, %2, %3\n\t"
|
||||
"move %3, %4\n\t"
|
||||
"rotri.d %2, %2, 1\n\t"
|
||||
/* Store value[i] */
|
||||
"st.d %2, %0, -8\n\t"
|
||||
/* Loop */
|
||||
"addi.d %0, %0, -8\n\t"
|
||||
"addi.w %1, %1, -1\n\t"
|
||||
"bnez %1, 1b\n\t"
|
||||
: "=r" ( discard_value ),
|
||||
"=r" ( discard_size ),
|
||||
"=r" ( discard_value_i ),
|
||||
"=r" ( discard_carry ),
|
||||
"=r" ( discard_temp ),
|
||||
"+m" ( *value )
|
||||
: "0" ( value0 + size ), "1" ( size ), "3" ( 0 )
|
||||
: "cc" );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,7 +358,9 @@ bigint_done_raw ( const uint64_t *value0, unsigned int size __unused,
|
||||
}
|
||||
|
||||
extern void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint64_t *multiplier0,
|
||||
uint64_t *value0, unsigned int size );
|
||||
unsigned int multiplier_size,
|
||||
uint64_t *value0 );
|
||||
|
||||
#endif /* _BITS_BIGINT_H */
|
||||
|
||||
@ -12,4 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
/** Page shift */
|
||||
#define PAGE_SHIFT 12
|
||||
|
||||
#include <ipxe/loong64_io.h>
|
||||
|
||||
#endif /* _BITS_IO_H */
|
||||
|
||||
@ -9,4 +9,6 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#endif /* _BITS_MAP_H */
|
||||
#include <ipxe/efi/efiloong64_nap.h>
|
||||
|
||||
#endif /* _BITS_NAP_H */
|
||||
|
||||
18
src/arch/loong64/include/ipxe/efi/efiloong64_nap.h
Normal file
18
src/arch/loong64/include/ipxe/efi/efiloong64_nap.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef _IPXE_EFILOONG64_NAP_H
|
||||
#define _IPXE_EFILOONG64_NAP_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* EFI CPU sleeping
|
||||
*
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#ifdef NAP_EFILOONG64
|
||||
#define NAP_PREFIX_efiloong64
|
||||
#else
|
||||
#define NAP_PREFIX_efiloong64 __efiloong64_
|
||||
#endif
|
||||
|
||||
#endif /* _IPXE_EFILOONG64_NAP_H */
|
||||
82
src/arch/loong64/include/ipxe/loong64_io.h
Normal file
82
src/arch/loong64/include/ipxe/loong64_io.h
Normal file
@ -0,0 +1,82 @@
|
||||
#ifndef _IPXE_LOONG64_IO_H
|
||||
#define _IPXE_LOONG64_IO_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* iPXE I/O API for LoongArch64
|
||||
*
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#ifdef IOAPI_LOONG64
|
||||
#define IOAPI_PREFIX_loong64
|
||||
#else
|
||||
#define IOAPI_PREFIX_loong64 __loong64_
|
||||
#endif
|
||||
|
||||
#include <ipxe/dummy_pio.h>
|
||||
|
||||
/*
|
||||
* Memory space mappings
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Physical<->Bus address mappings
|
||||
*
|
||||
*/
|
||||
|
||||
static inline __always_inline unsigned long
|
||||
IOAPI_INLINE ( loong64, phys_to_bus ) ( unsigned long phys_addr ) {
|
||||
return phys_addr;
|
||||
}
|
||||
|
||||
static inline __always_inline unsigned long
|
||||
IOAPI_INLINE ( loong64, bus_to_phys ) ( unsigned long bus_addr ) {
|
||||
return bus_addr;
|
||||
}
|
||||
|
||||
/*
|
||||
* MMIO reads and writes up to native word size
|
||||
*
|
||||
*/
|
||||
|
||||
#define LOONG64_READX( _suffix, _type, _insn_suffix ) \
|
||||
static inline __always_inline _type \
|
||||
IOAPI_INLINE ( loong64, read ## _suffix ) ( volatile _type *io_addr ) { \
|
||||
_type data; \
|
||||
__asm__ __volatile__ ( "ld." _insn_suffix " %0, %1" \
|
||||
: "=r" ( data ) : "m" ( *io_addr ) ); \
|
||||
return data; \
|
||||
}
|
||||
LOONG64_READX ( b, uint8_t, "bu");
|
||||
LOONG64_READX ( w, uint16_t, "hu");
|
||||
LOONG64_READX ( l, uint32_t, "wu");
|
||||
LOONG64_READX ( q, uint64_t, "d");
|
||||
|
||||
#define LOONG64_WRITEX( _suffix, _type, _insn_suffix ) \
|
||||
static inline __always_inline void \
|
||||
IOAPI_INLINE ( loong64, write ## _suffix ) ( _type data, \
|
||||
volatile _type *io_addr ) { \
|
||||
__asm__ __volatile__ ( "st." _insn_suffix " %0, %1" \
|
||||
: : "r" ( data ), "m" ( *io_addr ) ); \
|
||||
}
|
||||
LOONG64_WRITEX ( b, uint8_t, "b");
|
||||
LOONG64_WRITEX ( w, uint16_t, "h");
|
||||
LOONG64_WRITEX ( l, uint32_t, "w" );
|
||||
LOONG64_WRITEX ( q, uint64_t, "d");
|
||||
|
||||
/*
|
||||
* Memory barrier
|
||||
*
|
||||
*/
|
||||
static inline __always_inline void
|
||||
IOAPI_INLINE ( loong64, mb ) ( void ) {
|
||||
__asm__ __volatile__ ( "dbar 0" );
|
||||
}
|
||||
|
||||
/* Dummy PIO */
|
||||
DUMMY_PIO ( loong64 );
|
||||
|
||||
#endif /* _IPXE_LOONG64_IO_H */
|
||||
57
src/arch/loong64/interface/efi/efiloong64_nap.c
Normal file
57
src/arch/loong64/interface/efi/efiloong64_nap.c
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Xiaotian Wu <wuxiaotian@loongson.cn>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/nap.h>
|
||||
#include <ipxe/efi/efi.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
* iPXE CPU sleeping API for EFI
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sleep until next interrupt
|
||||
*
|
||||
*/
|
||||
static void efiloong64_cpu_nap ( void ) {
|
||||
/*
|
||||
* I can't find any EFI API that allows us to put the CPU to
|
||||
* sleep. The CpuSleep() function is defined in CpuLib.h, but
|
||||
* isn't part of any exposed protocol so we have no way to
|
||||
* call it.
|
||||
*
|
||||
* The EFI shell doesn't seem to bother sleeping the CPU; it
|
||||
* just sits there idly burning power.
|
||||
*
|
||||
* If a shutdown is in progess, there may be nothing to
|
||||
* generate an interrupt since the timer is disabled in the
|
||||
* first step of ExitBootServices().
|
||||
*/
|
||||
if ( ! efi_shutdown_in_progress )
|
||||
__asm__ __volatile__ ( "idle 0" );
|
||||
}
|
||||
|
||||
PROVIDE_NAP ( efiloong64, cpu_nap, efiloong64_cpu_nap );
|
||||
@ -13,6 +13,13 @@ LDSCRIPT_PREFIX = arch/x86/scripts/prefixonly.lds
|
||||
#
|
||||
LDFLAGS += -N --no-check-sections
|
||||
|
||||
# Do not warn about RWX segments (required by most prefixes)
|
||||
#
|
||||
WRWX_TEST = $(LD) --warn-rwx-segments --version 2>&1 > /dev/null
|
||||
WRWX_FLAGS := $(shell [ -z "`$(WRWX_TEST)`" ] && \
|
||||
$(ECHO) '--no-warn-rwx-segments')
|
||||
LDFLAGS += $(WRWX_FLAGS)
|
||||
|
||||
# Media types.
|
||||
#
|
||||
MEDIA += rom
|
||||
@ -54,9 +61,15 @@ LIST_NAME_mrom := ROMS
|
||||
LIST_NAME_pcirom := ROMS
|
||||
LIST_NAME_isarom := ROMS
|
||||
|
||||
# ISO or FAT filesystem images
|
||||
# ISO images
|
||||
NON_AUTO_MEDIA += iso
|
||||
$(BIN)/%.iso $(BIN)/%.sdsk: $(BIN)/%.lkrn util/genfsimg
|
||||
$(BIN)/%.iso : $(BIN)/%.lkrn util/genfsimg
|
||||
$(QM)$(ECHO) " [GENFSIMG] $@"
|
||||
$(Q)util/genfsimg -o $@ $<
|
||||
|
||||
# FAT filesystem images (via syslinux)
|
||||
NON_AUTO_MEDIA += sdsk
|
||||
$(BIN)/%.sdsk : $(BIN)/%.lkrn util/genfsimg
|
||||
$(QM)$(ECHO) " [GENFSIMG] $@"
|
||||
$(Q)util/genfsimg -o $@ $<
|
||||
|
||||
|
||||
@ -22,9 +22,9 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.text
|
||||
.arch i386
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
/****************************************************************************
|
||||
* Set/clear CF on the stack as appropriate, assumes stack is as it should
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.arch i386
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
|
||||
#ifdef __x86_64__
|
||||
#define STACK_SIZE 8192
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.arch i386
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
|
||||
/****************************************************************************
|
||||
* Internal stack
|
||||
|
||||
@ -36,19 +36,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* Multiply big integers
|
||||
*
|
||||
* @v multiplicand0 Element 0 of big integer to be multiplied
|
||||
* @v multiplicand_size Number of elements in multiplicand
|
||||
* @v multiplier0 Element 0 of big integer to be multiplied
|
||||
* @v multiplier_size Number of elements in multiplier
|
||||
* @v result0 Element 0 of big integer to hold result
|
||||
* @v size Number of elements
|
||||
*/
|
||||
void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint32_t *multiplier0,
|
||||
uint32_t *result0, unsigned int size ) {
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplicand =
|
||||
( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplier =
|
||||
( ( const void * ) multiplier0 );
|
||||
bigint_t ( size * 2 ) __attribute__ (( may_alias )) *result =
|
||||
( ( void * ) result0 );
|
||||
unsigned int multiplier_size,
|
||||
uint32_t *result0 ) {
|
||||
unsigned int result_size = ( multiplicand_size + multiplier_size );
|
||||
const bigint_t ( multiplicand_size ) __attribute__ (( may_alias ))
|
||||
*multiplicand = ( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( multiplier_size ) __attribute__ (( may_alias ))
|
||||
*multiplier = ( ( const void * ) multiplier0 );
|
||||
bigint_t ( result_size ) __attribute__ (( may_alias ))
|
||||
*result = ( ( void * ) result0 );
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
uint32_t multiplicand_element;
|
||||
@ -62,9 +66,9 @@ void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
memset ( result, 0, sizeof ( *result ) );
|
||||
|
||||
/* Multiply integers one element at a time */
|
||||
for ( i = 0 ; i < size ; i++ ) {
|
||||
for ( i = 0 ; i < multiplicand_size ; i++ ) {
|
||||
multiplicand_element = multiplicand->element[i];
|
||||
for ( j = 0 ; j < size ; j++ ) {
|
||||
for ( j = 0 ; j < multiplier_size ; j++ ) {
|
||||
multiplier_element = multiplier->element[j];
|
||||
result_elements = &result->element[ i + j ];
|
||||
/* Perform a single multiply, and add the
|
||||
@ -73,7 +77,7 @@ void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
* never overflow beyond the end of the
|
||||
* result, since:
|
||||
*
|
||||
* a < 2^{n}, b < 2^{n} => ab < 2^{2n}
|
||||
* a < 2^{n}, b < 2^{m} => ab < 2^{n+m}
|
||||
*/
|
||||
__asm__ __volatile__ ( "mull %5\n\t"
|
||||
"addl %%eax, (%6,%2,4)\n\t"
|
||||
|
||||
@ -10,9 +10,9 @@ FILE_LICENCE ( GPL2_OR_LATER )
|
||||
#define PIC1_ICR 0x20
|
||||
#define PIC2_ICR 0xa0
|
||||
|
||||
.text
|
||||
.arch i386
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
.section ".text16", "ax", @progbits
|
||||
.globl undiisr
|
||||
|
||||
@ -323,7 +323,9 @@ bigint_done_raw ( const uint32_t *value0, unsigned int size __unused,
|
||||
}
|
||||
|
||||
extern void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint32_t *multiplier0,
|
||||
uint32_t *value0, unsigned int size );
|
||||
unsigned int multiplier_size,
|
||||
uint32_t *value0 );
|
||||
|
||||
#endif /* _BITS_BIGINT_H */
|
||||
|
||||
@ -250,8 +250,10 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
|
||||
/* CODE_DEFAULT: restore default .code32/.code64 directive */
|
||||
#ifdef __x86_64__
|
||||
#define CODE_DEFAULT ".code64"
|
||||
#define STACK_DEFAULT "q"
|
||||
#else
|
||||
#define CODE_DEFAULT ".code32"
|
||||
#define STACK_DEFAULT "l"
|
||||
#endif
|
||||
|
||||
/* LINE_SYMBOL: declare a symbol for the current source code line */
|
||||
@ -268,7 +270,7 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
|
||||
|
||||
/* REAL_CODE: declare a fragment of code that executes in real mode */
|
||||
#define REAL_CODE( asm_code_str ) \
|
||||
"push $1f\n\t" \
|
||||
"push" STACK_DEFAULT " $1f\n\t" \
|
||||
"call real_call\n\t" \
|
||||
TEXT16_CODE ( "\n1:\n\t" \
|
||||
asm_code_str \
|
||||
@ -277,7 +279,7 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
|
||||
|
||||
/* PHYS_CODE: declare a fragment of code that executes in flat physical mode */
|
||||
#define PHYS_CODE( asm_code_str ) \
|
||||
"push $1f\n\t" \
|
||||
"push" STACK_DEFAULT " $1f\n\t" \
|
||||
"call phys_call\n\t" \
|
||||
".section \".text.phys\", \"ax\", @progbits\n\t"\
|
||||
"\n" LINE_SYMBOL "\n\t" \
|
||||
|
||||
@ -46,8 +46,12 @@ static void efix86_cpu_nap ( void ) {
|
||||
* The EFI shell doesn't seem to bother sleeping the CPU; it
|
||||
* just sits there idly burning power.
|
||||
*
|
||||
* If a shutdown is in progess, there may be nothing to
|
||||
* generate an interrupt since the timer is disabled in the
|
||||
* first step of ExitBootServices().
|
||||
*/
|
||||
__asm__ __volatile__ ( "hlt" );
|
||||
if ( ! efi_shutdown_in_progress )
|
||||
__asm__ __volatile__ ( "hlt" );
|
||||
}
|
||||
|
||||
PROVIDE_NAP ( efix86, cpu_nap, efix86_cpu_nap );
|
||||
|
||||
@ -290,29 +290,38 @@ static const char *bios_ansi_input = "";
|
||||
struct bios_key {
|
||||
/** Scancode */
|
||||
uint8_t scancode;
|
||||
/** Key code */
|
||||
uint16_t key;
|
||||
/** Relative key value */
|
||||
uint16_t rkey;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/**
|
||||
* Define a BIOS key mapping
|
||||
*
|
||||
* @v scancode Scancode
|
||||
* @v key iPXE key code
|
||||
* @v bioskey BIOS key mapping
|
||||
*/
|
||||
#define BIOS_KEY( scancode, key ) { scancode, KEY_REL ( key ) }
|
||||
|
||||
/** Mapping from BIOS scan codes to iPXE key codes */
|
||||
static const struct bios_key bios_keys[] = {
|
||||
{ 0x53, KEY_DC },
|
||||
{ 0x48, KEY_UP },
|
||||
{ 0x50, KEY_DOWN },
|
||||
{ 0x4b, KEY_LEFT },
|
||||
{ 0x4d, KEY_RIGHT },
|
||||
{ 0x47, KEY_HOME },
|
||||
{ 0x4f, KEY_END },
|
||||
{ 0x49, KEY_PPAGE },
|
||||
{ 0x51, KEY_NPAGE },
|
||||
{ 0x3f, KEY_F5 },
|
||||
{ 0x40, KEY_F6 },
|
||||
{ 0x41, KEY_F7 },
|
||||
{ 0x42, KEY_F8 },
|
||||
{ 0x43, KEY_F9 },
|
||||
{ 0x44, KEY_F10 },
|
||||
{ 0x85, KEY_F11 },
|
||||
{ 0x86, KEY_F12 },
|
||||
BIOS_KEY ( 0x53, KEY_DC ),
|
||||
BIOS_KEY ( 0x48, KEY_UP ),
|
||||
BIOS_KEY ( 0x50, KEY_DOWN ),
|
||||
BIOS_KEY ( 0x4b, KEY_LEFT ),
|
||||
BIOS_KEY ( 0x4d, KEY_RIGHT ),
|
||||
BIOS_KEY ( 0x47, KEY_HOME ),
|
||||
BIOS_KEY ( 0x4f, KEY_END ),
|
||||
BIOS_KEY ( 0x49, KEY_PPAGE ),
|
||||
BIOS_KEY ( 0x51, KEY_NPAGE ),
|
||||
BIOS_KEY ( 0x3f, KEY_F5 ),
|
||||
BIOS_KEY ( 0x40, KEY_F6 ),
|
||||
BIOS_KEY ( 0x41, KEY_F7 ),
|
||||
BIOS_KEY ( 0x42, KEY_F8 ),
|
||||
BIOS_KEY ( 0x43, KEY_F9 ),
|
||||
BIOS_KEY ( 0x44, KEY_F10 ),
|
||||
BIOS_KEY ( 0x85, KEY_F11 ),
|
||||
BIOS_KEY ( 0x86, KEY_F12 ),
|
||||
};
|
||||
|
||||
/**
|
||||
@ -323,7 +332,7 @@ static const struct bios_key bios_keys[] = {
|
||||
*/
|
||||
static const char * bios_ansi_seq ( unsigned int scancode ) {
|
||||
static char buf[ 5 /* "[" + two digits + terminator + NUL */ ];
|
||||
unsigned int key;
|
||||
unsigned int rkey;
|
||||
unsigned int terminator;
|
||||
unsigned int n;
|
||||
unsigned int i;
|
||||
@ -338,9 +347,9 @@ static const char * bios_ansi_seq ( unsigned int scancode ) {
|
||||
continue;
|
||||
|
||||
/* Construct escape sequence */
|
||||
key = bios_keys[i].key;
|
||||
n = KEY_ANSI_N ( key );
|
||||
terminator = KEY_ANSI_TERMINATOR ( key );
|
||||
rkey = bios_keys[i].rkey;
|
||||
n = KEY_ANSI_N ( rkey );
|
||||
terminator = KEY_ANSI_TERMINATOR ( rkey );
|
||||
*(tmp++) = '[';
|
||||
if ( n )
|
||||
tmp += sprintf ( tmp, "%d", n );
|
||||
@ -479,6 +488,7 @@ struct console_driver bios_console __console_driver = {
|
||||
static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
|
||||
unsigned int discard_a;
|
||||
unsigned int scancode;
|
||||
unsigned int rkey;
|
||||
unsigned int i;
|
||||
uint16_t keypress;
|
||||
int key;
|
||||
@ -521,9 +531,10 @@ static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
|
||||
|
||||
/* Handle special keys */
|
||||
if ( key >= KEY_MIN ) {
|
||||
rkey = KEY_REL ( key );
|
||||
for ( i = 0 ; i < ( sizeof ( bios_keys ) /
|
||||
sizeof ( bios_keys[0] ) ) ; i++ ) {
|
||||
if ( bios_keys[i].key == key ) {
|
||||
if ( bios_keys[i].rkey == rkey ) {
|
||||
scancode = bios_keys[i].scancode;
|
||||
keypress = ( scancode << 8 );
|
||||
break;
|
||||
|
||||
@ -44,11 +44,11 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* @v smbios SMBIOS entry point descriptor structure to fill in
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int bios_find_smbios ( struct smbios *smbios ) {
|
||||
static int bios_find_smbios2 ( struct smbios *smbios ) {
|
||||
struct smbios_entry entry;
|
||||
int rc;
|
||||
|
||||
/* Scan through BIOS segment to find SMBIOS entry point */
|
||||
/* Scan through BIOS segment to find SMBIOS 32-bit entry point */
|
||||
if ( ( rc = find_smbios_entry ( real_to_user ( BIOS_SEG, 0 ), 0x10000,
|
||||
&entry ) ) != 0 )
|
||||
return rc;
|
||||
@ -62,4 +62,55 @@ static int bios_find_smbios ( struct smbios *smbios ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find SMBIOS
|
||||
*
|
||||
* @v smbios SMBIOS entry point descriptor structure to fill in
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int bios_find_smbios3 ( struct smbios *smbios ) {
|
||||
struct smbios3_entry entry;
|
||||
int rc;
|
||||
|
||||
/* Scan through BIOS segment to find SMBIOS 64-bit entry point */
|
||||
if ( ( rc = find_smbios3_entry ( real_to_user ( BIOS_SEG, 0 ), 0x10000,
|
||||
&entry ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Check that address is accessible */
|
||||
if ( entry.smbios_address > ~( ( physaddr_t ) 0 ) ) {
|
||||
DBG ( "SMBIOS3 at %08llx is inaccessible\n",
|
||||
( ( unsigned long long ) entry.smbios_address ) );
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Fill in entry point descriptor structure */
|
||||
smbios->address = phys_to_user ( entry.smbios_address );
|
||||
smbios->len = entry.smbios_len;
|
||||
smbios->count = 0;
|
||||
smbios->version = SMBIOS_VERSION ( entry.major, entry.minor );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find SMBIOS
|
||||
*
|
||||
* @v smbios SMBIOS entry point descriptor structure to fill in
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int bios_find_smbios ( struct smbios *smbios ) {
|
||||
int rc;
|
||||
|
||||
/* Use 32-bit table if present */
|
||||
if ( ( rc = bios_find_smbios2 ( smbios ) ) == 0 )
|
||||
return 0;
|
||||
|
||||
/* Otherwise, use 64-bit table if present and accessible */
|
||||
if ( ( rc = bios_find_smbios3 ( smbios ) ) == 0 )
|
||||
return 0;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
PROVIDE_SMBIOS ( pcbios, find_smbios, bios_find_smbios );
|
||||
|
||||
@ -23,9 +23,9 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.text
|
||||
.arch i386
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
#define SMAP 0x534d4150
|
||||
|
||||
|
||||
@ -165,24 +165,27 @@ static void pcicloud_init ( void ) {
|
||||
static struct pci_api *apis[] = {
|
||||
&ecam_api, &pcibios_api, &pcidirect_api
|
||||
};
|
||||
struct pci_range range;
|
||||
struct pci_device pci;
|
||||
uint32_t busdevfn;
|
||||
unsigned int i;
|
||||
int rc;
|
||||
|
||||
/* Select first API that successfully discovers an address range */
|
||||
/* Select first API that successfully discovers a PCI device */
|
||||
for ( i = 0 ; i < ( sizeof ( apis ) / sizeof ( apis[0] ) ) ; i++ ) {
|
||||
pcicloud = apis[i];
|
||||
pcicloud_discover ( 0, &range );
|
||||
if ( range.count != 0 ) {
|
||||
DBGC ( pcicloud, "PCICLOUD selected %s API\n",
|
||||
pcicloud->name );
|
||||
break;
|
||||
busdevfn = 0;
|
||||
if ( ( rc = pci_find_next ( &pci, &busdevfn ) ) == 0 ) {
|
||||
DBGC ( pcicloud, "PCICLOUD selected %s API (found "
|
||||
PCI_FMT ")\n", pcicloud->name,
|
||||
PCI_ARGS ( &pci ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* The PCI direct API can never fail discovery since the range
|
||||
* is hardcoded.
|
||||
*/
|
||||
assert ( range.count != 0 );
|
||||
/* Fall back to using final attempted API if no devices found */
|
||||
pcicloud = apis[ i - 1 ];
|
||||
DBGC ( pcicloud, "PCICLOUD selected %s API (nothing detected)\n",
|
||||
pcicloud->name );
|
||||
}
|
||||
|
||||
/** Cloud VM PCI configuration space access initialisation function */
|
||||
|
||||
@ -375,9 +375,10 @@ int pxe_start_nbp ( void ) {
|
||||
* Notify BIOS of existence of network device
|
||||
*
|
||||
* @v netdev Network device
|
||||
* @v priv Private data
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int pxe_notify ( struct net_device *netdev ) {
|
||||
static int pxe_notify ( struct net_device *netdev, void *priv __unused ) {
|
||||
|
||||
/* Do nothing if we already have a network device */
|
||||
if ( pxe_netdev )
|
||||
|
||||
@ -26,6 +26,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
#include <librm.h>
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER )
|
||||
|
||||
#include "librm.h"
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
|
||||
.code32
|
||||
|
||||
@ -207,65 +207,35 @@ struct init_fn guestinfo_init_fn __init_fn ( INIT_NORMAL ) = {
|
||||
* Create per-netdevice GuestInfo settings
|
||||
*
|
||||
* @v netdev Network device
|
||||
* @v priv Private data
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int guestinfo_net_probe ( struct net_device *netdev ) {
|
||||
struct settings *settings;
|
||||
static int guestinfo_net_probe ( struct net_device *netdev, void *priv ) {
|
||||
struct settings *settings = priv;
|
||||
int rc;
|
||||
|
||||
/* Do nothing unless we have a GuestInfo channel available */
|
||||
if ( guestinfo_channel < 0 )
|
||||
return 0;
|
||||
|
||||
/* Allocate and initialise settings block */
|
||||
settings = zalloc ( sizeof ( *settings ) );
|
||||
if ( ! settings ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
}
|
||||
settings_init ( settings, &guestinfo_settings_operations, NULL, NULL );
|
||||
|
||||
/* Register settings */
|
||||
/* Initialise and register settings */
|
||||
settings_init ( settings, &guestinfo_settings_operations,
|
||||
&netdev->refcnt, NULL );
|
||||
if ( ( rc = register_settings ( settings, netdev_settings ( netdev ),
|
||||
"vmware" ) ) != 0 ) {
|
||||
DBGC ( settings, "GuestInfo %p could not register for %s: %s\n",
|
||||
settings, netdev->name, strerror ( rc ) );
|
||||
goto err_register;
|
||||
return rc;
|
||||
}
|
||||
DBGC ( settings, "GuestInfo %p registered for %s\n",
|
||||
settings, netdev->name );
|
||||
|
||||
return 0;
|
||||
|
||||
err_register:
|
||||
free ( settings );
|
||||
err_alloc:
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove per-netdevice GuestInfo settings
|
||||
*
|
||||
* @v netdev Network device
|
||||
*/
|
||||
static void guestinfo_net_remove ( struct net_device *netdev ) {
|
||||
struct settings *parent = netdev_settings ( netdev );
|
||||
struct settings *settings;
|
||||
|
||||
list_for_each_entry ( settings, &parent->children, siblings ) {
|
||||
if ( settings->op == &guestinfo_settings_operations ) {
|
||||
DBGC ( settings, "GuestInfo %p unregistered for %s\n",
|
||||
settings, netdev->name );
|
||||
unregister_settings ( settings );
|
||||
free ( settings );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** GuestInfo per-netdevice driver */
|
||||
struct net_driver guestinfo_net_driver __net_driver = {
|
||||
.name = "GuestInfo",
|
||||
.priv_len = sizeof ( struct settings ),
|
||||
.probe = guestinfo_net_probe,
|
||||
.remove = guestinfo_net_remove,
|
||||
};
|
||||
|
||||
@ -5,10 +5,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#define STACK_SEG 0x0200
|
||||
#define STACK_SIZE 0x2000
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "awx", @progbits
|
||||
.code16
|
||||
|
||||
/*
|
||||
* Find active partition
|
||||
|
||||
@ -24,11 +24,11 @@ FILE_LICENCE ( GPL2_ONLY )
|
||||
|
||||
.equ SYSSEG, 0x1000 /* system loaded at SYSSEG<<4 */
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.org 0
|
||||
.arch i386
|
||||
.text
|
||||
.section ".prefix", "ax", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
.globl _dsk_start
|
||||
_dsk_start:
|
||||
|
||||
|
||||
@ -36,10 +36,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#define PSP_CMDLINE_LEN 0x80
|
||||
#define PSP_CMDLINE_START 0x81
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.org 0
|
||||
.code16
|
||||
.section ".prefix", "awx", @progbits
|
||||
|
||||
signature:
|
||||
|
||||
@ -2,10 +2,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
#include <librm.h>
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "awx", @progbits
|
||||
.code16
|
||||
.org 0
|
||||
.globl _hd_start
|
||||
_hd_start:
|
||||
|
||||
@ -26,6 +26,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
#include <librm.h>
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
/* Image compression enabled */
|
||||
|
||||
@ -4,9 +4,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
#define BZI_LOAD_HIGH_ADDR 0x100000
|
||||
|
||||
.text
|
||||
.arch i386
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
.globl _lkrn_start
|
||||
_lkrn_start:
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "awx", @progbits
|
||||
.code16
|
||||
.org 0
|
||||
|
||||
.globl mbr
|
||||
|
||||
@ -41,9 +41,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#define _pcirom_start _mrom_start
|
||||
#include "pciromprefix.S"
|
||||
|
||||
.text
|
||||
.arch i386
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
/* Obtain access to payload by exposing the expansion ROM BAR at the
|
||||
* address currently used by a suitably large memory BAR on the same
|
||||
|
||||
@ -2,9 +2,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
#include <librm.h>
|
||||
|
||||
.text
|
||||
.arch i386
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
.org 0
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.org 0
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
.section ".prefix", "ax", @progbits
|
||||
.code16
|
||||
_prefix:
|
||||
|
||||
.section ".text16", "ax", @progbits
|
||||
|
||||
@ -11,10 +11,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
#define PXE_HACK_EB54 0x0001
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.org 0
|
||||
.code16
|
||||
|
||||
#include <librm.h>
|
||||
#include <undi.h>
|
||||
|
||||
@ -8,10 +8,10 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.org 0
|
||||
.code16
|
||||
|
||||
#include <librm.h>
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#define BUSTYPE "PCIR"
|
||||
#endif
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
|
||||
@ -2,7 +2,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
#include <librm.h>
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
|
||||
@ -43,7 +43,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code32
|
||||
.arch i486
|
||||
.section ".prefix.lib", "ax", @progbits
|
||||
|
||||
|
||||
@ -2,10 +2,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
#include <config/console.h>
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "awx", @progbits
|
||||
.code16
|
||||
.org 0
|
||||
|
||||
#include "mbr.S"
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@ -31,10 +31,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
/* Breakpoint for when debugging under bochs */
|
||||
#define BOCHSBP xchgw %bx, %bx
|
||||
|
||||
.text
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".text16", "awx", @progbits
|
||||
.code16
|
||||
|
||||
/****************************************************************************
|
||||
* init_libkir (real-mode or 16:xx protected-mode far call)
|
||||
|
||||
@ -83,6 +83,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#define if64 if 0
|
||||
#endif
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
|
||||
/****************************************************************************
|
||||
* Global descriptor table
|
||||
*
|
||||
|
||||
@ -38,6 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define SIGFPE 8
|
||||
#define SIGSTKFLT 16
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.section ".text.gdbmach_interrupt", "ax", @progbits
|
||||
.code64
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code64
|
||||
|
||||
|
||||
1
src/bin/.gitignore
vendored
1
src/bin/.gitignore
vendored
@ -1 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
|
||||
@ -83,6 +83,11 @@ REQUIRE_OBJECT ( oid_sha512_224 );
|
||||
REQUIRE_OBJECT ( oid_sha512_256 );
|
||||
#endif
|
||||
|
||||
/* X25519 */
|
||||
#if defined ( CRYPTO_CURVE_X25519 )
|
||||
REQUIRE_OBJECT ( oid_x25519 );
|
||||
#endif
|
||||
|
||||
/* RSA and MD5 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_DIGEST_MD5 )
|
||||
REQUIRE_OBJECT ( rsa_md5 );
|
||||
@ -114,25 +119,79 @@ REQUIRE_OBJECT ( rsa_sha512 );
|
||||
#endif
|
||||
|
||||
/* RSA, AES-CBC, and SHA-1 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_CIPHER_AES_CBC ) && \
|
||||
defined ( CRYPTO_DIGEST_SHA1 )
|
||||
#if defined ( CRYPTO_EXCHANGE_PUBKEY ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA1 )
|
||||
REQUIRE_OBJECT ( rsa_aes_cbc_sha1 );
|
||||
#endif
|
||||
|
||||
/* RSA, AES-CBC, and SHA-256 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_CIPHER_AES_CBC ) && \
|
||||
defined ( CRYPTO_DIGEST_SHA256 )
|
||||
#if defined ( CRYPTO_EXCHANGE_PUBKEY ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( rsa_aes_cbc_sha256 );
|
||||
#endif
|
||||
|
||||
/* RSA, AES-GCM, and SHA-256 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_CIPHER_AES_GCM ) && \
|
||||
defined ( CRYPTO_DIGEST_SHA256 )
|
||||
#if defined ( CRYPTO_EXCHANGE_PUBKEY ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( rsa_aes_gcm_sha256 );
|
||||
#endif
|
||||
|
||||
/* RSA, AES-GCM, and SHA-384 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_CIPHER_AES_GCM ) && \
|
||||
defined ( CRYPTO_DIGEST_SHA384 )
|
||||
#if defined ( CRYPTO_EXCHANGE_PUBKEY ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA384 )
|
||||
REQUIRE_OBJECT ( rsa_aes_gcm_sha384 );
|
||||
#endif
|
||||
|
||||
/* DHE, RSA, AES-CBC, and SHA-1 */
|
||||
#if defined ( CRYPTO_EXCHANGE_DHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA1 )
|
||||
REQUIRE_OBJECT ( dhe_rsa_aes_cbc_sha1 );
|
||||
#endif
|
||||
|
||||
/* DHE, RSA, AES-CBC, and SHA-256 */
|
||||
#if defined ( CRYPTO_EXCHANGE_DHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( dhe_rsa_aes_cbc_sha256 );
|
||||
#endif
|
||||
|
||||
/* DHE, RSA, AES-GCM, and SHA-256 */
|
||||
#if defined ( CRYPTO_EXCHANGE_DHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( dhe_rsa_aes_gcm_sha256 );
|
||||
#endif
|
||||
|
||||
/* DHE, RSA, AES-GCM, and SHA-384 */
|
||||
#if defined ( CRYPTO_EXCHANGE_DHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA384 )
|
||||
REQUIRE_OBJECT ( dhe_rsa_aes_gcm_sha384 );
|
||||
#endif
|
||||
|
||||
/* ECDHE, RSA, AES-CBC, and SHA-1 */
|
||||
#if defined ( CRYPTO_EXCHANGE_ECDHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA1 )
|
||||
REQUIRE_OBJECT ( ecdhe_rsa_aes_cbc_sha1 );
|
||||
#endif
|
||||
|
||||
/* ECDHE, RSA, AES-CBC, and SHA-256 */
|
||||
#if defined ( CRYPTO_EXCHANGE_ECDHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( ecdhe_rsa_aes_cbc_sha256 );
|
||||
#endif
|
||||
|
||||
/* ECDHE, RSA, AES-CBC, and SHA-384 */
|
||||
#if defined ( CRYPTO_EXCHANGE_ECDHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA384 )
|
||||
REQUIRE_OBJECT ( ecdhe_rsa_aes_cbc_sha384 );
|
||||
#endif
|
||||
|
||||
/* ECDHE, RSA, AES-GCM, and SHA-256 */
|
||||
#if defined ( CRYPTO_EXCHANGE_ECDHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( ecdhe_rsa_aes_gcm_sha256 );
|
||||
#endif
|
||||
|
||||
/* ECDHE, RSA, AES-GCM, and SHA-384 */
|
||||
#if defined ( CRYPTO_EXCHANGE_ECDHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA384 )
|
||||
REQUIRE_OBJECT ( ecdhe_rsa_aes_gcm_sha384 );
|
||||
#endif
|
||||
|
||||
@ -12,6 +12,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
/** Minimum TLS version */
|
||||
#define TLS_VERSION_MIN TLS_VERSION_TLS_1_1
|
||||
|
||||
/** Public-key exchange algorithm */
|
||||
#define CRYPTO_EXCHANGE_PUBKEY
|
||||
|
||||
/** DHE key exchange algorithm */
|
||||
#define CRYPTO_EXCHANGE_DHE
|
||||
|
||||
/** ECDHE key exchange algorithm */
|
||||
#define CRYPTO_EXCHANGE_ECDHE
|
||||
|
||||
/** RSA public-key algorithm */
|
||||
#define CRYPTO_PUBKEY_RSA
|
||||
|
||||
@ -48,6 +57,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
/** SHA-512/256 digest algorithm */
|
||||
//#define CRYPTO_DIGEST_SHA512_256
|
||||
|
||||
/** X25519 elliptic curve */
|
||||
#define CRYPTO_CURVE_X25519
|
||||
|
||||
/** Margin of error (in seconds) allowed in signed timestamps
|
||||
*
|
||||
* We default to allowing a reasonable margin of error: 12 hours to
|
||||
|
||||
@ -67,4 +67,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define IMAGE_GZIP /* GZIP image support */
|
||||
#endif
|
||||
|
||||
#if defined ( __loongarch__ )
|
||||
#define IOAPI_LOONG64
|
||||
#define NAP_EFILOONG64
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_DEFAULTS_EFI_H */
|
||||
|
||||
1
src/config/local/.gitignore
vendored
1
src/config/local/.gitignore
vendored
@ -1 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
|
||||
@ -295,9 +295,10 @@ struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_LATE ) = {
|
||||
* Apply cached DHCPACK to network device, if applicable
|
||||
*
|
||||
* @v netdev Network device
|
||||
* @v priv Private data
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int cachedhcp_probe ( struct net_device *netdev ) {
|
||||
static int cachedhcp_probe ( struct net_device *netdev, void *priv __unused ) {
|
||||
|
||||
/* Apply cached DHCPACK to network device, if applicable */
|
||||
return cachedhcp_apply ( &cached_dhcpack, netdev );
|
||||
|
||||
@ -285,6 +285,7 @@ void intf_shutdown ( struct interface *intf, int rc ) {
|
||||
intf_nullify ( intf );
|
||||
|
||||
/* Transfer destination to temporary interface */
|
||||
intf_temp_init ( &tmp, intf );
|
||||
tmp.dest = intf->dest;
|
||||
intf->dest = &null_intf;
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <ipxe/netdevice.h>
|
||||
@ -35,6 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <ipxe/settings.h>
|
||||
#include <ipxe/params.h>
|
||||
#include <ipxe/timer.h>
|
||||
#include <ipxe/keys.h>
|
||||
#include <ipxe/parseopt.h>
|
||||
#include <config/branding.h>
|
||||
|
||||
@ -213,6 +215,7 @@ int parse_flag ( char *text __unused, int *flag ) {
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int parse_key ( char *text, unsigned int *key ) {
|
||||
int rc;
|
||||
|
||||
/* Interpret single characters as being a literal key character */
|
||||
if ( text[0] && ! text[1] ) {
|
||||
@ -221,7 +224,17 @@ int parse_key ( char *text, unsigned int *key ) {
|
||||
}
|
||||
|
||||
/* Otherwise, interpret as an integer */
|
||||
return parse_integer ( text, key );
|
||||
if ( ( rc = parse_integer ( text, key ) ) < 0 )
|
||||
return rc;
|
||||
|
||||
/* For backwards compatibility with existing scripts, treat
|
||||
* integers between the ASCII range and special key range as
|
||||
* being relative special key values.
|
||||
*/
|
||||
if ( ( ! isascii ( *key ) ) && ( *key < KEY_MIN ) )
|
||||
*key += KEY_MIN;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -6,8 +6,9 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <ipxe/timer.h>
|
||||
#include <time.h>
|
||||
|
||||
static int32_t rnd_seed = 0;
|
||||
|
||||
@ -30,8 +31,9 @@ void srandom ( unsigned int seed ) {
|
||||
long int random ( void ) {
|
||||
int32_t q;
|
||||
|
||||
if ( ! rnd_seed ) /* Initialize linear congruential generator */
|
||||
srandom ( currticks() );
|
||||
/* Initialize linear congruential generator */
|
||||
if ( ! rnd_seed )
|
||||
srandom ( time ( NULL ) );
|
||||
|
||||
/* simplified version of the LCG given in Bruce Schneier's
|
||||
"Applied Cryptography" */
|
||||
|
||||
@ -60,7 +60,7 @@ static struct xfer_metadata dummy_metadata;
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int xfer_vredirect ( struct interface *intf, int type, va_list args ) {
|
||||
struct interface tmp = INTF_INIT ( null_intf_desc );
|
||||
struct interface tmp;
|
||||
struct interface *dest;
|
||||
xfer_vredirect_TYPE ( void * ) *op =
|
||||
intf_get_dest_op_no_passthru ( intf, xfer_vredirect, &dest );
|
||||
@ -85,6 +85,7 @@ int xfer_vredirect ( struct interface *intf, int type, va_list args ) {
|
||||
* If redirection fails, then send intf_close() to the
|
||||
* parent interface.
|
||||
*/
|
||||
intf_temp_init ( &tmp, intf );
|
||||
intf_plug ( &tmp, dest );
|
||||
rc = xfer_vreopen ( dest, type, args );
|
||||
if ( rc == 0 ) {
|
||||
|
||||
@ -50,6 +50,31 @@ static struct profiler bigint_mod_multiply_rescale_profiler __profiler =
|
||||
static struct profiler bigint_mod_multiply_subtract_profiler __profiler =
|
||||
{ .name = "bigint_mod_multiply.subtract" };
|
||||
|
||||
/**
|
||||
* Conditionally swap big integers (in constant time)
|
||||
*
|
||||
* @v first0 Element 0 of big integer to be conditionally swapped
|
||||
* @v second0 Element 0 of big integer to be conditionally swapped
|
||||
* @v size Number of elements in big integers
|
||||
* @v swap Swap first and second big integers
|
||||
*/
|
||||
void bigint_swap_raw ( bigint_element_t *first0, bigint_element_t *second0,
|
||||
unsigned int size, int swap ) {
|
||||
bigint_element_t mask;
|
||||
bigint_element_t xor;
|
||||
unsigned int i;
|
||||
|
||||
/* Construct mask */
|
||||
mask = ( ( bigint_element_t ) ( ! swap ) - 1 );
|
||||
|
||||
/* Conditionally swap elements */
|
||||
for ( i = 0 ; i < size ; i++ ) {
|
||||
xor = ( mask & ( first0[i] ^ second0[i] ) );
|
||||
first0[i] ^= xor;
|
||||
second0[i] ^= xor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform modular multiplication of big integers
|
||||
*
|
||||
|
||||
695
src/crypto/des.c
Normal file
695
src/crypto/des.c
Normal file
@ -0,0 +1,695 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
/** @file
|
||||
*
|
||||
* DES algorithm
|
||||
*
|
||||
* DES was not designed to be implemented in software, and therefore
|
||||
* contains a large number of bit permutation operations that are
|
||||
* essentially free in hardware (requiring only wires, no gates) but
|
||||
* expensive in software.
|
||||
*
|
||||
* Since DES is no longer used as a practical block cipher for large
|
||||
* volumes of data, we optimise for code size, and do not attempt to
|
||||
* obtain fast throughput.
|
||||
*
|
||||
* The algorithm is specified in NIST SP 800-67, downloadable from
|
||||
* https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-67r2.pdf
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/rotate.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/ecb.h>
|
||||
#include <ipxe/cbc.h>
|
||||
#include <ipxe/init.h>
|
||||
#include <ipxe/des.h>
|
||||
|
||||
/**
|
||||
* DES shift schedule
|
||||
*
|
||||
* The DES shift schedule (ordered from round 16 down to round 1) is
|
||||
* {1,2,2,2,2,2,2,1,2,2,2,2,2,2,1,1}. In binary, this may be
|
||||
* represented as {1,10,10,10,10,10,10,1,10,10,10,10,10,10,1,1} and
|
||||
* concatenated (without padding) to produce a single binary integer
|
||||
* 1101010101010110101010101011 (equal to 0x0d556aab in hexadecimal).
|
||||
*
|
||||
* This integer may then be consumed LSB-first, where a 1 bit
|
||||
* indicates a shift and the generation of a round key, and a 0 bit
|
||||
* indicates a shift without the generation of a round key.
|
||||
*/
|
||||
#define DES_SCHEDULE 0x0d556aab
|
||||
|
||||
/**
|
||||
* Define an element pair in a DES S-box
|
||||
*
|
||||
* @v x Upper element of element pair
|
||||
* @v y Lower element of element pair
|
||||
*
|
||||
* DES S-box elements are 4-bit values. We encode two values per
|
||||
* byte, ordering the elements so that the six-bit input value may be
|
||||
* used directly as a lookup index.
|
||||
*
|
||||
* Specifically, if the input value is {r1,c3,c2,c1,c0,r0}, where
|
||||
* {r1,r0} is the table row index and {c3,c2,c1,c0} is the table
|
||||
* column index (as used in the DES specification), then:
|
||||
*
|
||||
* - {r1,c3,c2,c1,c0} is the byte index into the table
|
||||
*
|
||||
* - (4*r0) is the required bit shift to extract the 4-bit value
|
||||
*/
|
||||
#define SBYTE( x, y ) ( ( (y) << 4 ) | (x) )
|
||||
|
||||
/**
|
||||
* Define a row pair in a DES S-box
|
||||
*
|
||||
* @v x0..xf Upper row of row pair
|
||||
* @v y0..yf Lower row of row pair
|
||||
*/
|
||||
#define SBOX( x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf, \
|
||||
y0, y1, y2, y3, y4, y5, y6, y7, y8, y9, ya, yb, yc, yd, ye, yf ) \
|
||||
SBYTE ( x0, y0 ), SBYTE ( x1, y1 ), SBYTE ( x2, y2 ), SBYTE ( x3, y3 ),\
|
||||
SBYTE ( x4, y4 ), SBYTE ( x5, y5 ), SBYTE ( x6, y6 ), SBYTE ( x7, y7 ),\
|
||||
SBYTE ( x8, y8 ), SBYTE ( x9, y9 ), SBYTE ( xa, ya ), SBYTE ( xb, yb ),\
|
||||
SBYTE ( xc, yc ), SBYTE ( xd, yd ), SBYTE ( xe, ye ), SBYTE ( xf, yf )
|
||||
|
||||
/** DES S-boxes S1..S8 */
|
||||
static const uint8_t des_s[8][32] = { {
|
||||
/* S1 */
|
||||
SBOX ( 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
|
||||
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8 ),
|
||||
SBOX ( 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
|
||||
15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 )
|
||||
}, {
|
||||
/* S2 */
|
||||
SBOX ( 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
|
||||
3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5 ),
|
||||
SBOX ( 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
|
||||
13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 )
|
||||
}, {
|
||||
/* S3 */
|
||||
SBOX ( 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
|
||||
13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1 ),
|
||||
SBOX ( 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
|
||||
1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 )
|
||||
}, {
|
||||
/* S4 */
|
||||
SBOX ( 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
|
||||
13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9 ),
|
||||
SBOX ( 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
|
||||
3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 )
|
||||
}, {
|
||||
/* S5 */
|
||||
SBOX ( 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
|
||||
14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6 ),
|
||||
SBOX ( 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
|
||||
11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3 )
|
||||
}, {
|
||||
/* S6 */
|
||||
SBOX ( 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
|
||||
10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8 ),
|
||||
SBOX ( 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
|
||||
4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 )
|
||||
}, {
|
||||
/* S7 */
|
||||
SBOX ( 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
|
||||
13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6 ),
|
||||
SBOX ( 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
|
||||
6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 )
|
||||
}, {
|
||||
/* S8 */
|
||||
SBOX ( 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
|
||||
1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2 ),
|
||||
SBOX ( 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
|
||||
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 )
|
||||
} };
|
||||
|
||||
/**
|
||||
* Define a bit index within permuted choice 2 (PC2)
|
||||
*
|
||||
* @v bit Bit index
|
||||
*
|
||||
* Permuted choice 2 (PC2) is used to select bits from a concatenated
|
||||
* pair of 28-bit registers ("C" and "D") as part of the key schedule.
|
||||
* We store these as 32-bit registers and so must add 4 to indexes
|
||||
* above 28.
|
||||
*/
|
||||
#define DES_PC2( x ) ( (x) + ( ( (x) > 28 ) ? 4 : 0 ) )
|
||||
|
||||
/**
|
||||
* Define six bits of permuted choice 2 (PC2)
|
||||
*
|
||||
* @v r1:r0 Bits corresponding to S-box row index
|
||||
* @v c3:c0 Bits corresponding to S-box column index
|
||||
*
|
||||
* There are 8 steps within a DES round (one step per S-box). Each
|
||||
* step requires six bits of the round key, corresponding to the S-box
|
||||
* input value {r1,c3,c2,c1,c0,r0}, where {r1,r0} is the table row
|
||||
* index and {c3,c2,c1,c0} is the table column index.
|
||||
*
|
||||
* As an optimisation, we store the least significant of the 6 bits in
|
||||
* the sign bit of a signed 8-bit value, and the remaining 5 bits in
|
||||
* the least significant 5 bits of the 8-bit value. See the comments
|
||||
* in des_sbox() for further details.
|
||||
*/
|
||||
#define DES_PC2R( r1, c3, c2, c1, c0, r0 ) \
|
||||
DES_PC2 ( r0 ), /* LSB stored in sign bit */ \
|
||||
DES_PC2 ( r0 ), /* Unused bit */ \
|
||||
DES_PC2 ( r0 ), /* Unused bit */ \
|
||||
DES_PC2 ( r1 ), /* Remaining 5 bits */ \
|
||||
DES_PC2 ( c3 ), /* ... */ \
|
||||
DES_PC2 ( c2 ), /* ... */ \
|
||||
DES_PC2 ( c1 ), /* ... */ \
|
||||
DES_PC2 ( c0 ) /* ... */
|
||||
|
||||
/**
|
||||
* A DES systematic permutation generator
|
||||
*
|
||||
* Many of the permutations used in DES comprise systematic bit
|
||||
* patterns. We generate these permutations at runtime to save on
|
||||
* code size.
|
||||
*/
|
||||
struct des_generator {
|
||||
/** Permutation */
|
||||
uint8_t *permutation;
|
||||
/** Seed value */
|
||||
uint32_t seed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Define a DES permutation generator
|
||||
*
|
||||
* @v PERMUTATION Permutation
|
||||
* @v OFFSET Fixed input bit offset (0 or 1)
|
||||
* @v INV<n> Input bit index bit <n> should be inverted
|
||||
* @v BIT<n> Source bit for input bit index bit <n>
|
||||
* @ret generator Permutation generator
|
||||
*/
|
||||
#define DES_GENERATOR( PERMUTATION, OFFSET, INV5, BIT5, INV4, BIT4, \
|
||||
INV3, BIT3, INV2, BIT2, INV1, BIT1, INV0, BIT0 ) \
|
||||
{ \
|
||||
.permutation = (PERMUTATION), \
|
||||
.seed = ( ( (INV0) << 31 ) | ( (BIT0) << 28 ) | \
|
||||
( (INV1) << 27 ) | ( (BIT1) << 24 ) | \
|
||||
( (INV2) << 23 ) | ( (BIT2) << 20 ) | \
|
||||
( (INV3) << 19 ) | ( (BIT3) << 16 ) | \
|
||||
( (INV4) << 15 ) | ( (BIT4) << 12 ) | \
|
||||
( (INV5) << 11 ) | ( (BIT5) << 8 ) | \
|
||||
( ( uint32_t ) sizeof (PERMUTATION) - 1 ) | \
|
||||
(OFFSET) ), \
|
||||
}
|
||||
|
||||
/** DES permuted choice 1 (PC1) "C" register */
|
||||
static uint8_t des_pc1c[29];
|
||||
|
||||
/** DES permuted choice 1 (PC1) "D" register */
|
||||
static uint8_t des_pc1d[33];
|
||||
|
||||
/** DES permuted choice 2 (PC2) */
|
||||
static const uint8_t des_pc2[65] = {
|
||||
DES_PC2R ( 14, 17, 11, 24, 1, 5 ),
|
||||
DES_PC2R ( 3, 28, 15, 6, 21, 10 ),
|
||||
DES_PC2R ( 23, 19, 12, 4, 26, 8 ),
|
||||
DES_PC2R ( 16, 7, 27, 20, 13, 2 ),
|
||||
DES_PC2R ( 41, 52, 31, 37, 47, 55 ),
|
||||
DES_PC2R ( 30, 40, 51, 45, 33, 48 ),
|
||||
DES_PC2R ( 44, 49, 39, 56, 34, 53 ),
|
||||
DES_PC2R ( 46, 42, 50, 36, 29, 32 ),
|
||||
0 /* terminator */
|
||||
};
|
||||
|
||||
/** DES initial permutation (IP) */
|
||||
static uint8_t des_ip[65];
|
||||
|
||||
/** DES data permutation (P) */
|
||||
static const uint8_t des_p[33] = {
|
||||
16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
|
||||
2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25,
|
||||
0 /* terminator */
|
||||
};
|
||||
|
||||
/** DES final / inverse initial permutation (FP / IP^-1) */
|
||||
static uint8_t des_fp[65];
|
||||
|
||||
/** DES permutation generators */
|
||||
static struct des_generator des_generators[] = {
|
||||
|
||||
/* The DES initial permutation transforms the bit index
|
||||
* {x5,x4,x3,x2,x1,x0}+1 into {~x2,~x1,~x0,x4,x3,~x5}+1
|
||||
*/
|
||||
DES_GENERATOR ( des_ip, 1, 1, 2, 1, 1, 1, 0, 0, 4, 0, 3, 1, 5 ),
|
||||
|
||||
/* The DES final permutation transforms the bit index
|
||||
* {x5,x4,x3,x2,x1,x0}+1 into {~x0,x2,x1,~x5,~x4,~x3}+1
|
||||
*
|
||||
* There is an asymmetry in the DES block diagram for the last
|
||||
* of the 16 rounds, which is functionally equivalent to
|
||||
* performing 16 identical rounds and then swapping the left
|
||||
* and right halves before applying the final permutation. We
|
||||
* may therefore account for this asymmetry by inverting the
|
||||
* MSB in each bit index, to point to the corresponding bit in
|
||||
* the other half.
|
||||
*
|
||||
* This is equivalent to using a permutation that transforms
|
||||
* {x5,x4,x3,x2,x1,x0}+1 into {x0,x2,x1,~x5,~x4,~x3}+1
|
||||
*/
|
||||
DES_GENERATOR ( des_fp, 1, 0, 0, 0, 2, 0, 1, 1, 5, 1, 4, 1, 3 ),
|
||||
|
||||
/* The "C" half of DES permuted choice 1 (PC1) transforms the
|
||||
* bit index {x5,x4,x3,x2,x1,x0}+1 into {~x2,~x1,~x0,x5,x4,x3}+1
|
||||
*/
|
||||
DES_GENERATOR ( des_pc1c, 1, 1, 2, 1, 1, 1, 0, 0, 5, 0, 4, 0, 3 ),
|
||||
|
||||
/* The "D" half of DES permuted choice 1 (PC1) transforms the
|
||||
* bit index {x5,x4,x3,x2,x1,x0}+1 into {~x2,~x1,~x0,~x5,~x4,~x3}+0
|
||||
*
|
||||
* Due to the idosyncratic design choice of using 28-bit
|
||||
* registers in the DES key expansion schedule, the final four
|
||||
* permutation values appear at indices [28:31] instead of
|
||||
* [24:27]. This is adjusted for in @c des_setkey().
|
||||
*/
|
||||
DES_GENERATOR ( des_pc1d, 0, 1, 2, 1, 1, 1, 0, 1, 5, 1, 4, 1, 3 ),
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate DES permutation
|
||||
*
|
||||
* @v generator Generator
|
||||
*/
|
||||
static __attribute__ (( noinline )) void
|
||||
des_generate ( struct des_generator *generator ) {
|
||||
uint8_t *permutation = generator->permutation;
|
||||
uint32_t seed = generator->seed;
|
||||
unsigned int index = 0;
|
||||
uint8_t accum;
|
||||
uint8_t bit;
|
||||
|
||||
/* Generate permutations
|
||||
*
|
||||
* This loop is optimised for code size on a
|
||||
* register-constrained architecture such as i386.
|
||||
*/
|
||||
do {
|
||||
/* Rotate seed to access MSB's bit descriptor */
|
||||
seed = ror32 ( seed, 8 );
|
||||
|
||||
/* Initialise accumulator with six flag bits */
|
||||
accum = 0xfc;
|
||||
|
||||
/* Accumulate bits until all six flag bits are cleared */
|
||||
do {
|
||||
/* Extract specified bit from index. Use a
|
||||
* rotation instead of a shift, since this
|
||||
* will allow the mask to be elided.
|
||||
*/
|
||||
bit = ror8 ( index, ( seed & 0x07 ) );
|
||||
seed = ror32 ( seed, 3 );
|
||||
|
||||
/* Toggle bit if applicable */
|
||||
bit ^= seed;
|
||||
seed = ror32 ( seed, 1 );
|
||||
|
||||
/* Add bit to accumulator and clear one flag bit */
|
||||
accum <<= 1;
|
||||
accum |= ( bit & 0x01 );
|
||||
|
||||
} while ( accum & 0x80 );
|
||||
|
||||
/* Add constant offset if applicable */
|
||||
accum += ( seed & 0x01 );
|
||||
|
||||
/* Store permutation */
|
||||
permutation[index] = accum;
|
||||
|
||||
/* Loop until reaching length (which is always even) */
|
||||
} while ( ++index < ( seed & 0xfe ) );
|
||||
DBGC2 ( permutation, "DES generated permutation %p:\n", permutation );
|
||||
DBGC2_HDA ( permutation, 0, permutation,
|
||||
( ( seed & 0xfe ) + 1 /* zero terminator */ ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise permutations
|
||||
*/
|
||||
static void des_init ( void ) {
|
||||
unsigned int i;
|
||||
|
||||
/* Generate all generated permutations */
|
||||
for ( i = 0 ; i < ( sizeof ( des_generators ) /
|
||||
sizeof ( des_generators[0] ) ) ; i++ ) {
|
||||
des_generate ( &des_generators[i] );
|
||||
}
|
||||
}
|
||||
|
||||
/** Initialisation function */
|
||||
struct init_fn des_init_fn __init_fn ( INIT_NORMAL ) = {
|
||||
.initialise = des_init,
|
||||
};
|
||||
|
||||
/**
|
||||
* Perform bit permutation
|
||||
*
|
||||
* @v permutation Bit permutation (zero-terminated)
|
||||
* @v in Input value
|
||||
* @v out Output value
|
||||
*/
|
||||
static void des_permute ( const uint8_t *permutation, const uint8_t *in,
|
||||
uint8_t *out ) {
|
||||
uint8_t mask = 0x80;
|
||||
uint8_t accum = 0;
|
||||
unsigned int bit;
|
||||
|
||||
/* Extract individual input bits to construct output value */
|
||||
while ( ( bit = *(permutation++) ) ) {
|
||||
bit--;
|
||||
if ( in[ bit / 8 ] & ( 0x80 >> ( bit % 8 ) ) )
|
||||
accum |= mask;
|
||||
*out = accum;
|
||||
mask = ror8 ( mask, 1 );
|
||||
if ( mask == 0x80 ) {
|
||||
out++;
|
||||
accum = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform DES S-box substitution
|
||||
*
|
||||
* @v in 32-bit input value (native endian)
|
||||
* @v rkey 48-bit round key
|
||||
* @ret out 32-bit output value (native endian)
|
||||
*/
|
||||
static uint32_t des_sbox ( uint32_t in, const union des_round_key *rkey ) {
|
||||
uint32_t out = 0;
|
||||
uint32_t lookup;
|
||||
int32_t key;
|
||||
uint8_t sub;
|
||||
unsigned int i;
|
||||
|
||||
/* Perform input expansion, key addition, and S-box substitution */
|
||||
for ( i = 0 ; i < 8 ; i++ ) {
|
||||
|
||||
/* Rotate input and output */
|
||||
out = rol32 ( out, 4 );
|
||||
in = rol32 ( in, 4 );
|
||||
|
||||
/* Extract step key from relevant 6 bits of round key
|
||||
*
|
||||
* The least significant of the 6 bits (corresponding
|
||||
* to bit r0 in the S-box lookup index) is stored in
|
||||
* the sign bit of the step key byte. It will
|
||||
* therefore be propagated via sign extension to the
|
||||
* MSB of the 32-bit step key.
|
||||
*
|
||||
* The remaining 5 of the 6 bits (corresponding to
|
||||
* bits {r1,c3,c2,c1,c0} in the S-box lookup index)
|
||||
* are stored in the least significant 5 bits of the
|
||||
* step key byte and will end up in the least
|
||||
* significant 5 bits of the 32-bit step key.
|
||||
*/
|
||||
key = rkey->step[i];
|
||||
|
||||
/* Add step key to input to produce S-box lookup index
|
||||
*
|
||||
* We do not ever perform an explicit expansion of the
|
||||
* input value from 32 to 48 bits. Instead, we rotate
|
||||
* the 32-bit input value by 4 bits on each step, and
|
||||
* extract the relevant 6 bits.
|
||||
*
|
||||
* The least significant of the 6 bits (corresponding
|
||||
* to bit r0 in the S-box lookup index) is currently
|
||||
* in the MSB of the 32-bit (rotated) input value.
|
||||
*
|
||||
* The remaining 5 of the 6 bits (corresponding to
|
||||
* bits {r1,c3,c2,c1,c0} in the S-box lookup index)
|
||||
* are currently in the least significant 5 bits of
|
||||
* the 32-bit (rotated) input value.
|
||||
*
|
||||
* This aligns with the placement of the bits in the
|
||||
* step key (see above), and we can therefore perform
|
||||
* a single XOR to add the 6-bit step key to the
|
||||
* relevant 6 bits of the input value.
|
||||
*/
|
||||
lookup = ( in ^ key );
|
||||
|
||||
/* Look up S[i][in ^ key] from S-box
|
||||
*
|
||||
* We have bits {r1,c3,c2,c1,c0} in the least
|
||||
* significant 5 bits of the lookup index, and so can
|
||||
* use the masked lookup index directly as a byte
|
||||
* index into the relevant S-box to extract the byte
|
||||
* containing both {r1,c3,c2,c1,c0,'0'} and
|
||||
* {r1,c3,c2,c1,c0,'1'}.
|
||||
*
|
||||
* We then use the MSB of the 32-bit lookup index to
|
||||
* extract the relevant nibble for the full lookup
|
||||
* index {r1,c3,c2,c1,c0,r0}.
|
||||
*/
|
||||
sub = des_s[i][ lookup & 0x1f ];
|
||||
sub >>= ( ( lookup >> 29 ) & 4 );
|
||||
sub &= 0x0f;
|
||||
|
||||
/* Substitute S[i][input ^ key] into output */
|
||||
out |= sub;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a single DES round
|
||||
*
|
||||
* @v block DES block
|
||||
* @v rkey 48-bit round key
|
||||
*/
|
||||
static void des_round ( union des_block *block,
|
||||
const union des_round_key *rkey ) {
|
||||
union des_dword sbox;
|
||||
uint32_t left;
|
||||
uint32_t right;
|
||||
|
||||
/* Extract left and right halves L[n-1] and R[n-1] */
|
||||
left = block->left.dword;
|
||||
right = block->right.dword;
|
||||
DBGC2 ( block, "DES L=%08x R=%08x K=%08x%08x", be32_to_cpu ( left ),
|
||||
be32_to_cpu ( right ), be32_to_cpu ( rkey->dword[0] ),
|
||||
be32_to_cpu ( rkey->dword[1] ) );
|
||||
|
||||
/* L[n] = R[n-1] */
|
||||
block->left.dword = right;
|
||||
|
||||
/* Calculate Feistel function f(R[n-1], K[n]) */
|
||||
sbox.dword = cpu_to_be32 ( des_sbox ( be32_to_cpu ( right ), rkey ) );
|
||||
des_permute ( des_p, sbox.byte, block->right.byte );
|
||||
|
||||
/* R[n] = L[n-1] + f(R[n-1], K[n]) */
|
||||
block->right.dword ^= left;
|
||||
DBGC2 ( block, " => L=%08x R=%08x\n",
|
||||
be32_to_cpu ( block->left.dword ),
|
||||
be32_to_cpu ( block->right.dword ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform all DES rounds
|
||||
*
|
||||
* @v in Input DES block
|
||||
* @v out Output DES block
|
||||
* @v rkey Starting 48-bit round key
|
||||
* @v offset Byte offset between round keys
|
||||
*/
|
||||
static void des_rounds ( const union des_block *in, union des_block *out,
|
||||
const union des_round_key *rkey,
|
||||
ssize_t offset ) {
|
||||
union des_block tmp;
|
||||
unsigned int i;
|
||||
|
||||
/* Apply initial permutation */
|
||||
des_permute ( des_ip, in->byte, tmp.byte );
|
||||
|
||||
/* Perform all DES rounds, consuming keys in the specified order */
|
||||
for ( i = 0 ; i < DES_ROUNDS ; i++ ) {
|
||||
des_round ( &tmp, rkey );
|
||||
rkey = ( ( ( void * ) rkey ) + offset );
|
||||
}
|
||||
|
||||
/* Apply final permutation */
|
||||
DBGC ( &tmp, "DES %scrypted %08x%08x => ",
|
||||
( ( offset > 0 ) ? "en" : "de" ), be32_to_cpu ( in->dword[0] ),
|
||||
be32_to_cpu ( in->dword[1] ) );
|
||||
des_permute ( des_fp, tmp.byte, out->byte );
|
||||
DBGC ( &tmp, "%08x%08x\n", be32_to_cpu ( out->dword[0] ),
|
||||
be32_to_cpu ( out->dword[1] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate 28-bit word
|
||||
*
|
||||
* @v dword 28-bit dword value
|
||||
* @ret dword Rotated 28-bit dword value
|
||||
*/
|
||||
static uint32_t des_rol28 ( uint32_t dword ) {
|
||||
int32_t sdword;
|
||||
|
||||
/* Convert to native-endian */
|
||||
sdword = be32_to_cpu ( dword );
|
||||
|
||||
/* Signed shift right by 4 places to copy bit 31 to bits 27:31 */
|
||||
sdword >>= 4;
|
||||
|
||||
/* Rotate left */
|
||||
sdword = rol32 ( sdword, 1 );
|
||||
|
||||
/* Shift left by 4 places to restore bit positions */
|
||||
sdword <<= 4;
|
||||
|
||||
/* Convert back to big-endian */
|
||||
dword = cpu_to_be32 ( sdword );
|
||||
|
||||
return dword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set key
|
||||
*
|
||||
* @v ctx Context
|
||||
* @v key Key
|
||||
* @v keylen Key length
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int des_setkey ( void *ctx, const void *key, size_t keylen ) {
|
||||
struct des_context *des = ctx;
|
||||
union des_round_key *rkey = des->rkey;
|
||||
union des_block reg;
|
||||
uint32_t schedule;
|
||||
|
||||
/* Validate key length */
|
||||
if ( keylen != DES_BLOCKSIZE )
|
||||
return -EINVAL;
|
||||
DBGC ( des, "DES %p new key:\n", des );
|
||||
DBGC_HDA ( des, 0, key, keylen );
|
||||
|
||||
/* Apply permuted choice 1 */
|
||||
des_permute ( des_pc1c, key, reg.c.byte );
|
||||
des_permute ( des_pc1d, key, reg.d.byte );
|
||||
reg.d.byte[3] <<= 4; /* see comment for @c des_pc1d */
|
||||
DBGC2 ( des, "DES %p C[ 0]=%07x D[ 0]=%07x\n",
|
||||
des, ( be32_to_cpu ( reg.c.dword ) >> 4 ),
|
||||
( be32_to_cpu ( reg.d.dword ) >> 4 ) );
|
||||
|
||||
/* Generate round keys */
|
||||
for ( schedule = DES_SCHEDULE ; schedule ; schedule >>= 1 ) {
|
||||
|
||||
/* Shift 28-bit words */
|
||||
reg.c.dword = des_rol28 ( reg.c.dword );
|
||||
reg.d.dword = des_rol28 ( reg.d.dword );
|
||||
|
||||
/* Skip rounds according to shift schedule */
|
||||
if ( ! ( schedule & 1 ) )
|
||||
continue;
|
||||
|
||||
/* Apply permuted choice 2 */
|
||||
des_permute ( des_pc2, reg.byte, rkey->byte );
|
||||
DBGC2 ( des, "DES %p C[%2zd]=%07x D[%2zd]=%07x K[%2zd]="
|
||||
"%08x%08x\n", des, ( ( rkey - des->rkey ) + 1 ),
|
||||
( be32_to_cpu ( reg.c.dword ) >> 4 ),
|
||||
( ( rkey - des->rkey ) + 1 ),
|
||||
( be32_to_cpu ( reg.d.dword ) >> 4 ),
|
||||
( ( rkey - des->rkey ) + 1 ),
|
||||
be32_to_cpu ( rkey->dword[0] ),
|
||||
be32_to_cpu ( rkey->dword[1] ) );
|
||||
|
||||
/* Move to next key */
|
||||
rkey++;
|
||||
}
|
||||
|
||||
/* Sanity check */
|
||||
assert ( rkey == &des->rkey[DES_ROUNDS] );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt data
|
||||
*
|
||||
* @v ctx Context
|
||||
* @v src Data to encrypt
|
||||
* @v dst Buffer for encrypted data
|
||||
* @v len Length of data
|
||||
*/
|
||||
static void des_encrypt ( void *ctx, const void *src, void *dst, size_t len ) {
|
||||
struct des_context *des = ctx;
|
||||
|
||||
/* Sanity check */
|
||||
assert ( len == DES_BLOCKSIZE );
|
||||
|
||||
/* Cipher using keys in forward direction */
|
||||
des_rounds ( src, dst, &des->rkey[0], sizeof ( des->rkey[0] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt data
|
||||
*
|
||||
* @v ctx Context
|
||||
* @v src Data to decrypt
|
||||
* @v dst Buffer for decrypted data
|
||||
* @v len Length of data
|
||||
*/
|
||||
static void des_decrypt ( void *ctx, const void *src, void *dst, size_t len ) {
|
||||
struct des_context *des = ctx;
|
||||
|
||||
/* Sanity check */
|
||||
assert ( len == DES_BLOCKSIZE );
|
||||
|
||||
/* Cipher using keys in reverse direction */
|
||||
des_rounds ( src, dst, &des->rkey[ DES_ROUNDS - 1 ],
|
||||
-sizeof ( des->rkey[0] ) );
|
||||
}
|
||||
|
||||
/** Basic DES algorithm */
|
||||
struct cipher_algorithm des_algorithm = {
|
||||
.name = "des",
|
||||
.ctxsize = sizeof ( struct des_context ),
|
||||
.blocksize = DES_BLOCKSIZE,
|
||||
.alignsize = 0,
|
||||
.authsize = 0,
|
||||
.setkey = des_setkey,
|
||||
.setiv = cipher_null_setiv,
|
||||
.encrypt = des_encrypt,
|
||||
.decrypt = des_decrypt,
|
||||
.auth = cipher_null_auth,
|
||||
};
|
||||
|
||||
/* DES in Electronic Codebook mode */
|
||||
ECB_CIPHER ( des_ecb, des_ecb_algorithm,
|
||||
des_algorithm, struct des_context, DES_BLOCKSIZE );
|
||||
|
||||
/* DES in Cipher Block Chaining mode */
|
||||
CBC_CIPHER ( des_cbc, des_cbc_algorithm,
|
||||
des_algorithm, struct des_context, DES_BLOCKSIZE );
|
||||
@ -469,13 +469,15 @@ int gcm_setkey ( struct gcm_context *context, const void *key, size_t keylen,
|
||||
* @v ivlen Initialisation vector length
|
||||
*/
|
||||
void gcm_setiv ( struct gcm_context *context, const void *iv, size_t ivlen ) {
|
||||
union gcm_block *check = ( ( void * ) context );
|
||||
|
||||
/* Sanity checks */
|
||||
linker_assert ( &context->hash == check, gcm_bad_layout );
|
||||
linker_assert ( &context->len == check + 1, gcm_bad_layout );
|
||||
linker_assert ( &context->ctr == check + 2, gcm_bad_layout );
|
||||
linker_assert ( &context->key == check + 3, gcm_bad_layout );
|
||||
/* Sanity check: ensure that memset()s will clear expected state */
|
||||
build_assert ( &context->hash < &context->ctr );
|
||||
build_assert ( &context->len < &context->ctr );
|
||||
build_assert ( &context->ctr < &context->key );
|
||||
build_assert ( ( ( void * ) &context->raw_cipher ) >
|
||||
( ( void * ) &context->key ) );
|
||||
build_assert ( ( ( void * ) context->raw_ctx ) >
|
||||
( ( void * ) &context->key ) );
|
||||
|
||||
/* Reset non-key state */
|
||||
memset ( context, 0, offsetof ( typeof ( *context ), key ) );
|
||||
|
||||
@ -155,11 +155,11 @@ static void md4_digest ( struct md4_context *context ) {
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( ( context->len % sizeof ( context->ddd.dd.data ) ) == 0 );
|
||||
linker_assert ( &u.ddd.dd.digest.h[0] == a, md4_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[1] == b, md4_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[2] == c, md4_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[3] == d, md4_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.data.dword[0] == w, md4_bad_layout );
|
||||
build_assert ( &u.ddd.dd.digest.h[0] == a );
|
||||
build_assert ( &u.ddd.dd.digest.h[1] == b );
|
||||
build_assert ( &u.ddd.dd.digest.h[2] == c );
|
||||
build_assert ( &u.ddd.dd.digest.h[3] == d );
|
||||
build_assert ( &u.ddd.dd.data.dword[0] == w );
|
||||
|
||||
DBGC ( context, "MD4 digesting:\n" );
|
||||
DBGC_HDA ( context, 0, &context->ddd.dd.digest,
|
||||
|
||||
@ -178,11 +178,11 @@ static void md5_digest ( struct md5_context *context ) {
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( ( context->len % sizeof ( context->ddd.dd.data ) ) == 0 );
|
||||
linker_assert ( &u.ddd.dd.digest.h[0] == a, md5_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[1] == b, md5_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[2] == c, md5_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[3] == d, md5_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.data.dword[0] == w, md5_bad_layout );
|
||||
build_assert ( &u.ddd.dd.digest.h[0] == a );
|
||||
build_assert ( &u.ddd.dd.digest.h[1] == b );
|
||||
build_assert ( &u.ddd.dd.digest.h[2] == c );
|
||||
build_assert ( &u.ddd.dd.digest.h[3] == d );
|
||||
build_assert ( &u.ddd.dd.data.dword[0] == w );
|
||||
|
||||
DBGC ( context, "MD5 digesting:\n" );
|
||||
DBGC_HDA ( context, 0, &context->ddd.dd.digest,
|
||||
|
||||
61
src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c
Normal file
61
src/crypto/mishmash/dhe_rsa_aes_cbc_sha1.c
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha1.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 15 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_CBC_SHA ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_cbc_sha __tls_cipher_suite ( 16 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_CBC_SHA ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
60
src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c
Normal file
60
src/crypto/mishmash/dhe_rsa_aes_cbc_sha256.c
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 13 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA256_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_cbc_sha256 __tls_cipher_suite ( 14 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA256_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
45
src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c
Normal file
45
src/crypto/mishmash/dhe_rsa_aes_gcm_sha256.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_gcm_sha256 __tls_cipher_suite ( 11 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
45
src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c
Normal file
45
src/crypto/mishmash/dhe_rsa_aes_gcm_sha384.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_gcm_sha384 __tls_cipher_suite ( 12 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha384_algorithm,
|
||||
.handshake = &sha384_algorithm,
|
||||
};
|
||||
61
src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c
Normal file
61
src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha1.c
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha1.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 05 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_256_cbc_sha __tls_cipher_suite ( 06 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
45
src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c
Normal file
45
src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha256.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 03 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA256_DIGEST_SIZE,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
45
src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c
Normal file
45
src/crypto/mishmash/ecdhe_rsa_aes_cbc_sha384.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_256_cbc_sha384 __tls_cipher_suite ( 04 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA384_DIGEST_SIZE,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha384_algorithm,
|
||||
.handshake = &sha384_algorithm,
|
||||
};
|
||||
45
src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c
Normal file
45
src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha256.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_128_gcm_sha256 __tls_cipher_suite ( 01 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
45
src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c
Normal file
45
src/crypto/mishmash/ecdhe_rsa_aes_gcm_sha384.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_256_gcm_sha384 __tls_cipher_suite ( 02 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha384_algorithm,
|
||||
.handshake = &sha384_algorithm,
|
||||
};
|
||||
45
src/crypto/mishmash/oid_x25519.c
Normal file
45
src/crypto/mishmash/oid_x25519.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <ipxe/x25519.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** "x25519" object identifier */
|
||||
static uint8_t oid_x25519[] = { ASN1_OID_X25519 };
|
||||
|
||||
/** "x25519" OID-identified algorithm */
|
||||
struct asn1_algorithm x25519_algorithm __asn1_algorithm = {
|
||||
.name = "x25519",
|
||||
.curve = &x25519_curve,
|
||||
.oid = ASN1_CURSOR ( oid_x25519 ),
|
||||
};
|
||||
|
||||
/** X25519 named curve */
|
||||
struct tls_named_curve tls_x25519_named_curve __tls_named_curve ( 01 ) = {
|
||||
.curve = &x25519_curve,
|
||||
.code = htons ( TLS_NAMED_CURVE_X25519 ),
|
||||
};
|
||||
@ -30,39 +30,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 05 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_CBC_SHA ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_cbc_sha __tls_cipher_suite ( 06 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_CBC_SHA ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_RSA_WITH_AES_128_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 15 ) = {
|
||||
tls_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 25 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_128_CBC_SHA ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
@ -77,7 +47,7 @@ tls_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 15 ) = {
|
||||
|
||||
/** TLS_RSA_WITH_AES_256_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_256_cbc_sha __tls_cipher_suite ( 16 ) = {
|
||||
tls_rsa_with_aes_256_cbc_sha __tls_cipher_suite ( 26 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_256_CBC_SHA ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
|
||||
@ -29,39 +29,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 03 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA256_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_cbc_sha256 __tls_cipher_suite ( 04 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA256_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_RSA_WITH_AES_128_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 13 ) = {
|
||||
tls_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 23 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_128_CBC_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
@ -76,7 +46,7 @@ tls_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 13 ) = {
|
||||
|
||||
/** TLS_RSA_WITH_AES_256_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_256_cbc_sha256 __tls_cipher_suite ( 14 ) = {
|
||||
tls_rsa_with_aes_256_cbc_sha256 __tls_cipher_suite ( 24 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_256_CBC_SHA256 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
|
||||
@ -29,24 +29,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_gcm_sha256 __tls_cipher_suite ( 01 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_RSA_WITH_AES_128_GCM_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_128_gcm_sha256 __tls_cipher_suite ( 11 ) = {
|
||||
tls_rsa_with_aes_128_gcm_sha256 __tls_cipher_suite ( 21 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_128_GCM_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
|
||||
@ -29,24 +29,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_gcm_sha384 __tls_cipher_suite ( 02 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha384_algorithm,
|
||||
.handshake = &sha384_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_RSA_WITH_AES_256_GCM_SHA384 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_256_gcm_sha384 __tls_cipher_suite ( 12 ) = {
|
||||
tls_rsa_with_aes_256_gcm_sha384 __tls_cipher_suite ( 22 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_256_GCM_SHA384 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
|
||||
@ -145,12 +145,12 @@ static void sha1_digest ( struct sha1_context *context ) {
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( ( context->len % sizeof ( context->ddd.dd.data ) ) == 0 );
|
||||
linker_assert ( &u.ddd.dd.digest.h[0] == a, sha1_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[1] == b, sha1_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[2] == c, sha1_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[3] == d, sha1_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[4] == e, sha1_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.data.dword[0] == w, sha1_bad_layout );
|
||||
build_assert ( &u.ddd.dd.digest.h[0] == a );
|
||||
build_assert ( &u.ddd.dd.digest.h[1] == b );
|
||||
build_assert ( &u.ddd.dd.digest.h[2] == c );
|
||||
build_assert ( &u.ddd.dd.digest.h[3] == d );
|
||||
build_assert ( &u.ddd.dd.digest.h[4] == e );
|
||||
build_assert ( &u.ddd.dd.data.dword[0] == w );
|
||||
|
||||
DBGC ( context, "SHA1 digesting:\n" );
|
||||
DBGC_HDA ( context, 0, &context->ddd.dd.digest,
|
||||
|
||||
@ -140,15 +140,15 @@ static void sha256_digest ( struct sha256_context *context ) {
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( ( context->len % sizeof ( context->ddd.dd.data ) ) == 0 );
|
||||
linker_assert ( &u.ddd.dd.digest.h[0] == a, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[1] == b, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[2] == c, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[3] == d, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[4] == e, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[5] == f, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[6] == g, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[7] == h, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.data.dword[0] == w, sha256_bad_layout );
|
||||
build_assert ( &u.ddd.dd.digest.h[0] == a );
|
||||
build_assert ( &u.ddd.dd.digest.h[1] == b );
|
||||
build_assert ( &u.ddd.dd.digest.h[2] == c );
|
||||
build_assert ( &u.ddd.dd.digest.h[3] == d );
|
||||
build_assert ( &u.ddd.dd.digest.h[4] == e );
|
||||
build_assert ( &u.ddd.dd.digest.h[5] == f );
|
||||
build_assert ( &u.ddd.dd.digest.h[6] == g );
|
||||
build_assert ( &u.ddd.dd.digest.h[7] == h );
|
||||
build_assert ( &u.ddd.dd.data.dword[0] == w );
|
||||
|
||||
DBGC ( context, "SHA256 digesting:\n" );
|
||||
DBGC_HDA ( context, 0, &context->ddd.dd.digest,
|
||||
|
||||
@ -156,15 +156,15 @@ static void sha512_digest ( struct sha512_context *context ) {
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( ( context->len % sizeof ( context->ddq.dd.data ) ) == 0 );
|
||||
linker_assert ( &u.ddq.dd.digest.h[0] == a, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[1] == b, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[2] == c, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[3] == d, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[4] == e, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[5] == f, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[6] == g, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[7] == h, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.data.qword[0] == w, sha512_bad_layout );
|
||||
build_assert ( &u.ddq.dd.digest.h[0] == a );
|
||||
build_assert ( &u.ddq.dd.digest.h[1] == b );
|
||||
build_assert ( &u.ddq.dd.digest.h[2] == c );
|
||||
build_assert ( &u.ddq.dd.digest.h[3] == d );
|
||||
build_assert ( &u.ddq.dd.digest.h[4] == e );
|
||||
build_assert ( &u.ddq.dd.digest.h[5] == f );
|
||||
build_assert ( &u.ddq.dd.digest.h[6] == g );
|
||||
build_assert ( &u.ddq.dd.digest.h[7] == h );
|
||||
build_assert ( &u.ddq.dd.data.qword[0] == w );
|
||||
|
||||
DBGC ( context, "SHA512 digesting:\n" );
|
||||
DBGC_HDA ( context, 0, &context->ddq.dd.digest,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user