more change for new ChibiOS/RT

This commit is contained in:
NIIBE Yutaka 2013-02-18 15:07:13 +09:00
parent 427dd5e5bf
commit daeac800d8
20 changed files with 8574 additions and 28 deletions

View File

@ -1,5 +1,16 @@
2013-02-18 Niibe Yutaka <gniibe@fsij.org>
Changes for new ChibiOS/RT.
* src/main.c: Include adc.h.
(main): Call halInit, adc_init, and chSysInit (change for
ChibiOS/RT 2.4.x).
* src/random.h: New.
* src/ac.c, src/bn.c, src/call-rsa.c, src/main.c: Include random.h.
* src/openpgp.c, src/openpgp-do.c: Likewise.
* src/configure, src/gnuk.ld.in: Add MEMORY_SIZE.
* src/ec_p256.c: Fix call of bn256_add_uint.
* boards/STM8S_DISCOVERY/*: Update for ChibiOS/RT 2.4.x.
Merge ec_p256 branch.
* src/Makefile.in: Add ECC files.
* src/bn.h, src/bn.c: New.
@ -10,7 +21,8 @@
2013-02-17 Niibe Yutaka <gniibe@fsij.org>
* chibios: New submodule for ChibioS/RT 2.4.x.
* boards/*/*: Update for ChibiOS/RT 2.4.x.
* boards/FST_01/*: Update for ChibiOS/RT 2.4.x.
* boards/common/mcuconf-common.h: Ditto.
* src/chconf.h, src/halconf.h, src/Makefile.in, src/gnuk.ld.in:
Update for ChibiOS/RT 2.4.x.

View File

@ -2,13 +2,11 @@
#include "ch.h"
#include "hal.h"
#include "../common/hwinit.c"
void
hwinit1 (void)
/*
* Board-specific initialization code.
*/
void boardInit(void)
{
hwinit1_common ();
#if defined(PINPAD_CIR_SUPPORT)
/* EXTI5 <= PB5 */
AFIO->EXTICR[1] = AFIO_EXTICR2_EXTI5_PB;

View File

@ -37,12 +37,13 @@
#define GPIO_LED GPIOA_LED
#define IOPORT_LED GPIOA
/* NeuG settings for ADC2 is default. */
/*
* Board identifier.
*/
#define BOARD_ST_DISCOVERY
#define BOARD_NAME "STM8S Discovery"
#define CPU_WITH_NO_GPIOE 1
/*
* Board frequencies.
@ -92,6 +93,8 @@
/*
* Port A setup.
* PA0 - Digital input with PullUp. AN0 for NeuG
* PA1 - Digital input with PullUp. AN1 for NeuG
* PA11 - input with pull-up (USBDM)
* PA12 - input with pull-up (USBDP)
* Everything input with pull-up except:
@ -138,4 +141,22 @@
#define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
#define VAL_GPIODODR 0xFFFFFFFF
/*
* Port E setup.
* Everything input with pull-up except:
*/
#define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */
#define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
#define VAL_GPIOEODR 0xFFFFFFFF
#if !defined(_FROM_ASM_)
#ifdef __cplusplus
extern "C" {
#endif
void boardInit(void);
#ifdef __cplusplus
}
#endif
#endif /* _FROM_ASM_ */
#endif /* _BOARD_H_ */

View File

@ -7,8 +7,8 @@
#define STM32_PLLMUL_VALUE 9
#define STM32_HPRE STM32_HPRE_DIV1
#define STM32_PPRE1 STM32_PPRE1_DIV2
#define STM32_PPRE2 STM32_PPRE2_DIV2
#define STM32_ADCPRE STM32_ADCPRE_DIV4
#define STM32_MCO STM32_MCO_NOCLOCK
#define STM32_PPRE2 STM32_PPRE2_DIV1
#define STM32_ADCPRE STM32_ADCPRE_DIV6
#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK
#include "mcuconf-common.h"

View File

@ -25,6 +25,7 @@
#include "ch.h"
#include "gnuk.h"
#include "sha256.h"
#include "random.h"
uint8_t volatile auth_status; /* Initialized to AC_NONE_AUTHORIZED */

View File

@ -22,6 +22,7 @@
*/
#include <stdint.h>
#include "random.h"
#include "bn.h"
uint32_t

BIN
src/build/gnuk.bin Executable file

Binary file not shown.

721
src/build/gnuk.dmp Normal file
View File

@ -0,0 +1,721 @@
build/gnuk.elf: file format elf32-littlearm
build/gnuk.elf
architecture: arm, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x080010f0
Program Header:
LOAD off 0x00008000 vaddr 0x08000000 paddr 0x08000000 align 2**15
filesz 0x00001000 memsz 0x00001000 flags rwx
LOAD off 0x00009000 vaddr 0x08001000 paddr 0x08001000 align 2**15
filesz 0x0000b8b4 memsz 0x0000b8b8 flags rwx
LOAD off 0x000148b8 vaddr 0x0800c8b8 paddr 0x0800c8b8 align 2**15
filesz 0x00000b48 memsz 0x00000b48 flags rw-
LOAD off 0x00018600 vaddr 0x20000600 paddr 0x0800c8b8 align 2**15
filesz 0x00000000 memsz 0x00001448 flags rw-
LOAD off 0x00015400 vaddr 0x0800d400 paddr 0x0800d400 align 2**15
filesz 0x00001400 memsz 0x00001400 flags r--
LOAD off 0x00018000 vaddr 0x20000000 paddr 0x20000000 align 2**15
filesz 0x00000000 memsz 0x00000600 flags rw-
private flags = 5000002: [Version5 EABI] [has entry point]
Sections:
Idx Name Size VMA LMA File off Algn
0 .sys 00001000 08000000 08000000 00008000 2**4
CONTENTS, ALLOC, LOAD, CODE
1 startup 000000f0 08001000 08001000 00009000 2**4
CONTENTS, ALLOC, LOAD, DATA
2 .text 0000b7c4 080010f0 080010f0 000090f0 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .textalign 00000004 0800c8b4 0800c8b4 000148b4 2**0
ALLOC
4 .stacks 00000600 20000000 20000000 00018000 2**0
ALLOC
5 .bss 00001448 20000600 0800c8b8 00018600 2**3
ALLOC
6 .gnuk_ch_certificate 00000b48 0800c8b8 0800c8b8 000148b8 2**0
CONTENTS, ALLOC, LOAD, DATA
7 .gnuk_flash 00001400 0800d400 0800d400 00015400 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .debug_info 0001a366 00000000 00000000 00016800 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_abbrev 000069fe 00000000 00000000 00030b66 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_loc 0000fee4 00000000 00000000 00037564 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_aranges 000011e8 00000000 00000000 00047448 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_ranges 00001db8 00000000 00000000 00048630 2**0
CONTENTS, READONLY, DEBUGGING
13 .debug_line 0000a2cc 00000000 00000000 0004a3e8 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_str 00004a8f 00000000 00000000 000546b4 2**0
CONTENTS, READONLY, DEBUGGING
15 .comment 00000070 00000000 00000000 00059143 2**0
CONTENTS, READONLY
16 .ARM.attributes 00000033 00000000 00000000 000591b3 2**0
CONTENTS, READONLY
17 .debug_frame 00003474 00000000 00000000 000591e8 2**2
CONTENTS, READONLY, DEBUGGING
SYMBOL TABLE:
08000000 l d .sys 00000000 .sys
08001000 l d startup 00000000 startup
080010f0 l d .text 00000000 .text
0800c8b4 l d .textalign 00000000 .textalign
20000000 l d .stacks 00000000 .stacks
20000600 l d .bss 00000000 .bss
0800c8b8 l d .gnuk_ch_certificate 00000000 .gnuk_ch_certificate
0800d400 l d .gnuk_flash 00000000 .gnuk_flash
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_loc 00000000 .debug_loc
00000000 l d .debug_aranges 00000000 .debug_aranges
00000000 l d .debug_ranges 00000000 .debug_ranges
00000000 l d .debug_line 00000000 .debug_line
00000000 l d .debug_str 00000000 .debug_str
00000000 l d .comment 00000000 .comment
00000000 l d .ARM.attributes 00000000 .ARM.attributes
00000000 l d .debug_frame 00000000 .debug_frame
00000000 l df *ABS* 00000000 sys.c
08000050 l F .sys 00000014 set_led
08000070 l F .sys 00000018 flash_unlock
08000090 l F .sys 00000018 flash_wait_for_last_operation
080000b0 l F .sys 0000003c flash_program_halfword
080000f0 l F .sys 00000044 flash_erase_page
08000140 l F .sys 0000001a flash_check_blank
08000160 l F .sys 00000028 flash_erase_all_and_exec
08000190 l F .sys 0000003c usb_lld_sys_init
080001d0 l F .sys 00000010 usb_lld_sys_shutdown
080001e0 l F .sys 0000001c nvic_system_reset
08000200 l F .sys 00000028 reset
08000230 l F .sys 00000048 flash_write
08000280 l F .sys 00000068 flash_protect
00000000 l df *ABS* 00000000 aes.c
08000400 l O .sys 00000400 FT0
08000800 l O .sys 00000400 FT1
08000c00 l O .sys 00000400 FT2
0800ab40 l O .text 00000100 FSb
0800ac40 l O .text 00000400 RT0
0800b040 l O .text 00000400 RT1
0800b440 l O .text 00000400 RT2
0800b840 l O .text 00000400 RT3
0800bc40 l O .text 00000028 RCON
0800bc70 l O .text 00000400 FT3
0800c070 l O .text 00000100 RSb
00000000 l df *ABS* 00000000 vectors.c
00000000 l df *ABS* 00000000 main.c
08005e70 l F .text 00000010 set_led
08005e80 l F .text 00000040 emit_led
20000818 l O .bss 00000004 main_thread
2000081c l O .bss 00000001 led_inverted
2000081d l O .bss 00000001 fatal_code
20000820 l O .bss 00000120 waUSBthread
00000000 l df *ABS* 00000000 crt0.c
00000000 l df *ABS* 00000000 chcore.c
00000000 l df *ABS* 00000000 chcore_v7m.c
080014c4 l .text 00000000 _port_exit_from_isr
00000000 l df *ABS* 00000000 nvic.c
00000000 l df *ABS* 00000000 chsys.c
20000600 l O .bss 00000038 mainthread.4557
00000000 l df *ABS* 00000000 chdebug.c
00000000 l df *ABS* 00000000 chvt.c
00000000 l df *ABS* 00000000 chschd.c
08001860 l F .text 0000002e wakeup
00000000 l df *ABS* 00000000 chthreads.c
00000000 l df *ABS* 00000000 chdynamic.c
00000000 l df *ABS* 00000000 chmtx.c
08001b90 l F .text 0000001e prio_insert
00000000 l df *ABS* 00000000 chcond.c
08001d20 l F .text 0000001e prio_insert
00000000 l df *ABS* 00000000 chevents.c
00000000 l df *ABS* 00000000 chmemcore.c
2000071c l O .bss 00000004 endmem
20000720 l O .bss 00000004 nextmem
00000000 l df *ABS* 00000000 chheap.c
20000728 l O .bss 00000020 default_heap
00000000 l df *ABS* 00000000 hal.c
00000000 l df *ABS* 00000000 stm32_dma.c
20000748 l O .bss 00000038 dma_isr_redir
20000780 l O .bss 00000004 dma_streams_mask
00000000 l df *ABS* 00000000 hal_lld.c
00000000 l df *ABS* 00000000 pal_lld.c
00000000 l df *ABS* 00000000 board-common.c
00000000 l df *ABS* 00000000 board.c
00000000 l df *ABS* 00000000 bignum.c
08002450 l F .text 0000005e mpi_sub_hlp
080024b0 l F .text 000002da mpi_mul_hlp
08002c10 l F .text 000000c8 mpi_montmul
0800a8a0 l O .text 000002a0 small_prime
00000000 l df *ABS* 00000000 rsa.c
00000000 l df *ABS* 00000000 sha256.c
08005190 l F .text 00000018 bswap32_buf
00000000 l df *ABS* 00000000 call-rsa.c
20000784 l O .bss 00000094 rsa_ctx
00000000 l df *ABS* 00000000 usb_stm32f103.c
08005ef0 l F .text 00000018 st103_ep_clear_ctr_rx
08005f10 l F .text 00000024 st103_ep_set_rx_status
08005f40 l F .text 00000024 st103_ep_set_tx_status
08005f70 l F .text 00000004 std_none
08005f80 l F .text 000000c8 std_get_status
08006050 l F .text 0000002c std_set_address
08006080 l F .text 00000024 std_get_configuration
080060b0 l F .text 0000002c std_set_configuration
080060e0 l F .text 00000048 std_set_interface
08006130 l F .text 000000a4 std_clear_feature
080061e0 l F .text 00000088 std_set_feature
08006270 l F .text 00000028 std_get_descriptor
080062a0 l F .text 00000048 std_get_interface
080062f0 l F .text 00000028 st103_ep_set_rxtx_status.constprop.7
08006390 l F .text 00000002 nop_proc
080065a0 l F .text 00000088 handle_datastage_in
20000940 l O .bss 0000000c data_info
0800c2d0 l O .text 00000034 std_request_handler
2000094c l O .bss 00000008 control_info
20000954 l O .bss 00000003 device_info
20000958 l O .bss 00000002 status_info.5973
00000000 l df *ABS* 00000000 adc_stm32f103.c
08006920 l F .text 0000002c adc_stop_conversion
08006950 l F .text 000000ac adc_lld_serve_rx_interrupt
2000095c l O .bss 00000004 adc_size
20000960 l O .bss 00000004 adc_mode
20000964 l O .bss 00000004 adc_ptr
00000000 l df *ABS* 00000000 usb_ctrl.c
08006bc0 l F .text 00000054 gnuk_get_descriptor
08006c20 l F .text 00000032 gnuk_setup_endpoints_for_interface
08006c60 l F .text 00000044 gnuk_device_reset
08006cb0 l F .text 00000034 gnuk_interface
08006cf0 l F .text 00000068 gnuk_usb_event
08006d60 l F .text 00000108 gnuk_setup
08006e70 l F .text 00000034 gnuk_ctrl_write_finish
0800c590 l O .text 00000008 mem_info
0800c5a0 l O .text 00000004 data_rate_table
0800c5b0 l O .text 00000004 freq_table
2000096c l O .bss 00000001 zero.6036
00000000 l df *ABS* 00000000 usb-icc.c
08006ed0 l F .text 0000000a no_buf
08006ee0 l F .text 00000018 get_sw1sw2
08006f00 l F .text 0000000c end_icc_rx
08006f10 l F .text 00000024 end_abdata
08006f40 l F .text 00000082 end_cmd_apdu_head
08006fd0 l F .text 0000000c end_nomore_data
08006fe0 l F .text 00000050 end_cmd_apdu_data
08007030 l F .text 00000020 nomore_data
08007050 l F .text 00000080 icc_cmd_apdu_data
080070d0 l F .text 00000050 icc_abdata
08007120 l F .text 00000114 icc_send_data_block_gr
08007240 l F .text 00000058 icc_send_status
080072a0 l F .text 0000000e notify_icc
080072b0 l F .text 0000000a notify_tx
080072c0 l F .text 00000058 icc_error.constprop.1
08007320 l F .text 00000020 ccid_reset.constprop.2
08007340 l F .text 0000002c icc_prepare_receive.constprop.4
08007370 l F .text 00000138 icc_send_data_block_internal.constprop.5
20000974 l O .bss 00000020 endpoint_out
200009b0 l O .bss 00000034 ccid
200009e4 l O .bss 0000011f icc_buffer
20000b04 l O .bss 0000001c endpoint_in
0800c5c0 l O .text 00000015 ATR
20000b20 l O .bss 000008a0 waGPGthread
00000000 l df *ABS* 00000000 openpgp.c
08007b60 l F .text 0000002c cmd_put_data
08007b90 l F .text 000000d0 modify_binary
08007c60 l F .text 00000014 cmd_update_binary
08007c80 l F .text 00000014 cmd_write_binary
08007ca0 l F .text 00000028 cmd_get_data
08007cd0 l F .text 000000b0 cmd_read_binary
08007d80 l F .text 000000e0 cmd_select_file
08007e60 l F .text 00000054 cmd_internal_authenticate
08007ec0 l F .text 00000048 cmd_get_challenge
08007f10 l F .text 00000080 cmd_external_authenticate
08007f90 l F .text 000000b0 cmd_pso
08008040 l F .text 0000007c cmd_verify
080080c0 l F .text 00000038 cmd_pgp_gakp
08008200 l F .text 00000138 cmd_reset_user_password
08008340 l F .text 00000144 cmd_change_password
0800c5e0 l O .text 00000014 select_file_TOP_result
200013c0 l O .bss 00000004 challenge
200013c4 l O .bss 00000001 file_selection
00000000 l df *ABS* 00000000 ac.c
08008550 l F .text 00000066 calc_md
00000000 l df *ABS* 00000000 openpgp-do.c
08008950 l F .text 00000028 get_do_entry
08008980 l F .text 00000054 compute_key_data_checksum
080089e0 l F .text 00000022 encrypt_dek
08008a10 l F .text 00000022 decrypt_dek
08008a40 l F .text 00000020 copy_tag
08008a60 l F .text 00000038 do_ds_count
08008aa0 l F .text 00000070 do_openpgpcard_aid
08008b10 l F .text 00000040 copy_do_1
08008b50 l F .text 00000014 do_hist_bytes
08008b70 l F .text 000000b4 copy_do
08008c30 l F .text 000000a0 rw_pw_status
080093d0 l F .text 00000078 do_kgtime_all
08009450 l F .text 0000007c do_cafp_all
080094d0 l F .text 0000007c do_fp_all
080095a0 l F .text 0000024c gpg_do_write_prvkey
080097f0 l F .text 00000100 proc_key_import
080098f0 l F .text 00000058 proc_resetting_code
0800c6b0 l O .text 00000016 cmp_app_data
0800c6d0 l O .text 00000168 gpg_do_table
200013ec l O .bss 00000054 do_ptr
0800c840 l O .text 0000000b extended_capabilities
0800c870 l O .text 00000007 algorithm_attr
0800c850 l O .text 00000008 cmp_ch_data
0800c8b0 l O .text 00000004 cmp_ss_temp
200013e8 l O .bss 00000004 res_p
20001744 l O .bss 00000004 digital_signature_counter
0800c860 l O .text 0000000b historical_bytes
0800c890 l O .text 00000002 CSWTCH.74
20001748 l O .bss 00000001 num_prv_keys
2000174c l O .bss 0000000c pw_err_counter_p
20001758 l O .bss 00000004 pw1_lifetime_p
00000000 l df *ABS* 00000000 flash.c
080099f0 l F .text 00000010 flash_program_halfword
08009a00 l F .text 00000080 flash_data_pool_allocate
2000175c l O .bss 00000004 keystore
20001760 l O .bss 00000004 data_pool
20001764 l O .bss 00000004 last_p
00000000 l df *ABS* 00000000 random.c
20001768 l O .bss 00000020 random_word
00000000 l df *ABS* 00000000 neug.c
08009f50 l F .text 0000004c noise_source_error
08009fa0 l F .text 000000e0 noise_source_continuous_test
0800a080 l F .text 00000040 ep_fill_wbuf
0800a0c0 l F .text 0000005c ep_init
0800a120 l F .text 000001b4 rng
0800a2e0 l F .text 00000050 rb_del.constprop.2
20001788 l O .bss 00000028 the_ring_buffer
200017b8 l O .bss 00000001 ap64t_b
200017ba l O .bss 00000002 ap4096t_s
200017bd l O .bss 00000001 rct_a
200017be l O .bss 00000001 rct_b
200017c2 l O .bss 00000001 ap64t_s
200017c3 l O .bss 00000001 ap64t_a
200017c8 l O .bss 00000020 sha256_output
200017e8 l O .bss 00000040 adc_buf
20001828 l O .bss 00000001 ap4096t_a
2000182c l O .bss 00000002 ap4096t_b
20001834 l O .bss 00000001 ep_round
20001838 l O .bss 00000068 sha256_ctx_data
200018a8 l O .bss 000001a0 wa_rng
00000000 l df *ABS* 00000000 memcmp.c
00000000 l df *ABS* 00000000 memcpy.c
00000000 l df *ABS* 00000000 memmove.c
00000000 l df *ABS* 00000000 memset.c
00000000 l df *ABS* 00000000 strncmp.c
00000000 l df *ABS* 00000000 chregistry.c
00000000 l df *ABS* 00000000 usb_desc.c
0800c340 l O .text 00000004 gnukStringLangID
0800c380 l O .text 00000012 gnukDeviceDescriptor
0800c360 l O .text 00000016 gnukStringProduct
0800c440 l O .text 00000044 gnukStringVendor
0800c3e0 l O .text 00000046 gnuk_revision_detail
0800c4f0 l O .text 00000080 gnuk_config_options
0800c490 l O .text 00000056 gnukConfigDescriptor
00000000 l df *ABS* 00000000 chlists.c
00000000 l df *ABS* 00000000 chsem.c
00000000 l df *ABS* 00000000 chmsg.c
00000000 l df *ABS* 00000000 chmboxes.c
00000000 l df *ABS* 00000000 chqueues.c
00000000 l df *ABS* 00000000 chmempools.c
00000000 l df *ABS* 00000000 adc.c
00000000 l df *ABS* 00000000 can.c
00000000 l df *ABS* 00000000 ext.c
00000000 l df *ABS* 00000000 gpt.c
00000000 l df *ABS* 00000000 i2c.c
00000000 l df *ABS* 00000000 icu.c
00000000 l df *ABS* 00000000 mac.c
00000000 l df *ABS* 00000000 pal.c
00000000 l df *ABS* 00000000 pwm.c
00000000 l df *ABS* 00000000 sdc.c
00000000 l df *ABS* 00000000 serial.c
00000000 l df *ABS* 00000000 spi.c
00000000 l df *ABS* 00000000 uart.c
00000000 l df *ABS* 00000000 usb.c
00000000 l df *ABS* 00000000 tm.c
00000000 l df *ABS* 00000000 mmc_spi.c
00000000 l df *ABS* 00000000 serial_usb.c
00000000 l df *ABS* 00000000 rtc.c
00000000 l df *ABS* 00000000 adc_lld.c
00000000 l df *ABS* 00000000 can_lld.c
00000000 l df *ABS* 00000000 ext_lld.c
00000000 l df *ABS* 00000000 gpt_lld.c
00000000 l df *ABS* 00000000 i2c_lld.c
00000000 l df *ABS* 00000000 icu_lld.c
00000000 l df *ABS* 00000000 mac_lld.c
00000000 l df *ABS* 00000000 pwm_lld.c
00000000 l df *ABS* 00000000 serial_lld.c
00000000 l df *ABS* 00000000 sdc_lld.c
00000000 l df *ABS* 00000000 spi_lld.c
00000000 l df *ABS* 00000000 uart_lld.c
00000000 l df *ABS* 00000000 usb_lld.c
00000000 l df *ABS* 00000000 rtc_lld.c
00000000 l df *ABS* 00000000 evtimer.c
00000000 l df *ABS* 00000000 syscalls.c
00000000 l df *ABS* 00000000 bn.c
00000000 l df *ABS* 00000000 modp256.c
00000000 l df *ABS* 00000000 jpc.c
00000000 l df *ABS* 00000000 mod.c
00000000 l df *ABS* 00000000 ec_p256.c
0800a860 g O .text 0000003c pal_default_config
080014a0 w F .text 00000002 Vector58
080014a0 w F .text 00000002 VectorE8
080014a0 w F .text 00000002 Vector9C
08008de0 g F .text 000000d4 gpg_do_load_prvkey
08006b90 g F .text 00000030 adc_stop
080084a0 g F .text 000000ac GPGthread
080015e0 g F .text 00000044 nvicEnableVector
08001df0 g F .text 0000002e chEvtSignalFlagsI
080014a0 w F .text 00000002 VectorAC
08001b00 g F .text 0000000a chThdExit
08001730 g F .text 00000044 chSysTimerHandlerI
080018e0 g F .text 00000040 chSchGoSleepTimeoutS
080064b0 g F .text 0000000c usb_lld_set_configuration
0800c8a0 g O .text 0000000e openpgpcard_aid
080045c0 g F .text 0000004a rsa_free
080085f0 g F .text 00000018 ac_reset_pso_cds
08008f80 g F .text 00000114 gpg_data_scan
08004440 g F .text 00000180 rsa_pkcs1_verify
08001bc0 g F .text 0000008c chMtxLockS
080014a0 w F .text 00000002 Vector5C
08006410 g F .text 0000000a usb_lld_stall_rx
08009d50 g F .text 00000030 flash_cnt123_write_internal
08005b00 g F .text 0000010c rsa_sign
080014a0 w F .text 00000002 NMIVector
200013c6 g O .bss 00000020 keystring_md_pw3
08001ff0 g F .text 0000007a chHeapFree
20001830 g O .bss 00000004 rng_thread
08009550 g F .text 0000004c gpg_do_write_simple
08001e20 g F .text 00000018 chEvtSignalFlags
080021e0 g F .text 00000038 dmaInit
20001c00 g *ABS* 00000000 _regnual_start
0800a330 g F .text 00000094 neug_init
080093b0 g F .text 00000014 gpg_do_read_simple
080014a0 w F .text 00000002 Vector8C
08009ef0 g F .text 00000018 random_bytes_free
08002f40 g F .text 00000046 mpi_sub_mpi
20001442 g O .bss 00000300 kd
08004a00 g F .text 00000710 aes_crypt_ecb
08005110 g F .text 00000074 aes_crypt_cfb128
080088e0 g F .text 0000002c ac_reset_admin
0800a580 g F .text 000000ae memmove
080014a0 w F .text 00000002 VectorDC
08002860 g F .text 00000050 mpi_copy
080030f0 g F .text 000003b2 mpi_div_mpi
08001000 g O startup 000000ec _vectors
08008630 g F .text 000000c4 verify_user_0
08001890 g F .text 00000044 chSchGoSleepS
08006390 w F .text 00000002 EP4_IN_Callback
08005ec0 g F .text 00000010 led_blink
20001a48 g *ABS* 00000000 __heap_base__
0800c350 g O .text 00000008 Device_Descriptor
080064d0 g F .text 0000000c usb_lld_set_feature
0800c8b8 g *ABS* 00000000 _etext
20000970 g O .bss 00000004 icc_state_p
08001a30 g F .text 00000020 chThdCreateI
08006370 g F .text 00000018 usb_lld_shutdown
08009310 g F .text 00000098 gpg_do_public_key
080014a0 w F .text 00000002 VectorC8
08008700 g F .text 00000030 verify_pso_cds
08001920 g F .text 00000054 chSchWakeupS
08004030 g F .text 0000001a rsa_init
08002fc0 g F .text 0000002a mpi_sub_int
0800a3d0 g F .text 00000038 neug_flush
08001810 g F .text 00000018 _scheduler_init
08006390 w F .text 00000002 EP5_OUT_Callback
080019d0 g F .text 00000018 chSchRescheduleS
08001a50 g F .text 00000026 chThdCreateStatic
080014a0 w F .text 00000002 Vector94
08006430 g F .text 00000080 usb_lld_setup_endpoint
08008d50 g F .text 00000010 gpg_pw_increment_err_counter
080014a0 w F .text 00000002 VectorA8
08009dc0 g F .text 0000001e flash_cnt123_clear
0800a4f0 g F .text 00000084 memcpy
080014a0 w F .text 00000002 VectorB4
08007540 g F .text 00000080 EP1_OUT_Callback
08008840 g F .text 0000005c gpg_set_pw3
08009cc0 g F .text 00000014 flash_put_data
08001830 g F .text 00000024 chSchReadyI
080030d0 g F .text 00000018 mpi_mul_int
080010f0 g startup 00000000 __fini_array_end
080014b0 w F .text 00000004 port_halt
08006390 w F .text 00000002 EP3_OUT_Callback
20000600 g .stacks 00000000 __main_thread_stack_end__
08009e20 g F .text 00000098 flash_write_binary
08001790 g F .text 00000018 _vt_init
08001f00 g F .text 00000024 chCoreAllocI
08002ff0 g F .text 000000d6 mpi_mul_mpi
08001f50 g F .text 0000001c _heap_init
080020f0 g F .text 0000002c Vector74
08002070 g F .text 00000018 halInit
08000040 g O .sys 00000008 sys_version
08002da0 g F .text 000000c4 mpi_add_abs
08006390 w F .text 00000002 EP2_IN_Callback
20000600 g .bss 00000000 _bss_start
200017b0 g O .bss 00000002 neug_err_cnt_rc
080014a0 w F .text 00000002 UsageFaultVector
08009d80 g F .text 0000003c flash_cnt123_increment
08006390 w F .text 00000002 EP6_IN_Callback
20005000 g *ABS* 00000000 __heap_end__
080014a0 w F .text 00000002 DebugMonitorVector
080014a0 w F .text 00000002 Vector40
080013e0 g F .text 000000c0 ResetHandler
0800dc00 g .gnuk_flash 00000000 _keystore_pool
080014a0 w F .text 00000002 VectorBC
08008cd0 g F .text 00000030 gpg_pw_get_retry_counter
0800cc00 g .gnuk_ch_certificate 00000000 ch_certificate_start
080064c0 g F .text 0000000c usb_lld_current_configuration
08002790 g F .text 0000002a mpi_init
08002960 g F .text 00000038 mpi_msb
08005de0 g F .text 00000090 rsa_genkey
080088a0 g F .text 00000038 verify_admin
08000000 g .sys 00000000 _sys
080014f0 g F .text 00000034 _port_init
08002ef0 g F .text 00000044 mpi_add_mpi
08002d70 g F .text 0000002a mpi_cmp_int
08009de0 g F .text 0000003c flash_erase_binary
080022d0 g F .text 00000068 hal_lld_init
08001ac0 g F .text 0000003c chThdExitS
08002f90 g F .text 0000002a mpi_add_int
08009950 g F .text 0000009c gpg_do_keygen
08008760 g F .text 000000e0 verify_admin_0
08009a80 g F .text 00000054 flash_init
0800c3a0 g O .text 00000038 String_Descriptors
2000182a g O .bss 00000002 neug_err_cnt
08003590 g F .text 000003a0 mpi_exp_mod
080081b0 g F .text 0000004c s2k
08009f10 g F .text 00000006 get_salt
080014a0 w F .text 00000002 PendSVVector
08009d30 g F .text 00000016 flash_cnt123_get_value
08009ee0 g F .text 00000010 random_bytes_get
08006630 g F .text 00000058 usb_lld_from_pmabuf
080017b0 g F .text 00000030 chVTSetI
080014a0 w F .text 00000002 Vector64
20001a48 g .bss 00000000 _bss_end
200006e8 g O .bss 00000004 dbg_panic_msg
080013d0 w F .text 00000002 _default_exit
080014a0 w F .text 00000002 VectorCC
08002920 g F .text 00000032 mpi_lsb
080014a0 w F .text 00000002 Vector54
200013e6 g O .bss 00000001 admin_authorized
080014a0 w F .text 00000002 Vector98
08002800 g F .text 00000052 mpi_grow
080014a0 w F .text 00000002 VectorD8
080014a0 w F .text 00000002 Vector24
08001c50 g F .text 00000014 chMtxLock
08006a90 g F .text 0000008c adc_start
08003520 g F .text 00000068 mpi_mod_int
080063a0 g F .text 00000014 usb_lld_reset
08001980 g F .text 00000044 chSchDoReschedule
080016c0 g F .text 00000064 chSysInit
080051b0 g F .text 0000081e sha256_process
08003f00 g F .text 00000126 mpi_gen_prime
08001aa0 g F .text 00000018 chThdSleep
08009ba0 g F .text 0000005c flash_do_release
0800a800 g O .text 00000054 _stm32_dma_streams
080021b0 g F .text 0000002c Vector84
080015a0 g F .text 0000001a SysTickVector
080034b0 g F .text 00000064 mpi_mod_mpi
080063c0 g F .text 00000014 usb_lld_tx_enable
080029b0 g F .text 00000068 mpi_read_binary
08001db0 g F .text 00000014 chCondWait
08001dd0 g F .text 00000020 chEvtClearFlags
080075c0 g F .text 00000090 icc_power_on
08002340 g F .text 0000007c stm32_clock_init
08005ed0 g F .text 0000001c fatal
080023c0 g F .text 0000006c _pal_lld_init
080014a0 w F .text 00000002 BusFaultVector
080014a0 w F .text 00000002 VectorD0
08006320 g F .text 0000003c usb_lld_init
08001ed0 g F .text 00000028 _core_init
08001cd0 g F .text 0000004c chMtxUnlockS
08005ae0 g F .text 00000020 sha256_start
08000040 g *ABS* 00000000 __flash_end__
080014a0 w F .text 00000002 VectorE4
08006400 g F .text 00000008 usb_lld_stall_tx
200017bc g O .bss 00000001 neug_err_state
080014a0 w F .text 00000002 VectorC0
080028b0 g F .text 00000028 mpi_swap
0800a6c0 g F .text 000000a2 strncmp
08009d10 g F .text 00000018 flash_bool_write
0800c2b0 g O .text 0000001c ep_intr_handler_OUT
200017c4 g O .bss 00000002 neug_err_cnt_p4k
080015c0 g F .text 00000010 _port_switch
08004050 g F .text 00000088 rsa_public
00005000 g *ABS* 00000000 __ram_size__
0800c570 g O .text 00000018 Device_Method
08005c80 g F .text 000000f8 rsa_decrypt
08008910 g F .text 00000038 ac_fini
080028e0 g F .text 00000038 mpi_lset
0800c170 g O .text 00000020 initial_state
080014d0 g F .text 00000012 SVCallVector
080013c0 w F .text 00000002 __late_init
08001780 g F .text 0000000c chDbgPanic
200006ec g O .bss 00000010 vtlist
080014a0 w F .text 00000002 HardFaultVector
08001530 g F .text 00000070 _port_irq_epilogue
20001440 g O .bss 00000002 data_objects_number_of_bytes
08001f30 g F .text 00000014 chCoreAlloc
08002a70 g F .text 00000096 mpi_shift_l
20000994 g O .bss 0000001c apdu
08008490 g F .text 0000000c gpg_get_firmware_update_key
08001d50 g F .text 00000024 chCondSignal
08001f70 g F .text 00000078 chHeapAlloc
08009c80 g F .text 00000028 flash_keystore_release
0800a490 g F .text 00000060 memcmp
080029a0 g F .text 0000000c mpi_size
08005c70 g F .text 00000004 modulus_free
08008610 g F .text 00000020 ac_reset_other
08004900 g F .text 000000f8 aes_setkey_dec
08009ae0 g F .text 0000000c flash_set_data_pool_last
08002e70 g F .text 00000078 mpi_sub_abs
08009cb0 g F .text 00000004 flash_put_data_internal
0800c8b8 g *ABS* 00000000 _textdata
080014a0 w F .text 00000002 VectorE0
08001000 g *ABS* 00000000 _text
080014a0 w F .text 00000002 MemManageVector
080010f0 g startup 00000000 __fini_array_start
200017b6 g O .bss 00000002 neug_err_cnt_p64
08006580 g F .text 00000018 usb_lld_txcpy
08005d80 g F .text 0000005c rsa_verify
0800a630 g F .text 0000008e memset
080010f0 g F .text 000002c8 main
08002090 g F .text 00000028 Vector6C
200006fc g O .bss 00000020 rlist
080014a0 w F .text 00000002 VectorA0
08003a40 g F .text 0000029e mpi_inv_mod
080010f0 g startup 00000000 __init_array_end
080091f0 g F .text 0000011c gpg_do_put_data
08002b90 g F .text 00000076 mpi_cmp_abs
080014a0 w F .text 00000002 VectorC4
08002150 g F .text 0000002c Vector7C
08008ec0 g F .text 000000b8 gpg_do_chks_prvkey
08008dc0 g F .text 00000014 gpg_do_clear_prvkey
08009b90 g F .text 00000002 flash_warning
08002290 g F .text 00000034 dmaStreamRelease
08006390 w F .text 00000002 EP5_IN_Callback
08001bb0 g F .text 0000000a chMtxInit
08005c10 g F .text 0000005e modulus_calc
08006550 g F .text 00000030 usb_lld_write
080016a0 g F .text 00000014 _idle_thread
08007680 g F .text 000004d8 USBthread
080014a0 w F .text 00000002 VectorB0
0800a7e0 g O .text 00000016 ch_debug
08006390 w F .text 00000002 EP4_OUT_Callback
08006eb0 g F .text 0000001a Vector90
0800d400 g O .gnuk_flash 00000004 flash_data
08008110 g F .text 0000009a gpg_change_keystring
08001e40 g F .text 00000038 chEvtWaitOne
20000000 g *ABS* 00000000 __ram_start__
0800c290 g O .text 0000001c ep_intr_handler_IN
0800c310 g O .text 00000028 gnukStringSerial
080015d0 g F .text 00000010 _port_thread_start
080014a0 w F .text 00000002 Vector60
08006390 w F .text 00000002 EP6_OUT_Callback
080014a0 w F .text 00000002 Vector1C
200018a0 g O .bss 00000002 neug_p4k_max
08006390 w F .text 00000002 EP7_IN_Callback
08006b20 g F .text 00000070 adc_start_conversion
08009b60 g F .text 00000022 flash_do_write
080014a0 w F .text 00000002 Vector48
20000400 g .stacks 00000000 __process_stack_base__
08002b10 g F .text 00000072 mpi_shift_r
08009ce0 g F .text 00000014 flash_bool_clear
08006690 g F .text 0000001c usb_lld_rxcpy
080063e0 g F .text 00000014 usb_lld_rx_data_len
08001d40 g F .text 00000006 chCondInit
08009ec0 g F .text 0000001c random_init
08004760 g F .text 000001a0 aes_setkey_enc
080059d0 g F .text 00000058 sha256_update
080020c0 g F .text 00000028 Vector70
08009d00 g F .text 00000006 flash_bool_write_internal
08006a00 g F .text 00000084 adc_init
080014a0 w F .text 00000002 VectorD4
08006420 g F .text 0000000a usb_lld_rx_enable
08001670 g F .text 0000002c nvicSetSystemHandlerPriority
08009f20 g F .text 00000028 random_byte
0800c190 g O .text 00000100 k256
08001b50 g F .text 0000003e chThdRelease
08001e80 g F .text 00000044 chEvtWaitOneTimeout
08004250 g F .text 000001e8 rsa_pkcs1_sign
20000638 g O .bss 000000b0 _idle_thread_wa
08006360 g F .text 00000010 usb_lld_prepare_shutdown
08008100 g F .text 00000010 set_res_sw
20000600 g .bss 00000000 _data
080074b0 g F .text 00000088 EP1_IN_Callback
08009180 g F .text 00000070 gpg_do_get_data
080014a0 w F .text 00000002 Vector4C
08002180 g F .text 0000002c Vector80
080014c0 g F .text 00000006 _port_switch_from_isr
0800d400 g .gnuk_flash 00000000 _data_pool
080014a0 w F .text 00000002 Vector68
08001c70 g F .text 00000058 chMtxUnlock
080041c0 g F .text 0000008c rsa_pkcs1_decrypt
080027c0 g F .text 00000040 mpi_free
0800a460 g F .text 00000030 neug_wait_full
20000400 g .stacks 00000000 __main_stack_end__
08006390 w F .text 00000002 EP2_OUT_Callback
08002120 g F .text 0000002c Vector78
08009c20 g F .text 00000052 flash_key_write
200013c5 g O .bss 00000001 auth_status
20005000 g *ABS* 00000000 __ram_end__
20000600 g .bss 00000000 _edata
20001a48 g *ABS* 00000000 _end
08003ce0 g F .text 00000218 mpi_is_prime
080064e0 g F .text 0000000c usb_lld_set_data_to_send
080017e0 g F .text 00000024 chVTResetI
08008d20 g F .text 00000028 gpg_pw_reset_err_counter
080014a0 g F .text 00000002 _unhandled_exception
08006390 w F .text 00000002 EP3_IN_Callback
200017b2 g O .bss 00000002 neug_rc_max
08009af0 g F .text 00000068 flash_do_write_internal
080014a0 w F .text 00000002 Vector88
08007650 g F .text 0000002c icc_power_off
20000400 g .stacks 00000000 __main_thread_stack_base__
080064f0 g F .text 0000005c usb_lld_to_pmabuf
08009c00 g F .text 00000020 flash_key_alloc
08001000 g *ABS* 00000000 __flash_start__
080066b0 g F .text 00000270 usb_interrupt_handler
080085c0 g F .text 00000024 ac_check_status
08008730 g F .text 00000030 verify_other
080010f0 g startup 00000000 __init_array_start
08003930 g F .text 00000108 mpi_gcd
0800c430 g O .text 00000008 Config_Descriptor
08001b10 g F .text 00000038 chThdWait
0800e400 g .gnuk_flash 00000000 _updatekey_store
200017b4 g O .bss 00000001 neug_mode
080019f0 g F .text 0000003c _thread_init
080014a0 w F .text 00000002 Vector50
0800c620 g O .text 00000078 cmds
08002220 g F .text 0000006c dmaStreamAllocate
08002a20 g F .text 00000048 mpi_write_binary
08008d00 g F .text 0000001c gpg_pw_locked
200017c0 g O .bss 00000002 neug_p64_max
08001630 g F .text 00000038 nvicDisableVector
080090a0 g F .text 000000d8 gpg_data_copy
20000968 g O .bss 00000004 bDeviceState
20000000 g .stacks 00000000 __main_stack_base__
080014a0 w F .text 00000002 Vector44
080014a0 w F .text 00000002 Vector28
08002440 g F .text 00000010 boardInit
08002ce0 g F .text 0000008e mpi_cmp_mpi
080014a0 w F .text 00000002 VectorB8
00000400 g *ABS* 00000000 __main_stack_size__
0800a410 g F .text 00000048 neug_get
08001d80 g F .text 00000030 chCondWaitS
08008d60 g F .text 00000058 gpg_increment_digital_signature_counter
08000000 g O .sys 00000034 vector
08004610 g F .text 00000148 rsa_gen_key
08005a30 g F .text 000000aa sha256_finish
20000600 g .stacks 00000000 __process_stack_end__
08006390 w F .text 00000002 EP7_OUT_Callback
080014a0 w F .text 00000002 Vector34
08002430 g F .text 00000004 __early_init
08001a80 g F .text 0000001a chThdTerminate
080014a0 w F .text 00000002 VectorA4
00000200 g *ABS* 00000000 __process_stack_size__
080014a0 w F .text 00000002 Vector20
080040e0 g F .text 000000d8 rsa_private

BIN
src/build/gnuk.elf Executable file

Binary file not shown.

3716
src/build/gnuk.hex Normal file

File diff suppressed because it is too large Load Diff

4060
src/build/gnuk.map Normal file

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,7 @@
#include "ch.h"
#include "gnuk.h"
#include "openpgp.h"
#include "random.h"
#include "polarssl/config.h"
#include "polarssl/rsa.h"

6
src/configure vendored
View File

@ -119,6 +119,8 @@ fi
FLASH_PAGE_SIZE=1024
# Flash memory size in KB
FLASH_SIZE=128
# Memory size in KiB
MEMORY_SIZE=20
# Settings for TARGET
case $target in
@ -129,10 +131,12 @@ CQ_STARM|STBEE_MINI)
STM32_PRIMER2)
FLASH_PAGE_SIZE=2048
FLASH_SIZE=512
MEMORY_SIZE=64
;;
STBEE)
FLASH_PAGE_SIZE=2048
FLASH_SIZE=512
MEMORY_SIZE=64
if test "$with_dfu" = "default"; then
with_dfu=yes;
fi ;;
@ -254,11 +258,13 @@ sed -e "s%@BOARD_DIR@%$BOARD_DIR%" \
if test "$certdo" = "yes"; then
sed -e "/^@CERTDO_SUPPORT_START@$/ d" -e "/^@CERTDO_SUPPORT_END@$/ d" \
-e "s/@ORIGIN@/$ORIGIN/" -e "s/@FLASH_SIZE@/$FLASH_SIZE/" \
-e "s/@MEMORY_SIZE@/$MEMORY_SIZE/" \
-e "s/@FLASH_PAGE_SIZE@/$FLASH_PAGE_SIZE/" \
< gnuk.ld.in > gnuk.ld
else
sed -e "/^@CERTDO_SUPPORT_START@$/,/^@CERTDO_SUPPORT_END@$/ d" \
-e "s/@ORIGIN@/$ORIGIN/" -e "s/@FLASH_SIZE@/$FLASH_SIZE/" \
-e "s/@MEMORY_SIZE@/$MEMORY_SIZE/" \
-e "s/@FLASH_PAGE_SIZE@/$FLASH_PAGE_SIZE/" \
< gnuk.ld.in > gnuk.ld
fi

