1 2017-09-29 NIIBE Yutaka <gniibe@fsij.org>
3 * src/openpgp.c (modify_binary): Fix for 64-bit machine.
4 * src/openpgp-do.c (encrypt, decrypt): Likewise.
5 (gpg_data_scan): Likewise.
6 (gpg_do_chks_prvkey): Fix error return path.
8 * src/stack-def.h: New.
10 * src/gnuk.ld.in: Remove stack definitions.
11 * src/configure: Remove stack size modifications.
13 * src/main.c (STACK_MAIN, STACK_PROCESS_1): Use stack-def.h.
14 * src/usb-ccid.c (STACK_PROCESS_3): Likewise.
15 * src/usb-msc.c (STACK_PROCESS_5): Likewise.
16 * src/pin-cir.c (STACK_PROCESS_6, STACK_PROCESS_7): Likewise.
18 * src/usb_ctrl.c (download_check_crc32): Use chrc32_rv_ functions.
20 * src/mcu-stm32f103.c (rbit, check_crc32): Remove.
22 * src/neug.c: Update from NeuG.
25 2017-09-28 NIIBE Yutaka <gniibe@fsij.org>
27 * src/ec_p256k1.c (coefficient_a): Remove.
29 * library/bignum.c (mpi_fill_pseudo_random): Fix for 64-bit.
31 * src/call-rsa.c (rsa_decrypt): Fix for 64-bit machine.
33 * src/flash.c (flash_do_storage_init): Rename from flash_init.
34 (flash_key_storage_init): Rename from flash_init_keys.
35 * src/openpgp.c (gpg_init): Use new function names.
37 * src/stdlib.h: Update for GNU/Linux emulation.
39 * src/Makefile: Support GNU/Linux emulation.
40 * src/configure: Support GNU/Linux emulation.
43 2017-08-11 NIIBE Yutaka <gniibe@fsij.org>
46 * chopstx: Update to 1.4.
48 * src/gnuk.ld.in (__process3_stack_size__): Tweak the size.
50 * src/configure: Define STM32F103_OVERRIDE_FLASH_SIZE_KB for
53 * src/configure: Let generate src/config.mk.
54 * src/Makefile: Rename from src/Makefile.in.
55 * regnual/Makefile: Use src/config.mk.
57 2017-08-03 NIIBE Yutaka <gniibe@fsij.org>
59 * src/openpgp.c (cmd_terminate_df): Fix for admin-less mode.
61 2017-08-03 Jeremy Drake <jeremydrake+gnuk@eacceleration.com>
63 * regnual/regnual.c (main): Allow compile time
64 flash size definition by STM32F103_OVERRIDE_FLASH_SIZE_KB.
66 2017-08-02 Jeremy Drake <jeremydrake+gnuk@eacceleration.com>
68 * src/flash.c (flash_terminate): Erase Certificate DO, too.
70 2017-08-01 NIIBE Yutaka <gniibe@fsij.org>
72 * src/openpgp.c (FILE_CARD_TERMINATED_OPENPGP): Remove.
73 (cmd_select_file): Don't change file_selection.
75 2017-07-19 NIIBE Yutaka <gniibe@fsij.org>
77 * src/mod.c (mod_inv): Clear TMP.
79 * src/configure (REVISION): Generate even when no git.
81 * polarssl/library/bignum.c (mpi_exp_mod): Call mpi_grow for X
82 after the initialization of RR.
84 2017-07-18 NIIBE Yutaka <gniibe@fsij.org>
86 * src/configure: Bark when no git available.
88 2017-07-18 Anthony Romano <anthony.romano@coreos.com>
92 2017-07-18 Anthony Romano <anthony.romano@coreos.com>
94 * src/main.c (MEMORY_SIZE, MEM_HEAD_IS_CORRUPT, MEM_HEAD_CHECK):
96 (gnuk_malloc, gnuk_free): Add calls to MEM_HEAD_CHECK.
98 * src/gnuk.h (FATAL_HEAP): New.
100 2017-07-18 Anthony Romano <anthony.romano@coreos.com>
102 * src/openpgp-do.c (gpg_reset_algo_attr): New.
103 (rw_algorithm_attr): Use gpg_reset_algo_attr.
104 Fix null dereference.
106 2017-07-18 Anthony Romano <anthony.romano@coreos.com>
108 * src/mod.c (mod_reduce): Clean up unused code.
110 2017-07-18 Anthony Romano <anthony.romano@coreos.com>
112 * src/call-rsa.c (modulus_calc): Free modulus on error.
113 (rsa_genkey): Remove bogus check, and call chopstx_cleanup_pop
114 with 1 to release p_q_modulus on error. Assign NULL to clp.arg
115 when it's goes with no error.
117 * src/main.c (gnuk_free): Allow NULL.
119 2017-07-18 NIIBE Yutaka <gniibe@fsij.org>
121 * Update chopstx (with USBIP emulation).
123 2017-05-12 NIIBE Yutaka <gniibe@fsij.org>
127 2017-04-28 NIIBE Yutaka <gniibe@fsij.org>
129 * src/mcu-stm32f103.c: New.
130 (check_crc32, sram_address): New.
132 * src/usb_ctrl.c (download_check_crc32): Use check_crc32 and
135 * src/openpgp-do.c (gpg_write_digital_signature_counter): Fix
136 writing lower 10-bit.
138 2017-04-27 NIIBE Yutaka <gniibe@fsij.org>
140 * src/gnuk.ld.in (_data_pool): Move to the end.
142 * src/flash.c (flash_init): Return address of end of data object.
143 * src/openpgp.c (gpg_init): Get address of end of data object.
144 * src/openpgp-do.c (gpg_data_scan): Check the end address.
146 2017-02-02 NIIBE Yutaka <gniibe@fsij.org>
150 * src/gnuk.ld.in (__process1_stack_size__): Increase by 0x20.
151 * chopstx: Update to 1.3.
152 * src/configure: Add BLUE_PILL in the help message.
154 2017-02-01 NIIBE Yutaka <gniibe@fsij.org>
156 * README: Update README. Thanks to Paul Fertser.
158 2017-01-02 Szczepan Zalega <szczepan@nitrokey.com>
160 * tool/upgrade_by_passwd.py: Add file extention check.
162 2017-02-01 NIIBE Yutaka <gniibe@fsij.org>
164 * tool/upgrade_by_passwd.py (main): More verbose messages
165 suggested by Szczepan Zalega <szczepan@nitrokey.com>.
167 * tool/gnuk_token.py (USB_PRODUCT_LIST): New.
168 (gnuk_devices_by_vidpid): Support searching by USB_PRODUCT_LIST.
169 Thanks to Szczepan Zalega <szczepan@nitrokey.com>.
171 * tool/usb_strings.py: Use gnuk_token.py.
173 2016-10-21 Niibe Yutaka <gniibe@fsij.org>
175 * src/ecc.c (check_secret): Fix condition.
177 2016-10-15 NIIBE Yutaka <gniibe@fsij.org>
181 * tool/gnuk_put_binary_libusb.py (main): Likewise.
182 * tool/upgrade_by_passwd.py (main): Add call of cmd_select_openpgp
185 * src/openpgp.c (gpg_init): flash_init_keys shoule be after
186 gpg_data_scan since flash_init_keys accesses Data Object for
189 * src/usb-ccid.c (ccid_power_on): Don't waste stack.
191 2016-10-14 Niibe Yutaka <gniibe@fsij.org>
193 * src/usb-ccid.c (ccid_power_on) [LIFE_CYCLE_MANAGEMENT_SUPPORT]:
194 Change LCS value in ATR at run time.
196 * src/openpgp.c (gpg_init): Handle FILE_CARD_TERMINATED.
197 (cmd_select_file): Don't return AID.
198 (cmd_activate_file, cmd_terminate_df): New.
199 (process_command_apdu): Let return GPG_NO_RECORD() when
202 * src/openpgp-do.c (gpg_do_terminate): New.
203 (gpg_data_scan): Handle p_start is NULL.
204 (do_hist_bytes): Remove.
206 * src/flash.c (flash_data): Change the value from 0x0000.
207 (flash_init): Support termination state. Fix handling
208 of the boundary case where gen0 is 0xfffe.
209 (flash_terminate, flash_activate): New.
210 (flash_copying_gc): Skip 0xffff for generation number.
212 2016-10-13 Niibe Yutaka <gniibe@fsij.org>
214 * src/status-code.h: Rename from openpgp.h.
216 * chopstx: Update to 1.2.
218 * tests: New test suite for OpenPGP card with PyTest.
220 * src/configure (factory_reset): New.
222 * src/usb-ccid.c (ccid_power_on): Use ATR_head and historical
225 * src/openpgp-do.c (rw_algorithm_attr): Clear fingerprint, timestamp,
226 and possibly ds_counter.
228 2016-10-12 Niibe Yutaka <gniibe@fsij.org>
230 * test/features/steps.py (cmd_reset_retry_counter): Fix.
231 * tool/gnuk_token.py (gnuk_token.cmd_reset_retry_counter): Fix.
232 (gnuk_token.cmd_select_openpgp): Fix P2.
234 2016-09-02 Niibe Yutaka <gniibe@fsij.org>
236 * src/configure (REVISION): Fix the detection of .git.
237 It may be a regular file (if it's created by worktree).
239 2016-08-24 Niibe Yutaka <gniibe@fsij.org>
241 * test/features/steps.py (ini): Use GLC (the global context),
242 instead of FTC (the feature context), so that token only is
245 2016-08-03 Niibe Yutaka <gniibe@fsij.org>
247 * tool/hub_ctrl.py: Port to Python 3.
249 2016-07-11 NIIBE Yutaka <gniibe@fsij.org>
253 * src/usb-ccid.c (ccid_power_on): Fix call of chopstx_create.
254 * src/usb-msc.c (msc_init): Ditto.
255 * src/pin-cir.c (cir_init): Ditto.
256 * src/neug.c (neug_init): Ditto.
257 * src/main.c (main): Ditto.
259 * src/usb-ccid.c (struct ccid): Arrange for smaller footprint.
260 * src/gnuk.h (struct apdu): Likewise.
262 * src/usb-ccid.c (ccid_card_change_signal): Don't touch ccid_state_p.
263 (ccid_state_p): This is constant.
265 * src/configure (output_vendor_product_serial_strings): Add const
268 * src/usb-ccid.c (epo_init, epi_init): Simplify without notify method.
269 (EP1_IN_Callback, EP1_OUT_Callback): Call notify_tx and notify_icc
272 2016-07-09 NIIBE Yutaka <gniibe@fsij.org>
274 * src/openpgp.c (openpgp_card_thread): Don't need to get SELF.
276 2016-07-06 NIIBE Yutaka <gniibe@fsij.org>
278 * src/pin-cir.c (cir_getchar): Use chopstx_poll.
279 * src/usb-ccid.c (usb_tx_done): Fix ifdef condition.
280 * src/usb_ctrl.c (usb_ctrl_write_finish): Fix ifdef nesting.
282 2016-07-04 NIIBE Yutaka <gniibe@fsij.org>
284 * doc/conf.py: Remove 'sphinx.ext.pngmath' and 'sphinx.ext.mathjax'.
285 Reported by Kenji Rikitake.
287 2016-07-01 NIIBE Yutaka <gniibe@fsij.org>
289 * chopstx: Update to 1.1.
290 * src/usb-ccid.c (poll_event_intr, ccid_thread): Follow the
293 2016-06-21 Niibe Yutaka <gniibe@fsij.org>
295 * doc/index.rst: Update documentation by an example
298 2016-06-17 Niibe Yutaka <gniibe@fsij.org>
300 * chopstx: Update to 1.0.
302 2016-06-15 NIIBE Yutaka <gniibe@fsij.org>
304 * src/gnuk.ld.in (__process2_stack_size__): Update
305 thread size for rng by examining NeuG.
307 * src/usb-ccid.c (poll_event_intr): New.
309 2016-06-14 Niibe Yutaka <gniibe@fsij.org>
311 * regnual/regnual.c (usb_device_reset): Rename from
313 (usb_ctrl_write_finish): Rename from usb_cb_ctrl_write_finish.
314 (usb_setup): Rename from usb_cb_setup.
315 (usb_get_descriptor): Rename from usb_cb_get_descriptor.
316 (usb_set_configuration): New.
317 (usb_interrupt_handler): New.
319 * src/usb-ccid.c (usb_tx_done): Rename from usb_cb_tx_done.
320 (usb_rx_ready): Rename from usb_cb_rx_ready.
321 (usb_event_handle): New.
322 (ccid_thread): Use usb_event_handle.
324 * src/usb-msc.c (EP6_IN_Callback): Update to new USB API.
325 (EP6_OUT_Callback): Likewise.
327 * src/usb_ctrl.c (usb_device_reset): Rename from
329 (vcom_port_data_setup): Update to new USB API.
330 (usb_ctrl_write_finish): Rename from usb_cb_ctrl_write_finish.
331 (usb_setup): Rename from usb_cb_setup.
332 (usb_set_configuration): New, based on usb_cb_handle_event.
333 (usb_set_interface): Rename from usb_cb_interface.
334 (usb_get_interface): New.
335 (usb_get_status_interface): New.
337 * src/usb_desc.c (usb_get_descriptor): Rename from
338 usb_cb_get_descriptor.
340 2016-06-02 Niibe Yutaka <gniibe@fsij.org>
342 * regnual/regnual.c (usb_cb_tx_done): Follow the change of USB
345 * regnual/reset.c: Rename from sys.c.
347 2016-06-01 Niibe Yutaka <gniibe@fsij.org>
349 * tool/stlinkv2.py (stlinkv2.__init__): Don't
350 call setConfiguration.
352 * tool/gnuk_token.py (gnuk_token, regnual): Don't
353 call setAltInterface, it's not needed.
355 * src/usb-ccid.c (ccid_notify_slot_change): New.
356 (ccid_thread): Call ccid_notify_slot_change at
357 interface_reset and EV_CARD_CHANGE.
359 2016-05-31 NIIBE Yutaka <gniibe@fsij.org>
361 * src/usb_stm32f103.c, src/stm32f103.h: Remove.
362 * src/adc_stm32f103.c, src/sys.c: Remove.
364 * src/usb_ctrl.c (usb_cb_interface): call ccid_usb_reset.
365 (usb_cb_handle_event): Likewise.
367 * src/usb-ccid.c (ccid_thread): Handle RESET->CONFIGURE process
369 (ccid_thread): Handle SET_INTERFACE correctly.
371 * polarssl/library/aes.c (FT0, FT1, FT2): Add "weak" flag.
373 * src/neug.c: Update from NeuG.
375 * src/usb_desc.c (usb_cb_get_descriptor): Only valid if USE_SYS3.
377 * src/Makefile.in (USE_SYS, USE_USB, USE_ADC): Enabled.
380 * src/sys.c, src/sys.h: Remove.
381 * src/usb_stm32f103.c, src/usb_lld.h: Remove.
382 * src/adc_stm32f103.c, src/adc.h: Remove.
384 * chopstx: Update to 0.12.
386 2016-05-21 Niibe Yutaka <gniibe@fsij.org>
388 * src/main.c (led_blink, main): Fix LED blink protocol.
390 2016-05-20 NIIBE Yutaka <gniibe@fsij.org>
393 * src/usb-ccid.c (ccid_thread): Fix timeout.
394 (icc_handle_timeout, icc_send_status): Tweak.
396 2016-05-19 Niibe Yutaka <gniibe@fsij.org>
398 * src/usb_ctrl.c (usb_cb_ctrl_write_finish): Set bDeviceState.
400 * src/usb-ccid.c: Rename from usb-icc.c.
401 (ccid_thread): Handle reGNUal upgrade.
403 * src/Makefile.in (CSRC): Follow the change.
405 * chopstx: Update to 0.11.
407 2016-05-18 Niibe Yutaka <gniibe@fsij.org>
409 * src/gnuk.ld.in: Tweak thread size.
410 * src/main.c (main): Use chopstx_setpriority.
411 * src/usb-icc.c (ccid_init): Use new eventflag API.
413 * regnual/regnual.c (nvic_enable_intr): New.
414 (main): Call nvic_enable_intr.
418 2016-05-16 Niibe Yutaka <gniibe@fsij.org>
420 * regnual/regnual.c (usb_cb_rx_ready, usb_cb_tx_done)
421 (usb_cb_device_reset): Follow the change of USB API.
424 * src/sys.c: Update from Chopstx.
426 2016-05-13 Niibe Yutaka <gniibe@fsij.org>
428 * src/neug.c (rng): Call chopstx_claim_irq before adc_start.
429 Remove call of chopstx_release_irq.
431 2016-05-12 Niibe Yutaka <gniibe@fsij.org>
434 * src/sys.c: Update from Chopstx.
435 * src/usb_lld.h: Likewise.
436 * src/usb_stm32f103.c: Likewise.
438 * src/usb_ctrl.c (usb_intr): Follow the change of USB API.
439 (usb_cb_rx_ready, usb_cb_tx_done): Likewise.
441 * src/adc.h: Remove unused declarations.
443 2016-03-08 Niibe Yutaka <gniibe@fsij.org>
445 * tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__):
446 Don't call setConfiguration method.
448 * src/usb_lld.h (usb_cb_ctrl_write_finish): Change the API of
449 callback, which possibly needs INDEX, VALUE, and LEN parameters.
450 (usb_lld_set_data_to_recv): Fix the type of P.
451 (USB_DEVICE_DESCRIPTOR_TYPE, USB_CONFIGURATION_DESCRIPTOR_TYPE)
452 (USB_STRING_DESCRIPTOR_TYPE, USB_INTERFACE_DESCRIPTOR_TYPE)
453 (USB_ENDPOINT_DESCRIPTOR_TYPE): Remove, as we have the enumeration
454 values for same things.
456 * src/usb_stm32f103.c (handle_in0): Follow the change.
457 * src/usb_ctrl.c (usb_cb_ctrl_write_finish): Likewise.
459 * src/usb_desc.c (usb_cb_get_descriptor): Use HID_INTERFACE.
460 (device_desc, config_desc, string_descriptors)
461 (usb_cb_get_descriptor): Use the enumeration types.
462 * src/configure: Use the enumeration types.
464 * regnual/regnual.c: Follow the change of usb_lld.h.
466 2016-02-09 Niibe Yutaka <gniibe@fsij.org>
468 * src/openpgp.c (cmd_verify): Support VERIFY reset, which is
469 described in the specification V2.2 and V3.1.
471 * polarssl/library/bignum.c (mpi_exp_mod): Fix to our local
472 change. Thanks to Aidan Thornton for the failure test case.
474 Fix of mpi_div_mpi from upstream.
475 * polarssl/library/bignum.c (int_clz, int_div_int): New.
476 (mpi_div_mpi): Use int_div_int.
478 2016-02-09 Niibe Yutaka <gniibe@fsij.org>
480 * src/openpgp.c (s2k): Include the unique ID of MCU into the
481 computation of S2K function.
483 2016-02-08 Niibe Yutaka <gniibe@fsij.org>
485 * src/modp256r1.c (modp256r1_add, modp256r1_sub): Keep the result
487 (modp256r1_reduce): Fix wrong calculation.
488 * src/modp256k1.c (modp256k1_add, modp256k1_sub): Likewise.
489 Thanks to Aidan Thornton.
491 2016-02-05 Niibe Yutaka <gniibe@fsij.org>
493 * src/configure: Add submodule check suggested by Elliott
496 2015-11-30 perillamint <perillamint@gentoo.moe>
498 * src/openpgp.c (card_thread): Fix offset of bConfirmPIN.
500 2015-09-18 Niibe Yutaka <gniibe@fsij.org>
504 * src/openpgp-do.c (proc_key_import): Fix error return.
505 (rw_algorithm_attr): Check it's not ALGO_RSA2K.
507 2015-09-17 Niibe Yutaka <gniibe@fsij.org>
511 2015-09-15 Niibe Yutaka <gniibe@fsij.org>
513 * chopstx: Update to 0.10.
515 * src/main.c (main): Don't join after calling ccid_usb_reset.
516 * src/usb-icc.c (ccid_thread): Don't finish on reset, but
519 * src/usb_ctrl.c (usb_cb_device_reset): Stop the interface.
521 * src/usb_stm32f103.c (std_set_interface): Bug fix for conf.
523 * src/gnuk.ld.in (__process3_stack_size__): Increase stack size of
525 (__process2_stack_size__): Increase stack size of RNG.
526 (__process4_stack_size__): Increase stack size of USB.
527 (__main_stack_size__): Decrease stack size of exception handlers.
528 (__process1_stack_size__): Decrease stack size of CCID.
530 2015-09-14 Niibe Yutaka <gniibe@fsij.org>
532 * src/gnuk.h (LED_GNUK_EXEC): New.
533 * src/main.c, src/usb-icc.c, src/usb_ctrl.c: icc_state_p access
536 2015-09-11 Niibe Yutaka <gniibe@fsij.org>
538 * tool/upgrade_by_passwd.py (main): Loop until finding reGNUal
541 2015-09-10 Niibe Yutaka <gniibe@fsij.org>
543 * src/call-rsa.c (rsa_cleanup): New.
544 (rsa_sign, rsa_decrypt, rsa_genkey): Allow cancellation.
545 * src/openpgp.c (cmd_pso, cmd_internal_authenticate): Cancellation
546 is handled by each functions in case of RSA.
548 2015-09-09 Niibe Yutaka <gniibe@fsij.org>
550 * src/sys.h: Update from Chopstx.
551 * src/adc_stm32f103.c: Update from NeuG.
553 * src/openpgp.c (process_command_apdu): Protect command execution
554 against cancelling the execution thread.
555 (cmd_pso, cmd_internal_authenticate): Allow cancellation.
557 * src/main.c (main): Handle LED_USB_RESET.
559 * src/usb-icc.c (ccid_usb_reset): New.
560 (ccid_thread): Upon receival of EV_USB_RESET, finish
561 the thread, canceling the card thread.
563 2015-09-08 Niibe Yutaka <gniibe@fsij.org>
565 * src/gnuk.h (EV_USB_RESET, LED_USB_RESET): New.
567 * src/usb_ctrl.c (CDC_CTRL_DTR): New.
568 (vcom_port_data_setup): Distinguish detail->value for DTR.
570 * src/configure (help): Add ST_DONGLE and ST_NUCLEO_F103.
572 2015-09-04 Niibe Yutaka <gniibe@fsij.org>
574 * src/openpgp-do.c (do_openpgpcard_aid): Use upper bytes of unique
575 ID of MCU; same as USB serial number.
577 * src/configure (help): Add NITROKEY_START.
579 2015-08-26 Mateusz Zalega <mateusz@nitrokey.com>
581 * GNUK_USB_DEVICE_ID: Add Nitrokey Start.
583 2015-08-05 Niibe Yutaka <gniibe@fsij.org>
587 2015-08-04 Niibe Yutaka <gniibe@fsij.org>
589 * src/adc_stm32f103.c: Update from NeuG 1.0.3.
591 * chopstx: Update to 0.08.
594 2015-08-03 Niibe Yutaka <gniibe@fsij.org>
596 * test/features/steps.py (set_msg): Python3 fix.
597 * test/generate_keys.py: Likewise.
598 * test/rsa_keys.py: Likewise.
600 * tool/gnuk_token.py (gnuk_token.download, gnuk_token.execute)
601 (regnual.download): Python3 fix.
602 (list_to_string): Remove.
604 * tool/upgrade_by_passwd.py (maian): Python3 fix.
605 * tool/usb_strings.py (main): Python3 fix.
607 2015-07-31 Niibe Yutaka <gniibe@fsij.org>
609 * src/configure (output_vendor_product_serial_strings): Fix sed
610 script when string is short. Remove empty line.
612 * regnual/regnual.c (usb_cb_ctrl_write_finish, usb_cb_setup)
613 (usb_cb_get_descriptor, usb_cb_interface): Follow the change
616 * tool/stlinkv2.py: Support ST-Link/V2-1.
618 2015-07-28 Niibe Yutaka <gniibe@fsij.org>
620 * tool/stlinkv2.py: Fix for Python3. Thanks to Bertrand Jacquin.
622 * tool/gpg_agent.py: Fix for Python3.
624 * src/usb-msc.c: Update from Fraucheky.
626 * src/usb_stm32f103.c (struct DATA_INFO): Remove offset.
627 (struct DEVICE_INFO): Integrate CONTROL_INFO.
629 2015-07-27 Niibe Yutaka <gniibe@fsij.org>
631 * src/usb_stm32f103.c (usb_lld_reply_request): New.
632 (usb_lld_set_data_to_send): Remove.
633 (usb_lld_set_data_to_recv): Not a macro but a function.
634 (std_get_status): Don't use statically allocated memory.
635 (std_get_configuration): Use usb_lld_reply_request.
636 (handle_setup0): Follow the change.
637 * src/usb_ctrl.c (vcom_port_data_setup, usb_cb_setup)
638 (usb_cb_interface): Use usb_lld_reply_request.
639 * src/usb_desc.c (usb_cb_get_descriptor): Likewise.
641 2015-07-24 Niibe Yutaka <gniibe@fsij.org>
643 * tool/gnuk_put_binary.py: Remove.
644 * tool/gnuk_remove_keys.py: Remove.
646 2015-07-23 Niibe Yutaka <gniibe@fsij.org>
648 * src/configure (nl): New. Follow the change of NeuG.
650 2015-07-21 Niibe Yutaka <gniibe@fsij.org>
654 2015-07-20 Niibe Yutaka <gniibe@fsij.org>
656 * src/openpgp-do.c (gpg_do_keygen): Support ECC.
657 * src/call-ec.c (ecc_check_secret): New.
658 * src/ecc.c (check_secret): New.
660 2015-07-18 Niibe Yutaka <gniibe@fsij.org>
662 * src/configure (keygen): It's always enabled.
663 * src/openpgp-do.c (gpg_do_keygen): Support key generation.
664 * src/openpgp.c (cmd_pgp_gakp): Likewise.
665 * src/call-rsa.c (rsa_genkey): Likewise.
666 * src/random.c (random_gen): Likewise.
667 * src/Makefile.in (KEYGEN_SUPPORT): Remove.
668 * polarssl/include/polarssl/config.h (POLARSSL_GENPRIME): Define.
670 2015-07-16 Niibe Yutaka <gniibe@fsij.org>
672 * src/configure (FLASH_PAGE_SIZE, FLASH_SIZE, MEMORY_SIZE)
673 [sys1_compat]: Use safe values for common binary.
674 (TARGET_DEFINE): Remove.
676 2015-07-15 Niibe Yutaka <gniibe@fsij.org>
678 * tool/usb_strings.py (field): Add 'Board'.
680 * regnual/regnual.c (usb_cb_get_descriptor): Update.
681 * src/usb_ctrl.c (usb_cb_interface): Call usb_lld_write.
682 * src/usb_desc.c (usb_cb_get_descriptor): Support sys_board_name,
684 * src/usb_lld.h (usb_cb_get_descriptor): Add last argument length
686 * src/usb_stm32f103.c (handle_setup0): Allow setup callback to
687 call usb_lld_write with ENDP0.
688 * src/usb_conf.h (NUM_STRING_DESC): Remove.
690 * src/configure [!sys1_compat] (CONFIG): Don't include target
693 * src/flash.c: Detect flash_page_size at runtime.
695 * src/main.c: Remove dependency to board.h.
697 * src/neug.c: Update from NeuG 1.0.2.
698 * src/adc_stm32f103.c: Update.
700 * chopstx: Update to 0.07.
703 * src/gnuk.ld.in: Update.
705 * tool/stlinkv2.py (stlinkv2.get_chip_id): New. Detect flash
707 (main): Call stlinkv2.get_chip_id after MCU reset and stop.
710 2015-07-11 Niibe Yutaka <gniibe@fsij.org>
712 * src/configure (help): Add STM32_PRIMER2 and CQ_STARM.
714 * chopstx: Update to 0.06.
716 * tool/stlinkv2.py: Support 512kB version of STM32F103.
717 The size of executable file should be even.
719 2015-07-07 Niibe Yutaka <gniibe@fsij.org>
721 * src/Makefile.in (CSRC): Add ecc-mont.c.
723 * src/ecc-mont.c (mod25638_mul_121665): Fix.
724 (ecdh_compute_public_25519, ecdh_decrypt_curve25519): New.
726 * src/openpgp.c (cmd_pso): Support ALGO_CURVE25519.
728 * src/openpgp-do.c (algorithm_attr_cv25519): New.
729 (rw_algorithm_attr, get_algo_attr_data_object)
730 (gpg_get_algo_attr_key_size, gpg_do_write_prvkey)
731 (proc_key_import, gpg_do_public_key): Support ALGO_CURVE25519.
733 * src/gnuk.h (ALGO_CURVE25519): New.
735 2015-07-06 Niibe Yutaka <gniibe@fsij.org>
737 Enhancement for FSM-55.
738 * tool/stlinkv2.py (stlinkv2.control_nrst): New.
739 (stlinkv2.get_rdp_key,has_spi_flash,has_protection): New.
740 (stlinkv2.get_core_id): Rename.
741 (stlinkv2.blank_check): Use self.flash_size.
742 (stlinkv2.start): Call control_nrst. Call get_core_id.
743 Distinguishing chip, and set rdp_key, flash_size and require_nrst.
744 (stlinkv2.flash_write): Use self.flash_block_size.
745 (main): Call control_nrst.
746 (prog_flash_write_body, prog_option_bytes_write_body)
747 (prog_blank_check_body): Support Cortex-M0.
748 (main): Call API V2 halt twice.
749 * tool/asm-thumb/*.S: Updated for Cortex-M0.
751 2015-06-30 Niibe Yutaka <gniibe@fsij.org>
753 * src/sys.c: Update from chopstx/example-cdc/sys.c.
755 * src/main.c (device_initialize_once): Apply change of NeuG.
757 2015-06-03 Niibe Yutaka <gniibe@fsij.org>
761 * test/ecc_nistp256_keys.py: New.
763 * tool/upgrade_by_passwd.py: Remove -p option and add -f option.
765 * tool/gnuk_token.py (gnuk_token.download): Add verbose flag.
766 (regnual.download): Ditto.
768 * tool/gnuk_upgrade.py: Use gnuk_token module.
770 2015-06-02 Niibe Yutaka <gniibe@fsij.org>
772 * src/openpgp.c (cmd_pso): Support OpenPGPcard spec v3.0.
774 2015-04-20 Niibe Yutaka <gniibe@fsij.org>
776 * chopstx: Upgrade to 0.05.
778 2015-04-19 Niibe Yutaka <gniibe@fsij.org>
780 * src/gnuk.h (CCID_CARD_INIT): New.
781 * src/usb_desc.c (gnukConfigDescriptor): Update dwDefaultClock,
782 dwMaximumClock, dwFeatures, and bClassEnvelope.
783 * src/usb_ctrl.c (freq_table): Change the value to 4000MHz.
784 (usb_cb_handle_event): Call ccid_card_change_signal after configure.
785 * src/usb-icc.c (ccid_thread): Change EV_CARD_CHANGE handling.
787 2015-04-18 Niibe Yutaka <gniibe@fsij.org>
789 * src/main.c (main): Call chopstx_main_init.
790 * src/Makefile.in (DEFS): Remove CHX_PRIO_MAIN.
792 2015-04-17 Niibe Yutaka <gniibe@fsij.org>
794 * src/configure: Fix shell syntax.
796 2015-03-31 Niibe Yutaka <gniibe@fsij.org>
798 * src/usb_conf.h (ICC_NUM_INTERFACES, HID_NUM_INTERFACES)
799 (HID_NUM_INTERFACES, VCOM_NUM_INTERFACES, MSC_NUM_INTERFACES)
800 (NUM_INTERFACES): Define here (moved from usb_desc.c).
801 (ICC_INTERFACE, HID_INTERFACE, VCOM_INTERFACE_0, VCOM_INTERFACE_1)
802 (MSC_INTERFACE): New.
803 * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface)
804 (usb_cb_setup, usb_cb_ctrl_write_finish): Use *_INTERFACE.
805 * src/usb_desc.c (gnukConfigDescriptor): Likewise.
807 2015-03-06 Niibe Yutaka <gniibe@fsij.org>
809 * src/ecc-edwards.c (eddsa_sign_25519): Return 0.
811 2015-02-25 Niibe Yutaka <gniibe@fsij.org>
813 * src/openpgp.c (cmd_internal_authenticate): Fix storing to
816 2015-02-10 Niibe Yutaka <gniibe@fsij.org>
818 * src/openpgp.c (cmd_pso): Fix counter update for EdDSA. Thanks
819 to Jonathan Schleifer.
821 * src/call-rsa.c (rsa_sign): Don't set res_APDU_len.
822 (rsa_decrypt): Likewise, but get OUTPUT_LEN_P as an argument.
824 2015-02-09 Niibe Yutaka <gniibe@fsij.org>
826 * src/openpgp.c (cmd_pso): Fix EdDSA. Use GPG_KEY_FOR_SIGNING.
828 2014-12-15 Niibe Yutaka <gniibe@fsij.org>
832 2014-12-13 Niibe Yutaka <gniibe@fsij.org>
834 * src/flash.c (flash_key_getpage, flash_key_release_page): New.
836 * src/openpgp-do.c (gpg_do_delete_prvkey): New arg.
837 (rw_algorithm_attr): Call gpg_do_delete_prvkey with CLEAN_PAGE_FULL.
839 2014-12-12 Niibe Yutaka <gniibe@fsij.org>
841 * src/Makefile.in (build/bignum.o): Specific OPT for this target.
843 * src/configure (target): Default is FST-01.
844 (--with-dfu): FST-01 doesn't have DFU. If set, it must be
847 * boards/STBEE_MINI: Remove, since it is now supported by Chopstx.
849 * test/features/802_get_data_static.feature: Reflect the change
850 of extended capabilities.
851 * test/features/402_get_data_static.feature: Ditto.
852 * test/features/002_get_data_static.feature: Ditto.
854 * test/features/003_keyattr_change.feature: New test.
856 * src/usb_lld.h: Don't use 'extern' for function declarations.
857 * src/usb-icc.c (end_cmd_apdu_data): Fix Le handling.
859 2014-12-11 Niibe Yutaka <gniibe@fsij.org>
861 * chopstx: Upgrade to 0.04.
862 * src/syc.c: Update from 0.04.
864 2014-12-10 Niibe Yutaka <gniibe@fsij.org>
866 * src/ecc-cdh.c: Remove as smartcard only does
867 a part of ECDH computation as gpg-agent does.
869 * src/chconf.h, src/halconf.h: Remove files needed for ChibiOS/RT.
871 2014-12-09 Niibe Yutaka <gniibe@fsij.org>
873 * src/call-ec.c (ecc_compute_public): Rename, as we share
874 same routine among ECDSA and ECDH.
877 2014-12-09 Niibe Yutaka <gniibe@fsij.org>
879 * src/ecc.c (compute_kP): Bug fix. It's P, not G.
880 (point_is_on_the_curve): Bug fix.
882 2014-12-03 Niibe Yutaka <gniibe@fsij.org>
884 Changes for RSA-4096.
886 * src/gnuk.h (MAX_CMD_APDU_DATA_SIZE, MAX_RES_APDU_DATA_SIZE):
887 Send/Recv buffer should be bigger.
888 * polarssl/library/bignum.c (mpi_exp_mod): Don't consume much.
889 * polarssl/library/rsa.c (rsa_rsaes_pkcs1_v15_decrypt): buffer
890 allocation size should be variable.
892 2014-12-01 Niibe Yutaka <gniibe@fsij.org>
894 * src/Makefile.in (DEFS): Don't define compile time preference of
897 * src/openpgp-do.c (proc_key_import): Support modifiable key algo
900 2014-11-21 Niibe Yutaka <gniibe@fsij.org>
902 * src/gnuk.h (ALGO_RSA4K, ALGO_NISTP256R1, ALGO_SECP256K1)
903 (ALGO_ED25519, ALGO_RSA2K): New.
904 (struct key_data_internal): Move to ...
905 * src/openpgp-do.c (struct key_data_internal): ... here.
906 (CHECKSUM_ADDR, kdi_len): New.
907 (CKDC_CALC, CKDC_CHECK): New.
908 (compute_key_data_checksum): Add arg PRVKEY_LEN.
909 (gpg_do_load_prvkey, gpg_do_delete_prvkey): Support modifiable key
911 (gpg_do_write_prvkey, gpg_do_public_key, gpg_do_keygen): Likewise.
912 (gpg_do_clear_prvkey): Use MAX_PRVKEY_LEN.
914 * src/openpgp.c (gpg_init): Call flash_init_keys after
916 (cmd_pso): Support modifiable key algo attributes.
917 (cmd_internal_authenticate): Likewise.
919 2014-11-21 Niibe Yutaka <gniibe@fsij.org>
921 * src/openpgp-do.c (algorithm_attr_rsa2k): Rename from *_rsa.
922 (algorithm_attr_rsa4k): New.
923 (get_algo_attr_pointer, kk_to_nr, gpg_get_algo_attr)
924 (get_algo_attr_data_object, gpg_get_algo_attr_key_size): New.
925 (rw_algorithm_attr): New.
926 (gpg_do_table): Register rw_algorithm_attr for GPG_DO_ALG_*.
927 (gpg_data_scan, gpg_data_copy): Handle algo attributes.
929 (rw_pw_status): Fix checking against redundant write.
931 2014-11-20 Niibe Yutaka <gniibe@fsij.org>
933 * src/openpgp-do.c (extended_capabilities): Key attributes can be
936 2014-11-20 Niibe Yutaka <gniibe@fsij.org>
938 * src/gnuk.h (NR_NONE, NR_DO__FIRST__): Remove.
940 (NR_KEY_ALGO_ATTR_SIG, NR_KEY_ALGO_ATTR_DEC)
941 (NR_KEY_ALGO_ATTR_AUT): New.
943 * src/openpgp-do.c (gpg_do_load_prvkey, gpg_do_delete_prvkey)
944 (gpg_do_write_prvkey, gpg_do_chks_prvkey, gpg_data_scan)
945 (gpg_data_copy, gpg_do_read_simple)
946 (gpg_do_write_simple): Don't use NR_DO__FIRST__.
947 (gpg_do_put_data): Don't use NR_NONE any more.
948 (do_tag_to_nr): Use -1 to specify NONE.
950 * src/flash.c (flash_enum_clear, flash_enum_write_internal)
951 (flash_enum_write): New.
953 2014-11-19 Niibe Yutaka <gniibe@fsij.org>
955 * src/gnuk.h (FIRMWARE_UPDATE_KEY_CONTENT_LEN): New.
956 (size_of_key): New enum.
958 * src/openpgp.c (gpg_get_firmware_update_key)
959 (cmd_read_binary, cmd_external_authenticate): Use
960 FIRMWARE_UPDATE_KEY_CONTENT_LEN.
962 * src/flash.c (KEY_SIZE): Remove.
963 (key_available_at): Add new arg as KEY_SIZE.
964 (flash_check_all_other_keys_released): Likewise.
965 (flash_key_fill_zero_as_released, flash_key_release): Likewise.
967 (flash_init): Move initializing keys into another function.
968 (flash_init_keys): New function.
970 (flash_key_alloc): Use gpg_get_algo_attr_key_size.
971 (flash_key_write): Add new arg as KEY_DATA_LEN.
973 (flash_write_binary): Use FIRMWARE_UPDATE_KEY_CONTENT_LEN.
975 2014-09-16 Niibe Yutaka <gniibe@fsij.org>
977 * src/gnuk.h (MAX_PRVKEY_LEN): New.
978 (KEY_CONTENT_LEN): Remove.
980 * src/call-rsa.c (RSA_SIGNATURE_LENGTH): Remove.
981 (rsa_sign, rsa_verify, rsa_genkey): Add new arg: PUBKEY_LEN.
982 (rsa_decrypt): Don't use KEY_CONTENT_LEN.
984 2014-06-19 Niibe Yutaka <gniibe@fsij.org>
986 * src/ecc-mont.c (compute_nQ): Add comment.
988 * src/mod.c (mod_inv): Fix comment. X^-1 = 0 when X=0
989 is important for Montgomery curve computation.
991 2014-06-05 Niibe Yutaka <gniibe@fsij.org>
993 * tool/add_openpgp_authkey_from_gpgssh.py: New.
995 2014-04-17 Niibe Yutaka <gniibe@fsij.org>
997 * src/muladd_256.h (MULADD_256_ASM): New.
998 (MULADD_256): Use MULADD_256_ASM.
999 * src/ecc-mont.c (mod25638_mul_121665): Add asm implementation.
1001 * src/bn.c (bn256_add_uint, bn256_sub_uint): Simplify.
1002 * src/mod25638.c (mod25638_add, mod25638_sub): Simplify.
1003 (n25638, add19): Remove.
1004 (ADDWORD_256): Add s_ as source pointer.
1005 (mod25519_reduce): Remove a call to memcpy. Use bn256_add_uint.
1006 * src/ecc-edwards.c (point_double): Simplify.
1008 2014-04-16 Niibe Yutaka <gniibe@fsij.org>
1012 2014-04-15 Niibe Yutaka <gniibe@fsij.org>
1014 * src/ecc-mont.c: New.
1016 * src/mod25638.c (p25519): Move from ecc-edwards.c.
1017 (mod25519_reduce, add19): Likewise.
1018 (mod25638_reduce) [!ASM_IMPLEMENTATION]: Use bn256_add_uint.
1020 2014-04-14 Niibe Yutaka <gniibe@fsij.org>
1022 * src/jpc.c (jpc_to_ac): Error check before mod_inv.
1024 * src/mod.c (mod_inv): No return value (if N==0 returns ZERO).
1026 * src/bn.c [BN256_NO_RANDOM]: Only include "random.h" if needed.
1028 2014-04-08 Niibe Yutaka <gniibe@fsij.org>
1030 * src/mod.c (mod_inv): Use MAX_GCD_STEPS_BN256.
1031 Return failure or success.
1032 * src/jpc.c (jpc_to_ac): Use mod_inv.
1033 * src/modp256k1.c (modp256k1_inv): Remove.
1034 * src/modp256r1.c (modp256r1_inv): Remove.
1036 2014-04-07 Niibe Yutaka <gniibe@fsij.org>
1038 * src/openpgp-do.c (algorithm_attr_ed25519): It's OID only.
1040 2014-04-03 Niibe Yutaka <gniibe@fsij.org>
1042 * src/ecc-edwards.c (eddsa_sign_25519): Change type of OUT.
1043 * src/openpgp.c (cmd_internal_authenticate): Have a buffer.
1045 * src/flash.c (flash_init): Fix key address finder.
1047 2014-04-02 Niibe Yutaka <gniibe@fsij.org>
1049 * src/openpgp-do.c (proc_key_import): Handle EdDSA.
1050 (algorithm_attr_ed25519): Fix OID and add ID for SHA512.
1052 2014-04-01 Niibe Yutaka <gniibe@fsij.org>
1054 * src/ecc-edwards.c (eddsa_compute_public_25519): New.
1056 * src/openpgp-do.c (algorithm_attr_ed25519): New.
1057 (gpg_do_write_prvkey, proc_key_import, gpg_do_public_key): Add
1060 2014-03-31 Niibe Yutaka <gniibe@fsij.org>
1062 * src/ecc-edwards.c (eddsa_sign_25519): Rename and API change.
1064 * src/openpgp-do.c (gpg_do_load_prvkey, gpg_do_delete_prvkey)
1065 (gpg_do_write_prvkey, gpg_do_public_key, gpg_do_keygen): Follow
1066 the change of PRVKEY_DATA and KEY_DATA.
1068 * src/flash.c (key_available_at): New.
1069 (flash_init): Initilize KD.
1071 * src/gnuk.h (struct prvkey_data): Remove member KEY_ADDR.
1072 (struct key_data): Addd member KEY_ADDR.
1074 * src/openpgp-do.c (gpg_do_keygen): Bug fix. Reset the signature
1075 counter when new key is generated.
1077 * src/flash.c (flash_key_alloc): Change API, supply KK.
1079 2014-03-29 Niibe Yutaka <gniibe@fsij.org>
1081 * src/ecc-edwards.c (point_double, point_add): Rename.
1082 (mod25519_reduce): New.
1084 2014-03-28 Niibe Yutaka <gniibe@fsij.org>
1086 * misc/t-eddsa.c (main): Update for new API of eddsa_25519.
1088 * src/ecc-edwards.c (compute_kG_25519): Tune for 252-bit.
1089 (eddsa_25519): Public key should be provided by caller.
1090 (eddsa_public_key_25519): New.
1092 2014-03-27 Niibe Yutaka <gniibe@fsij.org>
1094 * src/ecc-edwards.c (ed_add_25638): Remove the third argument.
1095 (compute_kG_25519): The curve is complete, we don't need to avoid
1096 identity element as NIST curve or secp256k1 curve.
1097 (eddsa_25519): Change the API, with A and the seed.
1099 2014-03-26 Niibe Yutaka <gniibe@fsij.org>
1101 * src/mod25638.c (mod25638_reduce): New.
1102 (mod25638_mul, mod25638_sqr): Use mod25638_reduce.
1104 * src/ecc-edwards.c (ptc_to_ac_25519): No need to subtract p25519.
1106 2014-03-25 Niibe Yutaka <gniibe@fsij.org>
1108 * misc/t-eddsa.c: New.
1110 * src/ecc-edwards.c (bnX_mul_C, mod_reduce_M): New.
1113 2014-03-20 Niibe Yutaka <gniibe@fsij.org>
1115 * src/ecc-edwards.c (ed_add_25638): Fix for X == A.
1116 (main): Compute pre-computed tables.
1117 (precomputed_KG, precomputed_2E_KG): Add.
1118 (compute_kG_25519): New.
1120 2014-03-19 Niibe Yutaka <gniibe@fsij.org>
1122 * src/bn.c (bn256_add): Fix for X == B.
1123 (bn256_sub): Likewise.
1125 * src/ecc-edwards.c: New.
1127 2014-03-18 Niibe Yutaka <gniibe@fsij.org>
1129 * src/mod25638.c (mod25638_add, mod25638_sub, mod25638_sqr)
1130 (mod25638_shift): New.
1132 2014-03-13 Niibe Yutaka <gniibe@fsij.org>
1134 * src/mod25638.c: Rename from fe25519.c.
1135 * src/mod25638.h: Likewise.
1137 2014-03-07 Niibe Yutaka <gniibe@fsij.org>
1141 2014-02-25 Niibe Yutaka <gniibe@fsij.org>
1143 * src/openpgp-do.c (gpg_do_public_key): Don't put OID.
1145 * src/configure [certdo] (gnuk.ld): Add TIM_SIZE and EXT_SIZE.
1146 Thanks to Vasily Evseenko for the bug report.
1148 2014-02-21 Niibe Yutaka <gniibe@fsij.org>
1150 * src/ecc.c (compute_kG): Compute higer index at first.
1151 (point_is_on_the_curve): Don't use coefficient_a if it's zero.
1153 * src/jpc.c (jpc_double): Care coefficient A.
1155 * src/ec_p256r1.c (COEFFICIENT_A_IS_MINUS_3): New.
1156 * src/ec_p256k1.c (COEFFICIENT_A_IS_ZERO): New.
1157 * src/jpc_p256r1.c (COEFFICIENT_A_IS_MINUS_3): Likewise.
1158 * src/jpc_p256k1.c (COEFFICIENT_A_IS_MINUS_3): Likewise.
1160 * src/modp256k1.c (modp256k1_shift): Bug fix.
1162 2014-02-20 Niibe Yutaka <gniibe@fsij.org>
1164 * src/Makefile.in (CSRC): Add files of p256k1.
1166 * src/openpgp.c (cmd_pso): Support p256k1 for signature.
1168 * src/openpgp-do.c (algorithm_attr_p256k1): New.
1169 (gpg_do_write_prvkey): Support p256k1 for signature.
1170 (proc_key_import, gpg_do_table, gpg_do_public_key): Likewise.
1172 * src/Makefile.in (DEFS): Add -DRSA_SIG.
1174 * src/openpgp-do.c (gpg_do_write_prvkey): Use _p256r1.
1175 * src/openpgp.c (cmd_internal_authenticate): Likewise.
1177 * src/call-ec_p256k1.c: New. Use call-ec.c.
1178 * src/call-ec_p256r1.c: Use call-ec.c.
1179 * src/call-ec.c: New.
1180 (ecdsa_sign): Change the signature.
1182 2014-02-19 Niibe Yutaka <gniibe@fsij.org>
1184 * tool/calc_precompute_table_ecc.py: New.
1186 * src/ec_p256k1.c: New. Use ecc.c.
1187 * src/ec_p256k1.h: New.
1188 * src/ec_p256r1.c: Use ecc.c.
1191 2014-02-18 Niibe Yutaka <gniibe@fsij.org>
1193 * src/jpc_p256k1.c: New. Use jpc.c.
1194 * src/jpc_p256r1.c: Use jpc.c.
1197 * src/sha256.c (memcpy_output_bswap32): Bug fix.
1199 * src/modp256k1.h, src/modp256k1.c: New.
1201 2014-02-17 Niibe Yutaka <gniibe@fsij.org>
1203 * src/Makefile.in (CSRC): Follow the changes of filenames.
1205 * src/modp256r1.c (modp256r1_add, modp256r1_sub, S3)
1206 (modp256r1_mul, modp256r1_sqr, modp256r1_inv, modp256r1_shift):
1207 Use new function names.
1208 * src/jpc_p256r1.c (jpc_double_p256r1, jpc_add_ac_signed_p256r1)
1209 (jpc_to_ac_p256r1): Likewise.
1210 * src/ec_p256r1.c (point_is_on_the_curve)
1211 (compute_kG_p256r1, compute_kP_p256r1): Likewise.
1212 * src/call-ec_p256r1.c (ecdsa_sign): Likewise.
1214 * src/modp256r1.h: Rename from modp256.h.
1215 * src/jpc-ac_p256r1.h: Rename from jpc-ac.h.
1216 * src/ec_p256r1.h: Rename from ec_p256.h.
1218 * src/modp256r1.c: Rename from modp256.c.
1219 * src/jpc_p256r1.c: Rename from jpc.c.
1220 * src/ec_p256r1.c: Rename from ec_p256.c.
1221 * src/call-ec_p256r1.c: Rename from call-ec_p256.c.
1223 2014-02-05 NIIBE Yutaka <gniibe@fsij.org>
1225 * src/sha512.h, src/sha512.c: New.
1227 * src/sha256.c (initial_state): Don't export, it's internal.
1228 (memcpy_output_bswap32): Rename and remove last argument.
1230 2014-01-28 Niibe Yutaka <gniibe@fsij.org>
1232 * src/muladd_256.h: New.
1233 * src/bn.c (bn256_mul, bn256_sqr): Assembler implementation.
1235 * src/ec_p256.c (get_vk_kP): Bug fix.
1236 (compute_kP): Bug fix for index table.
1238 2014-01-27 Niibe Yutaka <gniibe@fsij.org>
1240 * src/ec_p256.c (get_vk_kP): New.
1241 (naf4_257_set, naf4_257_get, compute_naf4_257): Remove.
1242 (compute_kP): Change the argument, fixing for constant time.
1244 2014-01-24 Niibe Yutaka <gniibe@fsij.org>
1246 * src/ec_p256.c (get_vk): New.
1247 (compute_kG): Fix for constant time.
1248 (compute_kP): Simplify.
1250 2014-01-23 Niibe Yutaka <gniibe@fsij.org>
1252 * src/jpc.c (jpc_add_ac_signed): Fix for constant time.
1254 * src/ec_p256.c (ecdsa): Bug fix for k selection.
1256 2014-01-22 Niibe Yutaka <gniibe@fsij.org>
1258 * src/modp256.c (modp256_inv): Fix for constant time.
1260 * src/bn.c (bn256_sqr): Fix for constant time.
1262 * src/mod.c (mod_inv): Fix for constant time.
1264 * src/ec_p256.c (compute_kG): Simplify.
1266 * src/jpc.c (jpc_double): Support calling with A = infinity.
1268 2014-01-21 Niibe Yutaka <gniibe@fsij.org>
1270 * src/jpc.c (jpc_add_ac_signed): Bug fix for A check.
1272 * src/ec_p256.c (ecdsa): Fix for constant time.
1274 * src/modp256.c (modp256_add, modp256_sub, modp256_reduce)
1275 (modp256_shift): Fix for constant time.
1276 (modp256_inv): Likewise (not fully constant time, yet).
1278 * src/mod.c (mod_reduce): Fix for constant time.
1279 (mod_inv): Likewise (not fully constant time, yet).
1281 * src/bn.h (bn256, bn512): words -> word.
1282 * src/ec_p256.h (naf4_257): Likewise.
1284 2014-01-20 Niibe Yutaka <gniibe@fsij.org>
1286 * src/fe25519.h, src/fe25519.c: New.
1288 2014-01-15 Niibe Yutaka <gniibe@fsij.org>
1290 * src/bn.c (bn256_is_zero, bn256_is_ge, bn256_cmp): Computation
1291 should be constant time.
1293 2013-12-25 Niibe Yutaka <gniibe@fsij.org>
1297 * tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__): Fix
1298 the argument of setAltInterface.
1299 * tool/gnuk_upgrade.py: Likewise.
1300 * tool/dfuse.py (DFU_STM32.__init__): Likewise.
1301 * tool/stlinkv2.py (stlinkv2.__init__): Likewise.
1303 2013-12-24 Niibe Yutaka <gniibe@fsij.org>
1305 * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE)
1306 (MULADDC_1024_LOOP): Use younger number registers more for shorter
1307 instructions and better performance.
1308 * polarssl/library/bignum.c (mpi_montsqr): Likewise. Change loop
1309 structure and conditional branch for better performance.
1311 2013-12-23 Niibe Yutaka <gniibe@fsij.org>
1313 * polarssl/library/bignum.c (mpi_montmul): Computation
1314 time should not depends on input.
1315 (mpi_montmul, mpi_montred, mpi_montsqr): Change the API.
1316 (mpi_exp_mod): Follow the change of the API. Allocate memory on
1317 stack instead of malloc.
1319 * src/gnuk.ld.in (__process3_stack_size__): Increase stack size.
1321 2013-12-20 Niibe Yutaka <gniibe@fsij.org>
1325 * src/usb_ctrl.c (USB_FSIJ_GNUK_CARD_CHANGE): New.
1326 (usb_cb_setup): Support USB_FSIJ_GNUK_CARD_CHANGE.
1327 * src/usb-icc.c (ccid_card_change_signal): New argument HOW.
1329 2013-12-20 Niibe Yutaka <gniibe@fsij.org>
1331 * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE)
1332 (MULADDC_CORE): Reorder instructions for more speed up.
1333 * polarssl/library/bignum.c (mpi_montsqr): Likewise.
1335 2013-12-19 Niibe Yutaka <gniibe@fsij.org>
1337 * src/configure (--enable-hid-card-change): New (experimental).
1338 * src/config.h.in (HID_CARD_CHANGE_DEFINE): New.
1339 * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface)
1340 (usb_cb_setup, usb_cb_ctrl_write_finish): Conditionalize
1341 HID_CARD_CHANGE_SUPPORT.
1342 * src/usb_desc.c (gnukDeviceDescriptor, usb_cb_get_descriptor):
1345 2013-12-19 Niibe Yutaka <gniibe@fsij.org>
1347 * src/openpgp.c (S2KCOUNT): It's now 192, as the threat model
1348 of Gnuk Token is different.
1350 2013-12-19 Niibe Yutaka <gniibe@fsij.org>
1352 * polarssl/library/bignum.c (mpi_montsqr): New.
1353 (mpi_exp_mod): Use mpi_montsqr.
1355 Note that this change introduces a vulnerability by the
1356 Yarom/Falkner flush+reload cache side-channel attack. When this
1357 code is used on general purpose computer where we can observe
1358 which code is executed (sqr or mul), it's not safe.
1360 2013-12-16 Niibe Yutaka <gniibe@fsij.org>
1362 * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE)
1363 (MULADDC_1024_LOOP, MULADDC_HUIT, MULADDC_INIT, MULADDC_CORE)
1364 (MULADDC_STOP) [__arm__]: The value of input B won't change.
1365 More acculate specification for asm statement.
1367 * polarssl/library/bignum.c (mpi_cmp_abs_limbs): New.
1368 (mpi_montmul): Change the signature and use the upper half of T.
1369 (mpi_montred): Likewise.
1370 (mpi_exp_mod): Use improved mpi_montmul and mpi_montred.
1371 (mpi_sub_hlp, mpi_mul_hlp): Add const qualifier for S.
1373 2013-12-13 Niibe Yutaka <gniibe@fsij.org>
1375 * polarssl/library/bignum.c (mpi_exp_mod): Initialize lower
1376 half of T with zero.
1377 (mpi_montmul): Don't need to clear lower half of
1378 T, as we keep zero. Call mpi_sub_hlp with upper half of T.
1379 (mpi_montred): Ditto.
1381 * polarssl/library/bignum.c (mpi_montmul, mpi_montred): Minimize
1382 number of limbs for T.
1383 (mpi_exp_mod): Only allocate N-n * 2 for T.
1384 Only allocate N->n for X, W[i], and RR.
1386 2013-12-13 Niibe Yutaka <gniibe@fsij.org>
1388 * tool/upgrade_by_passwd.py (main): Support -k to specify KEYNO.
1390 2013-12-13 Niibe Yutaka <gniibe@fsij.org>
1392 * src/usb_ctrl.c (HID_LED_STATUS_CARDCHANGE): Rename from
1393 HID_LED_STATUS_NUMLOCK.
1395 * tool/gnuk_token.py (gnuk_token.stop_gnuk): Detach kernel
1398 2013-12-12 Niibe Yutaka <gniibe@fsij.org>
1400 * src/openpgp-do.c (do_openpgpcard_aid): Coerce to volatile to
1401 force memory access at run time.
1403 2013-12-11 Niibe Yutaka <gniibe@fsij.org>
1405 * regnual/sys.c (entry): Fix relocation calculation.
1407 2013-11-27 Niibe Yutaka <gniibe@fsij.org>
1409 * src/stm32f103.h (AFIO_MAPR_SWJ_CFG_DISABLE): New.
1410 * src/sys.c: Likewise.
1412 2013-11-26 Niibe Yutaka <gniibe@fsij.org>
1414 * src/usb_desc.c (hid_report_desc): New.
1415 (ICC_TOTAL_LENGTH): Update.
1416 (HID_TOTAL_LENGTH, HID_NUM_INTERFACES): New.
1417 (W_TOTAL_LENGTH, NUM_INTERFACES): Update.
1418 (gnukConfigDescriptor): Add IN2 interrupt endpoint descriptor.
1419 Add HID interface descriptor.
1420 (usb_cb_get_descriptor): Handle HID.
1422 * src/usb_ctrl.c (NUM_INTERFACES, MSC_INTERFACE_NO): Add 1.
1423 (USB_HID_REQ_*, HID_LED_STATUS_NUMLOCK): New.
1424 (gnuk_setup_endpoints_for_interface): Add ENDP2 interrupt
1426 (usb_cb_setup): Handle HID requests.
1427 (usb_cb_ctrl_write_finish): Likewise.
1429 * src/usb-icc.c (ccid_card_change_signal): New.
1430 (ccid_thread): Handle card change.
1431 (icc_error, icc_send_status): Handle ICC_STATE_NOCARD state.
1432 (icc_handle_data): Add the case of ICC_STATE_NOCARD.
1433 (EP2_IN_Callback): New.
1435 2013-11-26 Niibe Yutaka <gniibe@fsij.org>
1437 * src/pin-dial.c: Remove.
1438 * src/configure: Remove pin-dial support.
1440 2013-11-25 Niibe Yutaka <gniibe@fsij.org>
1442 * src/Makefile.in (HEXOUTPUT_MAKE_OPTION): New.
1443 * src/configure (HEXOUTPUT_MAKE_OPTION): New.
1444 * src/main.c: Include board.h.
1445 * src/stm32f103.h (EXTI0_IRQ, EXTI1_IRQ): New.
1447 2013-11-18 Niibe Yutaka <gniibe@fsij.org>
1449 * regnual/sys.c (entry): Bug fix of clearing BSS.
1451 * src/usb_stm32f103.c: Update from NeuG.
1452 (usb_handle_transfer): Add argument ISTR_VALUE.
1454 * src/openpgp.c (card_thread): Add noinline attribute.
1456 * src/usb-icc.c (ccid_thread): Join the OpenPGP thread.
1457 Add noinline attribute.
1459 2013-11-15 Niibe Yutaka <gniibe@fsij.org>
1461 * src/configure (options): Add --enable-sys1-compat.
1463 2013-11-12 Niibe Yutaka <gniibe@fsij.org>
1465 * chopstx: Upgrade to 0.03.
1467 * src/usb_desc.c (usb_initial_feature): Remove.
1468 (USB_SELF_POWERED): Move to ...
1469 * src/usb_conf.h (USB_SELF_POWERED): ... here.
1470 * src/usb_ctrl.c (usb_cb_device_reset, usb_intr): Follow the
1473 2013-11-11 Niibe Yutaka <gniibe@fsij.org>
1475 * src/adc_stm32f103.c (adc_wait_completion): Update from NeuG 1.0.
1477 2013-11-03 Niibe Yutaka <gniibe@fsij.org>
1479 * regnual/regnual.c (usb_cb_get_descriptor): Update to new API.
1481 * src/usb_lld.h (usb_initial_feature): Remove.
1483 * chopstx: Update to 0.01.
1484 * src/pin-cir.c: Chatter fix to 200ms.
1485 * src/main.c: Fix bDeviceState.
1487 2013-11-02 Niibe Yutaka <gniibe@fsij.org>
1489 * src/usb_lld.h, src/usb_stm32f103.c (std_get_descriptor): Change
1490 the API of usb_cb_get_descriptor.
1491 * src/usb_desc.c: Follow the change.
1492 * src/usb_conf.h: Modify for CCID INT and HID usage.
1494 2013-11-02 Niibe Yutaka <gniibe@fsij.org>
1496 * src/pin-cir.c: Port to Chopstx.
1499 * src/configure (TIM_SIZE, EXT_SIZE): New.
1500 * src/gnuk.ld.in (__process6_stack_size__)
1501 (__process7_stack_size__): New.
1502 * src/main.c (main): Call cir_init.
1503 * src/openpgp.c (openpgp_card_thread): Rename from GPGthread.
1504 * src/usb-icc.c (icc_power_on): Follow the change.
1506 2013-11-01 Niibe Yutaka <gniibe@fsij.org>
1508 * src/sys.c: Update from Chopstx.
1509 * src/usb_lld.h: Remove interrupt definition.
1510 * src/stm32f103.h: Add AFIO, EXTI, and TIMER constants.
1512 2013-10-31 Niibe Yutaka <gniibe@fsij.org>
1514 * src/main.c (main): Call msc_init before USB interrupt thread.
1515 * src/gnuk.h, src/usb-msc.h, src/usb-msc.c, src/pin-dnd.c: Port to
1517 * src/openpgp.c (get_pinpad_input): Follow the change.
1518 * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface): Don't stall
1521 2013-10-24 Niibe Yutaka <gniibe@fsij.org>
1523 * src/Makefile.in (DEFS): Add -DCHX_PRIO_MAIN=5 for LED blink.
1524 * src/main.c (PRIO_CCID): It's now 3 (was: 2).
1526 2013-10-24 Niibe Yutaka <gniibe@fsij.org>
1528 * src/gnuk.ld.in (.gnuk_flash): Three pages for three keys.
1529 * src/flash.c (FLASH_KEYSTORE_SIZE): Likewise.
1530 (flash_keystore_release): Remove.
1531 (flash_key_fill_zero_as_released)
1532 (flash_check_all_other_keys_released, flash_key_release): New.
1533 (flash_init, flash_key_alloc): New method to handle free space.
1534 * src/openpgp-do.c (fetch_four_bytes): New.
1535 (gpg_do_load_prvkey, gpg_do_delete_prvkey, gpg_do_public_key): Use
1537 (gpg_do_delete_prvkey): Call flash_key_release.
1539 2013-10-23 Niibe Yutaka <gniibe@fsij.org>
1541 * test/features/010_setup_passphrase.feature
1542 * test/features/030_key_registration.feature
1543 * test/features/040_passphrase_change.feature
1544 * test/features/410_setup_passphrase.feature
1545 * test/features/430_key_registration.feature
1546 * test/features/201_keygen.feature
1547 * test/features/601_keygen.feature: Modified to support new way of
1548 pass phrase reset by key import / key generation.
1550 * test/features/201_keygen.feature
1551 * test/features/601_keygen.feature
1552 * test/features/202_setup_passphrase.feature
1553 * test/features/602_setup_passphrase.feature: Rename to change
1556 2013-10-23 Niibe Yutaka <gniibe@fsij.org>
1558 * src/openpgp-do.c (gpg_do_write_prvkey): Bug fix of adding
1561 2013-10-22 Niibe Yutaka <gniibe@fsij.org>
1563 * src/openpgp-do.c (gpg_do_write_prvkey): Bug fix.
1565 2013-10-15 Niibe Yutaka <gniibe@fsij.org>
1567 * src/openpgp.c (cmd_change_password, cmd_reset_user_password): It
1568 is now error to change User's pass phrase with no keys.
1570 * src/openpgp-do.c (proc_resetting_code): Likewise for resetting
1572 (gpg_do_delete_prvkey): New.
1573 (gpg_do_write_prvkey): Make sure to delete the key before writing.
1574 User's pass phrase is always the one of factory setting.
1575 (gpg_do_chks_prvkey): Support removing the key.
1576 (proc_key_import): Use gpg_do_delete_prvkey.
1577 (gpg_do_keygen): Use factory setting pass phrase.
1579 2013-10-11 Niibe Yutaka <gniibe@fsij.org>
1581 * src/ac.c (verify_user_0, verify_admin_00): Fix conditions.
1583 * src/openpgp-do.c (gpg_do_write_prvkey): Delete keystring
1584 information from data object of NR_DO_KEYSTRING_PW3.
1586 (gpg_do_keygen): Likewise.
1588 * src/openpgp.c (cmd_reset_user_password): Likewise.
1590 2013-10-10 Niibe Yutaka <gniibe@fsij.org>
1592 * src/gnuk.h (S2K_ITER): Remove. It's determined at compile time.
1594 * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey)
1595 (proc_key_import): Remove "iteration" field.
1597 * src/openpgp.c (cmd_change_password): Likewise.
1599 2013-10-10 Niibe Yutaka <gniibe@fsij.org>
1601 * src/openpgp-do.c (gpg_do_write_prvkey): Access of data object
1602 considering garbage collection.
1604 * src/openpgp.c (cmd_change_password): Call gpg_do_write_simple
1605 after accessing the data object (it may cause garbage collection).
1607 2013-10-10 Niibe Yutaka <gniibe@fsij.org>
1609 * polarssl/library/bignum.c (mpi_montred): Constant time for
1610 carry propagation. Bug fix for carry propagation.
1611 (mpi_exp_mod): Bug fix. Shrink the size of RR as same as X.
1613 2013-10-09 Niibe Yutaka <gniibe@fsij.org>
1615 * src/ac.c (verify_user_0, verify_admin_00, verify_admin_0): Add a
1616 flag to save into keystring_md_pw3. Add SALT handling.
1617 (decode_iterate_count, calc_md, gpg_set_pw3): Remove.
1619 * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey)
1620 (gpg_do_keygen): Add SALT handling.
1621 * src/openpgp.c (cmd_change_password, cmd_reset_user_password)
1623 * src/random.c (random_get_salt): Rename from get_salt.
1625 2013-10-09 Niibe Yutaka <gniibe@fsij.org>
1627 * src/openpgp-do.c (gpg_do_write_prvkey): Remove information (but
1628 pass phrase length) for admin from keystring data object.
1629 (proc_key_import): Recover admin keystring to DO when key deletion.
1631 2013-10-09 Niibe Yutaka <gniibe@fsij.org>
1633 * src/ac.c (verify_user_0, verify_admin_00): Handle PW_LEN_MASK.
1634 * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey):
1637 * src/openpgp.c (cmd_change_password, cmd_reset_user_password):
1638 Handle PW_LEN_KEYSTRING_BIT.
1640 2013-10-09 Niibe Yutaka <gniibe@fsij.org>
1642 * src/ac.c (verify_admin_00): New. Add authentication by loading
1644 (verify_admin_0): Use verify_admin_00.
1646 * src/openpgp.c (cmd_change_password): Admin keystring handling as
1649 2013-10-08 Niibe Yutaka <gniibe@fsij.org>
1651 * src/openpgp.c (modify_binary): Allow odd size of certificate.
1653 * polarssl/library/rsa.c: Update from PolarSSL 1.2.10.
1654 * polarssl/include/polarssl/rsa.h: Ditto.
1656 2013-10-07 Niibe Yutaka <gniibe@fsij.org>
1658 * polarssl/library/bignum.c (mpi_sub_hlp): Return CARRY.
1659 (mpi_sub_abs): Carry propagatoin is done here.
1660 (mpi_mul_hlp_mm): Remove.
1661 (mpi_mul_hlp): Return CARRY, computation in constant time.
1662 (mpi_mul_mpi): Change the order of computation not to propagate
1664 (mpi_montmul): Minimum zero-ing of D and reduce usage of temporary
1665 memory, by one word. Use carry of mpi_mul_hlp. Use
1666 NEED_SUBTRACTION against timing attack.
1667 (mpi_exp_mod): Minimum usage of temporary memory.
1669 2013-10-06 Niibe Yutaka <gniibe@fsij.org>
1671 * polarssl/library/bignum.c (mpi_mul_hlp_mm): New. Handle
1672 extra-carry in constant time to mitigate timing attack.
1673 (mpi_montmul): Use mpi_mul_hlp_mm.
1674 * src/call-rsa.c (rsa_sign, rsa_decrypt, rsa_verify): Don't
1677 2013-10-05 Niibe Yutaka <gniibe@fsij.org>
1679 * polarssl/include/polarssl/aes.h: Update from PolarSSL 1.2.9.
1680 * polarssl/include/polarssl/bignum.h: Ditto.
1681 * polarssl/include/polarssl/config.h: Ditto.
1682 * polarssl/include/polarssl/rsa.h: Ditto.
1683 * polarssl/library/aes.c, polarssl/library/bignum.c: Ditto.
1684 * polarssl/library/rsa.c: Ditto. Fix rsa_free.
1685 * src/call-rsa.c (rsa_sign, modulus_calc, rsa_decrypt)
1686 (rsa_verify): Follow changes of PolarSSL 1.2.9 with RSA blinding.
1687 Better error checking.
1689 2013-10-04 Niibe Yutaka <gniibe@fsij.org>
1691 * src/main.c (gnuk_malloc): Update ->neighbor field of a chunk on
1693 (gnuk_free): Access free list after getting the lock.
1695 2013-10-01 Niibe Yutaka <gniibe@fsij.org>
1697 * src/random.c (random_gen): Bug fix for INDEXed copy.
1699 * src/call-rsa.c (rsa_genkey): Call neug_flush and prng_seed.
1700 * polarssl/library/bignum.c (small_prime): More constants.
1701 (prng_seed, jkiss, mpi_fill_pseudo_random): New.
1702 (mpi_is_prime): Use mpi_fill_pseudo_random.
1704 2013-09-30 Niibe Yutaka <gniibe@fsij.org>
1706 * polarssl/library/bignum.c (mpi_is_prime): Enable trial divisions
1708 Add Fermat primality test.
1709 (mpi_gen_prime): Limit random value so that two MSBs of result will
1712 2013-09-27 Niibe Yutaka <gniibe@fsij.org>
1714 * polarssl/include/polarssl/bignum.h (mpi_is_prime): ifdef-out.
1715 * polarssl/library/bignum.c (mpi_is_prime): It's now internal
1716 function, assuming we already know its coprime to small primes.
1717 (M): New constant MPI. Multiply primes 2*...*691.
1718 (MAX_A): New constant MPI. 2^1024 / M - 1.
1719 (mpi_gen_prime): Specialize for 1024-bit, using Fouque-Tibouchi
1722 2013-09-25 Niibe Yutaka <gniibe@fsij.org>
1724 * src/sha256.h, src/adc.h
1725 * src/neug.c, src/adc_stm32f103.c: Update from NeuG 0.11.
1727 * chopstx: Upgrade to new Chopstx 0.00.
1729 * VERSION: New file.
1731 * src/configure (SERIALNO, SERIALNO_STR_LEN_DEFINE): New.
1732 (REVISION): Use the file VERSION if it doesn't have .git.
1733 Thanks to Sumedha Widyadharma for the bug report.
1735 * src/config.h.in (SERIALNO_STR_LEN_DEFINE): New.
1736 * src/main.c (ID_OFFSET): Use SERIALNO_STR_LEN.
1737 * src/usb_desc.c (gnukStringSerial): Remove. It's now
1738 generated in usb-strings.c.inc.
1740 * src/ec_p256.c (compute_kP): Fix for impossible cases.
1741 (point_is_on_the_curve): New.
1742 (coefficient_a, coefficient_b): New.
1744 2013-09-20 Niibe Yutaka <gniibe@fsij.org>
1746 * src/call-ec_p256.c (ecdsa_compute_public): Handle possible
1747 error (where key_data is the order).
1749 * src/ec_p256.c (compute_kG, compute_kP): Handle errors.
1751 * src/jpc.c (jpc_to_ac): Return -1 on error.
1752 (jpc_add_ac_signed): Handle the case where A=inf.
1754 * src/modp256.c (modp256_inv): Handle error case.
1756 * src/bn.c (bn256_cmp): New.
1758 2013-07-19 Niibe Yutaka <gniibe@fsij.org>
1760 * src/gnuk.ld.in: Layout change following NeuG.
1761 (_end): Add alignment of 16.
1763 * src/neug.c, src/adc.h, src/adc_stm32f103.c: Update from NeuG.
1765 * src/main.c [DFU_SUPPORT] (main): Fix calling
1766 flash_erase_all_and_exec.
1768 * src/openpgp-do.c (gpg_do_write_prvkey, gpg_do_keygen): Fix
1769 allocated memory handling. Clean up before free.
1770 * src/call-rsa.c (modulus_calc, rsa_genkey): Fix removing const.
1771 * src/call-ec_p256.c (ecdsa_compute_public): Likewise.
1773 2013-07-18 Niibe Yutaka <gniibe@fsij.org>
1776 * src/Makefile.in: Change for Chopstx.
1777 * src/configure: Likewise.
1778 * src/gnuk.h, src/gnuk.ld.in: Likewise.
1779 * src/ac.c: Include stdint.h and string.h, not ch.h.
1780 * src/call-rsa.c, src/debug.c, src/flash.c: Likewise.
1781 * src/call-ec_p256.c, src/usb_desc.c
1782 * src/openpgp-do.c, src/random.c: Likewise.
1783 * src/openpgp.c: Likewise. Use eventflag of Chopstx.
1784 * src/usb-icc.c: Likewise.
1785 * src/usb_ctrl.c: Update for Chopstx.
1787 * src/stdlib.h: Use gnuk_malloc and gnuk_free for malloc/free.
1788 * src/config.h.in: Move FLASH_PAGE_SIZE in board.h.
1789 * polarssl/library/aes.c (FT0, FT1, FT2): Export (for sys 2.0).
1790 * src/main.c (struct stdout, _write, EP3_IN_Callback)
1791 (EP5_OUT_Callback): Rewrite for Chopstx. No independent thread
1793 (display_fatal_code, emit_led, display_status_code, led_blink):
1794 Use primitives of Chopstx.
1795 (main): Changes for Chopstx.
1796 (gnuk_malloc_init, sbrk, gnuk_malloc, gnuk_free): New.
1798 2013-06-20 Niibe Yutaka <gniibe@fsij.org>
1800 * src/sys.c, src/sys.h, src/neug.c, src/adc.h
1801 * src/adc_stm32f103.c, src/usb_stm32f103.c: Update from NeuG 0.10.
1802 * src/stm32f103.h: New. From NeuG 0.10.
1804 2013-06-18 Niibe Yutaka <gniibe@fsij.org>
1806 * src/openpgp-do.c (gpg_do_write_prvkey, proc_key_import, gpg_do_table)
1807 (gpg_do_public_key) [RSA_AUTH]: Conditional compilation for RSA/ECDSA.
1808 * src/openpgp.c (cmd_internal_authenticate) [RSA_AUTH]: Likewise.
1810 * src/modp256.c (p256): Add const qualifier.
1812 2013-03-19 Niibe Yutaka <gniibe@fsij.org>
1814 * src/random.c (random_gen): New (was: random_byte).
1816 * src/call-rsa.c (rsa_sign): Follow change of API.
1817 (rsa_genkey): Use random_gen.
1818 (modulus_calc, rsa_decrypt, rsa_verify): Follow change of API.
1819 * src/openpgp-do.c (encrypt, decrypt): Likewise.
1821 * polarssl/include/polarssl/aes.h: Updated from PolarSSL 1.2.6.
1822 * polarssl/library/aes.c: Ditto.
1823 * polarssl/include/polarssl/rsa.h: Ditto.
1824 * polarssl/library/rsa.c: Ditto.
1825 * polarssl/include/polarssl/bignum.h: Ditto.
1826 * polarssl/library/bignum.c: Ditto.
1827 * polarssl: Move from polarssl-0.14.0, and needed files only.
1829 2013-03-15 Niibe Yutaka <gniibe@fsij.org>
1831 * regnual/regnual.ld (.bss): Put at RAM1. This makes reGNUal can
1832 be loaded on the lower address.
1834 * regnual/sys.c (entry): Don't change SP. Put alignment.
1836 * regnual/regnual.c (usb_cb_get_descriptor): Fix adding break.
1838 2013-03-14 Niibe Yutaka <gniibe@fsij.org>
1840 * tool/stlinkv2.py (stlinkv2.start): Call write_debug_reg to run
1843 2013-03-12 Niibe Yutaka <gniibe@fsij.org>
1845 * src/gnuk.ld.in (__process_stack_size__): Increase (was: 0x200).
1847 * tool/stlinkv2.py (stlinkv2.exit_from_debug_swd)
1848 (stlinkv2.exit_from_debug_swim): New.
1849 (stlinkv2.start): Call exit_from_debug_swd or
1850 exit_from_debug_swim.
1852 2013-03-09 Niibe Yutaka <gniibe@fsij.org>
1854 * src/openpgp-do.c (gpg_do_public_key): Add OID for ECDSA.
1855 (gpg_do_write_prvkey): Add PUBKEY_LEN for ECDSA.
1857 * src/flash.c (flash_key_write): Argument change for ECDSA key.
1859 * src/main.c (calculate_regnual_entry_address): New.
1860 (main): Use calculate_regnual_entry_address for entry point.
1862 * src/openpgp-do.c (gpg_do_write_prvkey): Coerce KDI.DATA to
1865 * src/usb_stm32f103.c (handle_setup0): Fix selecting handler.
1867 2013-03-08 Niibe Yutaka <gniibe@fsij.org>
1869 Relocatable reGNUal.
1871 * regnual/regnual.ld (MEMORY): 0x1400 was the value of Gnuk 1.0.1.
1873 (.text): Include .text.entry next to the .vectors.
1876 * regnual/sys.c (entry): Now, it's at .text.entry section.
1878 Don't use absolute values which causes relocations, but
1881 * regnual/Makefile (CFLAGS): Add -fpie.
1883 2013-03-07 Niibe Yutaka <gniibe@fsij.org>
1885 Follow the USB stack change.
1887 * regnual/regnual.c (usb_cb_device_reset): Rename from
1888 regnual_device_reset.
1889 (mem): Change type to uint32_t.
1890 (mem_info): Removed.
1891 (fetch): Avoid pointer punning.
1892 (usb_cb_ctrl_write_finish): Rename from regnual_ctrl_write_finish.
1893 (usb_cb_setup): Rename from regnual_setup.
1894 (usb_cb_get_descriptor): Rename from regnual_get_descriptor.
1895 (usb_cb_handle_event): Rename regnual_usb_event.
1896 (usb_cb_interface): Rename regnual_interface.
1897 (Device_Method): Remove.
1898 (usb_cb_get_descriptor): Not use struct Descriptor.
1900 2013-03-06 Niibe Yutaka <gniibe@fsij.org>
1902 USB stack implementation improvement.
1904 * src/usb_stm32f103.c (Device_Method, method_p): Remove.
1905 (usb_interrupt_handler): Call usb_cb_device_reset.
1906 (std_get_descriptor): Call usb_cb_get_descriptor.
1907 (std_set_configuration): Call usb_cb_handle_event.
1908 (std_get_status, std_get_interface, std_set_interface): Call
1910 (handle_setup0): Call usb_cb_setup.
1911 (handle_in0): Call usb_cb_handle_event and
1912 usb_cb_ctrl_write_finish.
1913 (request_handler): Remove.
1914 (handle_setup0): Call std_* directly, not indirectly by
1916 (ep_intr_handler_IN, ep_intr_handler_OUT): Remove.
1917 (usb_handle_transfer): Call EP*_Callback directly, not indirectly
1918 by ep_intr_handler_IN, ep_intr_handler_OUT.
1920 * src/usb_lld.h (struct usb_device_method, Device_Method): Remove.
1921 (usb_cb_device_reset, usb_cb_ctrl_write_finish)
1922 (usb_cb_setup, usb_cb_get_descriptor, usb_cb_handle_event)
1923 (usb_cb_interface): Define callbacks.
1924 (usb_initial_feature): New.
1925 (struct Descriptor): Move to ...
1926 * src/usb_desc.c: ... here.
1927 (usb_initial_feature): New.
1928 (usb_cb_get_descriptor): Rename from gnuk_get_descriptor and move
1931 * src/usb_ctrl.c (usb_cb_device_reset): Rename from
1933 (usb_cb_setup): Rename from gnuk_setup.
1934 (usb_cb_ctrl_write_finish): Rename from gnuk_ctrl_write_finish.
1935 (usb_cb_event): Rename from gnuk_usb_event.
1936 (usb_cb_interface): Rename from gnuk_interface.
1937 (Device_Method): Remove.
1939 * src/main.c (main): Use usb_initial_feature.
1941 2013-02-27 Niibe Yutaka <gniibe@fsij.org>
1943 * src/usb-icc.c (set_sw1sw2): Arguments are C and CHUNK_LEN.
1944 Fix reporting remaining bytes.
1945 (icc_send_data_block_gr): Follow the arguments change of
1948 2013-02-26 Niibe Yutaka <gniibe@fsij.org>
1950 * regnual/regnual.ld (MEMORY): Fix start address.
1952 * src/random.c (random_fini): New.
1953 * src/main.c (main): Call random_fini.
1955 2013-02-25 Niibe Yutaka <gniibe@fsij.org>
1957 * src/configure: Correct typo in help text.
1959 * src/gnuk.h (struct key_data_internal): Use uint32_t.
1960 * src/openpgp-do.c (do_openpgpcard_aid): Fix calculation of VID.
1961 (compute_key_data_checksum): Don't use type-punning pointer.
1962 (gpg_do_write_prvkey): Use coercing to char *.
1964 2013-02-22 Niibe Yutaka <gniibe@fsij.org>
1966 * src/openpgp-do.c (gpg_do_public_key): Add header of EC point.
1968 * src/openpgp-do.c (GPG_DO_DISCRETIONARY, cmp_discretionary): New.
1969 (cmp_app_data): Change to factor out GPG_DO_DISCRETIONARY.
1970 (gpg_do_table): Add GPG_DO_DISCRETIONARY.
1972 2013-02-21 Niibe Yutaka <gniibe@fsij.org>
1974 * src/gnuk.ld.in (MEMORY): Fix adding FLASH_SIZE unit.
1976 * src/call-ec_p256.c (ecdsa_sign): Fix secret key access.
1978 2013-02-20 Niibe Yutaka <gniibe@fsij.org>
1980 * src/openpgp.c (cmd_internal_authenticate): Support ECDSA for
1983 * src/openpgp-do.c (algorithm_attr_ecdsa): New.
1984 (algorithm_attr_rsa): Rename (was: algorithm_attr).
1985 (gpg_do_table): Change for GPG_DO_ALG_AUT.
1986 (gpg_do_write_prvkey): Support ECDSA key for authentication.
1987 (proc_key_import): Likewise.
1988 (gpg_do_public_key): Likewise.
1990 * src/call-ec_p256.c: New.
1991 * src/Makefile.in: Add call-ec_p256.c.
1992 * src/call-rsa.c (modulus_free): Remove.
1994 2013-02-19 Niibe Yutaka <gniibe@fsij.org>
1996 * regnual/regnual.ld (MEMORY): Fix address of regnual.
1998 * regnual/Makefile (MCFLAGS): Remove -mfix-cortex-m3-ldrd.
1999 (CFLAGS): Add output to .lst.
2000 * src/Makefile.in (MCFLAGS): Remove.
2002 * src/sha256.c: Update from NeuG 0.05.
2004 * ChibiOS_2.0.8: Remove.
2006 2013-02-18 Niibe Yutaka <gniibe@fsij.org>
2008 Changes for new ChibiOS/RT.
2009 * src/main.c: Include adc.h.
2010 (main): Call halInit, adc_init, and chSysInit (change for
2012 * src/random.h: New.
2013 * src/ac.c, src/bn.c, src/call-rsa.c, src/main.c: Include random.h.
2014 * src/openpgp.c, src/openpgp-do.c: Likewise.
2015 * src/configure, src/gnuk.ld.in: Add MEMORY_SIZE.
2016 * src/ec_p256.c: Fix call of bn256_add_uint.
2017 * boards/STM8S_DISCOVERY/*: Update for ChibiOS/RT 2.4.x.
2018 * boards/CQ_STARM/*: Likewise.
2019 * boards/FST_01_00/*: Likewise.
2020 * boards/OLIMEX_STM32_H103/*: Likewise.
2021 * boards/STBEE/*: Likewise.
2022 * boards/STBEE_MINI/*: Likewise.
2023 * boards/STM32_PRIMER2/*: Likewise.
2025 Merge ec_p256 branch.
2026 * src/Makefile.in: Add ECC files.
2027 * src/bn.h, src/bn.c: New.
2028 * src/jpc-ac.h, src/jpc.c: New.
2029 * src/ec_p256.h, src/ec_p256.c, src/ecc-cdh.c: New.
2030 * src/mod.h, src/mod.c, src/modp256.h, src/modp256.c: New.
2032 2013-02-17 Niibe Yutaka <gniibe@fsij.org>
2034 * chibios: New submodule for ChibioS/RT 2.4.x.
2035 * boards/FST_01/*: Update for ChibiOS/RT 2.4.x.
2036 * boards/common/mcuconf-common.h: Ditto.
2038 * src/chconf.h, src/halconf.h, src/Makefile.in, src/gnuk.ld.in:
2039 Update for ChibiOS/RT 2.4.x.
2041 * src/main.c, src/openpgp.c, src/usb-icc.c: Follow the change of
2043 * boards/common/board-common.c: Rename from hwinit.c.
2044 * src/usb_stm32f103.c: Rename from usb_lld.c.
2046 * src/neug.h, src/neug.c: Update NeuG 0.05.
2047 * src/adc_stm32f103.c, src/adc.h: New from NeuG 0.05.
2049 * src/random.c: Follow the change of NeuG 0.05.