forked from wolfSSL/wolfssl
Merge branch 'master' of https://github.com/wolfSSL/wolfssl into RIOT_OS
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
<!DOCTYPE Board_Memory_Definition_File>
|
||||
<Root name="Kinetis">
|
||||
<MemorySegment size="0x80000" access="ReadOnly" start="0x00000000" name="FLASH" />
|
||||
<MemorySegment size="0x80000/2" access="Read/Write" start="0x00000000" name="FLASH_L" />
|
||||
<MemorySegment size="0x80000/2" access="Read/Write" start="0x00000000+0x80000/2" name="FLASH_H" />
|
||||
<MemorySegment size="0x20000" access="Read/Write" start="0x1fff0000" name="SRAM" />
|
||||
<MemorySegment size="0x10000" access="Read/Write" start="0x1fff0000" name="SRAM_L" />
|
||||
<MemorySegment size="0x10000" access="Read/Write" start="0x20000000" name="SRAM_H" />
|
||||
<MemorySegment size="0x100000" access="Read/Write" start="0x40000000" name="PERIPHERALS" />
|
||||
<MemorySegment size="0x100000" access="Read/Write" start="0xE0000000" name="PPB" />
|
||||
</Root>
|
@@ -27,12 +27,23 @@ Also the "Target Processor" in each of the projects ("Project Properties" -> "Ta
|
||||
|
||||
## Hardware Crypto Acceleration
|
||||
|
||||
To enable Freescale MMCAU:
|
||||
To enable NXP/Freescale MMCAU:
|
||||
|
||||
1. [Download the MMCAU library](http://www.freescale.com/products/arm-processors/kinetis-cortex-m/k-series/k7x-glcd-mcus/crypto-acceleration-unit-cau-and-mmcau-software-library:CAUAP).
|
||||
2. Copy the `lib_mmcau.a` and `cau_api.h` files into the project.
|
||||
3. Enable the `FREESCALE_MMCAU` define in `user_settings.h` and make sure its value is `1`.
|
||||
3. Define `USE_NXP_MMCAU` to enable in `user_settings.h`.
|
||||
4. Add the `lib_mmcau.a` file to `Source Files` in the application project.
|
||||
5. Open the wolfssl_ltc.hzp CrossWorks project
|
||||
6. Build and run
|
||||
|
||||
To enable the NXP/Freescale MMCAU and/or LTC:
|
||||
|
||||
1. [Download the NXP KSDK 2.0](https://nxp.flexnetoperations.com/control/frse/download?agree=Accept&element=7353807)
|
||||
2. Copy the following folders into IDE/ROWLEY-CROSSWORKS-ARM: drivers, mmcau_2.0.0 and CMSIS.
|
||||
3. Copy the following files into IDE/ROWLEY-CROSSWORKS-ARM: clock_config.c, clock_config.h, fsl_debug_console.c, fsl_debug_console.h, fsl_device_registers.h, system_MK82F25615.c, system_MK82F25615.h, MK82F25615.h and MK82F25615_features.h.
|
||||
4. Define `USE_NXP_LTX` to enable in `user_settings.h`.
|
||||
5. Open the wolfssl_ltc.hzp CrossWorks project
|
||||
6. Build and run
|
||||
|
||||
# Project Files
|
||||
|
||||
|
@@ -84,6 +84,8 @@ void reset_handler(void)
|
||||
// Vector Exception/Interrupt Handlers
|
||||
static void Default_Handler(void)
|
||||
{
|
||||
/* If we get here then need to implement real IRQ handler */
|
||||
while(1);
|
||||
}
|
||||
|
||||
void HardFault_HandlerC( uint32_t *hardfault_args )
|
||||
@@ -93,48 +95,48 @@ void HardFault_HandlerC( uint32_t *hardfault_args )
|
||||
values of the variables, make them global my moving their declaration outside
|
||||
of this function. */
|
||||
volatile uint32_t stacked_r0;
|
||||
volatile uint32_t stacked_r1;
|
||||
volatile uint32_t stacked_r2;
|
||||
volatile uint32_t stacked_r3;
|
||||
volatile uint32_t stacked_r12;
|
||||
volatile uint32_t stacked_lr;
|
||||
volatile uint32_t stacked_r1;
|
||||
volatile uint32_t stacked_r2;
|
||||
volatile uint32_t stacked_r3;
|
||||
volatile uint32_t stacked_r12;
|
||||
volatile uint32_t stacked_lr;
|
||||
volatile uint32_t stacked_pc;
|
||||
volatile uint32_t stacked_psr;
|
||||
volatile uint32_t _CFSR;
|
||||
volatile uint32_t _HFSR;
|
||||
volatile uint32_t _DFSR;
|
||||
volatile uint32_t _AFSR;
|
||||
volatile uint32_t _BFAR;
|
||||
volatile uint32_t _MMAR;
|
||||
volatile uint32_t stacked_psr;
|
||||
volatile uint32_t _CFSR;
|
||||
volatile uint32_t _HFSR;
|
||||
volatile uint32_t _DFSR;
|
||||
volatile uint32_t _AFSR;
|
||||
volatile uint32_t _BFAR;
|
||||
volatile uint32_t _MMAR;
|
||||
|
||||
stacked_r0 = ((uint32_t)hardfault_args[0]);
|
||||
stacked_r1 = ((uint32_t)hardfault_args[1]);
|
||||
stacked_r2 = ((uint32_t)hardfault_args[2]);
|
||||
stacked_r3 = ((uint32_t)hardfault_args[3]);
|
||||
stacked_r12 = ((uint32_t)hardfault_args[4]);
|
||||
stacked_lr = ((uint32_t)hardfault_args[5]);
|
||||
stacked_pc = ((uint32_t)hardfault_args[6]);
|
||||
stacked_psr = ((uint32_t)hardfault_args[7]);
|
||||
stacked_r0 = ((uint32_t)hardfault_args[0]);
|
||||
stacked_r1 = ((uint32_t)hardfault_args[1]);
|
||||
stacked_r2 = ((uint32_t)hardfault_args[2]);
|
||||
stacked_r3 = ((uint32_t)hardfault_args[3]);
|
||||
stacked_r12 = ((uint32_t)hardfault_args[4]);
|
||||
stacked_lr = ((uint32_t)hardfault_args[5]);
|
||||
stacked_pc = ((uint32_t)hardfault_args[6]);
|
||||
stacked_psr = ((uint32_t)hardfault_args[7]);
|
||||
|
||||
// Configurable Fault Status Register
|
||||
// Consists of MMSR, BFSR and UFSR
|
||||
_CFSR = (*((volatile uint32_t *)(0xE000ED28)));
|
||||
|
||||
// Hard Fault Status Register
|
||||
_HFSR = (*((volatile uint32_t *)(0xE000ED2C)));
|
||||
_CFSR = (*((volatile uint32_t *)(0xE000ED28)));
|
||||
|
||||
// Hard Fault Status Register
|
||||
_HFSR = (*((volatile uint32_t *)(0xE000ED2C)));
|
||||
|
||||
// Debug Fault Status Register
|
||||
_DFSR = (*((volatile uint32_t *)(0xE000ED30)));
|
||||
// Debug Fault Status Register
|
||||
_DFSR = (*((volatile uint32_t *)(0xE000ED30)));
|
||||
|
||||
// Auxiliary Fault Status Register
|
||||
_AFSR = (*((volatile uint32_t *)(0xE000ED3C)));
|
||||
// Auxiliary Fault Status Register
|
||||
_AFSR = (*((volatile uint32_t *)(0xE000ED3C)));
|
||||
|
||||
// Read the Fault Address Registers. These may not contain valid values.
|
||||
// Check BFARVALID/MMARVALID to see if they are valid values
|
||||
// MemManage Fault Address Register
|
||||
_MMAR = (*((volatile uint32_t *)(0xE000ED34)));
|
||||
// Bus Fault Address Register
|
||||
_BFAR = (*((volatile uint32_t *)(0xE000ED38)));
|
||||
// Read the Fault Address Registers. These may not contain valid values.
|
||||
// Check BFARVALID/MMARVALID to see if they are valid values
|
||||
// MemManage Fault Address Register
|
||||
_MMAR = (*((volatile uint32_t *)(0xE000ED34)));
|
||||
// Bus Fault Address Register
|
||||
_BFAR = (*((volatile uint32_t *)(0xE000ED38)));
|
||||
|
||||
printf ("\n\nHard fault handler (all numbers in hex):\n");
|
||||
printf ("R0 = %x\n", stacked_r0);
|
||||
@@ -195,5 +197,114 @@ const vector_entry vectors[] __attribute__ ((section(".vectors"),used)) =
|
||||
Default_Handler, // 0x0000_0038 14 - ARM core Pendable request for system service (PendableSrvReq)
|
||||
Default_Handler, // 0x0000_003C 15 - ARM core System tick timer (SysTick)
|
||||
|
||||
#ifdef CPU_MK82FN256VLL15
|
||||
// Add specific driver interrupt handlers below
|
||||
Default_Handler, /* DMA0_DMA16_IRQn = 0, /**< DMA channel 0,16 transfer complete */
|
||||
Default_Handler, /* DMA1_DMA17_IRQn = 1, /**< DMA channel 1,17 transfer complete */
|
||||
Default_Handler, /* DMA2_DMA18_IRQn = 2, /**< DMA channel 2,18 transfer complete */
|
||||
Default_Handler, /* DMA3_DMA19_IRQn = 3, /**< DMA channel 3,19 transfer complete */
|
||||
Default_Handler, /* DMA4_DMA20_IRQn = 4, /**< DMA channel 4,20 transfer complete */
|
||||
Default_Handler, /* DMA5_DMA21_IRQn = 5, /**< DMA channel 5,21 transfer complete */
|
||||
Default_Handler, /* DMA6_DMA22_IRQn = 6, /**< DMA channel 6,22 transfer complete */
|
||||
Default_Handler, /* DMA7_DMA23_IRQn = 7, /**< DMA channel 7,23 transfer complete */
|
||||
Default_Handler, /* DMA8_DMA24_IRQn = 8, /**< DMA channel 8,24 transfer complete */
|
||||
Default_Handler, /* DMA9_DMA25_IRQn = 9, /**< DMA channel 9,25 transfer complete */
|
||||
Default_Handler, /* DMA10_DMA26_IRQn = 10, /**< DMA channel 10,26 transfer complete */
|
||||
Default_Handler, /* DMA11_DMA27_IRQn = 11, /**< DMA channel 11,27 transfer complete */
|
||||
Default_Handler, /* DMA12_DMA28_IRQn = 12, /**< DMA channel 12,28 transfer complete */
|
||||
Default_Handler, /* DMA13_DMA29_IRQn = 13, /**< DMA channel 13,29 transfer complete */
|
||||
Default_Handler, /* DMA14_DMA30_IRQn = 14, /**< DMA channel 14,30 transfer complete */
|
||||
Default_Handler, /* DMA15_DMA31_IRQn = 15, /**< DMA channel 15,31 transfer complete */
|
||||
Default_Handler, /* DMA_Error_IRQn = 16, /**< DMA channel 0 - 31 error */
|
||||
Default_Handler, /* MCM_IRQn = 17, /**< MCM normal interrupt */
|
||||
Default_Handler, /* FTFA_IRQn = 18, /**< FTFA command complete */
|
||||
Default_Handler, /* Read_Collision_IRQn = 19, /**< FTFA read collision */
|
||||
Default_Handler, /* LVD_LVW_IRQn = 20, /**< PMC controller low-voltage detect, low-voltage warning */
|
||||
Default_Handler, /* LLWU_IRQn = 21, /**< Low leakage wakeup unit */
|
||||
Default_Handler, /* WDOG_EWM_IRQn = 22, /**< Single interrupt vector for WDOG and EWM */
|
||||
Default_Handler, /* TRNG0_IRQn = 23, /**< True randon number generator */
|
||||
Default_Handler, /* I2C0_IRQn = 24, /**< Inter-integrated circuit 0 */
|
||||
Default_Handler, /* I2C1_IRQn = 25, /**< Inter-integrated circuit 1 */
|
||||
Default_Handler, /* SPI0_IRQn = 26, /**< Serial peripheral Interface 0 */
|
||||
Default_Handler, /* SPI1_IRQn = 27, /**< Serial peripheral Interface 1 */
|
||||
Default_Handler, /* I2S0_Tx_IRQn = 28, /**< Integrated interchip sound 0 transmit interrupt */
|
||||
Default_Handler, /* I2S0_Rx_IRQn = 29, /**< Integrated interchip sound 0 receive interrupt */
|
||||
Default_Handler, /* LPUART0_IRQn = 30, /**< LPUART0 receive/transmit/error interrupt */
|
||||
Default_Handler, /* LPUART1_IRQn = 31, /**< LPUART1 receive/transmit/error interrupt */
|
||||
Default_Handler, /* LPUART2_IRQn = 32, /**< LPUART2 receive/transmit/error interrupt */
|
||||
Default_Handler, /* LPUART3_IRQn = 33, /**< LPUART3 receive/transmit/error interrupt */
|
||||
Default_Handler, /* LPUART4_IRQn = 34, /**< LPUART4 receive/transmit/error interrupt */
|
||||
Default_Handler, /* Reserved51_IRQn = 35, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved52_IRQn = 36, /**< Reserved interrupt */
|
||||
Default_Handler, /* EMVSIM0_IRQn = 37, /**< EMVSIM0 common interrupt */
|
||||
Default_Handler, /* EMVSIM1_IRQn = 38, /**< EMVSIM1 common interrupt */
|
||||
Default_Handler, /* ADC0_IRQn = 39, /**< Analog-to-digital converter 0 */
|
||||
Default_Handler, /* CMP0_IRQn = 40, /**< Comparator 0 */
|
||||
Default_Handler, /* CMP1_IRQn = 41, /**< Comparator 1 */
|
||||
Default_Handler, /* FTM0_IRQn = 42, /**< FlexTimer module 0 fault, overflow and channels interrupt */
|
||||
Default_Handler, /* FTM1_IRQn = 43, /**< FlexTimer module 1 fault, overflow and channels interrupt */
|
||||
Default_Handler, /* FTM2_IRQn = 44, /**< FlexTimer module 2 fault, overflow and channels interrupt */
|
||||
Default_Handler, /* CMT_IRQn = 45, /**< Carrier modulator transmitter */
|
||||
Default_Handler, /* RTC_IRQn = 46, /**< Real time clock */
|
||||
Default_Handler, /* RTC_Seconds_IRQn = 47, /**< Real time clock seconds */
|
||||
Default_Handler, /* PIT0CH0_IRQn = 48, /**< Periodic interrupt timer 0 channel 0 */
|
||||
Default_Handler, /* PIT0CH1_IRQn = 49, /**< Periodic interrupt timer 0 channel 1 */
|
||||
Default_Handler, /* PIT0CH2_IRQn = 50, /**< Periodic interrupt timer 0 channel 2 */
|
||||
Default_Handler, /* PIT0CH3_IRQn = 51, /**< Periodic interrupt timer 0 channel 3 */
|
||||
Default_Handler, /* PDB0_IRQn = 52, /**< Programmable delay block */
|
||||
Default_Handler, /* USB0_IRQn = 53, /**< USB OTG interrupt */
|
||||
Default_Handler, /* USBDCD_IRQn = 54, /**< USB charger detect */
|
||||
Default_Handler, /* Reserved71_IRQn = 55, /**< Reserved interrupt */
|
||||
Default_Handler, /* DAC0_IRQn = 56, /**< Digital-to-analog converter 0 */
|
||||
Default_Handler, /* MCG_IRQn = 57, /**< Multipurpose clock generator */
|
||||
Default_Handler, /* LPTMR0_LPTMR1_IRQn = 58, /**< Single interrupt vector for Low Power Timer 0 and 1 */
|
||||
Default_Handler, /* PORTA_IRQn = 59, /**< Port A pin detect interrupt */
|
||||
Default_Handler, /* PORTB_IRQn = 60, /**< Port B pin detect interrupt */
|
||||
Default_Handler, /* PORTC_IRQn = 61, /**< Port C pin detect interrupt */
|
||||
Default_Handler, /* PORTD_IRQn = 62, /**< Port D pin detect interrupt */
|
||||
Default_Handler, /* PORTE_IRQn = 63, /**< Port E pin detect interrupt */
|
||||
Default_Handler, /* SWI_IRQn = 64, /**< Software interrupt */
|
||||
Default_Handler, /* SPI2_IRQn = 65, /**< Serial peripheral Interface 2 */
|
||||
Default_Handler, /* Reserved82_IRQn = 66, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved83_IRQn = 67, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved84_IRQn = 68, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved85_IRQn = 69, /**< Reserved interrupt */
|
||||
Default_Handler, /* FLEXIO0_IRQn = 70, /**< FLEXIO0 */
|
||||
Default_Handler, /* FTM3_IRQn = 71, /**< FlexTimer module 3 fault, overflow and channels interrupt */
|
||||
Default_Handler, /* Reserved88_IRQn = 72, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved89_IRQn = 73, /**< Reserved interrupt */
|
||||
Default_Handler, /* I2C2_IRQn = 74, /**< Inter-integrated circuit 2 */
|
||||
Default_Handler, /* Reserved91_IRQn = 75, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved92_IRQn = 76, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved93_IRQn = 77, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved94_IRQn = 78, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved95_IRQn = 79, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved96_IRQn = 80, /**< Reserved interrupt */
|
||||
Default_Handler, /* SDHC_IRQn = 81, /**< Secured digital host controller */
|
||||
Default_Handler, /* Reserved98_IRQn = 82, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved99_IRQn = 83, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved100_IRQn = 84, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved101_IRQn = 85, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved102_IRQn = 86, /**< Reserved interrupt */
|
||||
Default_Handler, /* TSI0_IRQn = 87, /**< Touch Sensing Input */
|
||||
Default_Handler, /* TPM1_IRQn = 88, /**< TPM1 single interrupt vector for all sources */
|
||||
Default_Handler, /* TPM2_IRQn = 89, /**< TPM2 single interrupt vector for all sources */
|
||||
Default_Handler, /* Reserved106_IRQn = 90, /**< Reserved interrupt */
|
||||
Default_Handler, /* I2C3_IRQn = 91, /**< Inter-integrated circuit 3 */
|
||||
Default_Handler, /* Reserved108_IRQn = 92, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved109_IRQn = 93, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved110_IRQn = 94, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved111_IRQn = 95, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved112_IRQn = 96, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved113_IRQn = 97, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved114_IRQn = 98, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved115_IRQn = 99, /**< Reserved interrupt */
|
||||
Default_Handler, /* QuadSPI0_IRQn = 100, /**< qspi */
|
||||
Default_Handler, /* Reserved117_IRQn = 101, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved118_IRQn = 102, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved119_IRQn = 103, /**< Reserved interrupt */
|
||||
Default_Handler, /* LTC0_IRQn = 104, /**< LP Trusted Cryptography */
|
||||
Default_Handler, /* Reserved121_IRQn = 105, /**< Reserved interrupt */
|
||||
Default_Handler, /* Reserved122_IRQn = 106 /**< Reserved interrupt */
|
||||
#endif /* CPU_MK82FN256VLL15 */
|
||||
};
|
||||
|
@@ -54,7 +54,7 @@ void main(void)
|
||||
|
||||
/*
|
||||
SAMPLE OUTPUT: Freescale K64 running at 96MHz with no MMCAU:
|
||||
Benchmark Test 1:
|
||||
Benchmark Test 0:
|
||||
AES 25 kB took 0.073 seconds, 0.334 MB/s
|
||||
ARC4 25 kB took 0.033 seconds, 0.740 MB/s
|
||||
RABBIT 25 kB took 0.027 seconds, 0.904 MB/s
|
||||
@@ -66,10 +66,10 @@ RSA 1024 encryption took 91.000 milliseconds, avg over 1 iterations
|
||||
RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
|
||||
DH 1024 key generation 253.000 milliseconds, avg over 1 iterations
|
||||
DH 1024 key agreement 311.000 milliseconds, avg over 1 iterations
|
||||
Benchmark Test 1: Return code 0
|
||||
Benchmark Test 0: Return code 0
|
||||
|
||||
SAMPLE OUTPUT: Freescale K64 running at 96MHz with MMCAU enabled:
|
||||
Benchmark Test 1:
|
||||
Benchmark Test 0:
|
||||
AES 25 kB took 0.019 seconds, 1.285 MB/s
|
||||
ARC4 25 kB took 0.033 seconds, 0.740 MB/s
|
||||
RABBIT 25 kB took 0.028 seconds, 0.872 MB/s
|
||||
@@ -81,5 +81,74 @@ RSA 1024 encryption took 89.000 milliseconds, avg over 1 iterations
|
||||
RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
|
||||
DH 1024 key generation 250.000 milliseconds, avg over 1 iterations
|
||||
DH 1024 key agreement 308.000 milliseconds, avg over 1 iterations
|
||||
Benchmark Test 1: Return code 0
|
||||
Benchmark Test 0: Return code 0
|
||||
|
||||
|
||||
SAMPLE OUTPUT: NXP K82 running at 150Mhz w/MMCAU and LTC
|
||||
Benchmark Test 0:
|
||||
RNG 25 kB took 0.026 seconds, 0.939 MB/s
|
||||
AES enc 25 kB took 0.002 seconds, 12.207 MB/s
|
||||
AES dec 25 kB took 0.002 seconds, 12.207 MB/s
|
||||
AES-GCM 25 kB took 0.002 seconds, 12.207 MB/s
|
||||
AES-CTR 25 kB took 0.003 seconds, 8.138 MB/s
|
||||
AES-CCM 25 kB took 0.004 seconds, 6.104 MB/s
|
||||
CHACHA 25 kB took 0.008 seconds, 3.052 MB/s
|
||||
CHA-POLY 25 kB took 0.013 seconds, 1.878 MB/s
|
||||
|
||||
POLY1305 25 kB took 0.003 seconds, 8.138 MB/s
|
||||
SHA 25 kB took 0.006 seconds, 4.069 MB/s
|
||||
SHA-256 25 kB took 0.009 seconds, 2.713 MB/s
|
||||
SHA-384 25 kB took 0.032 seconds, 0.763 MB/s
|
||||
SHA-512 25 kB took 0.035 seconds, 0.698 MB/s
|
||||
|
||||
RSA 2048 public 12.000 milliseconds, avg over 1 iterations
|
||||
RSA 2048 private 135.000 milliseconds, avg over 1 iterations
|
||||
|
||||
ECC 256 key generation 17.400 milliseconds, avg over 5 iterations
|
||||
EC-DHE key agreement 15.200 milliseconds, avg over 5 iterations
|
||||
EC-DSA sign time 20.200 milliseconds, avg over 5 iterations
|
||||
EC-DSA verify time 33.000 milliseconds, avg over 5 iterations
|
||||
|
||||
CURVE25519 256 key generation 14.400 milliseconds, avg over 5 iterations
|
||||
CURVE25519 key agreement 14.400 milliseconds, avg over 5 iterations
|
||||
|
||||
ED25519 key generation 14.800 milliseconds, avg over 5 iterations
|
||||
ED25519 sign time 16.800 milliseconds, avg over 5 iterations
|
||||
ED25519 verify time 30.400 milliseconds, avg over 5 iterations
|
||||
Benchmark Test 0: Return code 0
|
||||
|
||||
SAMPLE OUTPUT: NXP K82 running at 150Mhz software only
|
||||
Benchmark Test 0:
|
||||
RNG 25 kB took 0.035 seconds, 0.698 MB/s
|
||||
AES enc 25 kB took 0.038 seconds, 0.642 MB/s
|
||||
AES dec 25 kB took 0.036 seconds, 0.678 MB/s
|
||||
AES-GCM 25 kB took 0.485 seconds, 0.050 MB/s
|
||||
AES-CTR 25 kB took 0.038 seconds, 0.642 MB/s
|
||||
AES-CCM 25 kB took 0.077 seconds, 0.317 MB/s
|
||||
CHACHA 25 kB took 0.009 seconds, 2.713 MB/s
|
||||
CHA-POLY 25 kB took 0.013 seconds, 1.878 MB/s
|
||||
|
||||
POLY1305 25 kB took 0.003 seconds, 8.138 MB/s
|
||||
SHA 25 kB took 0.006 seconds, 4.069 MB/s
|
||||
SHA-256 25 kB took 0.014 seconds, 1.744 MB/s
|
||||
SHA-384 25 kB took 0.032 seconds, 0.763 MB/s
|
||||
SHA-512 25 kB took 0.034 seconds, 0.718 MB/s
|
||||
|
||||
RSA 1024 encryption took 18.000 milliseconds, avg over 1 iterations
|
||||
RSA 1024 decryption took 123.000 milliseconds, avg over 1 iterations
|
||||
RSA 2048 encryption took 63.000 milliseconds, avg over 1 iterations
|
||||
RSA 2048 decryption took 1011.000 milliseconds, avg over 1 iterations
|
||||
|
||||
ECC 256 key generation 180.800 milliseconds, avg over 5 iterations
|
||||
EC-DHE key agreement 178.600 milliseconds, avg over 5 iterations
|
||||
EC-DSA sign time 184.600 milliseconds, avg over 5 iterations
|
||||
EC-DSA verify time 130.200 milliseconds, avg over 5 iterations
|
||||
|
||||
CURVE25519 256 key generation 41.800 milliseconds, avg over 5 iterations
|
||||
CURVE25519 key agreement 41.600 milliseconds, avg over 5 iterations
|
||||
|
||||
ED25519 key generation 14.800 milliseconds, avg over 5 iterations
|
||||
ED25519 sign time 16.600 milliseconds, avg over 5 iterations
|
||||
ED25519 verify time 48.000 milliseconds, avg over 5 iterations
|
||||
Benchmark Test 0: Return code 0
|
||||
*/
|
||||
|
@@ -6,10 +6,10 @@ EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/arm_startup.c
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/benchmark_main.c
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/hw.h
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/kinetis_hw.c
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/Kinetis_MemoryMap.xml
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/Kinetis_FlashPlacement.xml
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/README.md
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/test_main.c
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/retarget.c
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/wolfssl.hzp
|
||||
EXTRA_DIST+= IDE/ROWLEY-CROSSWORKS-ARM/wolfssl_ltc.hzp
|
||||
|
@@ -21,10 +21,10 @@
|
||||
|
||||
|
||||
#include "hw.h"
|
||||
#include "user_settings.h"
|
||||
|
||||
#if defined(FREESCALE) && defined(K_SERIES)
|
||||
|
||||
|
||||
/**********************************************
|
||||
* NOTE: Customize for actual hardware
|
||||
**********************************************/
|
||||
@@ -33,27 +33,53 @@
|
||||
// $(TargetsDir) location:
|
||||
// On Mac OS/X: Users/USERNAME/Library/Rowley Associates Limited/CrossWorks for ARM/packages/targets/
|
||||
// On Windows: C:/Users/USERNAME/Application Data/Local/Rowley Associates Limited/CrossWorks for ARM/packages/targets/
|
||||
#include <MK64F12.h> // Located in $(TargetsDir)/Kinetis/CMSIS/
|
||||
|
||||
// Located in $(TargetsDir)/Kinetis/CMSIS/
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_debug_console.h"
|
||||
#include "fsl_rtc.h"
|
||||
#include "fsl_trng.h"
|
||||
#include "fsl_lpuart.h"
|
||||
#include "fsl_port.h"
|
||||
#include "clock_config.h"
|
||||
#else
|
||||
#include <MK64F12.h> // Located in $(TargetsDir)/Kinetis/CMSIS/
|
||||
#endif
|
||||
|
||||
|
||||
// System clock
|
||||
#define SYS_CLK_KHZ 96000ul /* Core system clock in KHz */
|
||||
#define SYS_CLK_DRS MCG_C4_DRST_DRS(0x03) /* DRS 0=24MHz, 1=48MHz, 2=72MHz, 3=96MHz */
|
||||
#define SYS_CLK_DMX MCG_C4_DMX32_MASK /* 0=Disable DMX32 (lower actual speed), MCG_C4_DMX32_MASK=Enable DMX32 */
|
||||
#define SYS_CLK_DIV 1 /* System clock divisor */
|
||||
#define BUS_CLK_DIV 2 /* Bus clock divisor */
|
||||
#define BUS_CLK_KHZ (SYS_CLK_KHZ/BUS_CLK_DIV) /* Helper to calculate bus speed for UART */
|
||||
#define FLASH_CLK_DIV 4 /* Flash clock divisor */
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
#define SYS_CLK_HZ SystemCoreClock
|
||||
#else
|
||||
#define SYS_CLK_HZ 96000000ul /* Core system clock in Hz */
|
||||
#define SYS_CLK_DRS MCG_C4_DRST_DRS(0x03) /* DRS 0=24MHz, 1=48MHz, 2=72MHz, 3=96MHz */
|
||||
#define SYS_CLK_DMX MCG_C4_DMX32_MASK /* 0=Disable DMX32 (lower actual speed), MCG_C4_DMX32_MASK=Enable DMX32 */
|
||||
#define SYS_CLK_DIV 1 /* System clock divisor */
|
||||
#define BUS_CLK_DIV 2 /* Bus clock divisor */
|
||||
#define BUS_CLK_KHZ (SYS_CLK_HZ/BUS_CLK_DIV) /* Helper to calculate bus speed for UART */
|
||||
#define FLASH_CLK_DIV 4 /* Flash clock divisor */
|
||||
#endif
|
||||
|
||||
// UART TX Port, Pin, Mux and Baud
|
||||
#define UART_PORT UART4 /* UART Port */
|
||||
#define UART_TX_PORT PORTE /* UART TX Port */
|
||||
#define UART_TX_PIN 24 /* UART TX Pin */
|
||||
#define UART_TX_MUX 0x3 /* Kinetis UART pin mux */
|
||||
#define UART_BAUD 115200 /* UART Baud Rate */
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
#define UART_PORT LPUART0 /* UART Port */
|
||||
#define UART_TX_PORT PORTA /* UART TX Port */
|
||||
#define UART_TX_PIN 2U /* UART TX Pin */
|
||||
#define UART_TX_MUX kPORT_MuxAlt2 /* Kinetis UART pin mux */
|
||||
#else
|
||||
#define UART_PORT UART4 /* UART Port */
|
||||
#define UART_TX_PORT PORTE /* UART TX Port */
|
||||
#define UART_TX_PIN 24U /* UART TX Pin */
|
||||
#define UART_TX_MUX 0x3 /* Kinetis UART pin mux */
|
||||
#endif
|
||||
#define UART_BAUD 115200 /* UART Baud Rate */
|
||||
|
||||
/* Note: You will also need to update the UART clock gate in hw_uart_init (SIM_SCGC1_UART5_MASK) */
|
||||
/* Note: TWR-K60 is UART3, PTC17 */
|
||||
/* Note: FRDM-K64 is UART4, PTE24 */
|
||||
/* Note: TWR-K64 is UART5, PTE8 */
|
||||
/* Note: FRDM-K82F is LPUART0 A2, LPUART4 PTC15 */
|
||||
|
||||
/***********************************************/
|
||||
|
||||
@@ -70,6 +96,9 @@ static void delay_nop(uint32_t count)
|
||||
|
||||
static void hw_mcg_init(void)
|
||||
{
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
BOARD_BootClockHSRUN();
|
||||
#else
|
||||
/* Adjust clock dividers (core/system=div/1, bus=div/2, flex bus=div/2, flash=div/4) */
|
||||
SIM->CLKDIV1 = SIM_CLKDIV1_OUTDIV1(SYS_CLK_DIV-1) | SIM_CLKDIV1_OUTDIV2(BUS_CLK_DIV-1) |
|
||||
SIM_CLKDIV1_OUTDIV3(BUS_CLK_DIV-1) | SIM_CLKDIV1_OUTDIV4(FLASH_CLK_DIV-1);
|
||||
@@ -77,10 +106,18 @@ static void hw_mcg_init(void)
|
||||
/* Configure FEI internal clock speed */
|
||||
MCG->C4 = (SYS_CLK_DMX | SYS_CLK_DRS);
|
||||
while((MCG->C4 & (MCG_C4_DRST_DRS_MASK | MCG_C4_DMX32_MASK)) != (SYS_CLK_DMX | SYS_CLK_DRS));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void hw_gpio_init(void)
|
||||
{
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
CLOCK_EnableClock(kCLOCK_PortA);
|
||||
CLOCK_EnableClock(kCLOCK_PortB);
|
||||
CLOCK_EnableClock(kCLOCK_PortC);
|
||||
CLOCK_EnableClock(kCLOCK_PortD);
|
||||
CLOCK_EnableClock(kCLOCK_PortE);
|
||||
#else
|
||||
/* Enable clocks to all GPIO ports */
|
||||
SIM->SCGC5 |= (SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK
|
||||
#ifdef SIM_SCGC5_PORTC_MASK
|
||||
@@ -93,6 +130,7 @@ static void hw_gpio_init(void)
|
||||
| SIM_SCGC5_PORTE_MASK
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void hw_uart_init(void)
|
||||
@@ -100,7 +138,13 @@ static void hw_uart_init(void)
|
||||
register uint16_t sbr, brfa;
|
||||
uint8_t temp;
|
||||
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
PORT_SetPinMux(UART_TX_PORT, UART_TX_PIN, UART_TX_MUX);
|
||||
CLOCK_SetLpuartClock(1); /* MCGPLLCLK */
|
||||
DbgConsole_Init((uint32_t)UART_PORT, UART_BAUD, DEBUG_CONSOLE_DEVICE_TYPE_LPUART, SYS_CLK_HZ);
|
||||
#else
|
||||
/* Enable UART core clock */
|
||||
/* Note: Remember to update me if UART_PORT changes */
|
||||
SIM->SCGC1 |= SIM_SCGC1_UART4_MASK;
|
||||
|
||||
/* Configure UART TX pin */
|
||||
@@ -125,12 +169,13 @@ static void hw_uart_init(void)
|
||||
|
||||
/* Enable receiver and transmitter */
|
||||
UART_PORT->C2 |= (UART_C2_TE_MASK | UART_C2_RE_MASK);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void hw_rtc_init(void)
|
||||
{
|
||||
/* Init nop delay */
|
||||
mDelayCyclesPerUs = (SYS_CLK_KHZ / 1000 / NOP_FOR_LOOP_INSTRUCTION_COUNT);
|
||||
mDelayCyclesPerUs = (SYS_CLK_HZ / 1000000 / NOP_FOR_LOOP_INSTRUCTION_COUNT);
|
||||
|
||||
/* Enable RTC clock and oscillator */
|
||||
SIM->SCGC6 |= SIM_SCGC6_RTC_MASK;
|
||||
@@ -145,7 +190,7 @@ static void hw_rtc_init(void)
|
||||
}
|
||||
|
||||
/* Disable RTC Interrupts */
|
||||
RTC_IER = 0;
|
||||
RTC->IER = 0;
|
||||
|
||||
/* Enable OSC */
|
||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0) {
|
||||
@@ -164,6 +209,14 @@ static void hw_rtc_init(void)
|
||||
|
||||
static void hw_rand_init(void)
|
||||
{
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
trng_config_t trngConfig;
|
||||
TRNG_GetDefaultConfig(&trngConfig);
|
||||
/* Set sample mode of the TRNG ring oscillator to Von Neumann, for better random data.*/
|
||||
trngConfig.sampleMode = kTRNG_SampleModeVonNeumann;
|
||||
/* Initialize TRNG */
|
||||
TRNG_Init(TRNG0, &trngConfig);
|
||||
#else
|
||||
/* Enable RNG clocks */
|
||||
SIM->SCGC6 |= SIM_SCGC6_RNGA_MASK;
|
||||
SIM->SCGC3 |= SIM_SCGC3_RNGA_MASK;
|
||||
@@ -176,6 +229,7 @@ static void hw_rand_init(void)
|
||||
|
||||
/* Enable RNG generation to RANDOUT FIFO */
|
||||
RNG->CR |= RNG_CR_GO_MASK;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -204,14 +258,24 @@ uint32_t hw_get_time_msec(void)
|
||||
|
||||
void hw_uart_printchar(int c)
|
||||
{
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
LPUART_WriteBlocking(UART_PORT, (const uint8_t*)&c, 1); /* Send the character */
|
||||
#else
|
||||
while(!(UART_PORT->S1 & UART_S1_TDRE_MASK)); /* Wait until space is available in the FIFO */
|
||||
UART_PORT->D = (uint8_t)c; /* Send the character */
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t hw_rand(void)
|
||||
{
|
||||
uint32_t rng;
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
TRNG_GetRandomData(TRNG0, &rng, sizeof(rng));
|
||||
#else
|
||||
while((RNG->SR & RNG_SR_OREG_LVL(0xF)) == 0) {}; /* Wait until FIFO has a value available */
|
||||
return RNG->OR; /* Return next value in FIFO output register */
|
||||
rng = RNG->OR; /* Return next value in FIFO output register */
|
||||
#endif
|
||||
return rng;
|
||||
}
|
||||
|
||||
void delay_us(uint32_t microseconds)
|
||||
|
@@ -22,6 +22,17 @@
|
||||
|
||||
#include "hw.h"
|
||||
#include "user_settings.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void __assert(const char *__expression, const char *__filename, int __line)
|
||||
{
|
||||
printf("Assert: %s, File %s (%d)\n", __expression, __filename, __line);
|
||||
}
|
||||
|
||||
unsigned int LowResTimer(void)
|
||||
{
|
||||
return hw_get_time_sec();
|
||||
}
|
||||
|
||||
double current_time(int reset)
|
||||
{
|
||||
|
@@ -54,24 +54,26 @@ void main(void)
|
||||
|
||||
|
||||
/* SAMPLE OUTPUT:
|
||||
Crypt Test 1:
|
||||
MD5 test passed!
|
||||
MD4 test passed!
|
||||
Crypt Test 0:
|
||||
SHA test passed!
|
||||
SHA-256 test passed!
|
||||
HMAC-MD5 test passed!
|
||||
SHA-384 test passed!
|
||||
SHA-512 test passed!
|
||||
HMAC-SHA test passed!
|
||||
HMAC-SHA256 test passed!
|
||||
ARC4 test passed!
|
||||
HC-128 test passed!
|
||||
Rabbit test passed!
|
||||
DES test passed!
|
||||
DES3 test passed!
|
||||
HMAC-SHA384 test passed!
|
||||
HMAC-SHA512 test passed!
|
||||
GMAC test passed!
|
||||
Chacha test passed!
|
||||
POLY1305 test passed!
|
||||
ChaCha20-Poly1305 AEAD test passed!
|
||||
AES test passed!
|
||||
AES-GCM test passed!
|
||||
AES-CCM test passed!
|
||||
RANDOM test passed!
|
||||
RSA test passed!
|
||||
DH test passed!
|
||||
DSA test passed!
|
||||
PWDBASED test passed!
|
||||
Crypt Test 1: Return code 0
|
||||
ECC test passed!
|
||||
CURVE25519 test passed!
|
||||
ED25519 test passed!
|
||||
Crypt Test 0: Return code 0
|
||||
*/
|
||||
|
@@ -56,7 +56,9 @@ extern "C" {
|
||||
#define HAVE_ECC224
|
||||
#undef NO_ECC256
|
||||
#define HAVE_ECC384
|
||||
#define HAVE_ECC521
|
||||
#ifndef USE_NXP_LTC /* NXP LTC HW supports up to 512 */
|
||||
#define HAVE_ECC521
|
||||
#endif
|
||||
|
||||
/* Fixed point cache (speeds repeated operations against same private key) */
|
||||
#undef FP_ECC
|
||||
@@ -72,7 +74,9 @@ extern "C" {
|
||||
/* Optional ECC calculation method */
|
||||
/* Note: doubles heap usage, but slightly faster */
|
||||
#undef ECC_SHAMIR
|
||||
#define ECC_SHAMIR
|
||||
#ifndef USE_NXP_LTC /* Don't enable Shamir code for HW ECC */
|
||||
#define ECC_SHAMIR
|
||||
#endif
|
||||
|
||||
/* Reduces heap usage, but slower */
|
||||
#undef ECC_TIMING_RESISTANT
|
||||
@@ -83,16 +87,22 @@ extern "C" {
|
||||
#undef ALT_ECC_SIZE
|
||||
#define ALT_ECC_SIZE
|
||||
|
||||
/* optionally override the default max ecc bits */
|
||||
#undef FP_MAX_BITS_ECC
|
||||
//#define FP_MAX_BITS_ECC 512
|
||||
|
||||
/* Enable TFM optimizations for ECC */
|
||||
#define TFM_ECC192
|
||||
#define TFM_ECC224
|
||||
#define TFM_ECC256
|
||||
#define TFM_ECC384
|
||||
#define TFM_ECC521
|
||||
#if defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)
|
||||
#define TFM_ECC192
|
||||
#endif
|
||||
#if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)
|
||||
#define TFM_ECC224
|
||||
#endif
|
||||
#if !defined(NO_ECC256) || defined(HAVE_ALL_CURVES)
|
||||
#define TFM_ECC256
|
||||
#endif
|
||||
#if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)
|
||||
#define TFM_ECC384
|
||||
#endif
|
||||
#if defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)
|
||||
#define TFM_ECC521
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -140,7 +150,7 @@ extern "C" {
|
||||
/* Ed25519 / Curve25519 */
|
||||
#undef HAVE_CURVE25519
|
||||
#undef HAVE_ED25519
|
||||
#if 0
|
||||
#if 1
|
||||
#define HAVE_CURVE25519
|
||||
#define HAVE_ED25519
|
||||
|
||||
@@ -195,9 +205,20 @@ extern "C" {
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* HW Crypto Acceleration */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
// See README.md for instructions
|
||||
//#define FREESCALE_MMCAU 1
|
||||
|
||||
#define FSL_HW_CRYPTO_MANUAL_SELECTION
|
||||
#if 1
|
||||
/* NXP MMCAU / LTC Support (See README.md for instructions) */
|
||||
#if defined(USE_NXP_MMCAU) || defined(USE_NXP_LTC)
|
||||
#ifdef USE_NXP_MMCAU
|
||||
#define FREESCALE_USE_MMCAU
|
||||
#endif
|
||||
#ifdef USE_NXP_LTC
|
||||
#define FREESCALE_USE_LTC
|
||||
#define LTC_MAX_ECC_BITS (512)
|
||||
#define LTC_MAX_INT_BYTES (256)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Benchmark / Test */
|
||||
@@ -243,6 +264,7 @@ extern "C" {
|
||||
/* Override Current Time */
|
||||
/* Allows custom "custom_time()" function to be used for benchmark */
|
||||
#define WOLFSSL_USER_CURRTIME
|
||||
#define USER_TICKS
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
@@ -83,6 +83,9 @@
|
||||
<file file_name="../../wolfcrypt/src/memory.c" />
|
||||
<file file_name="../../wolfcrypt/src/misc.c">
|
||||
<configuration Name="ARM_Debug" build_exclude_from_build="Yes" />
|
||||
<configuration
|
||||
Name="ARM_Release"
|
||||
build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="../../wolfcrypt/src/pkcs7.c" />
|
||||
<file file_name="../../wolfcrypt/src/poly1305.c" />
|
||||
@@ -140,6 +143,8 @@
|
||||
arm_target_loader_default_loader="Flash"
|
||||
c_preprocessor_definitions="WOLFSSL_ROWLEY_ARM;WOLFSSL_USER_SETTINGS"
|
||||
c_user_include_directories=".;../;../../;$(TargetsDir);$(TargetsDir)/Kinetis;$(TargetsDir)/Kinetis/CMSIS;$(TargetsDir)/Kinetis/CMSIS/include;$(TargetsDir)/CMSIS_3/CMSIS/include"
|
||||
debug_register_definition_file="$(TargetsDir)/Kinetis/MK64F12_Peripherals.xml"
|
||||
linker_memory_map_file="$(TargetsDir)/Kinetis/MK64FN1M0xxx12_MemoryMap.xml"
|
||||
linker_memory_map_macros="FLASHSIZE=0x80000;SRAMSIZE=0x20000"
|
||||
linker_output_format="bin"
|
||||
project_dependencies="libwolfssl"
|
||||
@@ -161,7 +166,6 @@
|
||||
</folder>
|
||||
<folder Name="System Files">
|
||||
<file file_name="Kinetis_FlashPlacement.xml" />
|
||||
<file file_name="Kinetis_MemoryMap.xml" />
|
||||
</folder>
|
||||
</project>
|
||||
<project Name="benchmark">
|
||||
@@ -169,16 +173,21 @@
|
||||
Name="Common"
|
||||
Placement="Flash"
|
||||
Target="MK64FN1M0xxx12"
|
||||
arm_architecture="v7EM"
|
||||
arm_core_type="Cortex-M4"
|
||||
arm_fpu_type="FPv4-SP-D16"
|
||||
arm_linker_fiq_stack_size="0"
|
||||
arm_linker_heap_size="91136"
|
||||
arm_linker_irq_stack_size="0"
|
||||
arm_linker_stack_size="30720"
|
||||
arm_simulator_memory_simulation_filename="$(TargetsDir)/Kinetis/KinetisSimulatorMemory.dll"
|
||||
arm_simulator_memory_simulation_parameter="MK64FN1M0xxx12;0x100000;0x0;0x0;0x40000"
|
||||
arm_simulator_memory_simulation_parameter="MK64FN1M0xxx12;0x100000;0x0;0x0;0x40000;4"
|
||||
arm_target_loader_applicable_loaders="Flash"
|
||||
arm_target_loader_default_loader="Flash"
|
||||
c_preprocessor_definitions="WOLFSSL_ROWLEY_ARM;WOLFSSL_USER_SETTINGS"
|
||||
c_user_include_directories=".;../;../../;$(TargetsDir);$(TargetsDir)/Kinetis;$(TargetsDir)/Kinetis/CMSIS;$(TargetsDir)/Kinetis/CMSIS/include;$(TargetsDir)/CMSIS_3/CMSIS/include"
|
||||
debug_register_definition_file="$(TargetsDir)/Kinetis/MK64F12_Peripherals.xml"
|
||||
linker_memory_map_file="$(TargetsDir)/Kinetis/MK64FN1M0xxx12_MemoryMap.xml"
|
||||
linker_memory_map_macros="FLASHSIZE=0x80000;SRAMSIZE=0x20000"
|
||||
linker_output_format="bin"
|
||||
project_dependencies="libwolfssl"
|
||||
@@ -200,8 +209,11 @@
|
||||
</folder>
|
||||
<folder Name="System Files">
|
||||
<file file_name="Kinetis_FlashPlacement.xml" />
|
||||
<file file_name="Kinetis_MemoryMap.xml" />
|
||||
</folder>
|
||||
<configuration
|
||||
Name="Flash"
|
||||
arm_target_flash_loader_file_path="$(TargetsDir)/Kinetis/Release/Loader.elf"
|
||||
arm_target_loader_parameter="4" />
|
||||
</project>
|
||||
<configuration
|
||||
Name="ARM"
|
||||
@@ -278,11 +290,10 @@
|
||||
c_preprocessor_definitions="__RAM_BUILD"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="Kineits"
|
||||
Name="Kinetis"
|
||||
arm_target_debug_interface_type="ADIv5"
|
||||
c_preprocessor_definitions="FREESCALE;K_SERIES"
|
||||
hidden="Yes"
|
||||
linker_memory_map_file="$(ProjectDir)/Kinetis_MemoryMap.xml"
|
||||
linker_section_placement_file="$(ProjectDir)/Kinetis_FlashPlacement.xml" />
|
||||
<configuration
|
||||
Name="V4"
|
||||
@@ -400,11 +411,11 @@
|
||||
<configuration
|
||||
Name="ARM_Debug"
|
||||
batch_build_configurations="V7EM THUMB * Debug"
|
||||
inherited_configurations="ARM;V7EM;Debug;Kineits;THUMB;Flash" />
|
||||
inherited_configurations="ARM;V7EM;Debug;Kinetis;THUMB;Flash" />
|
||||
<configuration
|
||||
Name="ARM_Release"
|
||||
batch_build_configurations="V7EM THUMB * Release"
|
||||
inherited_configurations="ARM;V7EM;Release;Kineits;Flash;THUMB" />
|
||||
inherited_configurations="ARM;V7EM;Release;Kinetis;Flash;THUMB" />
|
||||
<configuration
|
||||
Name="Common"
|
||||
build_intermediate_directory="$(ProjectName)_$(Configuration)"
|
||||
|
626
IDE/ROWLEY-CROSSWORKS-ARM/wolfssl_ltc.hzp
Normal file
626
IDE/ROWLEY-CROSSWORKS-ARM/wolfssl_ltc.hzp
Normal file
@@ -0,0 +1,626 @@
|
||||
<!DOCTYPE CrossStudio_Project_File>
|
||||
<solution Name="wolfssl_ltc" target="8" version="2">
|
||||
<project Name="libwolfssl_ltc">
|
||||
<configuration
|
||||
Name="Common"
|
||||
build_output_file_name="$(OutDir)/$(ProjectName)$(LibExt)$(LIB)"
|
||||
c_preprocessor_definitions="WOLFSSL_ROWLEY_ARM;WOLFSSL_USER_SETTINGS"
|
||||
c_user_include_directories=".;../;../../;./drivers;./mmcau_2.0.0;./CMSIS/Include"
|
||||
project_directory=""
|
||||
project_type="Library" />
|
||||
<folder Name="Source Files">
|
||||
<configuration Name="Common" filter="c;cpp;cxx;cc;h;s;inc" />
|
||||
<folder Name="wolfcrypt">
|
||||
<folder Name="benchmark">
|
||||
<file file_name="../../wolfcrypt/benchmark/benchmark.c" />
|
||||
<file file_name="../../wolfcrypt/benchmark/benchmark.h" />
|
||||
<file file_name="../../wolfcrypt/benchmark/include.am" />
|
||||
</folder>
|
||||
<folder Name="src">
|
||||
<file file_name="../../wolfcrypt/src/aes.c" />
|
||||
<file file_name="../../wolfcrypt/src/arc4.c" />
|
||||
<file file_name="../../wolfcrypt/src/asm.c">
|
||||
<configuration Name="ARM_Debug" build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="../../wolfcrypt/src/asn.c" />
|
||||
<file file_name="../../wolfcrypt/src/blake2b.c" />
|
||||
<file file_name="../../wolfcrypt/src/camellia.c" />
|
||||
<file file_name="../../wolfcrypt/src/chacha.c" />
|
||||
<file file_name="../../wolfcrypt/src/chacha20_poly1305.c" />
|
||||
<file file_name="../../wolfcrypt/src/coding.c" />
|
||||
<file file_name="../../wolfcrypt/src/compress.c" />
|
||||
<file file_name="../../wolfcrypt/src/curve25519.c" />
|
||||
<file file_name="../../wolfcrypt/src/des3.c" />
|
||||
<file file_name="../../wolfcrypt/src/dh.c" />
|
||||
<file file_name="../../wolfcrypt/src/dsa.c" />
|
||||
<file file_name="../../wolfcrypt/src/ecc.c" />
|
||||
<file file_name="../../wolfcrypt/src/ecc_fp.c" />
|
||||
<file file_name="../../wolfcrypt/src/ed25519.c" />
|
||||
<file file_name="../../wolfcrypt/src/error.c" />
|
||||
<file file_name="../../wolfcrypt/src/fe_low_mem.c" />
|
||||
<file file_name="../../wolfcrypt/src/fe_operations.c" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mont_small.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_12.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_17.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_20.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_24.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_28.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_3.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_32.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_4.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_48.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_6.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_64.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_7.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_8.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_9.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_mul_comba_small_set.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_12.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_17.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_20.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_24.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_28.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_3.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_32.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_4.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_48.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_6.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_64.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_7.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_8.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_9.i" />
|
||||
<file file_name="../../wolfcrypt/src/fp_sqr_comba_small_set.i" />
|
||||
<file file_name="../../wolfcrypt/src/ge_low_mem.c" />
|
||||
<file file_name="../../wolfcrypt/src/ge_operations.c" />
|
||||
<file file_name="../../wolfcrypt/src/hash.c" />
|
||||
<file file_name="../../wolfcrypt/src/hc128.c" />
|
||||
<file file_name="../../wolfcrypt/src/hmac.c" />
|
||||
<file file_name="../../wolfcrypt/src/idea.c" />
|
||||
<file file_name="../../wolfcrypt/src/include.am" />
|
||||
<file file_name="../../wolfcrypt/src/integer.c" />
|
||||
<file file_name="../../wolfcrypt/src/logging.c" />
|
||||
<file file_name="../../wolfcrypt/src/md2.c" />
|
||||
<file file_name="../../wolfcrypt/src/md4.c" />
|
||||
<file file_name="../../wolfcrypt/src/md5.c" />
|
||||
<file file_name="../../wolfcrypt/src/memory.c" />
|
||||
<file file_name="../../wolfcrypt/src/misc.c">
|
||||
<configuration Name="ARM_Debug" build_exclude_from_build="Yes" />
|
||||
<configuration
|
||||
Name="ARM_Release"
|
||||
build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="../../wolfcrypt/src/pkcs7.c" />
|
||||
<file file_name="../../wolfcrypt/src/poly1305.c" />
|
||||
<file file_name="../../wolfcrypt/src/pwdbased.c" />
|
||||
<file file_name="../../wolfcrypt/src/rabbit.c" />
|
||||
<file file_name="../../wolfcrypt/src/random.c" />
|
||||
<file file_name="../../wolfcrypt/src/ripemd.c" />
|
||||
<file file_name="../../wolfcrypt/src/rsa.c" />
|
||||
<file file_name="../../wolfcrypt/src/sha.c" />
|
||||
<file file_name="../../wolfcrypt/src/sha256.c" />
|
||||
<file file_name="../../wolfcrypt/src/sha512.c" />
|
||||
<file file_name="../../wolfcrypt/src/signature.c" />
|
||||
<file file_name="../../wolfcrypt/src/srp.c" />
|
||||
<file file_name="../../wolfcrypt/src/tfm.c" />
|
||||
<file file_name="../../wolfcrypt/src/wc_encrypt.c" />
|
||||
<file file_name="../../wolfcrypt/src/wc_port.c" />
|
||||
<folder Name="port">
|
||||
<folder Name="nxp">
|
||||
<file file_name="../../wolfcrypt/src/port/nxp/ksdk_port.c" />
|
||||
<file file_name="fsl_debug_console.c" />
|
||||
<file file_name="MK82F25615.h" />
|
||||
<file file_name="MK82F25615_features.h" />
|
||||
<file file_name="arm_common_tables.h" />
|
||||
<file file_name="arm_const_structs.h" />
|
||||
<file file_name="arm_math.h" />
|
||||
<file file_name="cmsis_gcc.h" />
|
||||
<file file_name="core_cm4.h" />
|
||||
<file file_name="core_cmFunc.h" />
|
||||
<file file_name="core_cmInstr.h" />
|
||||
<file file_name="core_cmSimd.h" />
|
||||
<file file_name="fsl_debug_console.h" />
|
||||
<file file_name="fsl_device_registers.h" />
|
||||
<file file_name="system_MK82F25615.h" />
|
||||
<file file_name="clock_config.c" />
|
||||
<file file_name="clock_config.h" />
|
||||
<folder Name="drivers">
|
||||
<file file_name="drivers/fsl_adc16.c" />
|
||||
<file file_name="drivers/fsl_adc16.h" />
|
||||
<file file_name="drivers/fsl_clock.c" />
|
||||
<file file_name="drivers/fsl_clock.h" />
|
||||
<file file_name="drivers/fsl_cmp.c" />
|
||||
<file file_name="drivers/fsl_cmp.h" />
|
||||
<file file_name="drivers/fsl_cmt.c" />
|
||||
<file file_name="drivers/fsl_cmt.h" />
|
||||
<file file_name="drivers/fsl_common.c" />
|
||||
<file file_name="drivers/fsl_common.h" />
|
||||
<file file_name="drivers/fsl_crc.c" />
|
||||
<file file_name="drivers/fsl_crc.h" />
|
||||
<file file_name="drivers/fsl_dac.c" />
|
||||
<file file_name="drivers/fsl_dac.h" />
|
||||
<file file_name="drivers/fsl_dmamux.c" />
|
||||
<file file_name="drivers/fsl_dmamux.h" />
|
||||
<file file_name="drivers/fsl_dspi.c" />
|
||||
<file file_name="drivers/fsl_dspi.h" />
|
||||
<file file_name="drivers/fsl_dspi_edma.c" />
|
||||
<file file_name="drivers/fsl_dspi_edma.h" />
|
||||
<file file_name="drivers/fsl_dspi_freertos.c">
|
||||
<configuration
|
||||
Name="ARM_Debug"
|
||||
build_exclude_from_build="Yes" />
|
||||
<configuration
|
||||
Name="ARM_Release"
|
||||
build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="drivers/fsl_dspi_freertos.h" />
|
||||
<file file_name="drivers/fsl_edma.c" />
|
||||
<file file_name="drivers/fsl_edma.h" />
|
||||
<file file_name="drivers/fsl_ewm.c" />
|
||||
<file file_name="drivers/fsl_ewm.h" />
|
||||
<file file_name="drivers/fsl_flash.c" />
|
||||
<file file_name="drivers/fsl_flash.h" />
|
||||
<file file_name="drivers/fsl_flexbus.c" />
|
||||
<file file_name="drivers/fsl_flexbus.h" />
|
||||
<file file_name="drivers/fsl_flexio.c" />
|
||||
<file file_name="drivers/fsl_flexio.h" />
|
||||
<file file_name="drivers/fsl_flexio_camera.c" />
|
||||
<file file_name="drivers/fsl_flexio_camera.h" />
|
||||
<file file_name="drivers/fsl_flexio_camera_edma.c" />
|
||||
<file file_name="drivers/fsl_flexio_camera_edma.h" />
|
||||
<file file_name="drivers/fsl_flexio_i2c_master.c" />
|
||||
<file file_name="drivers/fsl_flexio_i2c_master.h" />
|
||||
<file file_name="drivers/fsl_flexio_i2s.c" />
|
||||
<file file_name="drivers/fsl_flexio_i2s.h" />
|
||||
<file file_name="drivers/fsl_flexio_i2s_edma.c" />
|
||||
<file file_name="drivers/fsl_flexio_i2s_edma.h" />
|
||||
<file file_name="drivers/fsl_flexio_spi.c" />
|
||||
<file file_name="drivers/fsl_flexio_spi.h" />
|
||||
<file file_name="drivers/fsl_flexio_spi_edma.c" />
|
||||
<file file_name="drivers/fsl_flexio_spi_edma.h" />
|
||||
<file file_name="drivers/fsl_flexio_uart.c" />
|
||||
<file file_name="drivers/fsl_flexio_uart.h" />
|
||||
<file file_name="drivers/fsl_flexio_uart_edma.c" />
|
||||
<file file_name="drivers/fsl_flexio_uart_edma.h" />
|
||||
<file file_name="drivers/fsl_ftm.c" />
|
||||
<file file_name="drivers/fsl_ftm.h" />
|
||||
<file file_name="drivers/fsl_gpio.c" />
|
||||
<file file_name="drivers/fsl_gpio.h" />
|
||||
<file file_name="drivers/fsl_i2c.c" />
|
||||
<file file_name="drivers/fsl_i2c.h" />
|
||||
<file file_name="drivers/fsl_i2c_edma.c" />
|
||||
<file file_name="drivers/fsl_i2c_edma.h" />
|
||||
<file file_name="drivers/fsl_i2c_freertos.c">
|
||||
<configuration
|
||||
Name="ARM_Debug"
|
||||
build_exclude_from_build="Yes" />
|
||||
<configuration
|
||||
Name="ARM_Release"
|
||||
build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="drivers/fsl_i2c_freertos.h" />
|
||||
<file file_name="drivers/fsl_llwu.c" />
|
||||
<file file_name="drivers/fsl_llwu.h" />
|
||||
<file file_name="drivers/fsl_lmem_cache.c" />
|
||||
<file file_name="drivers/fsl_lmem_cache.h" />
|
||||
<file file_name="drivers/fsl_lptmr.c" />
|
||||
<file file_name="drivers/fsl_lptmr.h" />
|
||||
<file file_name="drivers/fsl_lpuart.c" />
|
||||
<file file_name="drivers/fsl_lpuart.h" />
|
||||
<file file_name="drivers/fsl_lpuart_edma.c" />
|
||||
<file file_name="drivers/fsl_lpuart_edma.h" />
|
||||
<file file_name="fsl_lpuart_freertos.c">
|
||||
<configuration
|
||||
Name="ARM_Debug"
|
||||
build_exclude_from_build="Yes" />
|
||||
<configuration
|
||||
Name="ARM_Release"
|
||||
build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="drivers/fsl_lpuart_freertos.h" />
|
||||
<file file_name="drivers/fsl_ltc.c" />
|
||||
<file file_name="drivers/fsl_ltc.h" />
|
||||
<file file_name="drivers/fsl_ltc_edma.c" />
|
||||
<file file_name="drivers/fsl_ltc_edma.h" />
|
||||
<file file_name="drivers/fsl_mpu.c" />
|
||||
<file file_name="drivers/fsl_mpu.h" />
|
||||
<file file_name="drivers/fsl_pdb.c" />
|
||||
<file file_name="drivers/fsl_pdb.h" />
|
||||
<file file_name="drivers/fsl_pit.c" />
|
||||
<file file_name="drivers/fsl_pit.h" />
|
||||
<file file_name="drivers/fsl_pmc.c" />
|
||||
<file file_name="drivers/fsl_pmc.h" />
|
||||
<file file_name="drivers/fsl_port.h" />
|
||||
<file file_name="drivers/fsl_qspi.c" />
|
||||
<file file_name="drivers/fsl_qspi.h" />
|
||||
<file file_name="drivers/fsl_qspi_edma.c" />
|
||||
<file file_name="drivers/fsl_qspi_edma.h" />
|
||||
<file file_name="drivers/fsl_rcm.c" />
|
||||
<file file_name="drivers/fsl_rcm.h" />
|
||||
<file file_name="drivers/fsl_rtc.c" />
|
||||
<file file_name="drivers/fsl_rtc.h" />
|
||||
<file file_name="drivers/fsl_sai.c" />
|
||||
<file file_name="drivers/fsl_sai.h" />
|
||||
<file file_name="drivers/fsl_sai_edma.c" />
|
||||
<file file_name="drivers/fsl_sai_edma.h" />
|
||||
<file file_name="drivers/fsl_sdhc.c" />
|
||||
<file file_name="drivers/fsl_sdhc.h" />
|
||||
<file file_name="drivers/fsl_sdramc.c" />
|
||||
<file file_name="drivers/fsl_sdramc.h" />
|
||||
<file file_name="drivers/fsl_sim.c" />
|
||||
<file file_name="drivers/fsl_sim.h" />
|
||||
<file file_name="drivers/fsl_smartcard.h" />
|
||||
<file file_name="drivers/fsl_smartcard_emvsim.c" />
|
||||
<file file_name="drivers/fsl_smartcard_emvsim.h" />
|
||||
<file file_name="drivers/fsl_smartcard_freertos.c">
|
||||
<configuration
|
||||
Name="ARM_Debug"
|
||||
build_exclude_from_build="Yes" />
|
||||
<configuration
|
||||
Name="ARM_Release"
|
||||
build_exclude_from_build="Yes" />
|
||||
</file>
|
||||
<file file_name="drivers/fsl_smartcard_freertos.h" />
|
||||
<file file_name="drivers/fsl_smartcard_phy_emvsim.c" />
|
||||
<file file_name="drivers/fsl_smartcard_phy_emvsim.h" />
|
||||
<file file_name="drivers/fsl_smartcard_phy_ncn8025.c" />
|
||||
<file file_name="drivers/fsl_smartcard_phy_ncn8025.h" />
|
||||
<file file_name="drivers/fsl_smc.c" />
|
||||
<file file_name="drivers/fsl_smc.h" />
|
||||
<file file_name="drivers/fsl_tpm.c" />
|
||||
<file file_name="drivers/fsl_tpm.h" />
|
||||
<file file_name="drivers/fsl_trng.c" />
|
||||
<file file_name="drivers/fsl_trng.h" />
|
||||
<file file_name="drivers/fsl_tsi_v4.c" />
|
||||
<file file_name="drivers/fsl_tsi_v4.h" />
|
||||
<file file_name="drivers/fsl_vref.c" />
|
||||
<file file_name="drivers/fsl_vref.h" />
|
||||
<file file_name="drivers/fsl_wdog.c" />
|
||||
<file file_name="drivers/fsl_wdog.h" />
|
||||
</folder>
|
||||
<file file_name="system_MK82F25615.c" />
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="test">
|
||||
<file file_name="../../wolfcrypt/test/include.am" />
|
||||
<file file_name="../../wolfcrypt/test/test.c" />
|
||||
<file file_name="../../wolfcrypt/test/test.h" />
|
||||
</folder>
|
||||
<folder Name="user-crypto" path="../../wolfcrypt/user-crypto">
|
||||
<configuration Name="Common" build_exclude_from_build="Yes" />
|
||||
</folder>
|
||||
</folder>
|
||||
<folder
|
||||
Name="wolfssl"
|
||||
exclude="*.asm;*.s"
|
||||
filter=""
|
||||
path="../../wolfssl"
|
||||
recurse="Yes" />
|
||||
<file file_name="user_settings.h" />
|
||||
<file file_name="README.md" />
|
||||
<folder
|
||||
Name="source"
|
||||
exclude=""
|
||||
filter=""
|
||||
path="../../src"
|
||||
recurse="No" />
|
||||
</folder>
|
||||
</project>
|
||||
<project Name="test_ltc">
|
||||
<configuration
|
||||
Name="Common"
|
||||
Placement="Flash"
|
||||
Target="MK82FN256xxx15"
|
||||
arm_architecture="v7EM"
|
||||
arm_core_type="Cortex-M4"
|
||||
arm_fpu_type="FPv4-SP-D16"
|
||||
arm_linker_fiq_stack_size="0"
|
||||
arm_linker_heap_size="91136"
|
||||
arm_linker_irq_stack_size="0"
|
||||
arm_linker_stack_size="30720"
|
||||
arm_simulator_memory_simulation_filename="$(TargetsDir)/Kinetis/KinetisSimulatorMemory.dll"
|
||||
arm_simulator_memory_simulation_parameter="MK82FN256xxx15;0x40000;0x0;0x0;0x40000;4"
|
||||
arm_target_loader_applicable_loaders="Flash"
|
||||
arm_target_loader_default_loader="Flash"
|
||||
c_preprocessor_definitions="WOLFSSL_ROWLEY_ARM;WOLFSSL_USER_SETTINGS"
|
||||
c_user_include_directories=".;./drivers;./mmcau_2.0.0;./CMSIS/Include;../;../../;$(TargetsDir);$(TargetsDir)/Kinetis;$(TargetsDir)/Kinetis/CMSIS;$(TargetsDir)/Kinetis/CMSIS/include;$(TargetsDir)/CMSIS_3/CMSIS/include"
|
||||
debug_register_definition_file="$(TargetsDir)/Kinetis/MK82F25615_Peripherals.xml"
|
||||
linker_memory_map_file="$(TargetsDir)/Kinetis/MK82FN256xxx15_MemoryMap.xml"
|
||||
linker_memory_map_macros="FLASHSIZE=0x40000;SRAMSIZE=0x40000"
|
||||
linker_output_format="bin"
|
||||
project_dependencies="libwolfssl_ltc"
|
||||
project_type="Executable"
|
||||
property_groups_file_path="$(TargetsDir)/Kinetis/propertyGroups.xml"
|
||||
target_get_partname_script="GetPartName()"
|
||||
target_match_partname_script="MatchPartName("$(Target)")"
|
||||
target_reset_script="FLASHReset()"
|
||||
target_script_file="$(TargetsDir)/Kinetis/Kinetis_Target.js" />
|
||||
<folder Name="Source Files">
|
||||
<configuration Name="Common" filter="c;cpp;cxx;cc;h;s;asm;inc" />
|
||||
<file file_name="retarget.c" />
|
||||
<file file_name="kinetis_hw.c" />
|
||||
<file file_name="hw.h" />
|
||||
<file file_name="test_main.c" />
|
||||
<file file_name="arm_startup.c" />
|
||||
<file file_name="user_settings.h" />
|
||||
<file file_name="README.md" />
|
||||
<folder Name="mmcau">
|
||||
<file file_name="mmcau_2.0.0/cau_api.h" />
|
||||
<file file_name="mmcau_2.0.0/fsl_mmcau.c" />
|
||||
<file file_name="mmcau_2.0.0/fsl_mmcau.h" />
|
||||
<file file_name="mmcau_2.0.0/README.txt" />
|
||||
<folder Name="asm-cm4-cm7">
|
||||
<file file_name="mmcau_2.0.0/asm-cm4-cm7/lib_mmcau.a" />
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="System Files">
|
||||
<file file_name="Kinetis_FlashPlacement.xml" />
|
||||
</folder>
|
||||
<configuration
|
||||
Name="Flash"
|
||||
arm_target_flash_loader_file_path="$(TargetsDir)/Kinetis/Release/Loader3.elf" />
|
||||
</project>
|
||||
<project Name="benchmark_ltc">
|
||||
<configuration
|
||||
Name="Common"
|
||||
Placement="Flash"
|
||||
Target="MK82FN256xxx15"
|
||||
arm_architecture="v7EM"
|
||||
arm_core_type="Cortex-M4"
|
||||
arm_fpu_type="FPv4-SP-D16"
|
||||
arm_linker_fiq_stack_size="0"
|
||||
arm_linker_heap_size="91136"
|
||||
arm_linker_irq_stack_size="0"
|
||||
arm_linker_stack_size="30720"
|
||||
arm_simulator_memory_simulation_filename="$(TargetsDir)/Kinetis/KinetisSimulatorMemory.dll"
|
||||
arm_simulator_memory_simulation_parameter="MK82FN256xxx15;0x40000;0x0;0x0;0x40000;4"
|
||||
arm_target_loader_applicable_loaders="Flash"
|
||||
arm_target_loader_default_loader="Flash"
|
||||
c_preprocessor_definitions="WOLFSSL_ROWLEY_ARM;WOLFSSL_USER_SETTINGS"
|
||||
c_user_include_directories=".;./drivers;./mmcau_2.0.0;./CMSIS/Include;../;../../;$(TargetsDir);$(TargetsDir)/Kinetis;$(TargetsDir)/Kinetis/CMSIS;$(TargetsDir)/Kinetis/CMSIS/include;$(TargetsDir)/CMSIS_3/CMSIS/include"
|
||||
debug_register_definition_file="$(TargetsDir)/Kinetis/MK82F25615_Peripherals.xml"
|
||||
linker_memory_map_file="$(TargetsDir)/Kinetis/MK82FN256xxx15_MemoryMap.xml"
|
||||
linker_memory_map_macros="FLASHSIZE=0x40000;SRAMSIZE=0x40000"
|
||||
linker_output_format="bin"
|
||||
project_dependencies="libwolfssl_ltc"
|
||||
project_type="Executable"
|
||||
property_groups_file_path="$(TargetsDir)/Kinetis/propertyGroups.xml"
|
||||
target_get_partname_script="GetPartName()"
|
||||
target_match_partname_script="MatchPartName("$(Target)")"
|
||||
target_reset_script="FLASHReset()"
|
||||
target_script_file="$(TargetsDir)/Kinetis/Kinetis_Target.js" />
|
||||
<folder Name="Source Files">
|
||||
<configuration Name="Common" filter="c;cpp;cxx;cc;h;s;asm;inc" />
|
||||
<file file_name="retarget.c" />
|
||||
<file file_name="kinetis_hw.c" />
|
||||
<file file_name="hw.h" />
|
||||
<file file_name="benchmark_main.c" />
|
||||
<file file_name="arm_startup.c" />
|
||||
<file file_name="user_settings.h" />
|
||||
<file file_name="README.md" />
|
||||
<folder Name="mmcau">
|
||||
<file file_name="mmcau_2.0.0/cau_api.h" />
|
||||
<file file_name="mmcau_2.0.0/fsl_mmcau.c" />
|
||||
<file file_name="mmcau_2.0.0/fsl_mmcau.h" />
|
||||
<file file_name="mmcau_2.0.0/README.txt" />
|
||||
<folder Name="asm-cm4-cm7">
|
||||
<file file_name="mmcau_2.0.0/asm-cm4-cm7/lib_mmcau.a">
|
||||
<configuration Name="ARM_Debug" build_exclude_from_build="No" />
|
||||
</file>
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="System Files">
|
||||
<file file_name="Kinetis_FlashPlacement.xml" />
|
||||
</folder>
|
||||
<configuration
|
||||
Name="Flash"
|
||||
arm_target_flash_loader_file_path="$(TargetsDir)/Kinetis/Release/Loader3.elf" />
|
||||
</project>
|
||||
<configuration
|
||||
Name="ARM"
|
||||
Platform="ARM"
|
||||
arm_architecture="v7EM"
|
||||
arm_core_type="Cortex-M4"
|
||||
arm_instruction_set="ARM"
|
||||
arm_library_instruction_set="ARM"
|
||||
c_preprocessor_definitions="__ARM"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="LE"
|
||||
arm_endian="Little"
|
||||
c_preprocessor_definitions="__LITTLE_ENDIAN"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="BE"
|
||||
arm_endian="Big"
|
||||
c_preprocessor_definitions="__BIG_ENDIAN"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="Soft"
|
||||
arm_fp_abi="Soft"
|
||||
c_preprocessor_definitions="__FP_ABI_SOFT__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="Small"
|
||||
arm_library_optimization="Small"
|
||||
c_preprocessor_definitions="__OPTIMIZATION_SMALL"
|
||||
gcc_optimization_level="Optimize For Size"
|
||||
hidden="Yes" />
|
||||
<configuration Name="WCHAR16" gcc_wchar_size="16-Bit" hidden="Yes" />
|
||||
<configuration
|
||||
Name="Debug"
|
||||
c_preprocessor_definitions="DEBUG"
|
||||
gcc_debugging_level="Level 3"
|
||||
gcc_optimization_level="None"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="Float"
|
||||
c_preprocessor_definitions="SHORT_FLOAT"
|
||||
double_is_float="Yes"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="Release"
|
||||
c_preprocessor_definitions="NDEBUG"
|
||||
gcc_debugging_level="Level 1"
|
||||
gcc_optimization_level="Level 1"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="Fast"
|
||||
arm_library_optimization="Fast"
|
||||
c_preprocessor_definitions="__OPTIMIZATION_FAST"
|
||||
gcc_optimization_level="Level 1"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="THUMB"
|
||||
Platform="ARM"
|
||||
arm_instruction_set="Thumb"
|
||||
arm_library_instruction_set="Thumb"
|
||||
c_preprocessor_definitions="__THUMB"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="Hard"
|
||||
arm_fp_abi="Hard"
|
||||
c_preprocessor_definitions="__FP_ABI_HARD__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="Flash"
|
||||
c_preprocessor_definitions="__FLASH_BUILD"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="RAM"
|
||||
c_preprocessor_definitions="__RAM_BUILD"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="Kinetis"
|
||||
arm_target_debug_interface_type="ADIv5"
|
||||
c_preprocessor_definitions="FREESCALE;K_SERIES;CPU_MK82FN256VLL15;FREESCALE_KSDK_BM;USE_NXP_LTC;USE_NXP_MMCAU"
|
||||
hidden="Yes"
|
||||
linker_section_placement_file="$(ProjectDir)/Kinetis_FlashPlacement.xml" />
|
||||
<configuration
|
||||
Name="V4"
|
||||
arm_architecture="v4T"
|
||||
arm_interwork="No"
|
||||
c_preprocessor_definitions="__ARCH_V4"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V4T"
|
||||
arm_architecture="v4T"
|
||||
c_preprocessor_definitions="__ARCH_V4T"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V5TE"
|
||||
arm_architecture="v5TE"
|
||||
c_preprocessor_definitions="__ARCH_V5TE"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V6"
|
||||
arm_architecture="v6"
|
||||
c_preprocessor_definitions="__ARCH_V6"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7A"
|
||||
arm_architecture="v7A"
|
||||
c_preprocessor_definitions="__ARCH_V7A"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7R"
|
||||
arm_architecture="v7R"
|
||||
c_preprocessor_definitions="__ARCH_V7R"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V6M"
|
||||
arm_architecture="v6M"
|
||||
c_preprocessor_definitions="__ARCH_V6M"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7M"
|
||||
arm_architecture="v7M"
|
||||
c_preprocessor_definitions="__ARCH_V7M"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7EM"
|
||||
arm_architecture="v7EM"
|
||||
c_preprocessor_definitions="__ARCH_V7EM"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V5TE VFP"
|
||||
arm_architecture="v5TE"
|
||||
arm_fpu_type="VFP"
|
||||
c_preprocessor_definitions="__ARCH_V5TE;__FPU_VFP__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="SoftFP"
|
||||
arm_fp_abi="SoftFP"
|
||||
c_preprocessor_definitions="__FP_ABI_SOFT_FP__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V6 VFP"
|
||||
arm_architecture="v6"
|
||||
arm_fpu_type="VFP"
|
||||
c_preprocessor_definitions="__ARCH_V6;__FPU_VFP__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7A VFPv3-D32"
|
||||
arm_architecture="v7A"
|
||||
arm_fpu_type="VFPv3-D32"
|
||||
c_preprocessor_definitions="__ARCH_V7A;__FPU_VFP__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7A VFPv4-D16"
|
||||
arm_architecture="v7A"
|
||||
arm_fpu_type="VFPv4-D16"
|
||||
c_preprocessor_definitions="__ARCH_V7A;__FPU_VFP__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7A_IDIV VFPv4-D16"
|
||||
arm_architecture="v7A"
|
||||
arm_fpu_type="VFPv4-D16"
|
||||
arm_v7_has_divide_instructions="Yes"
|
||||
c_preprocessor_definitions="__ARCH_V7A;__FPU_VFP__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7R VFPv3-D16"
|
||||
arm_architecture="v7R"
|
||||
arm_fpu_type="VFPv3-D16"
|
||||
c_preprocessor_definitions="__ARCH_V7R;__FPU_VFP__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7R_IDIV VFPv3-D16"
|
||||
arm_architecture="v7R"
|
||||
arm_fpu_type="VFPv3-D16"
|
||||
arm_v7_has_divide_instructions="Yes"
|
||||
c_preprocessor_definitions="__ARCH_V7R;__FPU_VFP__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7EM FPv4-SP-D16"
|
||||
arm_architecture="v7EM"
|
||||
arm_fpu_type="FPv4-SP-D16"
|
||||
c_preprocessor_definitions="__ARCH_V7EM;__FPV4_SP_D16__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7EM FPv5-SP-D16"
|
||||
arm_architecture="v7EM"
|
||||
arm_fpu_type="FPv5-SP-D16"
|
||||
c_preprocessor_definitions="__ARCH_V7EM;__FPV5_SP_D16__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="V7EM FPv5-D16"
|
||||
arm_architecture="v7EM"
|
||||
arm_fpu_type="FPv5-D16"
|
||||
c_preprocessor_definitions="__ARCH_V7EM;__FPU_VFP__"
|
||||
hidden="Yes" />
|
||||
<configuration
|
||||
Name="ARM_Debug"
|
||||
batch_build_configurations="V7EM THUMB * Debug"
|
||||
inherited_configurations="ARM;V7EM;Debug;Kinetis;THUMB;Flash" />
|
||||
<configuration
|
||||
Name="ARM_Release"
|
||||
batch_build_configurations="V7EM THUMB * Release"
|
||||
inherited_configurations="ARM;V7EM;Release;Kinetis;Flash;THUMB" />
|
||||
<configuration
|
||||
Name="Common"
|
||||
build_intermediate_directory="$(ProjectName)_$(Configuration)"
|
||||
build_output_directory="$(ProjectName)_$(Configuration)" />
|
||||
</solution>
|
@@ -474,6 +474,8 @@ then
|
||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_PK_CALLBACKS"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([BUILD_PKCALLBACKS], [ test "x$ENABLED_PKCALLBACKS" = "xyes" ])
|
||||
|
||||
|
||||
# SNIFFER
|
||||
AC_ARG_ENABLE([sniffer],
|
||||
|
@@ -47,6 +47,11 @@ if BUILD_TRUST_PEER_CERT
|
||||
dist_noinst_SCRIPTS+= scripts/trusted_peer.test
|
||||
endif
|
||||
|
||||
if BUILD_PKCALLBACKS
|
||||
dist_noinst_SCRIPTS+= scripts/pkcallbacks.test
|
||||
scripts/pkcallbacks.log: scripts/resume.log
|
||||
endif
|
||||
|
||||
endif # end of BUILD_EXAMPLE_SERVERS
|
||||
|
||||
if BUILD_EXAMPLE_CLIENTS
|
||||
|
123
scripts/pkcallbacks.test
Executable file
123
scripts/pkcallbacks.test
Executable file
@@ -0,0 +1,123 @@
|
||||
#!/bin/sh
|
||||
|
||||
#pkcallbacks.test
|
||||
|
||||
exit_code=1
|
||||
counter=0
|
||||
# need a unique resume port since may run the same time as testsuite
|
||||
# use server port zero hack to get one
|
||||
pk_port=0
|
||||
#no_pid tells us process was never started if -1
|
||||
no_pid=-1
|
||||
#server_pid captured on startup, stores the id of the server process
|
||||
server_pid=$no_pid
|
||||
# let's use absolute path to a local dir (make distcheck may be in sub dir)
|
||||
# also let's add some randomness by adding pid in case multiple 'make check's
|
||||
# per source tree
|
||||
ready_file=`pwd`/wolfssl_pk_ready$$
|
||||
|
||||
remove_ready_file() {
|
||||
if test -e $ready_file; then
|
||||
echo -e "removing existing ready file"
|
||||
rm $ready_file
|
||||
fi
|
||||
}
|
||||
|
||||
do_cleanup() {
|
||||
echo "in cleanup"
|
||||
|
||||
if [ $server_pid != $no_pid ]
|
||||
then
|
||||
echo "killing server"
|
||||
kill -9 $server_pid
|
||||
fi
|
||||
remove_ready_file
|
||||
}
|
||||
|
||||
# trap this function so if user aborts with ^C or other kill signal we still
|
||||
# get an exit that will in turn clean up the file system
|
||||
abort_trap() {
|
||||
echo "script aborted"
|
||||
|
||||
if [ $server_pid != $no_pid ]
|
||||
then
|
||||
echo "killing server"
|
||||
kill -9 $server_pid
|
||||
fi
|
||||
|
||||
exit_code=2 #different exit code in case of user interrupt
|
||||
|
||||
echo "got abort signal, exiting with $exit_code"
|
||||
exit $exit_code
|
||||
}
|
||||
trap abort_trap INT TERM
|
||||
|
||||
|
||||
# trap this function so that if we exit on an error the file system will still
|
||||
# be restored and the other tests may still pass. Never call this function
|
||||
# instead use "exit <some value>" and this function will run automatically
|
||||
restore_file_system() {
|
||||
remove_ready_file
|
||||
}
|
||||
trap restore_file_system EXIT
|
||||
|
||||
run_test() {
|
||||
echo -e "\nStarting example server for pkcallbacks test...\n"
|
||||
|
||||
remove_ready_file
|
||||
|
||||
# starts the server on pk_port, -R generates ready file to be used as a
|
||||
# mutex lock, -P does pkcallbacks. We capture the processid
|
||||
# into the variable server_pid
|
||||
./examples/server/server -P -R $ready_file -p $pk_port &
|
||||
server_pid=$!
|
||||
|
||||
while [ ! -s $ready_file -a "$counter" -lt 20 ]; do
|
||||
echo -e "waiting for ready file..."
|
||||
sleep 0.1
|
||||
counter=$((counter+ 1))
|
||||
done
|
||||
|
||||
if test -e $ready_file; then
|
||||
echo -e "found ready file, starting client..."
|
||||
else
|
||||
echo -e "NO ready file ending test..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get created port 0 ephemeral port
|
||||
pk_port=`cat $ready_file`
|
||||
|
||||
# starts client on pk_port with pkcallbacks, captures the output from client
|
||||
capture_out=$(./examples/client/client -P -p $pk_port 2>&1)
|
||||
client_result=$?
|
||||
|
||||
if [ $client_result != 0 ]
|
||||
then
|
||||
echo -e "client failed!"
|
||||
do_cleanup
|
||||
exit 1
|
||||
fi
|
||||
|
||||
wait $server_pid
|
||||
server_result=$?
|
||||
|
||||
if [ $server_result != 0 ]
|
||||
then
|
||||
echo -e "server failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
######### begin program #########
|
||||
|
||||
# run the test
|
||||
run_test
|
||||
|
||||
# If we get to this, success
|
||||
echo "Success!"
|
||||
exit 0
|
||||
########## end program ##########
|
||||
|
@@ -4507,7 +4507,32 @@ ProtocolVersion MakeDTLSv1_2(void)
|
||||
|
||||
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
#if defined(USER_TICKS)
|
||||
#if 0
|
||||
word32 LowResTimer(void)
|
||||
{
|
||||
/*
|
||||
write your own clock tick function if don't want time(0)
|
||||
needs second accuracy but doesn't have to correlated to EPOCH
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif defined(TIME_OVERRIDES)
|
||||
|
||||
/* use same asn time overrides unless user wants tick override above */
|
||||
|
||||
#ifndef HAVE_TIME_T_TYPE
|
||||
typedef long time_t;
|
||||
#endif
|
||||
extern time_t XTIME(time_t * timer);
|
||||
|
||||
word32 LowResTimer(void)
|
||||
{
|
||||
return (word32) XTIME(0);
|
||||
}
|
||||
|
||||
#elif defined(USE_WINDOWS_API)
|
||||
|
||||
word32 LowResTimer(void)
|
||||
{
|
||||
@@ -4587,14 +4612,21 @@ ProtocolVersion MakeDTLSv1_2(void)
|
||||
|
||||
return (word32) mqxTime.SECONDS;
|
||||
}
|
||||
#elif defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
|
||||
|
||||
#elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS)
|
||||
#include "include/task.h"
|
||||
|
||||
#include "fsl_pit_driver.h"
|
||||
unsigned int LowResTimer(void)
|
||||
{
|
||||
return (unsigned int)(((float)xTaskGetTickCount())/configTICK_RATE_HZ);
|
||||
}
|
||||
|
||||
#elif defined(FREESCALE_KSDK_BM)
|
||||
|
||||
#include "lwip/sys.h" /* lwIP */
|
||||
word32 LowResTimer(void)
|
||||
{
|
||||
return PIT_DRV_GetUs();
|
||||
return sys_now()/1000;
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_TIRTOS)
|
||||
@@ -4611,33 +4643,8 @@ ProtocolVersion MakeDTLSv1_2(void)
|
||||
return (word32)(uTaskerSystemTick / TICK_RESOLUTION);
|
||||
}
|
||||
|
||||
#elif defined(USER_TICKS)
|
||||
#if 0
|
||||
word32 LowResTimer(void)
|
||||
{
|
||||
/*
|
||||
write your own clock tick function if don't want time(0)
|
||||
needs second accuracy but doesn't have to correlated to EPOCH
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif defined(TIME_OVERRIDES)
|
||||
|
||||
/* use same asn time overrides unless user wants tick override above */
|
||||
|
||||
#ifndef HAVE_TIME_T_TYPE
|
||||
typedef long time_t;
|
||||
#endif
|
||||
extern time_t XTIME(time_t * timer);
|
||||
|
||||
word32 LowResTimer(void)
|
||||
{
|
||||
return (word32) XTIME(0);
|
||||
}
|
||||
|
||||
#else /* !USE_WINDOWS_API && !HAVE_RTP_SYS && !MICRIUM && !USER_TICKS */
|
||||
|
||||
#else
|
||||
/* Posix style time */
|
||||
#include <time.h>
|
||||
|
||||
word32 LowResTimer(void)
|
||||
@@ -4646,7 +4653,7 @@ ProtocolVersion MakeDTLSv1_2(void)
|
||||
}
|
||||
|
||||
|
||||
#endif /* USE_WINDOWS_API */
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NO_CERTS
|
||||
|
@@ -299,19 +299,36 @@ void wc_AesAsyncFree(Aes* aes)
|
||||
#include "sec.h"
|
||||
#include "mcf5475_sec.h"
|
||||
#include "mcf5475_siu.h"
|
||||
#elif defined(FREESCALE_LTC)
|
||||
#include "fsl_ltc.h"
|
||||
#if defined(FREESCALE_LTC_AES_GCM)
|
||||
#undef NEED_AES_TABLES
|
||||
#undef GCM_TABLE
|
||||
#else
|
||||
/* if LTC doesn't have GCM, use software with LTC AES ECB mode */
|
||||
static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
||||
{
|
||||
wc_AesEncryptDirect(aes, outBlock, inBlock);
|
||||
return 0;
|
||||
}
|
||||
static int wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
||||
{
|
||||
wc_AesDecryptDirect(aes, outBlock, inBlock);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#elif defined(FREESCALE_MMCAU)
|
||||
/* Freescale mmCAU hardware AES support for Direct, CBC, CCM, GCM modes
|
||||
* through the CAU/mmCAU library. Documentation located in
|
||||
* ColdFire/ColdFire+ CAU and Kinetis mmCAU Software Library User
|
||||
* Guide (See note in README).
|
||||
* NOTE: no support for AES-CTR */
|
||||
#include "cau_api.h"
|
||||
* Guide (See note in README). */
|
||||
#include "fsl_mmcau.h"
|
||||
|
||||
static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
||||
{
|
||||
int ret = wolfSSL_CryptHwMutexLock();
|
||||
if(ret == 0) {
|
||||
cau_aes_encrypt(inBlock, (byte*)aes->key, aes->rounds, outBlock);
|
||||
MMCAU_AES_EncryptEcb(inBlock, (byte*)aes->key, aes->rounds, outBlock);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
}
|
||||
return ret;
|
||||
@@ -321,7 +338,7 @@ void wc_AesAsyncFree(Aes* aes)
|
||||
{
|
||||
int ret = wolfSSL_CryptHwMutexLock();
|
||||
if(ret == 0) {
|
||||
cau_aes_decrypt(inBlock, (byte*)aes->key, aes->rounds, outBlock);
|
||||
MMCAU_AES_DecryptEcb(inBlock, (byte*)aes->key, aes->rounds, outBlock);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
}
|
||||
return ret;
|
||||
@@ -1592,6 +1609,28 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#elif defined(FREESCALE_LTC)
|
||||
int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv,
|
||||
int dir)
|
||||
{
|
||||
if (!((keylen == 16) || (keylen == 24) || (keylen == 32)))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
aes->rounds = keylen/4 + 6;
|
||||
XMEMCPY(aes->key, userKey, keylen);
|
||||
|
||||
#ifdef WOLFSSL_AES_COUNTER
|
||||
aes->left = 0;
|
||||
#endif /* WOLFSSL_AES_COUNTER */
|
||||
|
||||
return wc_AesSetIV(aes, iv);
|
||||
}
|
||||
|
||||
int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
|
||||
const byte* iv, int dir)
|
||||
{
|
||||
return wc_AesSetKey(aes, userKey, keylen, iv, dir);
|
||||
}
|
||||
#elif defined(FREESCALE_MMCAU)
|
||||
int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv,
|
||||
int dir)
|
||||
@@ -1607,11 +1646,15 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
||||
if (rk == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
#ifdef WOLFSSL_AES_COUNTER
|
||||
aes->left = 0;
|
||||
#endif /* WOLFSSL_AES_COUNTER */
|
||||
|
||||
aes->rounds = keylen/4 + 6;
|
||||
|
||||
ret = wolfSSL_CryptHwMutexLock();
|
||||
if(ret == 0) {
|
||||
cau_aes_set_key(userKey, keylen*8, rk);
|
||||
MMCAU_AES_SetKey(userKey, keylen, rk);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
|
||||
ret = wc_AesSetIV(aes, iv);
|
||||
@@ -1905,6 +1948,33 @@ int wc_InitAes_h(Aes* aes, void* h)
|
||||
#elif defined(WOLFSSL_PIC32MZ_CRYPT)
|
||||
#error "PIC32MZ doesn't yet support AES direct"
|
||||
|
||||
#elif defined(FREESCALE_LTC)
|
||||
/* Allow direct access to one block encrypt */
|
||||
void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
|
||||
{
|
||||
byte *key;
|
||||
uint32_t keySize;
|
||||
|
||||
key = (byte*)aes->key;
|
||||
wc_AesGetKeySize(aes, &keySize);
|
||||
|
||||
LTC_AES_EncryptEcb(LTC_BASE, in, out, AES_BLOCK_SIZE,
|
||||
key, keySize);
|
||||
}
|
||||
|
||||
/* Allow direct access to one block decrypt */
|
||||
void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
|
||||
{
|
||||
byte *key;
|
||||
uint32_t keySize;
|
||||
|
||||
key = (byte*)aes->key;
|
||||
wc_AesGetKeySize(aes, &keySize);
|
||||
|
||||
LTC_AES_DecryptEcb(LTC_BASE, in, out, AES_BLOCK_SIZE,
|
||||
key, keySize, kLTC_EncryptKey);
|
||||
}
|
||||
|
||||
#else
|
||||
/* Allow direct access to one block encrypt */
|
||||
void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
|
||||
@@ -2019,9 +2089,9 @@ int wc_InitAes_h(Aes* aes, void* h)
|
||||
/* store iv for next call */
|
||||
XMEMCPY(aes->reg, out + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||
|
||||
sz -= 16;
|
||||
in += 16;
|
||||
out += 16;
|
||||
sz -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
/* disable crypto processor */
|
||||
@@ -2141,9 +2211,9 @@ int wc_InitAes_h(Aes* aes, void* h)
|
||||
/* store iv for next call */
|
||||
XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
|
||||
|
||||
sz -= 16;
|
||||
in += 16;
|
||||
out += 16;
|
||||
sz -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
/* disable crypto processor */
|
||||
@@ -2257,6 +2327,48 @@ int wc_InitAes_h(Aes* aes, void* h)
|
||||
return (wc_AesCbcCrypt(aes, po, pi, sz, SEC_DESC_AES_CBC_DECRYPT));
|
||||
}
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
|
||||
#elif defined(FREESCALE_LTC)
|
||||
int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
uint32_t keySize;
|
||||
status_t status;
|
||||
byte *iv, *enc_key;
|
||||
|
||||
iv = (byte*)aes->reg;
|
||||
enc_key = (byte*)aes->key;
|
||||
|
||||
status = wc_AesGetKeySize(aes, &keySize);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = LTC_AES_EncryptCbc(LTC_BASE, in, out, sz,
|
||||
iv, enc_key, keySize);
|
||||
return (status == kStatus_Success) ? 0 : -1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
uint32_t keySize;
|
||||
status_t status;
|
||||
byte* iv, *dec_key;
|
||||
|
||||
iv = (byte*)aes->reg;
|
||||
dec_key = (byte*)aes->key;
|
||||
|
||||
status = wc_AesGetKeySize(aes, &keySize);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = LTC_AES_DecryptCbc(LTC_BASE, in, out, sz,
|
||||
iv, dec_key, keySize, kLTC_EncryptKey);
|
||||
return (status == kStatus_Success) ? 0 : -1;
|
||||
}
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
|
||||
#elif defined(FREESCALE_MMCAU)
|
||||
int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
@@ -2269,11 +2381,6 @@ int wc_InitAes_h(Aes* aes, void* h)
|
||||
|
||||
iv = (byte*)aes->reg;
|
||||
|
||||
if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
|
||||
WOLFSSL_MSG("Bad cau_aes_encrypt alignment");
|
||||
return BAD_ALIGN_E;
|
||||
}
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
XMEMCPY(temp_block, in + offset, AES_BLOCK_SIZE);
|
||||
@@ -2305,10 +2412,6 @@ int wc_InitAes_h(Aes* aes, void* h)
|
||||
|
||||
iv = (byte*)aes->reg;
|
||||
|
||||
if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
|
||||
WOLFSSL_MSG("Bad cau_aes_decrypt alignment");
|
||||
return BAD_ALIGN_E;
|
||||
}
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
@@ -2661,9 +2764,9 @@ int wc_InitAes_h(Aes* aes, void* h)
|
||||
/* store iv for next call */
|
||||
XMEMCPY(aes->reg, out + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||
|
||||
sz -= 16;
|
||||
in += 16;
|
||||
out += 16;
|
||||
sz -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
/* disable crypto processor */
|
||||
@@ -2731,8 +2834,31 @@ int wc_InitAes_h(Aes* aes, void* h)
|
||||
#elif defined(HAVE_COLDFIRE_SEC)
|
||||
#error "Coldfire SEC doesn't currently support AES-CTR mode"
|
||||
|
||||
#elif defined(FREESCALE_MMCAU)
|
||||
#error "Freescale mmCAU doesn't currently support AES-CTR mode"
|
||||
#elif defined(FREESCALE_LTC)
|
||||
void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
uint32_t keySize;
|
||||
byte *iv, *enc_key;
|
||||
byte* tmp = (byte*)aes->tmp + AES_BLOCK_SIZE - aes->left;
|
||||
|
||||
/* consume any unused bytes left in aes->tmp */
|
||||
while (aes->left && sz) {
|
||||
*(out++) = *(in++) ^ *(tmp++);
|
||||
aes->left--;
|
||||
sz--;
|
||||
}
|
||||
|
||||
if (sz) {
|
||||
iv = (byte*)aes->reg;
|
||||
enc_key = (byte*)aes->key;
|
||||
|
||||
wc_AesGetKeySize(aes, &keySize);
|
||||
|
||||
LTC_AES_CryptCtr(LTC_BASE, in, out, sz,
|
||||
iv, enc_key, keySize, (byte*)aes->tmp,
|
||||
(uint32_t*)&(aes->left));
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
/* Increment AES counter */
|
||||
@@ -2816,7 +2942,7 @@ enum {
|
||||
CTR_SZ = 4
|
||||
};
|
||||
|
||||
|
||||
#if !defined(FREESCALE_LTC_AES_GCM)
|
||||
static INLINE void IncrementGcmCounter(byte* inOutCtr)
|
||||
{
|
||||
int i;
|
||||
@@ -2827,7 +2953,7 @@ static INLINE void IncrementGcmCounter(byte* inOutCtr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !FREESCALE_LTC_AES_GCM */
|
||||
|
||||
#if defined(GCM_SMALL) || defined(GCM_TABLE)
|
||||
|
||||
@@ -2911,12 +3037,14 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
|
||||
return ret;
|
||||
#endif /* WOLFSSL_AESNI */
|
||||
|
||||
#if !defined(FREESCALE_LTC_AES_GCM)
|
||||
if (ret == 0) {
|
||||
wc_AesEncrypt(aes, iv, aes->H);
|
||||
#ifdef GCM_TABLE
|
||||
GenerateM0(aes);
|
||||
#endif /* GCM_TABLE */
|
||||
}
|
||||
#endif /* FREESCALE_LTC_AES_GCM */
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -3588,6 +3716,7 @@ static void GHASH(Aes* aes, const byte* a, word32 aSz,
|
||||
/* end GCM_TABLE */
|
||||
#elif defined(WORD64_AVAILABLE) && !defined(GCM_WORD32)
|
||||
|
||||
#if !defined(FREESCALE_LTC_AES_GCM)
|
||||
static void GMULT(word64* X, word64* Y)
|
||||
{
|
||||
word64 Z[2] = {0,0};
|
||||
@@ -3623,7 +3752,6 @@ static void GMULT(word64* X, word64* Y)
|
||||
X[1] = Z[1];
|
||||
}
|
||||
|
||||
|
||||
static void GHASH(Aes* aes, const byte* a, word32 aSz,
|
||||
const byte* c, word32 cSz, byte* s, word32 sSz)
|
||||
{
|
||||
@@ -3708,6 +3836,7 @@ static void GHASH(Aes* aes, const byte* a, word32 aSz,
|
||||
#endif
|
||||
XMEMCPY(s, x, sSz);
|
||||
}
|
||||
#endif /* !FREESCALE_LTC_AES_GCM */
|
||||
|
||||
/* end defined(WORD64_AVAILABLE) && !defined(GCM_WORD32) */
|
||||
#else /* GCM_WORD32 */
|
||||
@@ -3864,6 +3993,25 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz)
|
||||
{
|
||||
#if defined(FREESCALE_LTC_AES_GCM)
|
||||
byte *key;
|
||||
uint32_t keySize;
|
||||
status_t status;
|
||||
|
||||
key = (byte*)aes->key;
|
||||
|
||||
status = wc_AesGetKeySize(aes, &keySize);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = LTC_AES_EncryptTagGcm(LTC_BASE, in, out, sz,
|
||||
iv, ivSz, authIn, authInSz, key, keySize, authTag, authTagSz);
|
||||
|
||||
return (status == kStatus_Success) ? 0 : AES_GCM_AUTH_E;
|
||||
|
||||
#else /* FREESCALE_LTC_AES_GCM */
|
||||
|
||||
word32 blocks = sz / AES_BLOCK_SIZE;
|
||||
word32 partial = sz % AES_BLOCK_SIZE;
|
||||
const byte* p = in;
|
||||
@@ -3930,6 +4078,7 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
xorbuf(authTag, scratch, authTagSz);
|
||||
|
||||
return 0;
|
||||
#endif /* FREESCALE_LTC_AES_GCM */
|
||||
}
|
||||
|
||||
|
||||
@@ -3939,6 +4088,25 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
const byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz)
|
||||
{
|
||||
#if defined(FREESCALE_LTC_AES_GCM)
|
||||
byte *key;
|
||||
uint32_t keySize;
|
||||
status_t status;
|
||||
|
||||
key = (byte*)aes->key;
|
||||
|
||||
status = wc_AesGetKeySize(aes, &keySize);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = LTC_AES_DecryptTagGcm(LTC_BASE, in, out, sz,
|
||||
iv, ivSz, authIn, authInSz, key, keySize, authTag, authTagSz);
|
||||
|
||||
return (status == kStatus_Success) ? 0 : AES_GCM_AUTH_E;
|
||||
|
||||
#else /* FREESCALE_LTC_AES_GCM */
|
||||
|
||||
word32 blocks = sz / AES_BLOCK_SIZE;
|
||||
word32 partial = sz % AES_BLOCK_SIZE;
|
||||
const byte* c = in;
|
||||
@@ -4015,6 +4183,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
XMEMCPY(p, scratch, partial);
|
||||
}
|
||||
return 0;
|
||||
#endif /* FREESCALE_LTC_AES_GCM */
|
||||
}
|
||||
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
@@ -4058,6 +4227,7 @@ int wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz)
|
||||
}
|
||||
|
||||
|
||||
#ifndef FREESCALE_LTC
|
||||
static void roll_x(Aes* aes, const byte* in, word32 inSz, byte* out)
|
||||
{
|
||||
/* process the bulk of the data */
|
||||
@@ -4130,7 +4300,7 @@ static INLINE void AesCcmCtrInc(byte* B, word32 lenSz)
|
||||
if (++B[AES_BLOCK_SIZE - 1 - i] != 0) return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !FREESCALE_LTC */
|
||||
|
||||
/* return 0 on success */
|
||||
int wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
||||
@@ -4138,6 +4308,23 @@ int wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz)
|
||||
{
|
||||
#ifdef FREESCALE_LTC
|
||||
byte *key;
|
||||
uint32_t keySize;
|
||||
status_t status;
|
||||
|
||||
key = (byte*)aes->key;
|
||||
|
||||
status = wc_AesGetKeySize(aes, &keySize);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = LTC_AES_EncryptTagCcm(LTC_BASE, in, out, inSz,
|
||||
nonce, nonceSz, authIn, authInSz, key, keySize, authTag, authTagSz);
|
||||
|
||||
return (kStatus_Success == status) ? 0 : BAD_FUNC_ARG;
|
||||
#else
|
||||
byte A[AES_BLOCK_SIZE];
|
||||
byte B[AES_BLOCK_SIZE];
|
||||
byte lenSz;
|
||||
@@ -4196,6 +4383,7 @@ int wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
||||
ForceZero(B, AES_BLOCK_SIZE);
|
||||
|
||||
return 0;
|
||||
#endif /* FREESCALE_LTC */
|
||||
}
|
||||
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
@@ -4204,6 +4392,30 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
||||
const byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz)
|
||||
{
|
||||
#ifdef FREESCALE_LTC
|
||||
byte *key;
|
||||
uint32_t keySize;
|
||||
status_t status;
|
||||
|
||||
key = (byte*)aes->key;
|
||||
|
||||
status = wc_AesGetKeySize(aes, &keySize);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = LTC_AES_DecryptTagCcm(LTC_BASE, in, out, inSz,
|
||||
nonce, nonceSz, authIn, authInSz, key, keySize, authTag, authTagSz);
|
||||
|
||||
if (status == kStatus_Success) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
XMEMSET(out, 0, inSz);
|
||||
return AES_CCM_AUTH_E;
|
||||
}
|
||||
#else /* FREESCALE_LTC */
|
||||
|
||||
byte A[AES_BLOCK_SIZE];
|
||||
byte B[AES_BLOCK_SIZE];
|
||||
byte* o;
|
||||
@@ -4286,6 +4498,7 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
||||
o = NULL;
|
||||
|
||||
return result;
|
||||
#endif /* FREESCALE_LTC */
|
||||
}
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
#endif /* HAVE_AESCCM */
|
||||
@@ -4314,7 +4527,34 @@ void wc_AesAsyncFree(Aes* aes)
|
||||
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
|
||||
#endif /* WOLFSSL_TI_CRYPT */
|
||||
|
||||
int wc_AesGetKeySize(Aes* aes, word32* keySize)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (aes == NULL || keySize == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
switch (aes->rounds) {
|
||||
case 10:
|
||||
*keySize = 16;
|
||||
break;
|
||||
case 12:
|
||||
*keySize = 24;
|
||||
break;
|
||||
case 14:
|
||||
*keySize = 32;
|
||||
break;
|
||||
default:
|
||||
*keySize = 0;
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* !WOLFSSL_TI_CRYPT */
|
||||
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
|
@@ -104,7 +104,26 @@ ASN Options:
|
||||
#endif
|
||||
|
||||
#ifndef NO_ASN_TIME
|
||||
#if defined(HAVE_RTP_SYS)
|
||||
#if defined(USER_TIME)
|
||||
/* user time, and gmtime compatible functions, there is a gmtime
|
||||
implementation here that WINCE uses, so really just need some ticks
|
||||
since the EPOCH
|
||||
*/
|
||||
#define WOLFSSL_GMTIME
|
||||
#define USE_WOLF_TM
|
||||
#define USE_WOLF_TIME_T
|
||||
|
||||
#elif defined(TIME_OVERRIDES)
|
||||
/* user would like to override time() and gmtime() functionality */
|
||||
#ifndef HAVE_TIME_T_TYPE
|
||||
#define USE_WOLF_TIME_T
|
||||
#endif
|
||||
#ifndef HAVE_TM_TYPE
|
||||
#define USE_WOLF_TM
|
||||
#endif
|
||||
#define NEED_TMP_TIME
|
||||
|
||||
#elif defined(HAVE_RTP_SYS)
|
||||
/* uses parital <time.h> structures */
|
||||
#define XTIME(tl) (0)
|
||||
#define XGMTIME(c, t) rtpsys_gmtime((c))
|
||||
@@ -127,30 +146,13 @@ ASN Options:
|
||||
#define XTIME(t1) mqx_time((t1))
|
||||
#define HAVE_GMTIME_R
|
||||
|
||||
#elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS)
|
||||
#elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
|
||||
#include <time.h>
|
||||
#define XTIME(t1) ksdk_time((t1))
|
||||
#ifndef XTIME
|
||||
#define XTIME(t1) 0
|
||||
#endif
|
||||
#define XGMTIME(c, t) gmtime((c))
|
||||
|
||||
#elif defined(USER_TIME)
|
||||
/* user time, and gmtime compatible functions, there is a gmtime
|
||||
implementation here that WINCE uses, so really just need some ticks
|
||||
since the EPOCH
|
||||
*/
|
||||
#define WOLFSSL_GMTIME
|
||||
#define USE_WOLF_TM
|
||||
#define USE_WOLF_TIME_T
|
||||
|
||||
#elif defined(TIME_OVERRIDES)
|
||||
/* user would like to override time() and gmtime() functionality */
|
||||
#ifndef HAVE_TIME_T_TYPE
|
||||
#define USE_WOLF_TIME_T
|
||||
#endif
|
||||
#ifndef HAVE_TM_TYPE
|
||||
#define USE_WOLF_TM
|
||||
#endif
|
||||
#define NEED_TMP_TIME
|
||||
|
||||
#elif defined(IDIRECT_DEV_TIME)
|
||||
/*Gets the timestamp from cloak software owned by VT iDirect
|
||||
in place of time() from <time.h> */
|
||||
@@ -376,18 +378,8 @@ time_t mqx_time(time_t* timer)
|
||||
|
||||
#if defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS)
|
||||
|
||||
#include "fsl_pit_driver.h"
|
||||
|
||||
time_t ksdk_time(time_t* timer)
|
||||
{
|
||||
time_t localTime;
|
||||
|
||||
if (timer == NULL)
|
||||
timer = &localTime;
|
||||
|
||||
*timer = (PIT_DRV_ReadTimerUs(PIT_INSTANCE, PIT_CHANNEL)) / 1000000;
|
||||
return *timer;
|
||||
}
|
||||
/* */
|
||||
//extern time_t ksdk_time(time_t* timer);
|
||||
|
||||
#endif /* FREESCALE_KSDK_BM */
|
||||
|
||||
|
@@ -40,6 +40,10 @@
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#if defined(FREESCALE_LTC_ECC)
|
||||
#include <wolfssl/wolfcrypt/port/nxp/ksdk_port.h>
|
||||
#endif
|
||||
|
||||
const curve25519_set_type curve25519_sets[] = {
|
||||
{
|
||||
32,
|
||||
@@ -47,10 +51,13 @@ const curve25519_set_type curve25519_sets[] = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
|
||||
{
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
const ECPoint* basepoint = wc_curve25519_GetBasePoint();
|
||||
#else
|
||||
unsigned char basepoint[CURVE25519_KEYSIZE] = {9};
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
if (key == NULL || rng == NULL)
|
||||
@@ -71,7 +78,11 @@ int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
|
||||
key->k.point[CURVE25519_KEYSIZE-1] |= 64;
|
||||
|
||||
/* compute public key */
|
||||
ret = curve25519(key->p.point, key->k.point, basepoint);
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ret = wc_curve25519(&key->p, key->k.point, basepoint, kLTC_Weierstrass); /* input basepoint on Weierstrass curve */
|
||||
#else
|
||||
ret = curve25519(key->p.point, key->k.point, basepoint);
|
||||
#endif
|
||||
if (ret != 0) {
|
||||
ForceZero(key->k.point, keysize);
|
||||
ForceZero(key->p.point, keysize);
|
||||
@@ -95,21 +106,34 @@ int wc_curve25519_shared_secret_ex(curve25519_key* private_key,
|
||||
curve25519_key* public_key,
|
||||
byte* out, word32* outlen, int endian)
|
||||
{
|
||||
unsigned char o[CURVE25519_KEYSIZE];
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ECPoint o = {{0}};
|
||||
#else
|
||||
unsigned char o[CURVE25519_KEYSIZE];
|
||||
#endif
|
||||
int ret = 0;
|
||||
|
||||
/* sanity check */
|
||||
if (private_key == NULL || public_key == NULL ||
|
||||
out == NULL || outlen == NULL || *outlen < CURVE25519_KEYSIZE)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
|
||||
/* avoid implementation fingerprinting */
|
||||
if (public_key->p.point[CURVE25519_KEYSIZE-1] > 0x7F)
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
ret = curve25519(o, private_key->k.point, public_key->p.point);
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ret = wc_curve25519(&o, private_key->k.point, &public_key->p, kLTC_Curve25519 /* input point P on Curve25519 */);
|
||||
#else
|
||||
ret = curve25519(o, private_key->k.point, public_key->p.point);
|
||||
#endif
|
||||
if (ret != 0) {
|
||||
ForceZero(o, CURVE25519_KEYSIZE);
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ForceZero(o.point, CURVE25519_KEYSIZE);
|
||||
ForceZero(o.pointY, CURVE25519_KEYSIZE);
|
||||
#else
|
||||
ForceZero(o, CURVE25519_KEYSIZE);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -117,14 +141,27 @@ int wc_curve25519_shared_secret_ex(curve25519_key* private_key,
|
||||
int i;
|
||||
/* put shared secret key in Big Endian format */
|
||||
for (i = 0; i < CURVE25519_KEYSIZE; i++)
|
||||
out[i] = o[CURVE25519_KEYSIZE - i -1];
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
out[i] = o.point[CURVE25519_KEYSIZE - i -1];
|
||||
#else
|
||||
out[i] = o[CURVE25519_KEYSIZE - i -1];
|
||||
#endif
|
||||
}
|
||||
else /* put shared secret key in Little Endian format */
|
||||
XMEMCPY(out, o, CURVE25519_KEYSIZE);
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
XMEMCPY(out, o.point, CURVE25519_KEYSIZE);
|
||||
#else
|
||||
XMEMCPY(out, o, CURVE25519_KEYSIZE);
|
||||
#endif
|
||||
|
||||
*outlen = CURVE25519_KEYSIZE;
|
||||
|
||||
ForceZero(o, sizeof(o));
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ForceZero(o.point, CURVE25519_KEYSIZE);
|
||||
ForceZero(o.pointY, CURVE25519_KEYSIZE);
|
||||
#else
|
||||
ForceZero(o, CURVE25519_KEYSIZE);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -212,6 +249,15 @@ int wc_curve25519_import_public_ex(const byte* in, word32 inLen,
|
||||
XMEMCPY(key->p.point, in, inLen);
|
||||
|
||||
key->dp = &curve25519_sets[0];
|
||||
|
||||
|
||||
/* LTC needs also Y coordinate - let's compute it */
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ltc_pkha_ecc_point_t ltcPoint;
|
||||
ltcPoint.X = &key->p.point[0];
|
||||
ltcPoint.Y = &key->p.pointY[0];
|
||||
LTC_PKHA_Curve25519ComputeY(<cPoint);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -378,9 +424,12 @@ int wc_curve25519_init(curve25519_key* key)
|
||||
/* currently the format for curve25519 */
|
||||
key->dp = &curve25519_sets[0];
|
||||
|
||||
XMEMSET(key->k.point, 0, key->dp->size);
|
||||
XMEMSET(key->k.point, 0, key->dp->size);
|
||||
XMEMSET(key->p.point, 0, key->dp->size);
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
XMEMSET(key->k.pointY, 0, key->dp->size);
|
||||
XMEMSET(key->p.pointY, 0, key->dp->size);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -394,6 +443,10 @@ void wc_curve25519_free(curve25519_key* key)
|
||||
key->dp = NULL;
|
||||
ForceZero(key->p.point, sizeof(key->p.point));
|
||||
ForceZero(key->k.point, sizeof(key->k.point));
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ForceZero(key->p.point, sizeof(key->p.pointY));
|
||||
ForceZero(key->k.point, sizeof(key->k.pointY));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@@ -576,14 +576,99 @@ int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
||||
return 0;
|
||||
|
||||
}
|
||||
#elif (defined FREESCALE_LTC_DES)
|
||||
|
||||
#include "fsl_ltc.h"
|
||||
int wc_Des_SetKey(Des* des, const byte* key, const byte* iv, int dir)
|
||||
{
|
||||
byte* dkey = (byte*)des->key;
|
||||
|
||||
XMEMCPY(dkey, key, 8);
|
||||
|
||||
wc_Des_SetIV(des, iv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wc_Des3_SetKey(Des3* des, const byte* key, const byte* iv, int dir)
|
||||
{
|
||||
int ret = 0;
|
||||
byte* dkey1 = (byte*)des->key[0];
|
||||
byte* dkey2 = (byte*)des->key[1];
|
||||
byte* dkey3 = (byte*)des->key[2];
|
||||
|
||||
XMEMCPY(dkey1, key, 8); /* set key 1 */
|
||||
XMEMCPY(dkey2, key + 8, 8); /* set key 2 */
|
||||
XMEMCPY(dkey3, key + 16, 8); /* set key 3 */
|
||||
|
||||
ret = wc_Des3_SetIV(des, iv);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wc_Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
status_t status;
|
||||
status = LTC_DES_EncryptCbc(LTC_BASE, in, out, sz, (byte*)des->reg, (byte*)des->key);
|
||||
if (status == kStatus_Success)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wc_Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
status_t status;
|
||||
status = LTC_DES_DecryptCbc(LTC_BASE, in, out, sz, (byte*)des->reg, (byte*)des->key);
|
||||
if (status == kStatus_Success)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wc_Des3_CbcEncrypt(Des3* des, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
status_t status;
|
||||
status = LTC_DES3_EncryptCbc(LTC_BASE,
|
||||
in,
|
||||
out,
|
||||
sz,
|
||||
(byte*)des->reg,
|
||||
(byte*)des->key[0],
|
||||
(byte*)des->key[1],
|
||||
(byte*)des->key[2]);
|
||||
if (status == kStatus_Success)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wc_Des3_CbcDecrypt(Des3* des, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
status_t status;
|
||||
status = LTC_DES3_DecryptCbc(LTC_BASE,
|
||||
in,
|
||||
out,
|
||||
sz,
|
||||
(byte*)des->reg,
|
||||
(byte*)des->key[0],
|
||||
(byte*)des->key[1],
|
||||
(byte*)des->key[2]);
|
||||
if (status == kStatus_Success)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
|
||||
}
|
||||
#elif defined FREESCALE_MMCAU
|
||||
/*
|
||||
* Freescale mmCAU hardware DES/3DES support through the CAU/mmCAU library.
|
||||
* Documentation located in ColdFire/ColdFire+ CAU and Kinetis mmCAU
|
||||
* Software Library User Guide (See note in README).
|
||||
*/
|
||||
#include "cau_api.h"
|
||||
#include "fsl_mmcau.h"
|
||||
|
||||
const unsigned char parityLookup[128] =
|
||||
{
|
||||
@@ -648,12 +733,7 @@ int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
||||
byte temp_block[DES_BLOCK_SIZE];
|
||||
|
||||
iv = (byte*)des->reg;
|
||||
|
||||
if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
|
||||
WOLFSSL_MSG("Bad cau_des_encrypt alignment");
|
||||
return BAD_ALIGN_E;
|
||||
}
|
||||
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
XMEMCPY(temp_block, in + offset, DES_BLOCK_SIZE);
|
||||
@@ -666,7 +746,7 @@ int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
||||
if(ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
cau_des_encrypt(temp_block, (byte*)des->key, out + offset);
|
||||
MMCAU_DES_EncryptEcb(temp_block, (byte*)des->key, out + offset);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
|
||||
len -= DES_BLOCK_SIZE;
|
||||
@@ -690,11 +770,6 @@ int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
||||
|
||||
iv = (byte*)des->reg;
|
||||
|
||||
if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
|
||||
WOLFSSL_MSG("Bad cau_des_decrypt alignment");
|
||||
return BAD_ALIGN_E;
|
||||
}
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
XMEMCPY(temp_block, in + offset, DES_BLOCK_SIZE);
|
||||
@@ -703,7 +778,7 @@ int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
||||
if(ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
cau_des_decrypt(in + offset, (byte*)des->key, out + offset);
|
||||
MMCAU_DES_DecryptEcb(in + offset, (byte*)des->key, out + offset);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
|
||||
/* XOR block with IV for CBC */
|
||||
@@ -731,12 +806,7 @@ int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
||||
byte temp_block[DES_BLOCK_SIZE];
|
||||
|
||||
iv = (byte*)des->reg;
|
||||
|
||||
if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
|
||||
WOLFSSL_MSG("Bad 3ede cau_des_encrypt alignment");
|
||||
return BAD_ALIGN_E;
|
||||
}
|
||||
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
XMEMCPY(temp_block, in + offset, DES_BLOCK_SIZE);
|
||||
@@ -749,9 +819,9 @@ int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
||||
if(ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
cau_des_encrypt(temp_block , (byte*)des->key[0], out + offset);
|
||||
cau_des_decrypt(out + offset, (byte*)des->key[1], out + offset);
|
||||
cau_des_encrypt(out + offset, (byte*)des->key[2], out + offset);
|
||||
MMCAU_DES_EncryptEcb(temp_block , (byte*)des->key[0], out + offset);
|
||||
MMCAU_DES_DecryptEcb(out + offset, (byte*)des->key[1], out + offset);
|
||||
MMCAU_DES_EncryptEcb(out + offset, (byte*)des->key[2], out + offset);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
|
||||
len -= DES_BLOCK_SIZE;
|
||||
@@ -776,11 +846,6 @@ int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
||||
|
||||
iv = (byte*)des->reg;
|
||||
|
||||
if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) {
|
||||
WOLFSSL_MSG("Bad 3ede cau_des_decrypt alignment");
|
||||
return BAD_ALIGN_E;
|
||||
}
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
XMEMCPY(temp_block, in + offset, DES_BLOCK_SIZE);
|
||||
@@ -789,9 +854,9 @@ int wc_Des3_SetKey(Des3* des3, const byte* key, const byte* iv, int dir)
|
||||
if(ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
cau_des_decrypt(in + offset , (byte*)des->key[2], out + offset);
|
||||
cau_des_encrypt(out + offset, (byte*)des->key[1], out + offset);
|
||||
cau_des_decrypt(out + offset, (byte*)des->key[0], out + offset);
|
||||
MMCAU_DES_DecryptEcb(in + offset , (byte*)des->key[2], out + offset);
|
||||
MMCAU_DES_EncryptEcb(out + offset, (byte*)des->key[1], out + offset);
|
||||
MMCAU_DES_DecryptEcb(out + offset, (byte*)des->key[0], out + offset);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
|
||||
/* XOR block with IV for CBC */
|
||||
|
@@ -359,20 +359,26 @@ int wc_DsaSign(const byte* digest, byte* out, DsaKey* key, WC_RNG* rng)
|
||||
byte* tmp = out; /* initial output pointer */
|
||||
|
||||
sz = min((int)sizeof(buffer), mp_unsigned_bin_size(&key->q));
|
||||
|
||||
/* generate k */
|
||||
ret = wc_RNG_GenerateBlock(rng, buffer, sz);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
buffer[0] |= 0x0C;
|
||||
|
||||
|
||||
if (mp_init_multi(&k, &kInv, &r, &s, &H, 0) != MP_OKAY)
|
||||
return MP_INIT_E;
|
||||
|
||||
if (mp_read_unsigned_bin(&k, buffer, sz) != MP_OKAY)
|
||||
ret = MP_READ_E;
|
||||
do {
|
||||
/* generate k */
|
||||
ret = wc_RNG_GenerateBlock(rng, buffer, sz);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
buffer[0] |= 0x0C;
|
||||
|
||||
if (mp_read_unsigned_bin(&k, buffer, sz) != MP_OKAY)
|
||||
ret = MP_READ_E;
|
||||
|
||||
/* k is a random numnber and it should be less than q
|
||||
* if k greater than repeat
|
||||
*/
|
||||
} while (mp_cmp(&k, &key->q) != MP_LT);
|
||||
|
||||
if (ret == 0 && mp_cmp_d(&k, 1) != MP_GT)
|
||||
ret = MP_CMP_E;
|
||||
|
||||
|
@@ -103,6 +103,10 @@ ECC Curve Sizes:
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#if defined(FREESCALE_LTC_ECC)
|
||||
#include <wolfssl/wolfcrypt/port/nxp/ksdk_port.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_FAST_MATH
|
||||
#define GEN_MEM_ERR FP_MEM
|
||||
#else
|
||||
@@ -1645,6 +1649,7 @@ done:
|
||||
return err;
|
||||
}
|
||||
|
||||
#if !defined(FREESCALE_LTC_ECC)
|
||||
|
||||
#ifndef ECC_TIMING_RESISTANT
|
||||
|
||||
@@ -2122,6 +2127,8 @@ int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R, mp_int* a,
|
||||
#endif /* ! FP_ECC */
|
||||
#endif /* ECC_TIMING_RESISTANT */
|
||||
|
||||
#endif /* !FREESCALE_LTC_ECC */
|
||||
|
||||
|
||||
#ifdef ALT_ECC_SIZE
|
||||
|
||||
@@ -2424,7 +2431,8 @@ int wc_ecc_shared_secret_ssh(ecc_key* private_key, ecc_point* point,
|
||||
err = mp_read_radix(&a, private_key->dp->Af, 16);
|
||||
|
||||
if (err == MP_OKAY)
|
||||
err = wc_ecc_mulmod(&private_key->k, point, result, &a, &prime, 1);
|
||||
err = wc_ecc_mulmod_ex(&private_key->k, point, result, &a, &prime, 1,
|
||||
private_key->heap);
|
||||
|
||||
if (err == MP_OKAY) {
|
||||
x = mp_unsigned_bin_size(&prime);
|
||||
@@ -2580,6 +2588,12 @@ int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, int curve_id)
|
||||
err = mp_mod(&key->k, &order, &key->k);
|
||||
}
|
||||
|
||||
/* the key should be smaller than the order of base point */
|
||||
if (err == MP_OKAY) {
|
||||
if (mp_cmp(&key->k, &order) != MP_LT)
|
||||
err = mp_mod(&key->k, &order, &key->k);
|
||||
}
|
||||
|
||||
/* make the public key */
|
||||
if (err == MP_OKAY)
|
||||
err = wc_ecc_mulmod_ex(&key->k, base, &key->pubkey, &a, &prime, 1,
|
||||
@@ -3363,6 +3377,15 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
||||
if (err == MP_OKAY)
|
||||
err = mp_copy(key->pubkey.z, mQ->z);
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
/* use PKHA to compute u1*mG + u2*mQ */
|
||||
if (err == MP_OKAY)
|
||||
err = wc_ecc_mulmod_ex(&u1, mG, mG, &a, &modulus, 0, NULL);
|
||||
if (err == MP_OKAY)
|
||||
err = wc_ecc_mulmod_ex(&u2, mQ, mQ, &a, &modulus, 0, NULL);
|
||||
if (err == MP_OKAY)
|
||||
err = wc_ecc_point_add(mG, mQ, mG, &modulus);
|
||||
#else /* FREESCALE_LTC_ECC */
|
||||
#ifndef ECC_SHAMIR
|
||||
{
|
||||
mp_digit mp;
|
||||
@@ -3390,7 +3413,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
||||
if (err == MP_OKAY)
|
||||
err = ecc_mul2add(mG, &u1, mQ, &u2, mG, &a, &modulus, key->heap);
|
||||
#endif /* ECC_SHAMIR */
|
||||
|
||||
#endif /* FREESCALE_LTC_ECC */
|
||||
/* v = X_x1 mod n */
|
||||
if (err == MP_OKAY)
|
||||
err = mp_mod(mG->x, &order, &v);
|
||||
@@ -5639,6 +5662,7 @@ int ecc_mul2add(ecc_point* A, mp_int* kA,
|
||||
}
|
||||
#endif /* ECC_SHAMIR */
|
||||
|
||||
#if !defined(FREESCALE_LTC_TFM)
|
||||
/** ECC Fixed Point mulmod global
|
||||
k The multiplicand
|
||||
G Base point to multiply
|
||||
@@ -5654,7 +5678,7 @@ int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R, mp_int* a,
|
||||
{
|
||||
return wc_ecc_mulmod_ex(k, G, R, a, modulus, map, NULL);
|
||||
}
|
||||
|
||||
#endif /* !FREESCALE_LTC_TFM */
|
||||
|
||||
/** ECC Fixed Point mulmod global
|
||||
k The multiplicand
|
||||
|
@@ -41,6 +41,10 @@
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
#include <wolfssl/wolfcrypt/port/nxp/ksdk_port.h>
|
||||
#endif
|
||||
|
||||
/* generate an ed25519 key pair.
|
||||
* returns 0 on success
|
||||
*/
|
||||
@@ -48,7 +52,9 @@ int wc_ed25519_make_key(WC_RNG* rng, int keySz, ed25519_key* key)
|
||||
{
|
||||
byte az[ED25519_PRV_KEY_SIZE];
|
||||
int ret;
|
||||
#if !defined(FREESCALE_LTC_ECC)
|
||||
ge_p3 A;
|
||||
#endif
|
||||
|
||||
if (rng == NULL || key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
@@ -71,9 +77,16 @@ int wc_ed25519_make_key(WC_RNG* rng, int keySz, ed25519_key* key)
|
||||
az[31] &= 63; /* same than az[31] &= 127 because of az[31] |= 64 */
|
||||
az[31] |= 64;
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ltc_pkha_ecc_point_t publicKey = {0};
|
||||
publicKey.X = key->pointX;
|
||||
publicKey.Y = key->pointY;
|
||||
LTC_PKHA_Ed25519_PointMul(LTC_PKHA_Ed25519_BasePoint(), az, ED25519_KEY_SIZE, &publicKey, kLTC_Ed25519 /* result on Ed25519 */);
|
||||
LTC_PKHA_Ed25519_Compress(&publicKey, key->p);
|
||||
#else
|
||||
ge_scalarmult_base(&A, az);
|
||||
ge_p3_tobytes(key->p, &A);
|
||||
|
||||
#endif
|
||||
/* put public key after private key, on the same buffer */
|
||||
XMEMMOVE(key->k + ED25519_KEY_SIZE, key->p, ED25519_PUB_KEY_SIZE);
|
||||
|
||||
@@ -94,8 +107,12 @@ int wc_ed25519_make_key(WC_RNG* rng, int keySz, ed25519_key* key)
|
||||
int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
|
||||
word32 *outLen, ed25519_key* key)
|
||||
{
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
byte tempBuf[ED25519_PRV_KEY_SIZE];
|
||||
#else
|
||||
ge_p3 R;
|
||||
byte nonce[SHA512_DIGEST_SIZE];
|
||||
#endif
|
||||
byte nonce[SHA512_DIGEST_SIZE];
|
||||
byte hram[SHA512_DIGEST_SIZE];
|
||||
byte az[ED25519_PRV_KEY_SIZE];
|
||||
Sha512 sha;
|
||||
@@ -136,12 +153,21 @@ int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
ltc_pkha_ecc_point_t ltcPoint = {0};
|
||||
ltcPoint.X = &tempBuf[0];
|
||||
ltcPoint.Y = &tempBuf[32];
|
||||
LTC_PKHA_sc_reduce(nonce);
|
||||
LTC_PKHA_Ed25519_PointMul(LTC_PKHA_Ed25519_BasePoint(), nonce, ED25519_KEY_SIZE, <cPoint, kLTC_Ed25519 /* result on Ed25519 */);
|
||||
LTC_PKHA_Ed25519_Compress(<cPoint, out);
|
||||
#else
|
||||
sc_reduce(nonce);
|
||||
|
||||
/* step 2: computing R = rB where rB is the scalar multiplication of
|
||||
r and B */
|
||||
ge_scalarmult_base(&R,nonce);
|
||||
ge_p3_tobytes(out,&R);
|
||||
#endif
|
||||
|
||||
/* step 3: hash R + public key + message getting H(R,A,M) then
|
||||
creating S = (r + H(R,A,M)a) mod l */
|
||||
@@ -161,8 +187,13 @@ int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
LTC_PKHA_sc_reduce(hram);
|
||||
LTC_PKHA_sc_muladd(out + (ED25519_SIG_SIZE/2), hram, az, nonce);
|
||||
#else
|
||||
sc_reduce(hram);
|
||||
sc_muladd(out + (ED25519_SIG_SIZE/2), hram, az, nonce);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -184,8 +215,10 @@ int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg,
|
||||
{
|
||||
byte rcheck[ED25519_KEY_SIZE];
|
||||
byte h[SHA512_DIGEST_SIZE];
|
||||
#ifndef FREESCALE_LTC_ECC
|
||||
ge_p3 A;
|
||||
ge_p2 R;
|
||||
#endif
|
||||
int ret;
|
||||
Sha512 sha;
|
||||
|
||||
@@ -201,8 +234,10 @@ int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg,
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* uncompress A (public key), test if valid, and negate it */
|
||||
#ifndef FREESCALE_LTC_ECC
|
||||
if (ge_frombytes_negate_vartime(&A, key->p) != 0)
|
||||
return BAD_FUNC_ARG;
|
||||
#endif
|
||||
|
||||
/* find H(R,A,M) and store it as h */
|
||||
ret = wc_InitSha512(&sha);
|
||||
@@ -221,6 +256,10 @@ int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg,
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
LTC_PKHA_sc_reduce(h);
|
||||
LTC_PKHA_SignatureForVerify(rcheck, h, sig + (ED25519_SIG_SIZE/2), key);
|
||||
#else
|
||||
sc_reduce(h);
|
||||
|
||||
/*
|
||||
@@ -232,6 +271,7 @@ int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg,
|
||||
return ret;
|
||||
|
||||
ge_tobytes(rcheck, &R);
|
||||
#endif /* FREESCALE_LTC_ECC */
|
||||
|
||||
/* comparison of R created to R in sig */
|
||||
ret = ConstantCompare(rcheck, sig, ED25519_SIG_SIZE/2);
|
||||
@@ -319,14 +359,32 @@ int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key)
|
||||
if (in[0] == 0x40 && inLen > ED25519_PUB_KEY_SIZE) {
|
||||
/* key is stored in compressed format so just copy in */
|
||||
XMEMCPY(key->p, (in + 1), ED25519_PUB_KEY_SIZE);
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
/* recover X coordinate */
|
||||
ltc_pkha_ecc_point_t pubKey;
|
||||
pubKey.X = key->pointX;
|
||||
pubKey.Y = key->pointY;
|
||||
LTC_PKHA_Ed25519_PointDecompress(key->p, ED25519_PUB_KEY_SIZE, &pubKey);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* importing uncompressed public key */
|
||||
if (in[0] == 0x04 && inLen > 2*ED25519_PUB_KEY_SIZE) {
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
/* reverse bytes for little endian byte order */
|
||||
for (int i = 0; i < ED25519_KEY_SIZE; i++)
|
||||
{
|
||||
key->pointX[i] = *(in + ED25519_KEY_SIZE - i);
|
||||
key->pointY[i] = *(in + 2*ED25519_KEY_SIZE - i);
|
||||
}
|
||||
XMEMCPY(key->p, key->pointY, ED25519_KEY_SIZE);
|
||||
ret = 0;
|
||||
#else
|
||||
/* pass in (x,y) and store compressed key */
|
||||
ret = ge_compress_key(key->p, in+1,
|
||||
in+1+ED25519_PUB_KEY_SIZE, ED25519_PUB_KEY_SIZE);
|
||||
#endif /* FREESCALE_LTC_ECC */
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -334,6 +392,13 @@ int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key)
|
||||
if key size is equal to compressed key size copy in key */
|
||||
if (inLen == ED25519_PUB_KEY_SIZE) {
|
||||
XMEMCPY(key->p, in, ED25519_PUB_KEY_SIZE);
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
/* recover X coordinate */
|
||||
ltc_pkha_ecc_point_t pubKey;
|
||||
pubKey.X = key->pointX;
|
||||
pubKey.Y = key->pointY;
|
||||
LTC_PKHA_Ed25519_PointDecompress(key->p, ED25519_PUB_KEY_SIZE, &pubKey);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -130,7 +130,7 @@ static void xc_diffadd(byte *x5, byte *z5,
|
||||
fe_mul__distinct(z5, x1, b);
|
||||
}
|
||||
|
||||
|
||||
#ifndef FREESCALE_LTC_ECC
|
||||
int curve25519(byte *result, byte *e, byte *q)
|
||||
{
|
||||
/* Current point: P_m */
|
||||
@@ -174,7 +174,7 @@ int curve25519(byte *result, byte *e, byte *q)
|
||||
fe_normalize(result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !FREESCALE_LTC_ECC */
|
||||
|
||||
static void raw_add(byte *x, const byte *p)
|
||||
{
|
||||
|
@@ -107,7 +107,7 @@ void fe_0(fe h)
|
||||
h[9] = 0;
|
||||
}
|
||||
|
||||
|
||||
#ifndef FREESCALE_LTC_ECC
|
||||
int curve25519(byte* q, byte* n, byte* p)
|
||||
{
|
||||
#if 0
|
||||
@@ -183,7 +183,7 @@ int curve25519(byte* q, byte* n, byte* p)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !FREESCALE_LTC_ECC */
|
||||
|
||||
/*
|
||||
h = f * f
|
||||
|
@@ -45,8 +45,9 @@ EXTRA_DIST += wolfcrypt/src/port/ti/ti-aes.c \
|
||||
wolfcrypt/src/port/ti/ti-ccm.c \
|
||||
wolfcrypt/src/port/pic32/pic32mz-hash.c \
|
||||
wolfcrypt/src/port/nrf51.c \
|
||||
wolfcrypt/src/port/arm/armv8-aes.c \
|
||||
wolfcrypt/src/port/arm/armv8-sha256.c \
|
||||
wolfcrypt/src/port/arm/armv8-aes.c
|
||||
wolfssl/wolfcrypt/port/nxp/ksdk_port.c
|
||||
|
||||
if BUILD_CAVIUM
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/cavium/cavium_nitrox.c
|
||||
|
@@ -49,8 +49,8 @@
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#ifdef FREESCALE_MMCAU
|
||||
#include "cau_api.h"
|
||||
#ifdef FREESCALE_MMCAU_SHA
|
||||
#include "fsl_mmcau.h"
|
||||
#define XTRANSFORM(S,B) Transform((S), (B))
|
||||
#else
|
||||
#define XTRANSFORM(S,B) Transform((S))
|
||||
@@ -195,19 +195,19 @@ void wc_InitMd5(Md5* md5)
|
||||
md5->hiLen = 0;
|
||||
}
|
||||
|
||||
#ifdef FREESCALE_MMCAU
|
||||
#ifdef FREESCALE_MMCAU_SHA
|
||||
static int Transform(Md5* md5, byte* data)
|
||||
{
|
||||
int ret = wolfSSL_CryptHwMutexLock();
|
||||
if(ret == 0) {
|
||||
cau_md5_hash_n(data, 1, (unsigned char*)md5->digest);
|
||||
MMCAU_MD5_HashN(data, 1, (uint32_t*)(md5->digest));
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif /* FREESCALE_MMCAU */
|
||||
#endif /* FREESCALE_MMCAU_SHA */
|
||||
|
||||
#ifndef FREESCALE_MMCAU
|
||||
#ifndef FREESCALE_MMCAU_SHA
|
||||
|
||||
static void Transform(Md5* md5)
|
||||
{
|
||||
@@ -325,7 +325,7 @@ void wc_Md5Update(Md5* md5, const byte* data, word32 len)
|
||||
len -= add;
|
||||
|
||||
if (md5->buffLen == MD5_BLOCK_SIZE) {
|
||||
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
|
||||
ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
|
||||
#endif
|
||||
XTRANSFORM(md5, local);
|
||||
@@ -349,7 +349,7 @@ void wc_Md5Final(Md5* md5, byte* hash)
|
||||
XMEMSET(&local[md5->buffLen], 0, MD5_BLOCK_SIZE - md5->buffLen);
|
||||
md5->buffLen += MD5_BLOCK_SIZE - md5->buffLen;
|
||||
|
||||
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
|
||||
ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
|
||||
#endif
|
||||
XTRANSFORM(md5, local);
|
||||
@@ -363,7 +363,7 @@ void wc_Md5Final(Md5* md5, byte* hash)
|
||||
md5->loLen = md5->loLen << 3;
|
||||
|
||||
/* store lengths */
|
||||
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
|
||||
ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
|
||||
#endif
|
||||
/* ! length ordering dependent on digest endian type ! */
|
||||
|
1625
wolfcrypt/src/port/nxp/ksdk_port.c
Executable file
1625
wolfcrypt/src/port/nxp/ksdk_port.c
Executable file
File diff suppressed because it is too large
Load Diff
@@ -157,6 +157,10 @@ int wc_FreeRng(WC_RNG* rng)
|
||||
#ifndef EBSNET
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#elif defined(FREESCALE_KSDK_2_0_TRNG)
|
||||
#include "fsl_trng.h"
|
||||
#elif defined(FREESCALE_KSDK_2_0_RNGA)
|
||||
#include "fsl_rnga.h"
|
||||
#else
|
||||
/* include headers that may be needed to get good seed */
|
||||
#endif
|
||||
@@ -1356,12 +1360,36 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(FREESCALE_TRNG)
|
||||
#elif defined(FREESCALE_KSDK_2_0_TRNG)
|
||||
|
||||
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||
{
|
||||
TRNG_DRV_GetRandomData(TRNG_INSTANCE, output, sz);
|
||||
return 0;
|
||||
status_t status;
|
||||
status = TRNG_GetRandomData(TRNG0, output, sz);
|
||||
if (status == kStatus_Success)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return RAN_BLOCK_E;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(FREESCALE_KSDK_2_0_RNGA)
|
||||
|
||||
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||
{
|
||||
status_t status;
|
||||
status = RNGA_GetRandomData(RNG, output, sz);
|
||||
if (status == kStatus_Success)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return RAN_BLOCK_E;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1161,7 +1161,7 @@ int wc_RsaFunction(const byte* in, word32 inLen, byte* out,
|
||||
outLen: length of encrypted output buffer
|
||||
key : wolfSSL initialized RSA key struct
|
||||
rng : wolfSSL initialized random number struct
|
||||
rsa_type : type of RSA: RSA_PUBLIC_ENCRYPT, RSA_PUBLIC_DECRYPT,
|
||||
rsa_type : type of RSA: RSA_PUBLIC_ENCRYPT, RSA_PUBLIC_DECRYPT,
|
||||
RSA_PRIVATE_ENCRYPT or RSA_PRIVATE_DECRYPT
|
||||
pad_value: RSA_BLOCK_TYPE_1 or RSA_BLOCK_TYPE_2
|
||||
pad_type : type of padding: WC_RSA_PKCSV15_PAD or WC_RSA_OAEP_PAD
|
||||
@@ -1256,7 +1256,7 @@ static int RsaPublicEncryptEx(const byte* in, word32 inLen, byte* out,
|
||||
outLen: length of decrypted message in bytes
|
||||
outPtr: optional inline output pointer (if provided doing inline)
|
||||
key : wolfSSL initialized RSA key struct
|
||||
rsa_type : type of RSA: RSA_PUBLIC_ENCRYPT, RSA_PUBLIC_DECRYPT,
|
||||
rsa_type : type of RSA: RSA_PUBLIC_ENCRYPT, RSA_PUBLIC_DECRYPT,
|
||||
RSA_PRIVATE_ENCRYPT or RSA_PRIVATE_DECRYPT
|
||||
pad_value: RSA_BLOCK_TYPE_1 or RSA_BLOCK_TYPE_2
|
||||
pad_type : type of padding: WC_RSA_PKCSV15_PAD or WC_RSA_OAEP_PAD
|
||||
@@ -1403,7 +1403,7 @@ int wc_RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out, RsaKey* key)
|
||||
#ifdef WC_RSA_BLINDING
|
||||
rng = key->rng;
|
||||
#endif
|
||||
return RsaPrivateDecryptEx(in, inLen, in, inLen, out, key,
|
||||
return RsaPrivateDecryptEx(in, inLen, in, inLen, out, key,
|
||||
RSA_PRIVATE_DECRYPT, RSA_BLOCK_TYPE_2, WC_RSA_PKCSV15_PAD,
|
||||
WC_HASH_TYPE_NONE, WC_MGF1NONE, NULL, 0, rng);
|
||||
}
|
||||
@@ -1418,7 +1418,7 @@ int wc_RsaPrivateDecryptInline_ex(byte* in, word32 inLen, byte** out,
|
||||
#ifdef WC_RSA_BLINDING
|
||||
rng = key->rng;
|
||||
#endif
|
||||
return RsaPrivateDecryptEx(in, inLen, in, inLen, out, key,
|
||||
return RsaPrivateDecryptEx(in, inLen, in, inLen, out, key,
|
||||
RSA_PRIVATE_DECRYPT, RSA_BLOCK_TYPE_2, type, hash,
|
||||
mgf, label, labelSz, rng);
|
||||
}
|
||||
@@ -1461,7 +1461,7 @@ int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out, RsaKey* key)
|
||||
#ifdef WC_RSA_BLINDING
|
||||
rng = key->rng;
|
||||
#endif
|
||||
return RsaPrivateDecryptEx(in, inLen, in, inLen, out, key,
|
||||
return RsaPrivateDecryptEx(in, inLen, in, inLen, out, key,
|
||||
RSA_PUBLIC_DECRYPT, RSA_BLOCK_TYPE_1, WC_RSA_PKCSV15_PAD,
|
||||
WC_HASH_TYPE_NONE, WC_MGF1NONE, NULL, 0, rng);
|
||||
}
|
||||
@@ -1473,7 +1473,7 @@ int wc_RsaSSL_Verify(const byte* in, word32 inLen, byte* out, word32 outLen,
|
||||
#ifdef WC_RSA_BLINDING
|
||||
rng = key->rng;
|
||||
#endif
|
||||
return RsaPrivateDecryptEx((byte*)in, inLen, out, outLen, NULL, key,
|
||||
return RsaPrivateDecryptEx((byte*)in, inLen, out, outLen, NULL, key,
|
||||
RSA_PUBLIC_DECRYPT, RSA_BLOCK_TYPE_1, WC_RSA_PKCSV15_PAD,
|
||||
WC_HASH_TYPE_NONE, WC_MGF1NONE, NULL, 0, rng);
|
||||
}
|
||||
@@ -1619,16 +1619,16 @@ int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng)
|
||||
err = mp_copy(&q, &key->q);
|
||||
|
||||
if (err == MP_OKAY)
|
||||
key->type = RSA_PRIVATE;
|
||||
key->type = RSA_PRIVATE;
|
||||
|
||||
mp_clear(&tmp3);
|
||||
mp_clear(&tmp2);
|
||||
mp_clear(&tmp1);
|
||||
mp_clear(&q);
|
||||
mp_clear(&tmp3);
|
||||
mp_clear(&tmp2);
|
||||
mp_clear(&tmp1);
|
||||
mp_clear(&q);
|
||||
mp_clear(&p);
|
||||
|
||||
if (err != MP_OKAY) {
|
||||
wc_FreeRsaKey(key);
|
||||
wc_FreeRsaKey(key);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@@ -20,13 +20,13 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
|
||||
#if !defined(NO_SHA)
|
||||
|
||||
#include <wolfssl/wolfcrypt/sha.h>
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
|
||||
/* fips wrapper calls, user can call direct */
|
||||
#ifdef HAVE_FIPS
|
||||
int wc_InitSha(Sha* sha)
|
||||
@@ -47,13 +48,11 @@
|
||||
return InitSha_fips(sha);
|
||||
}
|
||||
|
||||
|
||||
int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
|
||||
{
|
||||
return ShaUpdate_fips(sha, data, len);
|
||||
}
|
||||
|
||||
|
||||
int wc_ShaFinal(Sha* sha, byte* out)
|
||||
{
|
||||
return ShaFinal_fips(sha,out);
|
||||
@@ -61,292 +60,332 @@
|
||||
|
||||
#else /* else build without fips */
|
||||
|
||||
|
||||
/****************************************/
|
||||
/* SHA Hardware Variations */
|
||||
/****************************************/
|
||||
#if defined(WOLFSSL_TI_HASH)
|
||||
/* #include <wolfcrypt/src/port/ti/ti-hash.c> included by wc_port.c */
|
||||
#else
|
||||
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
#define wc_InitSha wc_InitSha_sw
|
||||
#define wc_ShaUpdate wc_ShaUpdate_sw
|
||||
#define wc_ShaFinal wc_ShaFinal_sw
|
||||
#endif
|
||||
#elif defined(WOLFSSL_PIC32MZ_HASH)
|
||||
#define USE_SHA_SOFTWARE_IMPL
|
||||
#define wc_InitSha wc_InitSha_sw
|
||||
#define wc_ShaUpdate wc_ShaUpdate_sw
|
||||
#define wc_ShaFinal wc_ShaFinal_sw
|
||||
|
||||
|
||||
#ifdef FREESCALE_MMCAU
|
||||
#include "cau_api.h"
|
||||
#define XTRANSFORM(S,B) Transform((S), (B))
|
||||
#else
|
||||
#define XTRANSFORM(S,B) Transform((S))
|
||||
#endif
|
||||
|
||||
#ifdef STM32F2_HASH
|
||||
/*
|
||||
* STM32F2 hardware SHA1 support through the STM32F2 standard peripheral
|
||||
* library. Documentation located in STM32F2xx Standard Peripheral Library
|
||||
* document (See note in README).
|
||||
*/
|
||||
#include "stm32f2xx.h"
|
||||
#include "stm32f2xx_hash.h"
|
||||
|
||||
int wc_InitSha(Sha* sha)
|
||||
{
|
||||
/* STM32F2 struct notes:
|
||||
* sha->buffer = first 4 bytes used to hold partial block if needed
|
||||
* sha->buffLen = num bytes currently stored in sha->buffer
|
||||
* sha->loLen = num bytes that have been written to STM32 FIFO
|
||||
#elif defined(STM32F2_HASH)
|
||||
/*
|
||||
* STM32F2 hardware SHA1 support through the STM32F2 standard peripheral
|
||||
* library. Documentation located in STM32F2xx Standard Peripheral Library
|
||||
* document (See note in README).
|
||||
*/
|
||||
XMEMSET(sha->buffer, 0, SHA_REG_SIZE);
|
||||
sha->buffLen = 0;
|
||||
sha->loLen = 0;
|
||||
#include "stm32f2xx.h"
|
||||
#include "stm32f2xx_hash.h"
|
||||
|
||||
/* initialize HASH peripheral */
|
||||
HASH_DeInit();
|
||||
int wc_InitSha(Sha* sha)
|
||||
{
|
||||
/* STM32F2 struct notes:
|
||||
* sha->buffer = first 4 bytes used to hold partial block if needed
|
||||
* sha->buffLen = num bytes currently stored in sha->buffer
|
||||
* sha->loLen = num bytes that have been written to STM32 FIFO
|
||||
*/
|
||||
XMEMSET(sha->buffer, 0, SHA_REG_SIZE);
|
||||
sha->buffLen = 0;
|
||||
sha->loLen = 0;
|
||||
|
||||
/* configure algo used, algo mode, datatype */
|
||||
HASH->CR &= ~ (HASH_CR_ALGO | HASH_CR_DATATYPE | HASH_CR_MODE);
|
||||
HASH->CR |= (HASH_AlgoSelection_SHA1 | HASH_AlgoMode_HASH
|
||||
| HASH_DataType_8b);
|
||||
/* initialize HASH peripheral */
|
||||
HASH_DeInit();
|
||||
|
||||
/* reset HASH processor */
|
||||
HASH->CR |= HASH_CR_INIT;
|
||||
/* configure algo used, algo mode, datatype */
|
||||
HASH->CR &= ~ (HASH_CR_ALGO | HASH_CR_DATATYPE | HASH_CR_MODE);
|
||||
HASH->CR |= (HASH_AlgoSelection_SHA1 | HASH_AlgoMode_HASH
|
||||
| HASH_DataType_8b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* reset HASH processor */
|
||||
HASH->CR |= HASH_CR_INIT;
|
||||
|
||||
int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
|
||||
{
|
||||
word32 i = 0;
|
||||
word32 fill = 0;
|
||||
word32 diff = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if saved partial block is available */
|
||||
if (sha->buffLen) {
|
||||
fill = 4 - sha->buffLen;
|
||||
int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
|
||||
{
|
||||
word32 i = 0;
|
||||
word32 fill = 0;
|
||||
word32 diff = 0;
|
||||
|
||||
/* if enough data to fill, fill and push to FIFO */
|
||||
if (fill <= len) {
|
||||
XMEMCPY((byte*)sha->buffer + sha->buffLen, data, fill);
|
||||
/* if saved partial block is available */
|
||||
if (sha->buffLen) {
|
||||
fill = 4 - sha->buffLen;
|
||||
|
||||
/* if enough data to fill, fill and push to FIFO */
|
||||
if (fill <= len) {
|
||||
XMEMCPY((byte*)sha->buffer + sha->buffLen, data, fill);
|
||||
HASH_DataIn(*(uint32_t*)sha->buffer);
|
||||
|
||||
data += fill;
|
||||
len -= fill;
|
||||
sha->loLen += 4;
|
||||
sha->buffLen = 0;
|
||||
} else {
|
||||
/* append partial to existing stored block */
|
||||
XMEMCPY((byte*)sha->buffer + sha->buffLen, data, len);
|
||||
sha->buffLen += len;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* write input block in the IN FIFO */
|
||||
for(i = 0; i < len; i += 4)
|
||||
{
|
||||
diff = len - i;
|
||||
if ( diff < 4) {
|
||||
/* store incomplete last block, not yet in FIFO */
|
||||
XMEMSET(sha->buffer, 0, SHA_REG_SIZE);
|
||||
XMEMCPY((byte*)sha->buffer, data, diff);
|
||||
sha->buffLen = diff;
|
||||
} else {
|
||||
HASH_DataIn(*(uint32_t*)data);
|
||||
data+=4;
|
||||
}
|
||||
}
|
||||
|
||||
/* keep track of total data length thus far */
|
||||
sha->loLen += (len - sha->buffLen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wc_ShaFinal(Sha* sha, byte* hash)
|
||||
{
|
||||
__IO uint16_t nbvalidbitsdata = 0;
|
||||
|
||||
/* finish reading any trailing bytes into FIFO */
|
||||
if (sha->buffLen) {
|
||||
HASH_DataIn(*(uint32_t*)sha->buffer);
|
||||
|
||||
data += fill;
|
||||
len -= fill;
|
||||
sha->loLen += 4;
|
||||
sha->buffLen = 0;
|
||||
} else {
|
||||
/* append partial to existing stored block */
|
||||
XMEMCPY((byte*)sha->buffer + sha->buffLen, data, len);
|
||||
sha->buffLen += len;
|
||||
return 0;
|
||||
sha->loLen += sha->buffLen;
|
||||
}
|
||||
|
||||
/* calculate number of valid bits in last word of input data */
|
||||
nbvalidbitsdata = 8 * (sha->loLen % SHA_REG_SIZE);
|
||||
|
||||
/* configure number of valid bits in last word of the data */
|
||||
HASH_SetLastWordValidBitsNbr(nbvalidbitsdata);
|
||||
|
||||
/* start HASH processor */
|
||||
HASH_StartDigest();
|
||||
|
||||
/* wait until Busy flag == RESET */
|
||||
while (HASH_GetFlagStatus(HASH_FLAG_BUSY) != RESET) {}
|
||||
|
||||
/* read message digest */
|
||||
sha->digest[0] = HASH->HR[0];
|
||||
sha->digest[1] = HASH->HR[1];
|
||||
sha->digest[2] = HASH->HR[2];
|
||||
sha->digest[3] = HASH->HR[3];
|
||||
sha->digest[4] = HASH->HR[4];
|
||||
|
||||
ByteReverseWords(sha->digest, sha->digest, SHA_DIGEST_SIZE);
|
||||
|
||||
XMEMCPY(hash, sha->digest, SHA_DIGEST_SIZE);
|
||||
|
||||
return wc_InitSha(sha); /* reset state */
|
||||
}
|
||||
|
||||
/* write input block in the IN FIFO */
|
||||
for(i = 0; i < len; i += 4)
|
||||
|
||||
#elif defined(FREESCALE_LTC_SHA)
|
||||
|
||||
#include "fsl_ltc.h"
|
||||
int wc_InitSha(Sha* sha)
|
||||
{
|
||||
diff = len - i;
|
||||
if ( diff < 4) {
|
||||
/* store incomplete last block, not yet in FIFO */
|
||||
XMEMSET(sha->buffer, 0, SHA_REG_SIZE);
|
||||
XMEMCPY((byte*)sha->buffer, data, diff);
|
||||
sha->buffLen = diff;
|
||||
} else {
|
||||
HASH_DataIn(*(uint32_t*)data);
|
||||
data+=4;
|
||||
LTC_HASH_Init(LTC_BASE, &sha->ctx, kLTC_Sha1, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
|
||||
{
|
||||
LTC_HASH_Update(&sha->ctx, data, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wc_ShaFinal(Sha* sha, byte* hash)
|
||||
{
|
||||
uint32_t hashlen = SHA_DIGEST_SIZE;
|
||||
LTC_HASH_Finish(&sha->ctx, hash, &hashlen);
|
||||
return wc_InitSha(sha); /* reset state */
|
||||
}
|
||||
|
||||
|
||||
#elif defined(FREESCALE_MMCAU_SHA)
|
||||
|
||||
#include "fsl_mmcau.h"
|
||||
#define USE_SHA_SOFTWARE_IMPL /* Only for API's, actual transform is here */
|
||||
#define XSHATRANSFORM ShaTransform
|
||||
|
||||
int wc_InitSha(Sha* sha)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = wolfSSL_CryptHwMutexLock();
|
||||
if(ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
MMCAU_SHA1_InitializeOutput((uint32_t*)sha->digest);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
|
||||
/* keep track of total data length thus far */
|
||||
sha->loLen += (len - sha->buffLen);
|
||||
sha->buffLen = 0;
|
||||
sha->loLen = 0;
|
||||
sha->hiLen = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wc_ShaFinal(Sha* sha, byte* hash)
|
||||
{
|
||||
__IO uint16_t nbvalidbitsdata = 0;
|
||||
|
||||
/* finish reading any trailing bytes into FIFO */
|
||||
if (sha->buffLen) {
|
||||
HASH_DataIn(*(uint32_t*)sha->buffer);
|
||||
sha->loLen += sha->buffLen;
|
||||
}
|
||||
|
||||
/* calculate number of valid bits in last word of input data */
|
||||
nbvalidbitsdata = 8 * (sha->loLen % SHA_REG_SIZE);
|
||||
|
||||
/* configure number of valid bits in last word of the data */
|
||||
HASH_SetLastWordValidBitsNbr(nbvalidbitsdata);
|
||||
|
||||
/* start HASH processor */
|
||||
HASH_StartDigest();
|
||||
|
||||
/* wait until Busy flag == RESET */
|
||||
while (HASH_GetFlagStatus(HASH_FLAG_BUSY) != RESET) {}
|
||||
|
||||
/* read message digest */
|
||||
sha->digest[0] = HASH->HR[0];
|
||||
sha->digest[1] = HASH->HR[1];
|
||||
sha->digest[2] = HASH->HR[2];
|
||||
sha->digest[3] = HASH->HR[3];
|
||||
sha->digest[4] = HASH->HR[4];
|
||||
|
||||
ByteReverseWords(sha->digest, sha->digest, SHA_DIGEST_SIZE);
|
||||
|
||||
XMEMCPY(hash, sha->digest, SHA_DIGEST_SIZE);
|
||||
|
||||
return wc_InitSha(sha); /* reset state */
|
||||
}
|
||||
|
||||
#else /* wc_ software implementation */
|
||||
|
||||
#ifndef WOLFSSL_HAVE_MIN
|
||||
#define WOLFSSL_HAVE_MIN
|
||||
|
||||
static INLINE word32 min(word32 a, word32 b)
|
||||
{
|
||||
return a > b ? b : a;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_MIN */
|
||||
|
||||
|
||||
int wc_InitSha(Sha* sha)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef FREESCALE_MMCAU
|
||||
ret = wolfSSL_CryptHwMutexLock();
|
||||
if(ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
cau_sha1_initialize_output(sha->digest);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
|
||||
static int ShaTransform(Sha* sha, byte* data)
|
||||
{
|
||||
int ret = wolfSSL_CryptHwMutexLock();
|
||||
if(ret == 0) {
|
||||
MMCAU_SHA1_HashN(data, 1, (uint32_t*)sha->digest);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
sha->digest[0] = 0x67452301L;
|
||||
sha->digest[1] = 0xEFCDAB89L;
|
||||
sha->digest[2] = 0x98BADCFEL;
|
||||
sha->digest[3] = 0x10325476L;
|
||||
sha->digest[4] = 0xC3D2E1F0L;
|
||||
|
||||
/* Software implementation */
|
||||
#define USE_SHA_SOFTWARE_IMPL
|
||||
|
||||
int wc_InitSha(Sha* sha)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
sha->digest[0] = 0x67452301L;
|
||||
sha->digest[1] = 0xEFCDAB89L;
|
||||
sha->digest[2] = 0x98BADCFEL;
|
||||
sha->digest[3] = 0x10325476L;
|
||||
sha->digest[4] = 0xC3D2E1F0L;
|
||||
|
||||
sha->buffLen = 0;
|
||||
sha->loLen = 0;
|
||||
sha->hiLen = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
sha->buffLen = 0;
|
||||
sha->loLen = 0;
|
||||
sha->hiLen = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
/* Software implementation */
|
||||
#ifdef USE_SHA_SOFTWARE_IMPL
|
||||
|
||||
#ifdef FREESCALE_MMCAU
|
||||
static int Transform(Sha* sha, byte* data)
|
||||
{
|
||||
int ret = wolfSSL_CryptHwMutexLock();
|
||||
if(ret == 0) {
|
||||
cau_sha1_hash_n(data, 1, sha->digest);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
/* Check if custom Sha transform is used */
|
||||
#ifndef XSHATRANSFORM
|
||||
#define XSHATRANSFORM ShaTransform
|
||||
|
||||
#define blk0(i) (W[i] = sha->buffer[i])
|
||||
#define blk1(i) (W[(i)&15] = \
|
||||
rotlFixed(W[((i)+13)&15]^W[((i)+8)&15]^W[((i)+2)&15]^W[(i)&15],1))
|
||||
|
||||
#define f1(x,y,z) ((z)^((x) &((y)^(z))))
|
||||
#define f2(x,y,z) ((x)^(y)^(z))
|
||||
#define f3(x,y,z) (((x)&(y))|((z)&((x)|(y))))
|
||||
#define f4(x,y,z) ((x)^(y)^(z))
|
||||
|
||||
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
|
||||
#define R0(v,w,x,y,z,i) (z)+= f1((w),(x),(y)) + blk0((i)) + 0x5A827999+ \
|
||||
rotlFixed((v),5); (w) = rotlFixed((w),30);
|
||||
#define R1(v,w,x,y,z,i) (z)+= f1((w),(x),(y)) + blk1((i)) + 0x5A827999+ \
|
||||
rotlFixed((v),5); (w) = rotlFixed((w),30);
|
||||
#define R2(v,w,x,y,z,i) (z)+= f2((w),(x),(y)) + blk1((i)) + 0x6ED9EBA1+ \
|
||||
rotlFixed((v),5); (w) = rotlFixed((w),30);
|
||||
#define R3(v,w,x,y,z,i) (z)+= f3((w),(x),(y)) + blk1((i)) + 0x8F1BBCDC+ \
|
||||
rotlFixed((v),5); (w) = rotlFixed((w),30);
|
||||
#define R4(v,w,x,y,z,i) (z)+= f4((w),(x),(y)) + blk1((i)) + 0xCA62C1D6+ \
|
||||
rotlFixed((v),5); (w) = rotlFixed((w),30);
|
||||
|
||||
static void ShaTransform(Sha* sha, byte* data)
|
||||
{
|
||||
word32 W[SHA_BLOCK_SIZE / sizeof(word32)];
|
||||
|
||||
/* Copy context->state[] to working vars */
|
||||
word32 a = sha->digest[0];
|
||||
word32 b = sha->digest[1];
|
||||
word32 c = sha->digest[2];
|
||||
word32 d = sha->digest[3];
|
||||
word32 e = sha->digest[4];
|
||||
|
||||
#ifdef USE_SLOW_SHA
|
||||
word32 t, i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
R0(a, b, c, d, e, i);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
}
|
||||
|
||||
for (; i < 20; i++) {
|
||||
R1(a, b, c, d, e, i);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
}
|
||||
|
||||
for (; i < 40; i++) {
|
||||
R2(a, b, c, d, e, i);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
}
|
||||
|
||||
for (; i < 60; i++) {
|
||||
R3(a, b, c, d, e, i);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
}
|
||||
|
||||
for (; i < 80; i++) {
|
||||
R4(a, b, c, d, e, i);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
}
|
||||
#else
|
||||
/* nearly 1 K bigger in code size but 25% faster */
|
||||
/* 4 rounds of 20 operations each. Loop unrolled. */
|
||||
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
|
||||
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
|
||||
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
|
||||
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
|
||||
|
||||
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
|
||||
|
||||
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
|
||||
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
|
||||
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
|
||||
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
|
||||
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
|
||||
|
||||
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
|
||||
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
|
||||
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
|
||||
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
|
||||
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
|
||||
|
||||
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
|
||||
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
|
||||
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
|
||||
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
|
||||
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
|
||||
#endif
|
||||
|
||||
/* Add the working vars back into digest state[] */
|
||||
sha->digest[0] += a;
|
||||
sha->digest[1] += b;
|
||||
sha->digest[2] += c;
|
||||
sha->digest[3] += d;
|
||||
sha->digest[4] += e;
|
||||
|
||||
(void)data; /* Not used */
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif /* FREESCALE_MMCAU */
|
||||
|
||||
#ifndef FREESCALE_MMCAU
|
||||
#endif /* !USE_CUSTOM_SHA_TRANSFORM */
|
||||
|
||||
#define blk0(i) (W[i] = sha->buffer[i])
|
||||
#define blk1(i) (W[(i)&15] = \
|
||||
rotlFixed(W[((i)+13)&15]^W[((i)+8)&15]^W[((i)+2)&15]^W[(i)&15],1))
|
||||
|
||||
#define f1(x,y,z) ((z)^((x) &((y)^(z))))
|
||||
#define f2(x,y,z) ((x)^(y)^(z))
|
||||
#define f3(x,y,z) (((x)&(y))|((z)&((x)|(y))))
|
||||
#define f4(x,y,z) ((x)^(y)^(z))
|
||||
|
||||
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
|
||||
#define R0(v,w,x,y,z,i) (z)+= f1((w),(x),(y)) + blk0((i)) + 0x5A827999+ \
|
||||
rotlFixed((v),5); (w) = rotlFixed((w),30);
|
||||
#define R1(v,w,x,y,z,i) (z)+= f1((w),(x),(y)) + blk1((i)) + 0x5A827999+ \
|
||||
rotlFixed((v),5); (w) = rotlFixed((w),30);
|
||||
#define R2(v,w,x,y,z,i) (z)+= f2((w),(x),(y)) + blk1((i)) + 0x6ED9EBA1+ \
|
||||
rotlFixed((v),5); (w) = rotlFixed((w),30);
|
||||
#define R3(v,w,x,y,z,i) (z)+= f3((w),(x),(y)) + blk1((i)) + 0x8F1BBCDC+ \
|
||||
rotlFixed((v),5); (w) = rotlFixed((w),30);
|
||||
#define R4(v,w,x,y,z,i) (z)+= f4((w),(x),(y)) + blk1((i)) + 0xCA62C1D6+ \
|
||||
rotlFixed((v),5); (w) = rotlFixed((w),30);
|
||||
|
||||
static void Transform(Sha* sha)
|
||||
{
|
||||
word32 W[SHA_BLOCK_SIZE / sizeof(word32)];
|
||||
|
||||
/* Copy context->state[] to working vars */
|
||||
word32 a = sha->digest[0];
|
||||
word32 b = sha->digest[1];
|
||||
word32 c = sha->digest[2];
|
||||
word32 d = sha->digest[3];
|
||||
word32 e = sha->digest[4];
|
||||
|
||||
#ifdef USE_SLOW_SHA
|
||||
word32 t, i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
R0(a, b, c, d, e, i);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
#ifndef WOLFSSL_HAVE_MIN
|
||||
#define WOLFSSL_HAVE_MIN
|
||||
static INLINE word32 min(word32 a, word32 b) {
|
||||
return a > b ? b : a;
|
||||
}
|
||||
|
||||
for (; i < 20; i++) {
|
||||
R1(a, b, c, d, e, i);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
}
|
||||
|
||||
for (; i < 40; i++) {
|
||||
R2(a, b, c, d, e, i);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
}
|
||||
|
||||
for (; i < 60; i++) {
|
||||
R3(a, b, c, d, e, i);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
}
|
||||
|
||||
for (; i < 80; i++) {
|
||||
R4(a, b, c, d, e, i);
|
||||
t = e; e = d; d = c; c = b; b = a; a = t;
|
||||
}
|
||||
#else
|
||||
/* nearly 1 K bigger in code size but 25% faster */
|
||||
/* 4 rounds of 20 operations each. Loop unrolled. */
|
||||
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
|
||||
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
|
||||
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
|
||||
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
|
||||
|
||||
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
|
||||
|
||||
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
|
||||
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
|
||||
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
|
||||
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
|
||||
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
|
||||
|
||||
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
|
||||
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
|
||||
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
|
||||
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
|
||||
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
|
||||
|
||||
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
|
||||
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
|
||||
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
|
||||
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
|
||||
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
|
||||
#endif
|
||||
|
||||
/* Add the working vars back into digest state[] */
|
||||
sha->digest[0] += a;
|
||||
sha->digest[1] += b;
|
||||
sha->digest[2] += c;
|
||||
sha->digest[3] += d;
|
||||
sha->digest[4] += e;
|
||||
}
|
||||
|
||||
#endif /* FREESCALE_MMCAU */
|
||||
|
||||
#endif /* WOLFSSL_HAVE_MIN */
|
||||
|
||||
static INLINE void AddLength(Sha* sha, word32 len)
|
||||
{
|
||||
@@ -370,10 +409,10 @@ int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
|
||||
len -= add;
|
||||
|
||||
if (sha->buffLen == SHA_BLOCK_SIZE) {
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
|
||||
ByteReverseWords(sha->buffer, sha->buffer, SHA_BLOCK_SIZE);
|
||||
#endif
|
||||
XTRANSFORM(sha, local);
|
||||
XSHATRANSFORM(sha, local);
|
||||
AddLength(sha, SHA_BLOCK_SIZE);
|
||||
sha->buffLen = 0;
|
||||
}
|
||||
@@ -382,7 +421,6 @@ int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wc_ShaFinal(Sha* sha, byte* hash)
|
||||
{
|
||||
byte* local = (byte*)sha->buffer;
|
||||
@@ -396,10 +434,10 @@ int wc_ShaFinal(Sha* sha, byte* hash)
|
||||
XMEMSET(&local[sha->buffLen], 0, SHA_BLOCK_SIZE - sha->buffLen);
|
||||
sha->buffLen += SHA_BLOCK_SIZE - sha->buffLen;
|
||||
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
|
||||
ByteReverseWords(sha->buffer, sha->buffer, SHA_BLOCK_SIZE);
|
||||
#endif
|
||||
XTRANSFORM(sha, local);
|
||||
XSHATRANSFORM(sha, local);
|
||||
sha->buffLen = 0;
|
||||
}
|
||||
XMEMSET(&local[sha->buffLen], 0, SHA_PAD_SIZE - sha->buffLen);
|
||||
@@ -410,21 +448,21 @@ int wc_ShaFinal(Sha* sha, byte* hash)
|
||||
sha->loLen = sha->loLen << 3;
|
||||
|
||||
/* store lengths */
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
|
||||
ByteReverseWords(sha->buffer, sha->buffer, SHA_BLOCK_SIZE);
|
||||
#endif
|
||||
/* ! length ordering dependent on digest endian type ! */
|
||||
XMEMCPY(&local[SHA_PAD_SIZE], &sha->hiLen, sizeof(word32));
|
||||
XMEMCPY(&local[SHA_PAD_SIZE + sizeof(word32)], &sha->loLen, sizeof(word32));
|
||||
|
||||
#ifdef FREESCALE_MMCAU
|
||||
#ifdef FREESCALE_MMCAU_SHA
|
||||
/* Kinetis requires only these bytes reversed */
|
||||
ByteReverseWords(&sha->buffer[SHA_PAD_SIZE/sizeof(word32)],
|
||||
&sha->buffer[SHA_PAD_SIZE/sizeof(word32)],
|
||||
2 * sizeof(word32));
|
||||
#endif
|
||||
|
||||
XTRANSFORM(sha, local);
|
||||
XSHATRANSFORM(sha, local);
|
||||
#ifdef LITTLE_ENDIAN_ORDER
|
||||
ByteReverseWords(sha->digest, sha->digest, SHA_DIGEST_SIZE);
|
||||
#endif
|
||||
@@ -433,11 +471,7 @@ int wc_ShaFinal(Sha* sha, byte* hash)
|
||||
return wc_InitSha(sha); /* reset state */
|
||||
}
|
||||
|
||||
#endif /* STM32F2_HASH */
|
||||
|
||||
|
||||
#endif /* USE_SHA_SOFTWARE_IMPL */
|
||||
|
||||
#endif /* HAVE_FIPS */
|
||||
#endif /* WOLFSSL_TI_HASH */
|
||||
#endif /* NO_SHA */
|
||||
|
||||
#endif /* !NO_SHA */
|
||||
|
@@ -250,7 +250,7 @@ static void set_Transform(void) {
|
||||
}
|
||||
|
||||
#else
|
||||
#if defined(FREESCALE_MMCAU)
|
||||
#if defined(FREESCALE_MMCAU_SHA)
|
||||
#define XTRANSFORM(sha256, B) Transform(sha256, B)
|
||||
#else
|
||||
#define XTRANSFORM(sha256, B) Transform(sha256)
|
||||
@@ -285,8 +285,8 @@ static void set_Transform(void) {
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#ifdef FREESCALE_MMCAU
|
||||
#include "cau_api.h"
|
||||
#ifdef FREESCALE_MMCAU_SHA
|
||||
#include "fsl_mmcau.h"
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSL_HAVE_MIN
|
||||
@@ -299,16 +299,22 @@ static void set_Transform(void) {
|
||||
|
||||
#endif /* WOLFSSL_HAVE_MIN */
|
||||
|
||||
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
int wc_InitSha256(Sha256* sha256)
|
||||
{
|
||||
LTC_HASH_Init(LTC_BASE, &sha256->ctx, kLTC_Sha256, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int wc_InitSha256(Sha256* sha256)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef FREESCALE_MMCAU
|
||||
#ifdef FREESCALE_MMCAU_SHA
|
||||
ret = wolfSSL_CryptHwMutexLock();
|
||||
if(ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
cau_sha256_initialize_output(sha256->digest);
|
||||
MMCAU_SHA256_InitializeOutput((uint32_t*)sha256->digest);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
#else
|
||||
sha256->digest[0] = 0x6A09E667L;
|
||||
@@ -331,9 +337,10 @@ int wc_InitSha256(Sha256* sha256)
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* FREESCALE_LTC_SHA */
|
||||
|
||||
|
||||
#if !defined(FREESCALE_MMCAU)
|
||||
#if !defined(FREESCALE_LTC_SHA)
|
||||
#if !defined(FREESCALE_MMCAU_SHA)
|
||||
static const ALIGN32 word32 K[64] = {
|
||||
0x428A2F98L, 0x71374491L, 0xB5C0FBCFL, 0xE9B5DBA5L, 0x3956C25BL,
|
||||
0x59F111F1L, 0x923F82A4L, 0xAB1C5ED5L, 0xD807AA98L, 0x12835B01L,
|
||||
@@ -352,19 +359,19 @@ static const ALIGN32 word32 K[64] = {
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(FREESCALE_MMCAU)
|
||||
#if defined(FREESCALE_MMCAU_SHA)
|
||||
|
||||
static int Transform(Sha256* sha256, byte* buf)
|
||||
{
|
||||
int ret = wolfSSL_CryptHwMutexLock();
|
||||
if(ret == 0) {
|
||||
cau_sha256_hash_n(buf, 1, sha256->digest);
|
||||
MMCAU_SHA256_HashN(buf, 1, (uint32_t*)sha256->digest);
|
||||
wolfSSL_CryptHwMutexUnLock();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* FREESCALE_MMCAU */
|
||||
#endif /* FREESCALE_MMCAU_SHA */
|
||||
|
||||
#define Ch(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
||||
#define Maj(x,y,z) ((((x) | (y)) & (z)) | ((x) & (y)))
|
||||
@@ -382,7 +389,7 @@ static int Transform(Sha256* sha256, byte* buf)
|
||||
(d) += t0; \
|
||||
(h) = t0 + t1;
|
||||
|
||||
#if !defined(FREESCALE_MMCAU)
|
||||
#if !defined(FREESCALE_MMCAU_SHA)
|
||||
static int Transform(Sha256* sha256)
|
||||
{
|
||||
word32 S[8], t0, t1;
|
||||
@@ -431,7 +438,7 @@ static int Transform(Sha256* sha256)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* #if !defined(FREESCALE_MMCAU) */
|
||||
#endif /* #if !defined(FREESCALE_MMCAU_SHA) */
|
||||
|
||||
static INLINE void AddLength(Sha256* sha256, word32 len)
|
||||
{
|
||||
@@ -439,7 +446,15 @@ static INLINE void AddLength(Sha256* sha256, word32 len)
|
||||
if ( (sha256->loLen += len) < tmp)
|
||||
sha256->hiLen++; /* carry low to high */
|
||||
}
|
||||
#endif /* FREESCALE_LTC_SHA */
|
||||
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
int wc_Sha256Update(Sha256* sha256, const byte* data, word32 len)
|
||||
{
|
||||
LTC_HASH_Update(&sha256->ctx, data, len);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static INLINE int Sha256Update(Sha256* sha256, const byte* data, word32 len)
|
||||
{
|
||||
|
||||
@@ -459,7 +474,7 @@ static INLINE int Sha256Update(Sha256* sha256, const byte* data, word32 len)
|
||||
if (sha256->buffLen == SHA256_BLOCK_SIZE) {
|
||||
int ret;
|
||||
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
|
||||
#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2)
|
||||
#endif
|
||||
@@ -483,6 +498,16 @@ int wc_Sha256Update(Sha256* sha256, const byte* data, word32 len)
|
||||
return Sha256Update(sha256, data, len);
|
||||
}
|
||||
|
||||
#endif /* FREESCALE_LTC_SHA */
|
||||
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
int wc_Sha256Final(Sha256* sha256, byte* hash)
|
||||
{
|
||||
uint32_t hashlen = SHA256_DIGEST_SIZE;
|
||||
LTC_HASH_Finish(&sha256->ctx, hash, &hashlen);
|
||||
return wc_InitSha256(sha256); /* reset state */
|
||||
}
|
||||
#else
|
||||
static INLINE int Sha256Final(Sha256* sha256)
|
||||
{
|
||||
byte* local = (byte*)sha256->buffer;
|
||||
@@ -499,7 +524,7 @@ static INLINE int Sha256Final(Sha256* sha256)
|
||||
XMEMSET(&local[sha256->buffLen], 0, SHA256_BLOCK_SIZE - sha256->buffLen);
|
||||
sha256->buffLen += SHA256_BLOCK_SIZE - sha256->buffLen;
|
||||
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
|
||||
#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2)
|
||||
#endif
|
||||
@@ -520,7 +545,7 @@ static INLINE int Sha256Final(Sha256* sha256)
|
||||
sha256->loLen = sha256->loLen << 3;
|
||||
|
||||
/* store lengths */
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU_SHA)
|
||||
#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
if(!IS_INTEL_AVX1 && !IS_INTEL_AVX2)
|
||||
#endif
|
||||
@@ -531,7 +556,7 @@ static INLINE int Sha256Final(Sha256* sha256)
|
||||
XMEMCPY(&local[SHA256_PAD_SIZE + sizeof(word32)], &sha256->loLen,
|
||||
sizeof(word32));
|
||||
|
||||
#if defined(FREESCALE_MMCAU) || defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
#if defined(FREESCALE_MMCAU_SHA) || defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
/* Kinetis requires only these bytes reversed */
|
||||
#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
if(IS_INTEL_AVX1 || IS_INTEL_AVX2)
|
||||
@@ -559,6 +584,8 @@ int wc_Sha256Final(Sha256* sha256, byte* hash)
|
||||
|
||||
return wc_InitSha256(sha256); /* reset state */
|
||||
}
|
||||
#endif /* FREESCALE_LTC_SHA */
|
||||
|
||||
|
||||
|
||||
#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
|
@@ -50,6 +50,9 @@
|
||||
#include <wolfssl/wolfcrypt/tfm.h>
|
||||
#include <wolfcrypt/src/asm.c> /* will define asm MACROS or C ones */
|
||||
|
||||
#if defined(FREESCALE_LTC_TFM)
|
||||
#include <wolfssl/wolfcrypt/port/nxp/ksdk_port.h>
|
||||
#endif
|
||||
#ifdef WOLFSSL_DEBUG_MATH
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
@@ -194,7 +197,11 @@ void s_fp_sub(fp_int *a, fp_int *b, fp_int *c)
|
||||
}
|
||||
|
||||
/* c = a * b */
|
||||
#if defined(FREESCALE_LTC_TFM)
|
||||
void wolfcrypt_fp_mul(fp_int *A, fp_int *B, fp_int *C)
|
||||
#else
|
||||
void fp_mul(fp_int *A, fp_int *B, fp_int *C)
|
||||
#endif
|
||||
{
|
||||
int y, yy, oldused;
|
||||
|
||||
@@ -736,7 +743,11 @@ void fp_div_2d(fp_int *a, int b, fp_int *c, fp_int *d)
|
||||
}
|
||||
|
||||
/* c = a mod b, 0 <= c < b */
|
||||
#if defined(FREESCALE_LTC_TFM)
|
||||
int wolfcrypt_fp_mod(fp_int *a, fp_int *b, fp_int *c)
|
||||
#else
|
||||
int fp_mod(fp_int *a, fp_int *b, fp_int *c)
|
||||
#endif
|
||||
{
|
||||
fp_int t;
|
||||
int err;
|
||||
@@ -886,9 +897,12 @@ top:
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
|
||||
/* c = 1/a (mod b) for odd b only */
|
||||
#if defined(FREESCALE_LTC_TFM)
|
||||
int wolfcrypt_fp_invmod(fp_int *a, fp_int *b, fp_int *c)
|
||||
#else
|
||||
int fp_invmod(fp_int *a, fp_int *b, fp_int *c)
|
||||
#endif
|
||||
{
|
||||
fp_int x, y, u, v, B, D;
|
||||
int neg;
|
||||
@@ -980,7 +994,11 @@ top:
|
||||
}
|
||||
|
||||
/* d = a * b (mod c) */
|
||||
#if defined(FREESCALE_LTC_TFM)
|
||||
int wolfcrypt_fp_mulmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
|
||||
#else
|
||||
int fp_mulmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
|
||||
#endif
|
||||
{
|
||||
int err;
|
||||
fp_int t;
|
||||
@@ -1059,7 +1077,11 @@ const wolfssl_word wc_off_on_addr[2] =
|
||||
Based on work by Marc Joye, Sung-Ming Yen, "The Montgomery Powering Ladder",
|
||||
Cryptographic Hardware and Embedded Systems, CHES 2002
|
||||
*/
|
||||
#if defined(FREESCALE_LTC_TFM)
|
||||
int _wolfcrypt_fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
|
||||
#else
|
||||
static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
|
||||
#endif
|
||||
{
|
||||
#ifdef WC_NO_CACHE_RESISTANT
|
||||
fp_int R[2];
|
||||
@@ -1929,6 +1951,15 @@ void fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
||||
fp_clamp (a);
|
||||
}
|
||||
|
||||
int fp_to_unsigned_bin_at_pos(int x, fp_int *t, unsigned char *b)
|
||||
{
|
||||
while (fp_iszero (t) == FP_NO) {
|
||||
b[x++] = (unsigned char) (t->dp[0] & 255);
|
||||
fp_div_2d (t, 8, t, NULL);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
void fp_to_unsigned_bin(fp_int *a, unsigned char *b)
|
||||
{
|
||||
int x;
|
||||
@@ -1936,11 +1967,7 @@ void fp_to_unsigned_bin(fp_int *a, unsigned char *b)
|
||||
|
||||
fp_init_copy(&t, a);
|
||||
|
||||
x = 0;
|
||||
while (fp_iszero (&t) == FP_NO) {
|
||||
b[x++] = (unsigned char) (t.dp[0] & 255);
|
||||
fp_div_2d (&t, 8, &t, NULL);
|
||||
}
|
||||
x = fp_to_unsigned_bin_at_pos(0, &t, b);
|
||||
fp_reverse (b, x);
|
||||
}
|
||||
|
||||
|
@@ -35,6 +35,10 @@
|
||||
#include <ippcp.h>
|
||||
#endif
|
||||
|
||||
#if defined(FREESCALE_LTC_TFM)
|
||||
#include <wolfssl/wolfcrypt/port/nxp/ksdk_port.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
|
||||
#pragma warning(disable: 4996)
|
||||
@@ -69,6 +73,10 @@ int wolfCrypt_Init()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FREESCALE_LTC_TFM) || defined(FREESCALE_LTC_ECC)
|
||||
ksdk_port_init();
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ARMASM
|
||||
WOLFSSL_MSG("Using ARM hardware acceleration");
|
||||
#endif
|
||||
|
@@ -167,6 +167,8 @@ WOLFSSL_API int wc_AesCbcDecrypt(Aes* aes, byte* out,
|
||||
const byte* authIn, word32 authInSz);
|
||||
#endif /* HAVE_AESCCM */
|
||||
|
||||
WOLFSSL_API int wc_AesGetKeySize(Aes* aes, word32* keySize);
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
WOLFSSL_API int wc_AesAsyncInit(Aes*, int);
|
||||
WOLFSSL_API void wc_AesAsyncFree(Aes*);
|
||||
|
@@ -47,6 +47,9 @@ typedef struct {
|
||||
* the mathematical functions used the endianess */
|
||||
typedef struct {
|
||||
byte point[CURVE25519_KEYSIZE];
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
byte pointY[CURVE25519_KEYSIZE];
|
||||
#endif
|
||||
}ECPoint;
|
||||
|
||||
/* A CURVE25519 Key */
|
||||
|
@@ -58,6 +58,11 @@
|
||||
typedef struct {
|
||||
byte p[ED25519_PUB_KEY_SIZE]; /* compressed public key */
|
||||
byte k[ED25519_PRV_KEY_SIZE]; /* private key : 32 secret -- 32 public */
|
||||
#ifdef FREESCALE_LTC_ECC
|
||||
/* uncompressed point coordinates */
|
||||
byte pointX[ED25519_KEY_SIZE]; /* recovered X coordinate */
|
||||
byte pointY[ED25519_KEY_SIZE]; /* Y coordinate is the public key with The most significant bit of the final octet always zero. */
|
||||
#endif
|
||||
} ed25519_key;
|
||||
|
||||
|
||||
|
@@ -47,7 +47,9 @@ Bounds on each t[i] vary depending on context.
|
||||
typedef int32_t fe[10];
|
||||
#endif
|
||||
|
||||
#if! defined FREESCALE_LTC_ECC
|
||||
WOLFSSL_LOCAL int curve25519(byte * q, byte * n, byte * p);
|
||||
#endif
|
||||
WOLFSSL_LOCAL void fe_copy(fe, const fe);
|
||||
WOLFSSL_LOCAL void fe_add(fe, const fe, const fe);
|
||||
WOLFSSL_LOCAL void fe_neg(fe,const fe);
|
||||
|
@@ -64,7 +64,8 @@ noinst_HEADERS+= \
|
||||
wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h \
|
||||
wolfssl/wolfcrypt/port/ti/ti-hash.h \
|
||||
wolfssl/wolfcrypt/port/ti/ti-ccm.h \
|
||||
wolfssl/wolfcrypt/port/nrf51.h
|
||||
wolfssl/wolfcrypt/port/nrf51.h \
|
||||
wolfssl/wolfcrypt/port/nxp/ksdk_port.h
|
||||
|
||||
if BUILD_CAVIUM
|
||||
noinst_HEADERS+= wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h
|
||||
|
88
wolfssl/wolfcrypt/port/nxp/ksdk_port.h
Executable file
88
wolfssl/wolfcrypt/port/nxp/ksdk_port.h
Executable file
@@ -0,0 +1,88 @@
|
||||
/* ksdk_port.h
|
||||
*
|
||||
* Copyright (C) 2006-2016 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL 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.
|
||||
*
|
||||
* wolfSSL 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef _KSDK_PORT_H_
|
||||
#define _KSDK_PORT_H_
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/tfm.h>
|
||||
#include <wolfssl/wolfcrypt/ecc.h>
|
||||
#include <wolfssl/wolfcrypt/curve25519.h>
|
||||
#include <wolfssl/wolfcrypt/ed25519.h>
|
||||
|
||||
|
||||
/* API to init required hardware */
|
||||
int ksdk_port_init(void);
|
||||
|
||||
/* software algorithm, by wolfcrypt */
|
||||
#if defined(FREESCALE_LTC_TFM)
|
||||
void wolfcrypt_fp_mul(fp_int *A, fp_int *B, fp_int *C);
|
||||
int wolfcrypt_fp_mod(fp_int *a, fp_int *b, fp_int *c);
|
||||
int wolfcrypt_fp_mulmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d);
|
||||
int wolfcrypt_fp_mod(fp_int *a, fp_int *b, fp_int *c);
|
||||
int wolfcrypt_fp_invmod(fp_int *a, fp_int *b, fp_int *c);
|
||||
int _wolfcrypt_fp_exptmod(fp_int *G, fp_int *X, fp_int *P, fp_int *Y);
|
||||
int _fp_exptmod(fp_int *G, fp_int *X, fp_int *P, fp_int *Y);
|
||||
#ifndef NO_RSA
|
||||
#include <wolfssl/wolfcrypt/rsa.h>
|
||||
int wc_RsaFunction(const byte* in, word32 inLen, byte* out, word32* outLen, int type, RsaKey* key, WC_RNG* rng);
|
||||
#endif
|
||||
#endif /* FREESCALE_LTC_TFM */
|
||||
|
||||
#if defined(FREESCALE_LTC_ECC)
|
||||
#include "fsl_ltc.h"
|
||||
|
||||
typedef enum _fsl_ltc_ecc_coordinate_system
|
||||
{
|
||||
kLTC_Weierstrass = 0U, /*!< Point coordinates on an elliptic curve in Weierstrass form */
|
||||
kLTC_Curve25519 = 1U, /*!< Point coordinates on an Curve25519 elliptic curve in Montgomery form */
|
||||
kLTC_Ed25519 = 2U, /*!< Point coordinates on an Ed25519 elliptic curve in twisted Edwards form */
|
||||
} fsl_ltc_ecc_coordinate_system_t;
|
||||
|
||||
int wc_ecc_point_add(ecc_point *mG, ecc_point *mQ, ecc_point *mR, mp_int *m);
|
||||
|
||||
#ifdef HAVE_CURVE25519
|
||||
int wc_curve25519(ECPoint *q, byte *n, const ECPoint *p, fsl_ltc_ecc_coordinate_system_t type);
|
||||
const ECPoint *wc_curve25519_GetBasePoint(void);
|
||||
status_t LTC_PKHA_Curve25519ToWeierstrass(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
||||
status_t LTC_PKHA_WeierstrassToCurve25519(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
||||
status_t LTC_PKHA_Curve25519ComputeY(ltc_pkha_ecc_point_t *ltcPoint);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ED25519
|
||||
status_t LTC_PKHA_Ed25519ToWeierstrass(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
||||
status_t LTC_PKHA_WeierstrassToEd25519(const ltc_pkha_ecc_point_t *ltcPointIn, ltc_pkha_ecc_point_t *ltcPointOut);
|
||||
status_t LTC_PKHA_Ed25519_PointMul(const ltc_pkha_ecc_point_t *ltcPointIn,
|
||||
const uint8_t *N,
|
||||
size_t sizeN,
|
||||
ltc_pkha_ecc_point_t *ltcPointOut,
|
||||
fsl_ltc_ecc_coordinate_system_t typeOut);
|
||||
const ltc_pkha_ecc_point_t *LTC_PKHA_Ed25519_BasePoint(void);
|
||||
status_t LTC_PKHA_Ed25519_PointDecompress(const uint8_t *pubkey, size_t pubKeySize, ltc_pkha_ecc_point_t *ltcPointOut);
|
||||
status_t LTC_PKHA_sc_reduce(uint8_t *a);
|
||||
status_t LTC_PKHA_sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b, const uint8_t *c);
|
||||
status_t LTC_PKHA_SignatureForVerify(uint8_t *rcheck, const unsigned char *a, const unsigned char *b, ed25519_key *key);
|
||||
status_t LTC_PKHA_Ed25519_Compress(const ltc_pkha_ecc_point_t *ltcPointIn, uint8_t *p);
|
||||
#endif
|
||||
|
||||
#endif /* FREESCALE_LTC_ECC */
|
||||
|
||||
#endif /* _KSDK_PORT_H_ */
|
@@ -76,6 +76,7 @@ enum {
|
||||
RSA_MIN_PAD_SZ = 11 /* separator + 0 + pad value + 8 pads */
|
||||
};
|
||||
|
||||
|
||||
/* RSA */
|
||||
typedef struct RsaKey {
|
||||
mp_int n, e, d, p, q, dP, dQ, u;
|
||||
|
@@ -85,8 +85,8 @@
|
||||
/* Uncomment next line if building for Freescale KSDK Bare Metal */
|
||||
/* #define FREESCALE_KSDK_BM */
|
||||
|
||||
/* Uncomment next line if building for Freescale FreeRTOS */
|
||||
/* #define FREESCALE_FREE_RTOS */
|
||||
/* Uncomment next line if building for Freescale KSDK FreeRTOS (old name FREESCALE_FREE_RTOS) */
|
||||
/* #define FREESCALE_KSDK_FREERTOS */
|
||||
|
||||
/* Uncomment next line if using STM32F2 */
|
||||
/* #define WOLFSSL_STM32F2 */
|
||||
@@ -188,7 +188,9 @@
|
||||
#if defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_ROWLEY_ARM)
|
||||
#define NO_MAIN_DRIVER
|
||||
#define SINGLE_THREADED
|
||||
#define USE_CERT_BUFFERS_1024
|
||||
#if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
|
||||
#define USE_CERT_BUFFERS_1024
|
||||
#endif
|
||||
#define BENCH_EMBEDDED
|
||||
#define NO_FILESYSTEM
|
||||
#define NO_WRITEV
|
||||
@@ -240,7 +242,9 @@
|
||||
#define WOLFSSL_USER_IO
|
||||
#define NO_FILESYSTEM
|
||||
#define NO_CERT
|
||||
#define USE_CERT_BUFFERS_1024
|
||||
#if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
|
||||
#define USE_CERT_BUFFERS_1024
|
||||
#endif
|
||||
#define NO_WRITEV
|
||||
#define NO_DEV_RANDOM
|
||||
#define NO_SHA512
|
||||
@@ -713,76 +717,214 @@ static char *fgets(char *buff, int sz, FILE *fp)
|
||||
#define MQX_FILE_PTR FILE *
|
||||
#define IO_SEEK_SET SEEK_SET
|
||||
#define IO_SEEK_END SEEK_END
|
||||
#endif
|
||||
#endif /* FREESCALE_KSDK_MQX */
|
||||
|
||||
#if defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
|
||||
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
||||
/* WOLFSSL_DH_CONST */
|
||||
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
||||
/* WOLFSSL_DH_CONST */
|
||||
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
||||
/* WOLFSSL_DH_CONST */
|
||||
#define NO_FILESYSTEM
|
||||
#define WOLFSSL_CRYPT_HW_MUTEX 1
|
||||
|
||||
#if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY)
|
||||
#define XMALLOC(s, h, type) pvPortMalloc((s))
|
||||
#define XFREE(p, h, type) vPortFree((p))
|
||||
#endif
|
||||
|
||||
//#define USER_TICKS
|
||||
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
|
||||
/* WOLFSSL_DH_CONST */
|
||||
#define WOLFSSL_LWIP
|
||||
#define FREERTOS_TCP
|
||||
|
||||
#define FREESCALE_FREE_RTOS
|
||||
#define FREERTOS_SOCKET_ERROR ( -1 )
|
||||
#define FREERTOS_EWOULDBLOCK ( -2 )
|
||||
#define FREERTOS_EINVAL ( -4 )
|
||||
#define FREERTOS_EADDRNOTAVAIL ( -5 )
|
||||
#define FREERTOS_EADDRINUSE ( -6 )
|
||||
#define FREERTOS_ENOBUFS ( -7 )
|
||||
#define FREERTOS_ENOPROTOOPT ( -8 )
|
||||
#endif /* FREESCALE_FREE_RTOS || FREESCALE_KSDK_FREERTOS */
|
||||
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
#define FREESCALE_COMMON
|
||||
#define WOLFSSL_USER_IO
|
||||
#define SINGLE_THREADED
|
||||
#define NO_FILESYSTEM
|
||||
#define USE_WOLFSSL_MEMORY
|
||||
#endif
|
||||
|
||||
#ifdef FREESCALE_FREE_RTOS
|
||||
#define FREESCALE_COMMON
|
||||
#define NO_FILESYSTEM
|
||||
#define NO_MAIN_DRIVER
|
||||
#define XMALLOC(s, h, t) OSA_MemAlloc(s);(void)h;(void)t;
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) OSA_MemFree((xp));}
|
||||
#ifdef FREESCALE_KSDK_BM
|
||||
#error Baremetal and FreeRTOS cannot be both enabled at the same time!
|
||||
#endif
|
||||
#ifndef SINGLE_THREADED
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
#endif
|
||||
#endif
|
||||
#define USER_TICKS
|
||||
#endif /* FREESCALE_KSDK_BM */
|
||||
|
||||
#ifdef FREESCALE_COMMON
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
|
||||
/* disable features */
|
||||
#undef NO_WRITEV
|
||||
#define NO_WRITEV
|
||||
#undef NO_DEV_RANDOM
|
||||
#define NO_DEV_RANDOM
|
||||
#undef NO_RABBIT
|
||||
#define NO_RABBIT
|
||||
#undef NO_WOLFSSL_DIR
|
||||
#define NO_WOLFSSL_DIR
|
||||
#undef NO_RC4
|
||||
#define NO_RC4
|
||||
|
||||
/* enable features */
|
||||
#undef USE_FAST_MATH
|
||||
#define USE_FAST_MATH
|
||||
#define HAVE_ECC
|
||||
#define HAVE_AESGCM
|
||||
|
||||
/* memory reduction */
|
||||
#define USE_CERT_BUFFERS_2048
|
||||
#define BENCH_EMBEDDED
|
||||
|
||||
#define TFM_TIMING_RESISTANT
|
||||
#define ECC_TIMING_RESISTANT
|
||||
#define ALT_ECC_SIZE
|
||||
|
||||
/* setting for PIT timer */
|
||||
#define PIT_INSTANCE 0
|
||||
#define PIT_CHANNEL 0
|
||||
|
||||
#if defined(FREESCALE_KSDK_MQX) || defined(FREESCALE_KSDK_BM) || \
|
||||
defined(FREESCALE_FREE_RTOS)
|
||||
#include "fsl_device_registers.h"
|
||||
#undef HAVE_ECC
|
||||
#define HAVE_ECC
|
||||
#ifndef NO_AES
|
||||
#undef HAVE_AESCCM
|
||||
#define HAVE_AESCCM
|
||||
#undef HAVE_AESGCM
|
||||
#define HAVE_AESGCM
|
||||
#undef WOLFSSL_AES_COUNTER
|
||||
#define WOLFSSL_AES_COUNTER
|
||||
#undef WOLFSSL_AES_DIRECT
|
||||
#define WOLFSSL_AES_DIRECT
|
||||
#endif
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/* random seed */
|
||||
#define NO_OLD_RNGNAME
|
||||
#if (FSL_FEATURE_SOC_TRNG_COUNT > 0)
|
||||
#define FREESCALE_TRNG
|
||||
#define TRNG_INSTANCE (0)
|
||||
#elif (FSL_FEATURE_SOC_RNG_COUNT > 0)
|
||||
#include "fsl_rnga_driver.h"
|
||||
#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0)
|
||||
#define FREESCALE_KSDK_2_0_TRNG
|
||||
#elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0)
|
||||
#define FREESCALE_KSDK_2_0_RNGA
|
||||
#elif !defined(FREESCALE_KSDK_BM) && !defined(FREESCALE_FREE_RTOS) && !defined(FREESCALE_KSDK_FREERTOS)
|
||||
#define FREESCALE_RNGA
|
||||
#define RNGA_INSTANCE (0)
|
||||
#elif !defined(FREESCALE_KSDK_BM) && !defined(FREESCALE_FREE_RTOS)
|
||||
/* defaulting to K70 RNGA, user should change if different */
|
||||
/* #define FREESCALE_K53_RNGB */
|
||||
#define FREESCALE_K70_RNGA
|
||||
#endif
|
||||
|
||||
/* HW crypto */
|
||||
/* #define FREESCALE_MMCAU */
|
||||
/* automatic enable based on Kinetis feature */
|
||||
/* if case manual selection is required, for example for benchmarking purposes,
|
||||
* just define FREESCALE_USE_MMCAU or FREESCALE_USE_LTC or none of these two macros (for software only)
|
||||
* both can be enabled simultaneously as LTC has priority over MMCAU in source code.
|
||||
*/
|
||||
/* #define FSL_HW_CRYPTO_MANUAL_SELECTION */
|
||||
#ifndef FSL_HW_CRYPTO_MANUAL_SELECTION
|
||||
#if defined(FSL_FEATURE_SOC_MMCAU_COUNT) && FSL_FEATURE_SOC_MMCAU_COUNT
|
||||
#define FREESCALE_USE_MMCAU
|
||||
#endif
|
||||
|
||||
#if defined(FSL_FEATURE_SOC_LTC_COUNT) && FSL_FEATURE_SOC_LTC_COUNT
|
||||
#define FREESCALE_USE_LTC
|
||||
#endif
|
||||
#else
|
||||
/* #define FREESCALE_USE_MMCAU */
|
||||
/* #define FREESCALE_USE_LTC */
|
||||
#endif
|
||||
#endif /* FREESCALE_COMMON */
|
||||
|
||||
#ifdef FREESCALE_USE_MMCAU
|
||||
/* AES and DES */
|
||||
#define FREESCALE_MMCAU
|
||||
/* MD5, SHA-1 and SHA-256 */
|
||||
#define FREESCALE_MMCAU_SHA
|
||||
#endif /* FREESCALE_USE_MMCAU */
|
||||
|
||||
#ifdef FREESCALE_USE_LTC
|
||||
#if defined(FSL_FEATURE_SOC_LTC_COUNT) && FSL_FEATURE_SOC_LTC_COUNT
|
||||
#define FREESCALE_LTC
|
||||
#define LTC_BASE LTC0
|
||||
|
||||
#if defined(FSL_FEATURE_LTC_HAS_DES) && FSL_FEATURE_LTC_HAS_DES
|
||||
#define FREESCALE_LTC_DES
|
||||
#endif
|
||||
|
||||
#if defined(FSL_FEATURE_LTC_HAS_GCM) && FSL_FEATURE_LTC_HAS_GCM
|
||||
#define FREESCALE_LTC_AES_GCM
|
||||
#endif
|
||||
|
||||
#if defined(FSL_FEATURE_LTC_HAS_SHA) && FSL_FEATURE_LTC_HAS_SHA
|
||||
#define FREESCALE_LTC_SHA
|
||||
#endif
|
||||
|
||||
#if defined(FSL_FEATURE_LTC_HAS_PKHA) && FSL_FEATURE_LTC_HAS_PKHA
|
||||
#define FREESCALE_LTC_ECC
|
||||
#define FREESCALE_LTC_TFM
|
||||
|
||||
/* the LTC PKHA hardware limit is 2048 bits (256 bytes) for integer arithmetic.
|
||||
the LTC_MAX_INT_BYTES defines the size of local variables that hold big integers. */
|
||||
#ifndef LTC_MAX_INT_BYTES
|
||||
#define LTC_MAX_INT_BYTES (256)
|
||||
#endif
|
||||
|
||||
/* This FREESCALE_LTC_TFM_RSA_4096_ENABLE macro can be defined.
|
||||
* In such a case both software and hardware algorithm
|
||||
* for TFM is linked in. The decision for which algorithm is used is determined at runtime
|
||||
* from size of inputs. If inputs and result can fit into LTC (see LTC_MAX_INT_BYTES)
|
||||
* then we call hardware algorithm, otherwise we call software algorithm.
|
||||
*
|
||||
* Chinese reminder theorem is used to break RSA 4096 exponentiations (both public and private key)
|
||||
* into several computations with 2048-bit modulus and exponents.
|
||||
*/
|
||||
/* #define FREESCALE_LTC_TFM_RSA_4096_ENABLE */
|
||||
|
||||
/* ECC-384, ECC-256, ECC-224 and ECC-192 have been enabled with LTC PKHA acceleration */
|
||||
#ifdef HAVE_ECC
|
||||
#undef ECC_TIMING_RESISTANT
|
||||
#define ECC_TIMING_RESISTANT
|
||||
|
||||
/* the LTC PKHA hardware limit is 512 bits (64 bytes) for ECC.
|
||||
the LTC_MAX_ECC_BITS defines the size of local variables that hold ECC parameters
|
||||
and point coordinates */
|
||||
#ifndef LTC_MAX_ECC_BITS
|
||||
#define LTC_MAX_ECC_BITS (384)
|
||||
#endif
|
||||
|
||||
/* Enable curves up to 384 bits */
|
||||
#if !defined(ECC_USER_CURVES) && !defined(HAVE_ALL_CURVES)
|
||||
#define ECC_USER_CURVES
|
||||
#define HAVE_ECC192
|
||||
#define HAVE_ECC224
|
||||
#undef NO_ECC256
|
||||
#define HAVE_ECC384
|
||||
#endif
|
||||
|
||||
/* enable features */
|
||||
#undef HAVE_CURVE25519
|
||||
#define HAVE_CURVE25519
|
||||
#undef HAVE_ED25519
|
||||
#define HAVE_ED25519
|
||||
#undef WOLFSSL_SHA512
|
||||
#define WOLFSSL_SHA512
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif /* FREESCALE_USE_LTC */
|
||||
|
||||
#ifdef FREESCALE_LTC_TFM_RSA_4096_ENABLE
|
||||
#undef USE_CERT_BUFFERS_2048
|
||||
#define USE_CERT_BUFFERS_4096
|
||||
#define FP_MAX_BITS (8192)
|
||||
|
||||
#undef NO_DH
|
||||
#define NO_DH
|
||||
#undef NO_DSA
|
||||
#define NO_DSA
|
||||
#endif /* FREESCALE_LTC_TFM_RSA_4096_ENABLE */
|
||||
|
||||
/* if LTC has AES engine but doesn't have GCM, use software with LTC AES ECB mode */
|
||||
#if defined(FREESCALE_USE_LTC) && !defined(FREESCALE_LTC_AES_GCM)
|
||||
#define GCM_TABLE
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_STM32F2
|
||||
@@ -1044,9 +1186,10 @@ static char *fgets(char *buff, int sz, FILE *fp)
|
||||
#endif
|
||||
|
||||
|
||||
/* FreeScale MMCAU hardware crypto has 4 byte alignment */
|
||||
/* FreeScale MMCAU hardware crypto has 4 byte alignment.
|
||||
However, fsl_mmcau.h gives API with no alignment requirements (4 byte alignment is managed internally by fsl_mmcau.c) */
|
||||
#ifdef FREESCALE_MMCAU
|
||||
#define WOLFSSL_MMCAU_ALIGNMENT 4
|
||||
#define WOLFSSL_MMCAU_ALIGNMENT 0
|
||||
#endif
|
||||
|
||||
/* if using hardware crypto and have alignment requirements, specify the
|
||||
|
@@ -32,6 +32,10 @@
|
||||
#include <cyassl/ctaocrypt/sha.h>
|
||||
#endif
|
||||
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
#include "fsl_ltc.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -56,16 +60,20 @@ enum {
|
||||
|
||||
/* Sha digest */
|
||||
typedef struct Sha {
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word32 buffer[SHA_BLOCK_SIZE / sizeof(word32)];
|
||||
#ifndef WOLFSSL_PIC32MZ_HASH
|
||||
word32 digest[SHA_DIGEST_SIZE / sizeof(word32)];
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
ltc_hash_ctx_t ctx;
|
||||
#else
|
||||
word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
|
||||
pic32mz_desc desc; /* Crypt Engine descriptor */
|
||||
#endif
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word32 buffer[SHA_BLOCK_SIZE / sizeof(word32)];
|
||||
#ifndef WOLFSSL_PIC32MZ_HASH
|
||||
word32 digest[SHA_DIGEST_SIZE / sizeof(word32)];
|
||||
#else
|
||||
word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
|
||||
pic32mz_desc desc; /* Crypt Engine descriptor */
|
||||
#endif
|
||||
#endif /* FREESCALE_LTC_SHA */
|
||||
} Sha;
|
||||
|
||||
#else /* WOLFSSL_TI_HASH */
|
||||
|
@@ -34,6 +34,10 @@
|
||||
#include <cyassl/ctaocrypt/sha256.h>
|
||||
#endif
|
||||
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
#include "fsl_ltc.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -56,6 +60,9 @@ enum {
|
||||
|
||||
/* Sha256 digest */
|
||||
typedef struct Sha256 {
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
ltc_hash_ctx_t ctx;
|
||||
#else
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
@@ -64,6 +71,7 @@ typedef struct Sha256 {
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
pic32mz_desc desc ; /* Crypt Engine descriptor */
|
||||
#endif
|
||||
#endif /* FREESCALE_LTC_SHA */
|
||||
} Sha256;
|
||||
|
||||
#else /* WOLFSSL_TI_HASH */
|
||||
|
@@ -547,6 +547,7 @@ int fp_leading_bit(fp_int *a);
|
||||
int fp_unsigned_bin_size(fp_int *a);
|
||||
void fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c);
|
||||
void fp_to_unsigned_bin(fp_int *a, unsigned char *b);
|
||||
int fp_to_unsigned_bin_at_pos(int x, fp_int *t, unsigned char *b);
|
||||
|
||||
/*int fp_signed_bin_size(fp_int *a);*/
|
||||
/*void fp_read_signed_bin(fp_int *a, const unsigned char *b, int c);*/
|
||||
|
Reference in New Issue
Block a user