View File

@ -482,7 +482,7 @@ ecdsa (bn256 *r, bn256 *s, const bn256 *z, const bn256 *d)
continue;
if (bn256_add_uint (tmp_k, tmp_k, 2)) /* > N - 2, still big. */
continue;
bn256_add_uint (k, 1);
bn256_add_uint (k, k, 1);
compute_kG (KG, k);
if (bn256_is_ge (KG->x, N))
bn256_sub (r, KG->x, N);

View File

@ -329,16 +329,6 @@ extern uint8_t admin_authorized;
#define SIZE_PW_STATUS_BYTES 7
extern void random_init (void);
/* 16-byte random bytes */
extern const uint8_t *random_bytes_get (void);
extern void random_bytes_free (const uint8_t *);
/* 4-byte salt */
extern uint32_t get_salt (void);
/* iterator returning a byta at a time */
extern uint8_t random_byte (void *arg);
extern uint32_t hardclock (void);
#define NUM_ALL_PRV_KEYS 3 /* SIG, DEC and AUT */

View File

@ -32,9 +32,9 @@ __process_stack_size__ = 0x0200;
MEMORY
{
flash0 : org = 0x08000000, len = 4k
flash : org = 0x08000000+0x1000, len = 128k - 4k
ram : org = 0x20000000, len = 20k
flash0 : org = @ORIGIN@, len = 4k
flash : org = @ORIGIN@+0x1000, len = @FLASH_SIZE@ - 4k
ram : org = 0x20000000, len = @MEMORY_SIZE@k
}
/* __flash_start__: flash ROM start address regardless of DFU_SUPPORT */

View File

@ -25,9 +25,11 @@
#include "ch.h"
#include "hal.h"
#include "sys.h"
#include "adc.h"
#include "gnuk.h"
#include "usb_lld.h"
#include "usb-cdc.h"
#include "random.h"
#ifdef DEBUG
struct stdout {
@ -334,10 +336,15 @@ main (int argc, char *argv[])
(void)argc;
(void)argv;
main_thread = chThdSelf ();
flash_unlock ();
device_initialize_once ();
halInit ();
adc_init ();
chSysInit ();
main_thread = chThdSelf ();
usb_lld_init (Config_Descriptor.Descriptor[7]);
random_init ();

View File

@ -29,7 +29,7 @@
#include "sys.h"
#include "gnuk.h"
#include "openpgp.h"
#include "random.h"
#include "polarssl/config.h"
#include "polarssl/aes.h"

View File

@ -29,6 +29,7 @@
#include "sys.h"
#include "openpgp.h"
#include "sha256.h"
#include "random.h"
#define ADMIN_PASSWD_MINLEN 8

11
src/random.h Normal file
View File

@ -0,0 +1,11 @@
void random_init (void);
/* 32-byte random bytes */
const uint8_t *random_bytes_get (void);
void random_bytes_free (const uint8_t *p);
/* 4-byte salt */
uint32_t get_salt (void);
/* iterator returning a byta at a time */
uint8_t random_byte (void *arg);