1 2017-07-18 Anthony Romano <anthony.romano@coreos.com>
3 * src/main.c (MEMORY_SIZE, MEM_HEAD_IS_CORRUPT, MEM_HEAD_CHECK):
5 (gnuk_malloc, gnuk_free): Add calls to MEM_HEAD_CHECK.
7 * src/gnuk.h (FATAL_HEAP): New.
9 2017-07-18 Anthony Romano <anthony.romano@coreos.com>
11 * src/openpgp-do.c (gpg_reset_algo_attr): New.
12 (rw_algorithm_attr): Use gpg_reset_algo_attr.
15 2017-07-18 Anthony Romano <anthony.romano@coreos.com>
17 * src/mod.c (mod_reduce): Clean up unused code.
19 2017-07-18 Anthony Romano <anthony.romano@coreos.com>
21 * src/call-rsa.c (modulus_calc): Free modulus on error.
22 (rsa_genkey): Remove bogus check, and call chopstx_cleanup_pop
23 with 1 to release p_q_modulus on error. Assign NULL to clp.arg
24 when it's goes with no error.
26 * src/main.c (gnuk_free): Allow NULL.
28 2017-07-18 NIIBE Yutaka <gniibe@fsij.org>
30 * Update chopstx (with USBIP emulation).
32 2017-05-12 NIIBE Yutaka <gniibe@fsij.org>
36 2017-04-28 NIIBE Yutaka <gniibe@fsij.org>
38 * src/mcu-stm32f103.c: New.
39 (check_crc32, sram_address): New.
41 * src/usb_ctrl.c (download_check_crc32): Use check_crc32 and
44 * src/openpgp-do.c (gpg_write_digital_signature_counter): Fix
47 2017-04-27 NIIBE Yutaka <gniibe@fsij.org>
49 * src/gnuk.ld.in (_data_pool): Move to the end.
51 * src/flash.c (flash_init): Return address of end of data object.
52 * src/openpgp.c (gpg_init): Get address of end of data object.
53 * src/openpgp-do.c (gpg_data_scan): Check the end address.
55 2017-02-02 NIIBE Yutaka <gniibe@fsij.org>
59 * src/gnuk.ld.in (__process1_stack_size__): Increase by 0x20.
60 * chopstx: Update to 1.3.
61 * src/configure: Add BLUE_PILL in the help message.
63 2017-02-01 NIIBE Yutaka <gniibe@fsij.org>
65 * README: Update README. Thanks to Paul Fertser.
67 2017-01-02 Szczepan Zalega <szczepan@nitrokey.com>
69 * tool/upgrade_by_passwd.py: Add file extention check.
71 2017-02-01 NIIBE Yutaka <gniibe@fsij.org>
73 * tool/upgrade_by_passwd.py (main): More verbose messages
74 suggested by Szczepan Zalega <szczepan@nitrokey.com>.
76 * tool/gnuk_token.py (USB_PRODUCT_LIST): New.
77 (gnuk_devices_by_vidpid): Support searching by USB_PRODUCT_LIST.
78 Thanks to Szczepan Zalega <szczepan@nitrokey.com>.
80 * tool/usb_strings.py: Use gnuk_token.py.
82 2016-10-21 Niibe Yutaka <gniibe@fsij.org>
84 * src/ecc.c (check_secret): Fix condition.
86 2016-10-15 NIIBE Yutaka <gniibe@fsij.org>
90 * tool/gnuk_put_binary_libusb.py (main): Likewise.
91 * tool/upgrade_by_passwd.py (main): Add call of cmd_select_openpgp
94 * src/openpgp.c (gpg_init): flash_init_keys shoule be after
95 gpg_data_scan since flash_init_keys accesses Data Object for
98 * src/usb-ccid.c (ccid_power_on): Don't waste stack.
100 2016-10-14 Niibe Yutaka <gniibe@fsij.org>
102 * src/usb-ccid.c (ccid_power_on) [LIFE_CYCLE_MANAGEMENT_SUPPORT]:
103 Change LCS value in ATR at run time.
105 * src/openpgp.c (gpg_init): Handle FILE_CARD_TERMINATED.
106 (cmd_select_file): Don't return AID.
107 (cmd_activate_file, cmd_terminate_df): New.
108 (process_command_apdu): Let return GPG_NO_RECORD() when
111 * src/openpgp-do.c (gpg_do_terminate): New.
112 (gpg_data_scan): Handle p_start is NULL.
113 (do_hist_bytes): Remove.
115 * src/flash.c (flash_data): Change the value from 0x0000.
116 (flash_init): Support termination state. Fix handling
117 of the boundary case where gen0 is 0xfffe.
118 (flash_terminate, flash_activate): New.
119 (flash_copying_gc): Skip 0xffff for generation number.
121 2016-10-13 Niibe Yutaka <gniibe@fsij.org>
123 * src/status-code.h: Rename from openpgp.h.
125 * chopstx: Update to 1.2.
127 * tests: New test suite for OpenPGP card with PyTest.
129 * src/configure (factory_reset): New.
131 * src/usb-ccid.c (ccid_power_on): Use ATR_head and historical
134 * src/openpgp-do.c (rw_algorithm_attr): Clear fingerprint, timestamp,
135 and possibly ds_counter.
137 2016-10-12 Niibe Yutaka <gniibe@fsij.org>
139 * test/features/steps.py (cmd_reset_retry_counter): Fix.
140 * tool/gnuk_token.py (gnuk_token.cmd_reset_retry_counter): Fix.
141 (gnuk_token.cmd_select_openpgp): Fix P2.
143 2016-09-02 Niibe Yutaka <gniibe@fsij.org>
145 * src/configure (REVISION): Fix the detection of .git.
146 It may be a regular file (if it's created by worktree).
148 2016-08-24 Niibe Yutaka <gniibe@fsij.org>
150 * test/features/steps.py (ini): Use GLC (the global context),
151 instead of FTC (the feature context), so that token only is
154 2016-08-03 Niibe Yutaka <gniibe@fsij.org>
156 * tool/hub_ctrl.py: Port to Python 3.
158 2016-07-11 NIIBE Yutaka <gniibe@fsij.org>
162 * src/usb-ccid.c (ccid_power_on): Fix call of chopstx_create.
163 * src/usb-msc.c (msc_init): Ditto.
164 * src/pin-cir.c (cir_init): Ditto.
165 * src/neug.c (neug_init): Ditto.
166 * src/main.c (main): Ditto.
168 * src/usb-ccid.c (struct ccid): Arrange for smaller footprint.
169 * src/gnuk.h (struct apdu): Likewise.
171 * src/usb-ccid.c (ccid_card_change_signal): Don't touch ccid_state_p.
172 (ccid_state_p): This is constant.
174 * src/configure (output_vendor_product_serial_strings): Add const
177 * src/usb-ccid.c (epo_init, epi_init): Simplify without notify method.
178 (EP1_IN_Callback, EP1_OUT_Callback): Call notify_tx and notify_icc
181 2016-07-09 NIIBE Yutaka <gniibe@fsij.org>
183 * src/openpgp.c (openpgp_card_thread): Don't need to get SELF.
185 2016-07-06 NIIBE Yutaka <gniibe@fsij.org>
187 * src/pin-cir.c (cir_getchar): Use chopstx_poll.
188 * src/usb-ccid.c (usb_tx_done): Fix ifdef condition.
189 * src/usb_ctrl.c (usb_ctrl_write_finish): Fix ifdef nesting.
191 2016-07-04 NIIBE Yutaka <gniibe@fsij.org>
193 * doc/conf.py: Remove 'sphinx.ext.pngmath' and 'sphinx.ext.mathjax'.
194 Reported by Kenji Rikitake.
196 2016-07-01 NIIBE Yutaka <gniibe@fsij.org>
198 * chopstx: Update to 1.1.
199 * src/usb-ccid.c (poll_event_intr, ccid_thread): Follow the
202 2016-06-21 Niibe Yutaka <gniibe@fsij.org>
204 * doc/index.rst: Update documentation by an example
207 2016-06-17 Niibe Yutaka <gniibe@fsij.org>
209 * chopstx: Update to 1.0.
211 2016-06-15 NIIBE Yutaka <gniibe@fsij.org>
213 * src/gnuk.ld.in (__process2_stack_size__): Update
214 thread size for rng by examining NeuG.
216 * src/usb-ccid.c (poll_event_intr): New.
218 2016-06-14 Niibe Yutaka <gniibe@fsij.org>
220 * regnual/regnual.c (usb_device_reset): Rename from
222 (usb_ctrl_write_finish): Rename from usb_cb_ctrl_write_finish.
223 (usb_setup): Rename from usb_cb_setup.
224 (usb_get_descriptor): Rename from usb_cb_get_descriptor.
225 (usb_set_configuration): New.
226 (usb_interrupt_handler): New.
228 * src/usb-ccid.c (usb_tx_done): Rename from usb_cb_tx_done.
229 (usb_rx_ready): Rename from usb_cb_rx_ready.
230 (usb_event_handle): New.
231 (ccid_thread): Use usb_event_handle.
233 * src/usb-msc.c (EP6_IN_Callback): Update to new USB API.
234 (EP6_OUT_Callback): Likewise.
236 * src/usb_ctrl.c (usb_device_reset): Rename from
238 (vcom_port_data_setup): Update to new USB API.
239 (usb_ctrl_write_finish): Rename from usb_cb_ctrl_write_finish.
240 (usb_setup): Rename from usb_cb_setup.
241 (usb_set_configuration): New, based on usb_cb_handle_event.
242 (usb_set_interface): Rename from usb_cb_interface.
243 (usb_get_interface): New.
244 (usb_get_status_interface): New.
246 * src/usb_desc.c (usb_get_descriptor): Rename from
247 usb_cb_get_descriptor.
249 2016-06-02 Niibe Yutaka <gniibe@fsij.org>
251 * regnual/regnual.c (usb_cb_tx_done): Follow the change of USB
254 * regnual/reset.c: Rename from sys.c.
256 2016-06-01 Niibe Yutaka <gniibe@fsij.org>
258 * tool/stlinkv2.py (stlinkv2.__init__): Don't
259 call setConfiguration.
261 * tool/gnuk_token.py (gnuk_token, regnual): Don't
262 call setAltInterface, it's not needed.
264 * src/usb-ccid.c (ccid_notify_slot_change): New.
265 (ccid_thread): Call ccid_notify_slot_change at
266 interface_reset and EV_CARD_CHANGE.
268 2016-05-31 NIIBE Yutaka <gniibe@fsij.org>
270 * src/usb_stm32f103.c, src/stm32f103.h: Remove.
271 * src/adc_stm32f103.c, src/sys.c: Remove.
273 * src/usb_ctrl.c (usb_cb_interface): call ccid_usb_reset.
274 (usb_cb_handle_event): Likewise.
276 * src/usb-ccid.c (ccid_thread): Handle RESET->CONFIGURE process
278 (ccid_thread): Handle SET_INTERFACE correctly.
280 * polarssl/library/aes.c (FT0, FT1, FT2): Add "weak" flag.
282 * src/neug.c: Update from NeuG.
284 * src/usb_desc.c (usb_cb_get_descriptor): Only valid if USE_SYS3.
286 * src/Makefile.in (USE_SYS, USE_USB, USE_ADC): Enabled.
289 * src/sys.c, src/sys.h: Remove.
290 * src/usb_stm32f103.c, src/usb_lld.h: Remove.
291 * src/adc_stm32f103.c, src/adc.h: Remove.
293 * chopstx: Update to 0.12.
295 2016-05-21 Niibe Yutaka <gniibe@fsij.org>
297 * src/main.c (led_blink, main): Fix LED blink protocol.
299 2016-05-20 NIIBE Yutaka <gniibe@fsij.org>
302 * src/usb-ccid.c (ccid_thread): Fix timeout.
303 (icc_handle_timeout, icc_send_status): Tweak.
305 2016-05-19 Niibe Yutaka <gniibe@fsij.org>
307 * src/usb_ctrl.c (usb_cb_ctrl_write_finish): Set bDeviceState.
309 * src/usb-ccid.c: Rename from usb-icc.c.
310 (ccid_thread): Handle reGNUal upgrade.
312 * src/Makefile.in (CSRC): Follow the change.
314 * chopstx: Update to 0.11.
316 2016-05-18 Niibe Yutaka <gniibe@fsij.org>
318 * src/gnuk.ld.in: Tweak thread size.
319 * src/main.c (main): Use chopstx_setpriority.
320 * src/usb-icc.c (ccid_init): Use new eventflag API.
322 * regnual/regnual.c (nvic_enable_intr): New.
323 (main): Call nvic_enable_intr.
327 2016-05-16 Niibe Yutaka <gniibe@fsij.org>
329 * regnual/regnual.c (usb_cb_rx_ready, usb_cb_tx_done)
330 (usb_cb_device_reset): Follow the change of USB API.
333 * src/sys.c: Update from Chopstx.
335 2016-05-13 Niibe Yutaka <gniibe@fsij.org>
337 * src/neug.c (rng): Call chopstx_claim_irq before adc_start.
338 Remove call of chopstx_release_irq.
340 2016-05-12 Niibe Yutaka <gniibe@fsij.org>
343 * src/sys.c: Update from Chopstx.
344 * src/usb_lld.h: Likewise.
345 * src/usb_stm32f103.c: Likewise.
347 * src/usb_ctrl.c (usb_intr): Follow the change of USB API.
348 (usb_cb_rx_ready, usb_cb_tx_done): Likewise.
350 * src/adc.h: Remove unused declarations.
352 2016-03-08 Niibe Yutaka <gniibe@fsij.org>
354 * tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__):
355 Don't call setConfiguration method.
357 * src/usb_lld.h (usb_cb_ctrl_write_finish): Change the API of
358 callback, which possibly needs INDEX, VALUE, and LEN parameters.
359 (usb_lld_set_data_to_recv): Fix the type of P.
360 (USB_DEVICE_DESCRIPTOR_TYPE, USB_CONFIGURATION_DESCRIPTOR_TYPE)
361 (USB_STRING_DESCRIPTOR_TYPE, USB_INTERFACE_DESCRIPTOR_TYPE)
362 (USB_ENDPOINT_DESCRIPTOR_TYPE): Remove, as we have the enumeration
363 values for same things.
365 * src/usb_stm32f103.c (handle_in0): Follow the change.
366 * src/usb_ctrl.c (usb_cb_ctrl_write_finish): Likewise.
368 * src/usb_desc.c (usb_cb_get_descriptor): Use HID_INTERFACE.
369 (device_desc, config_desc, string_descriptors)
370 (usb_cb_get_descriptor): Use the enumeration types.
371 * src/configure: Use the enumeration types.
373 * regnual/regnual.c: Follow the change of usb_lld.h.
375 2016-02-09 Niibe Yutaka <gniibe@fsij.org>
377 * src/openpgp.c (cmd_verify): Support VERIFY reset, which is
378 described in the specification V2.2 and V3.1.
380 * polarssl/library/bignum.c (mpi_exp_mod): Fix to our local
381 change. Thanks to Aidan Thornton for the failure test case.
383 Fix of mpi_div_mpi from upstream.
384 * polarssl/library/bignum.c (int_clz, int_div_int): New.
385 (mpi_div_mpi): Use int_div_int.
387 2016-02-09 Niibe Yutaka <gniibe@fsij.org>
389 * src/openpgp.c (s2k): Include the unique ID of MCU into the
390 computation of S2K function.
392 2016-02-08 Niibe Yutaka <gniibe@fsij.org>
394 * src/modp256r1.c (modp256r1_add, modp256r1_sub): Keep the result
396 (modp256r1_reduce): Fix wrong calculation.
397 * src/modp256k1.c (modp256k1_add, modp256k1_sub): Likewise.
398 Thanks to Aidan Thornton.
400 2016-02-05 Niibe Yutaka <gniibe@fsij.org>
402 * src/configure: Add submodule check suggested by Elliott
405 2015-11-30 perillamint <perillamint@gentoo.moe>
407 * src/openpgp.c (card_thread): Fix offset of bConfirmPIN.
409 2015-09-18 Niibe Yutaka <gniibe@fsij.org>
413 * src/openpgp-do.c (proc_key_import): Fix error return.
414 (rw_algorithm_attr): Check it's not ALGO_RSA2K.
416 2015-09-17 Niibe Yutaka <gniibe@fsij.org>
420 2015-09-15 Niibe Yutaka <gniibe@fsij.org>
422 * chopstx: Update to 0.10.
424 * src/main.c (main): Don't join after calling ccid_usb_reset.
425 * src/usb-icc.c (ccid_thread): Don't finish on reset, but
428 * src/usb_ctrl.c (usb_cb_device_reset): Stop the interface.
430 * src/usb_stm32f103.c (std_set_interface): Bug fix for conf.
432 * src/gnuk.ld.in (__process3_stack_size__): Increase stack size of
434 (__process2_stack_size__): Increase stack size of RNG.
435 (__process4_stack_size__): Increase stack size of USB.
436 (__main_stack_size__): Decrease stack size of exception handlers.
437 (__process1_stack_size__): Decrease stack size of CCID.
439 2015-09-14 Niibe Yutaka <gniibe@fsij.org>
441 * src/gnuk.h (LED_GNUK_EXEC): New.
442 * src/main.c, src/usb-icc.c, src/usb_ctrl.c: icc_state_p access
445 2015-09-11 Niibe Yutaka <gniibe@fsij.org>
447 * tool/upgrade_by_passwd.py (main): Loop until finding reGNUal
450 2015-09-10 Niibe Yutaka <gniibe@fsij.org>
452 * src/call-rsa.c (rsa_cleanup): New.
453 (rsa_sign, rsa_decrypt, rsa_genkey): Allow cancellation.
454 * src/openpgp.c (cmd_pso, cmd_internal_authenticate): Cancellation
455 is handled by each functions in case of RSA.
457 2015-09-09 Niibe Yutaka <gniibe@fsij.org>
459 * src/sys.h: Update from Chopstx.
460 * src/adc_stm32f103.c: Update from NeuG.
462 * src/openpgp.c (process_command_apdu): Protect command execution
463 against cancelling the execution thread.
464 (cmd_pso, cmd_internal_authenticate): Allow cancellation.
466 * src/main.c (main): Handle LED_USB_RESET.
468 * src/usb-icc.c (ccid_usb_reset): New.
469 (ccid_thread): Upon receival of EV_USB_RESET, finish
470 the thread, canceling the card thread.
472 2015-09-08 Niibe Yutaka <gniibe@fsij.org>
474 * src/gnuk.h (EV_USB_RESET, LED_USB_RESET): New.
476 * src/usb_ctrl.c (CDC_CTRL_DTR): New.
477 (vcom_port_data_setup): Distinguish detail->value for DTR.
479 * src/configure (help): Add ST_DONGLE and ST_NUCLEO_F103.
481 2015-09-04 Niibe Yutaka <gniibe@fsij.org>
483 * src/openpgp-do.c (do_openpgpcard_aid): Use upper bytes of unique
484 ID of MCU; same as USB serial number.
486 * src/configure (help): Add NITROKEY_START.
488 2015-08-26 Mateusz Zalega <mateusz@nitrokey.com>
490 * GNUK_USB_DEVICE_ID: Add Nitrokey Start.
492 2015-08-05 Niibe Yutaka <gniibe@fsij.org>
496 2015-08-04 Niibe Yutaka <gniibe@fsij.org>
498 * src/adc_stm32f103.c: Update from NeuG 1.0.3.
500 * chopstx: Update to 0.08.
503 2015-08-03 Niibe Yutaka <gniibe@fsij.org>
505 * test/features/steps.py (set_msg): Python3 fix.
506 * test/generate_keys.py: Likewise.
507 * test/rsa_keys.py: Likewise.
509 * tool/gnuk_token.py (gnuk_token.download, gnuk_token.execute)
510 (regnual.download): Python3 fix.
511 (list_to_string): Remove.
513 * tool/upgrade_by_passwd.py (maian): Python3 fix.
514 * tool/usb_strings.py (main): Python3 fix.
516 2015-07-31 Niibe Yutaka <gniibe@fsij.org>
518 * src/configure (output_vendor_product_serial_strings): Fix sed
519 script when string is short. Remove empty line.
521 * regnual/regnual.c (usb_cb_ctrl_write_finish, usb_cb_setup)
522 (usb_cb_get_descriptor, usb_cb_interface): Follow the change
525 * tool/stlinkv2.py: Support ST-Link/V2-1.
527 2015-07-28 Niibe Yutaka <gniibe@fsij.org>
529 * tool/stlinkv2.py: Fix for Python3. Thanks to Bertrand Jacquin.
531 * tool/gpg_agent.py: Fix for Python3.
533 * src/usb-msc.c: Update from Fraucheky.
535 * src/usb_stm32f103.c (struct DATA_INFO): Remove offset.
536 (struct DEVICE_INFO): Integrate CONTROL_INFO.
538 2015-07-27 Niibe Yutaka <gniibe@fsij.org>
540 * src/usb_stm32f103.c (usb_lld_reply_request): New.
541 (usb_lld_set_data_to_send): Remove.
542 (usb_lld_set_data_to_recv): Not a macro but a function.
543 (std_get_status): Don't use statically allocated memory.
544 (std_get_configuration): Use usb_lld_reply_request.
545 (handle_setup0): Follow the change.
546 * src/usb_ctrl.c (vcom_port_data_setup, usb_cb_setup)
547 (usb_cb_interface): Use usb_lld_reply_request.
548 * src/usb_desc.c (usb_cb_get_descriptor): Likewise.
550 2015-07-24 Niibe Yutaka <gniibe@fsij.org>
552 * tool/gnuk_put_binary.py: Remove.
553 * tool/gnuk_remove_keys.py: Remove.
555 2015-07-23 Niibe Yutaka <gniibe@fsij.org>
557 * src/configure (nl): New. Follow the change of NeuG.
559 2015-07-21 Niibe Yutaka <gniibe@fsij.org>
563 2015-07-20 Niibe Yutaka <gniibe@fsij.org>
565 * src/openpgp-do.c (gpg_do_keygen): Support ECC.
566 * src/call-ec.c (ecc_check_secret): New.
567 * src/ecc.c (check_secret): New.
569 2015-07-18 Niibe Yutaka <gniibe@fsij.org>
571 * src/configure (keygen): It's always enabled.
572 * src/openpgp-do.c (gpg_do_keygen): Support key generation.
573 * src/openpgp.c (cmd_pgp_gakp): Likewise.
574 * src/call-rsa.c (rsa_genkey): Likewise.
575 * src/random.c (random_gen): Likewise.
576 * src/Makefile.in (KEYGEN_SUPPORT): Remove.
577 * polarssl/include/polarssl/config.h (POLARSSL_GENPRIME): Define.
579 2015-07-16 Niibe Yutaka <gniibe@fsij.org>
581 * src/configure (FLASH_PAGE_SIZE, FLASH_SIZE, MEMORY_SIZE)
582 [sys1_compat]: Use safe values for common binary.
583 (TARGET_DEFINE): Remove.
585 2015-07-15 Niibe Yutaka <gniibe@fsij.org>
587 * tool/usb_strings.py (field): Add 'Board'.
589 * regnual/regnual.c (usb_cb_get_descriptor): Update.
590 * src/usb_ctrl.c (usb_cb_interface): Call usb_lld_write.
591 * src/usb_desc.c (usb_cb_get_descriptor): Support sys_board_name,
593 * src/usb_lld.h (usb_cb_get_descriptor): Add last argument length
595 * src/usb_stm32f103.c (handle_setup0): Allow setup callback to
596 call usb_lld_write with ENDP0.
597 * src/usb_conf.h (NUM_STRING_DESC): Remove.
599 * src/configure [!sys1_compat] (CONFIG): Don't include target
602 * src/flash.c: Detect flash_page_size at runtime.
604 * src/main.c: Remove dependency to board.h.
606 * src/neug.c: Update from NeuG 1.0.2.
607 * src/adc_stm32f103.c: Update.
609 * chopstx: Update to 0.07.
612 * src/gnuk.ld.in: Update.
614 * tool/stlinkv2.py (stlinkv2.get_chip_id): New. Detect flash
616 (main): Call stlinkv2.get_chip_id after MCU reset and stop.
619 2015-07-11 Niibe Yutaka <gniibe@fsij.org>
621 * src/configure (help): Add STM32_PRIMER2 and CQ_STARM.
623 * chopstx: Update to 0.06.
625 * tool/stlinkv2.py: Support 512kB version of STM32F103.
626 The size of executable file should be even.
628 2015-07-07 Niibe Yutaka <gniibe@fsij.org>
630 * src/Makefile.in (CSRC): Add ecc-mont.c.
632 * src/ecc-mont.c (mod25638_mul_121665): Fix.
633 (ecdh_compute_public_25519, ecdh_decrypt_curve25519): New.
635 * src/openpgp.c (cmd_pso): Support ALGO_CURVE25519.
637 * src/openpgp-do.c (algorithm_attr_cv25519): New.
638 (rw_algorithm_attr, get_algo_attr_data_object)
639 (gpg_get_algo_attr_key_size, gpg_do_write_prvkey)
640 (proc_key_import, gpg_do_public_key): Support ALGO_CURVE25519.
642 * src/gnuk.h (ALGO_CURVE25519): New.
644 2015-07-06 Niibe Yutaka <gniibe@fsij.org>
646 Enhancement for FSM-55.
647 * tool/stlinkv2.py (stlinkv2.control_nrst): New.
648 (stlinkv2.get_rdp_key,has_spi_flash,has_protection): New.
649 (stlinkv2.get_core_id): Rename.
650 (stlinkv2.blank_check): Use self.flash_size.
651 (stlinkv2.start): Call control_nrst. Call get_core_id.
652 Distinguishing chip, and set rdp_key, flash_size and require_nrst.
653 (stlinkv2.flash_write): Use self.flash_block_size.
654 (main): Call control_nrst.
655 (prog_flash_write_body, prog_option_bytes_write_body)
656 (prog_blank_check_body): Support Cortex-M0.
657 (main): Call API V2 halt twice.
658 * tool/asm-thumb/*.S: Updated for Cortex-M0.
660 2015-06-30 Niibe Yutaka <gniibe@fsij.org>
662 * src/sys.c: Update from chopstx/example-cdc/sys.c.
664 * src/main.c (device_initialize_once): Apply change of NeuG.
666 2015-06-03 Niibe Yutaka <gniibe@fsij.org>
670 * test/ecc_nistp256_keys.py: New.
672 * tool/upgrade_by_passwd.py: Remove -p option and add -f option.
674 * tool/gnuk_token.py (gnuk_token.download): Add verbose flag.
675 (regnual.download): Ditto.
677 * tool/gnuk_upgrade.py: Use gnuk_token module.
679 2015-06-02 Niibe Yutaka <gniibe@fsij.org>
681 * src/openpgp.c (cmd_pso): Support OpenPGPcard spec v3.0.
683 2015-04-20 Niibe Yutaka <gniibe@fsij.org>
685 * chopstx: Upgrade to 0.05.
687 2015-04-19 Niibe Yutaka <gniibe@fsij.org>
689 * src/gnuk.h (CCID_CARD_INIT): New.
690 * src/usb_desc.c (gnukConfigDescriptor): Update dwDefaultClock,
691 dwMaximumClock, dwFeatures, and bClassEnvelope.
692 * src/usb_ctrl.c (freq_table): Change the value to 4000MHz.
693 (usb_cb_handle_event): Call ccid_card_change_signal after configure.
694 * src/usb-icc.c (ccid_thread): Change EV_CARD_CHANGE handling.
696 2015-04-18 Niibe Yutaka <gniibe@fsij.org>
698 * src/main.c (main): Call chopstx_main_init.
699 * src/Makefile.in (DEFS): Remove CHX_PRIO_MAIN.
701 2015-04-17 Niibe Yutaka <gniibe@fsij.org>
703 * src/configure: Fix shell syntax.
705 2015-03-31 Niibe Yutaka <gniibe@fsij.org>
707 * src/usb_conf.h (ICC_NUM_INTERFACES, HID_NUM_INTERFACES)
708 (HID_NUM_INTERFACES, VCOM_NUM_INTERFACES, MSC_NUM_INTERFACES)
709 (NUM_INTERFACES): Define here (moved from usb_desc.c).
710 (ICC_INTERFACE, HID_INTERFACE, VCOM_INTERFACE_0, VCOM_INTERFACE_1)
711 (MSC_INTERFACE): New.
712 * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface)
713 (usb_cb_setup, usb_cb_ctrl_write_finish): Use *_INTERFACE.
714 * src/usb_desc.c (gnukConfigDescriptor): Likewise.
716 2015-03-06 Niibe Yutaka <gniibe@fsij.org>
718 * src/ecc-edwards.c (eddsa_sign_25519): Return 0.
720 2015-02-25 Niibe Yutaka <gniibe@fsij.org>
722 * src/openpgp.c (cmd_internal_authenticate): Fix storing to
725 2015-02-10 Niibe Yutaka <gniibe@fsij.org>
727 * src/openpgp.c (cmd_pso): Fix counter update for EdDSA. Thanks
728 to Jonathan Schleifer.
730 * src/call-rsa.c (rsa_sign): Don't set res_APDU_len.
731 (rsa_decrypt): Likewise, but get OUTPUT_LEN_P as an argument.
733 2015-02-09 Niibe Yutaka <gniibe@fsij.org>
735 * src/openpgp.c (cmd_pso): Fix EdDSA. Use GPG_KEY_FOR_SIGNING.
737 2014-12-15 Niibe Yutaka <gniibe@fsij.org>
741 2014-12-13 Niibe Yutaka <gniibe@fsij.org>
743 * src/flash.c (flash_key_getpage, flash_key_release_page): New.
745 * src/openpgp-do.c (gpg_do_delete_prvkey): New arg.
746 (rw_algorithm_attr): Call gpg_do_delete_prvkey with CLEAN_PAGE_FULL.
748 2014-12-12 Niibe Yutaka <gniibe@fsij.org>
750 * src/Makefile.in (build/bignum.o): Specific OPT for this target.
752 * src/configure (target): Default is FST-01.
753 (--with-dfu): FST-01 doesn't have DFU. If set, it must be
756 * boards/STBEE_MINI: Remove, since it is now supported by Chopstx.
758 * test/features/802_get_data_static.feature: Reflect the change
759 of extended capabilities.
760 * test/features/402_get_data_static.feature: Ditto.
761 * test/features/002_get_data_static.feature: Ditto.
763 * test/features/003_keyattr_change.feature: New test.
765 * src/usb_lld.h: Don't use 'extern' for function declarations.
766 * src/usb-icc.c (end_cmd_apdu_data): Fix Le handling.
768 2014-12-11 Niibe Yutaka <gniibe@fsij.org>
770 * chopstx: Upgrade to 0.04.
771 * src/syc.c: Update from 0.04.
773 2014-12-10 Niibe Yutaka <gniibe@fsij.org>
775 * src/ecc-cdh.c: Remove as smartcard only does
776 a part of ECDH computation as gpg-agent does.
778 * src/chconf.h, src/halconf.h: Remove files needed for ChibiOS/RT.
780 2014-12-09 Niibe Yutaka <gniibe@fsij.org>
782 * src/call-ec.c (ecc_compute_public): Rename, as we share
783 same routine among ECDSA and ECDH.
786 2014-12-09 Niibe Yutaka <gniibe@fsij.org>
788 * src/ecc.c (compute_kP): Bug fix. It's P, not G.
789 (point_is_on_the_curve): Bug fix.
791 2014-12-03 Niibe Yutaka <gniibe@fsij.org>
793 Changes for RSA-4096.
795 * src/gnuk.h (MAX_CMD_APDU_DATA_SIZE, MAX_RES_APDU_DATA_SIZE):
796 Send/Recv buffer should be bigger.
797 * polarssl/library/bignum.c (mpi_exp_mod): Don't consume much.
798 * polarssl/library/rsa.c (rsa_rsaes_pkcs1_v15_decrypt): buffer
799 allocation size should be variable.
801 2014-12-01 Niibe Yutaka <gniibe@fsij.org>
803 * src/Makefile.in (DEFS): Don't define compile time preference of
806 * src/openpgp-do.c (proc_key_import): Support modifiable key algo
809 2014-11-21 Niibe Yutaka <gniibe@fsij.org>
811 * src/gnuk.h (ALGO_RSA4K, ALGO_NISTP256R1, ALGO_SECP256K1)
812 (ALGO_ED25519, ALGO_RSA2K): New.
813 (struct key_data_internal): Move to ...
814 * src/openpgp-do.c (struct key_data_internal): ... here.
815 (CHECKSUM_ADDR, kdi_len): New.
816 (CKDC_CALC, CKDC_CHECK): New.
817 (compute_key_data_checksum): Add arg PRVKEY_LEN.
818 (gpg_do_load_prvkey, gpg_do_delete_prvkey): Support modifiable key
820 (gpg_do_write_prvkey, gpg_do_public_key, gpg_do_keygen): Likewise.
821 (gpg_do_clear_prvkey): Use MAX_PRVKEY_LEN.
823 * src/openpgp.c (gpg_init): Call flash_init_keys after
825 (cmd_pso): Support modifiable key algo attributes.
826 (cmd_internal_authenticate): Likewise.
828 2014-11-21 Niibe Yutaka <gniibe@fsij.org>
830 * src/openpgp-do.c (algorithm_attr_rsa2k): Rename from *_rsa.
831 (algorithm_attr_rsa4k): New.
832 (get_algo_attr_pointer, kk_to_nr, gpg_get_algo_attr)
833 (get_algo_attr_data_object, gpg_get_algo_attr_key_size): New.
834 (rw_algorithm_attr): New.
835 (gpg_do_table): Register rw_algorithm_attr for GPG_DO_ALG_*.
836 (gpg_data_scan, gpg_data_copy): Handle algo attributes.
838 (rw_pw_status): Fix checking against redundant write.
840 2014-11-20 Niibe Yutaka <gniibe@fsij.org>
842 * src/openpgp-do.c (extended_capabilities): Key attributes can be
845 2014-11-20 Niibe Yutaka <gniibe@fsij.org>
847 * src/gnuk.h (NR_NONE, NR_DO__FIRST__): Remove.
849 (NR_KEY_ALGO_ATTR_SIG, NR_KEY_ALGO_ATTR_DEC)
850 (NR_KEY_ALGO_ATTR_AUT): New.
852 * src/openpgp-do.c (gpg_do_load_prvkey, gpg_do_delete_prvkey)
853 (gpg_do_write_prvkey, gpg_do_chks_prvkey, gpg_data_scan)
854 (gpg_data_copy, gpg_do_read_simple)
855 (gpg_do_write_simple): Don't use NR_DO__FIRST__.
856 (gpg_do_put_data): Don't use NR_NONE any more.
857 (do_tag_to_nr): Use -1 to specify NONE.
859 * src/flash.c (flash_enum_clear, flash_enum_write_internal)
860 (flash_enum_write): New.
862 2014-11-19 Niibe Yutaka <gniibe@fsij.org>
864 * src/gnuk.h (FIRMWARE_UPDATE_KEY_CONTENT_LEN): New.
865 (size_of_key): New enum.
867 * src/openpgp.c (gpg_get_firmware_update_key)
868 (cmd_read_binary, cmd_external_authenticate): Use
869 FIRMWARE_UPDATE_KEY_CONTENT_LEN.
871 * src/flash.c (KEY_SIZE): Remove.
872 (key_available_at): Add new arg as KEY_SIZE.
873 (flash_check_all_other_keys_released): Likewise.
874 (flash_key_fill_zero_as_released, flash_key_release): Likewise.
876 (flash_init): Move initializing keys into another function.
877 (flash_init_keys): New function.
879 (flash_key_alloc): Use gpg_get_algo_attr_key_size.
880 (flash_key_write): Add new arg as KEY_DATA_LEN.
882 (flash_write_binary): Use FIRMWARE_UPDATE_KEY_CONTENT_LEN.
884 2014-09-16 Niibe Yutaka <gniibe@fsij.org>
886 * src/gnuk.h (MAX_PRVKEY_LEN): New.
887 (KEY_CONTENT_LEN): Remove.
889 * src/call-rsa.c (RSA_SIGNATURE_LENGTH): Remove.
890 (rsa_sign, rsa_verify, rsa_genkey): Add new arg: PUBKEY_LEN.
891 (rsa_decrypt): Don't use KEY_CONTENT_LEN.
893 2014-06-19 Niibe Yutaka <gniibe@fsij.org>
895 * src/ecc-mont.c (compute_nQ): Add comment.
897 * src/mod.c (mod_inv): Fix comment. X^-1 = 0 when X=0
898 is important for Montgomery curve computation.
900 2014-06-05 Niibe Yutaka <gniibe@fsij.org>
902 * tool/add_openpgp_authkey_from_gpgssh.py: New.
904 2014-04-17 Niibe Yutaka <gniibe@fsij.org>
906 * src/muladd_256.h (MULADD_256_ASM): New.
907 (MULADD_256): Use MULADD_256_ASM.
908 * src/ecc-mont.c (mod25638_mul_121665): Add asm implementation.
910 * src/bn.c (bn256_add_uint, bn256_sub_uint): Simplify.
911 * src/mod25638.c (mod25638_add, mod25638_sub): Simplify.
912 (n25638, add19): Remove.
913 (ADDWORD_256): Add s_ as source pointer.
914 (mod25519_reduce): Remove a call to memcpy. Use bn256_add_uint.
915 * src/ecc-edwards.c (point_double): Simplify.
917 2014-04-16 Niibe Yutaka <gniibe@fsij.org>
921 2014-04-15 Niibe Yutaka <gniibe@fsij.org>
923 * src/ecc-mont.c: New.
925 * src/mod25638.c (p25519): Move from ecc-edwards.c.
926 (mod25519_reduce, add19): Likewise.
927 (mod25638_reduce) [!ASM_IMPLEMENTATION]: Use bn256_add_uint.
929 2014-04-14 Niibe Yutaka <gniibe@fsij.org>
931 * src/jpc.c (jpc_to_ac): Error check before mod_inv.
933 * src/mod.c (mod_inv): No return value (if N==0 returns ZERO).
935 * src/bn.c [BN256_NO_RANDOM]: Only include "random.h" if needed.
937 2014-04-08 Niibe Yutaka <gniibe@fsij.org>
939 * src/mod.c (mod_inv): Use MAX_GCD_STEPS_BN256.
940 Return failure or success.
941 * src/jpc.c (jpc_to_ac): Use mod_inv.
942 * src/modp256k1.c (modp256k1_inv): Remove.
943 * src/modp256r1.c (modp256r1_inv): Remove.
945 2014-04-07 Niibe Yutaka <gniibe@fsij.org>
947 * src/openpgp-do.c (algorithm_attr_ed25519): It's OID only.
949 2014-04-03 Niibe Yutaka <gniibe@fsij.org>
951 * src/ecc-edwards.c (eddsa_sign_25519): Change type of OUT.
952 * src/openpgp.c (cmd_internal_authenticate): Have a buffer.
954 * src/flash.c (flash_init): Fix key address finder.
956 2014-04-02 Niibe Yutaka <gniibe@fsij.org>
958 * src/openpgp-do.c (proc_key_import): Handle EdDSA.
959 (algorithm_attr_ed25519): Fix OID and add ID for SHA512.
961 2014-04-01 Niibe Yutaka <gniibe@fsij.org>
963 * src/ecc-edwards.c (eddsa_compute_public_25519): New.
965 * src/openpgp-do.c (algorithm_attr_ed25519): New.
966 (gpg_do_write_prvkey, proc_key_import, gpg_do_public_key): Add
969 2014-03-31 Niibe Yutaka <gniibe@fsij.org>
971 * src/ecc-edwards.c (eddsa_sign_25519): Rename and API change.
973 * src/openpgp-do.c (gpg_do_load_prvkey, gpg_do_delete_prvkey)
974 (gpg_do_write_prvkey, gpg_do_public_key, gpg_do_keygen): Follow
975 the change of PRVKEY_DATA and KEY_DATA.
977 * src/flash.c (key_available_at): New.
978 (flash_init): Initilize KD.
980 * src/gnuk.h (struct prvkey_data): Remove member KEY_ADDR.
981 (struct key_data): Addd member KEY_ADDR.
983 * src/openpgp-do.c (gpg_do_keygen): Bug fix. Reset the signature
984 counter when new key is generated.
986 * src/flash.c (flash_key_alloc): Change API, supply KK.
988 2014-03-29 Niibe Yutaka <gniibe@fsij.org>
990 * src/ecc-edwards.c (point_double, point_add): Rename.
991 (mod25519_reduce): New.
993 2014-03-28 Niibe Yutaka <gniibe@fsij.org>
995 * misc/t-eddsa.c (main): Update for new API of eddsa_25519.
997 * src/ecc-edwards.c (compute_kG_25519): Tune for 252-bit.
998 (eddsa_25519): Public key should be provided by caller.
999 (eddsa_public_key_25519): New.
1001 2014-03-27 Niibe Yutaka <gniibe@fsij.org>
1003 * src/ecc-edwards.c (ed_add_25638): Remove the third argument.
1004 (compute_kG_25519): The curve is complete, we don't need to avoid
1005 identity element as NIST curve or secp256k1 curve.
1006 (eddsa_25519): Change the API, with A and the seed.
1008 2014-03-26 Niibe Yutaka <gniibe@fsij.org>
1010 * src/mod25638.c (mod25638_reduce): New.
1011 (mod25638_mul, mod25638_sqr): Use mod25638_reduce.
1013 * src/ecc-edwards.c (ptc_to_ac_25519): No need to subtract p25519.
1015 2014-03-25 Niibe Yutaka <gniibe@fsij.org>
1017 * misc/t-eddsa.c: New.
1019 * src/ecc-edwards.c (bnX_mul_C, mod_reduce_M): New.
1022 2014-03-20 Niibe Yutaka <gniibe@fsij.org>
1024 * src/ecc-edwards.c (ed_add_25638): Fix for X == A.
1025 (main): Compute pre-computed tables.
1026 (precomputed_KG, precomputed_2E_KG): Add.
1027 (compute_kG_25519): New.
1029 2014-03-19 Niibe Yutaka <gniibe@fsij.org>
1031 * src/bn.c (bn256_add): Fix for X == B.
1032 (bn256_sub): Likewise.
1034 * src/ecc-edwards.c: New.
1036 2014-03-18 Niibe Yutaka <gniibe@fsij.org>
1038 * src/mod25638.c (mod25638_add, mod25638_sub, mod25638_sqr)
1039 (mod25638_shift): New.
1041 2014-03-13 Niibe Yutaka <gniibe@fsij.org>
1043 * src/mod25638.c: Rename from fe25519.c.
1044 * src/mod25638.h: Likewise.
1046 2014-03-07 Niibe Yutaka <gniibe@fsij.org>
1050 2014-02-25 Niibe Yutaka <gniibe@fsij.org>
1052 * src/openpgp-do.c (gpg_do_public_key): Don't put OID.
1054 * src/configure [certdo] (gnuk.ld): Add TIM_SIZE and EXT_SIZE.
1055 Thanks to Vasily Evseenko for the bug report.
1057 2014-02-21 Niibe Yutaka <gniibe@fsij.org>
1059 * src/ecc.c (compute_kG): Compute higer index at first.
1060 (point_is_on_the_curve): Don't use coefficient_a if it's zero.
1062 * src/jpc.c (jpc_double): Care coefficient A.
1064 * src/ec_p256r1.c (COEFFICIENT_A_IS_MINUS_3): New.
1065 * src/ec_p256k1.c (COEFFICIENT_A_IS_ZERO): New.
1066 * src/jpc_p256r1.c (COEFFICIENT_A_IS_MINUS_3): Likewise.
1067 * src/jpc_p256k1.c (COEFFICIENT_A_IS_MINUS_3): Likewise.
1069 * src/modp256k1.c (modp256k1_shift): Bug fix.
1071 2014-02-20 Niibe Yutaka <gniibe@fsij.org>
1073 * src/Makefile.in (CSRC): Add files of p256k1.
1075 * src/openpgp.c (cmd_pso): Support p256k1 for signature.
1077 * src/openpgp-do.c (algorithm_attr_p256k1): New.
1078 (gpg_do_write_prvkey): Support p256k1 for signature.
1079 (proc_key_import, gpg_do_table, gpg_do_public_key): Likewise.
1081 * src/Makefile.in (DEFS): Add -DRSA_SIG.
1083 * src/openpgp-do.c (gpg_do_write_prvkey): Use _p256r1.
1084 * src/openpgp.c (cmd_internal_authenticate): Likewise.
1086 * src/call-ec_p256k1.c: New. Use call-ec.c.
1087 * src/call-ec_p256r1.c: Use call-ec.c.
1088 * src/call-ec.c: New.
1089 (ecdsa_sign): Change the signature.
1091 2014-02-19 Niibe Yutaka <gniibe@fsij.org>
1093 * tool/calc_precompute_table_ecc.py: New.
1095 * src/ec_p256k1.c: New. Use ecc.c.
1096 * src/ec_p256k1.h: New.
1097 * src/ec_p256r1.c: Use ecc.c.
1100 2014-02-18 Niibe Yutaka <gniibe@fsij.org>
1102 * src/jpc_p256k1.c: New. Use jpc.c.
1103 * src/jpc_p256r1.c: Use jpc.c.
1106 * src/sha256.c (memcpy_output_bswap32): Bug fix.
1108 * src/modp256k1.h, src/modp256k1.c: New.
1110 2014-02-17 Niibe Yutaka <gniibe@fsij.org>
1112 * src/Makefile.in (CSRC): Follow the changes of filenames.
1114 * src/modp256r1.c (modp256r1_add, modp256r1_sub, S3)
1115 (modp256r1_mul, modp256r1_sqr, modp256r1_inv, modp256r1_shift):
1116 Use new function names.
1117 * src/jpc_p256r1.c (jpc_double_p256r1, jpc_add_ac_signed_p256r1)
1118 (jpc_to_ac_p256r1): Likewise.
1119 * src/ec_p256r1.c (point_is_on_the_curve)
1120 (compute_kG_p256r1, compute_kP_p256r1): Likewise.
1121 * src/call-ec_p256r1.c (ecdsa_sign): Likewise.
1123 * src/modp256r1.h: Rename from modp256.h.
1124 * src/jpc-ac_p256r1.h: Rename from jpc-ac.h.
1125 * src/ec_p256r1.h: Rename from ec_p256.h.
1127 * src/modp256r1.c: Rename from modp256.c.
1128 * src/jpc_p256r1.c: Rename from jpc.c.
1129 * src/ec_p256r1.c: Rename from ec_p256.c.
1130 * src/call-ec_p256r1.c: Rename from call-ec_p256.c.
1132 2014-02-05 NIIBE Yutaka <gniibe@fsij.org>
1134 * src/sha512.h, src/sha512.c: New.
1136 * src/sha256.c (initial_state): Don't export, it's internal.
1137 (memcpy_output_bswap32): Rename and remove last argument.
1139 2014-01-28 Niibe Yutaka <gniibe@fsij.org>
1141 * src/muladd_256.h: New.
1142 * src/bn.c (bn256_mul, bn256_sqr): Assembler implementation.
1144 * src/ec_p256.c (get_vk_kP): Bug fix.
1145 (compute_kP): Bug fix for index table.
1147 2014-01-27 Niibe Yutaka <gniibe@fsij.org>
1149 * src/ec_p256.c (get_vk_kP): New.
1150 (naf4_257_set, naf4_257_get, compute_naf4_257): Remove.
1151 (compute_kP): Change the argument, fixing for constant time.
1153 2014-01-24 Niibe Yutaka <gniibe@fsij.org>
1155 * src/ec_p256.c (get_vk): New.
1156 (compute_kG): Fix for constant time.
1157 (compute_kP): Simplify.
1159 2014-01-23 Niibe Yutaka <gniibe@fsij.org>
1161 * src/jpc.c (jpc_add_ac_signed): Fix for constant time.
1163 * src/ec_p256.c (ecdsa): Bug fix for k selection.
1165 2014-01-22 Niibe Yutaka <gniibe@fsij.org>
1167 * src/modp256.c (modp256_inv): Fix for constant time.
1169 * src/bn.c (bn256_sqr): Fix for constant time.
1171 * src/mod.c (mod_inv): Fix for constant time.
1173 * src/ec_p256.c (compute_kG): Simplify.
1175 * src/jpc.c (jpc_double): Support calling with A = infinity.
1177 2014-01-21 Niibe Yutaka <gniibe@fsij.org>
1179 * src/jpc.c (jpc_add_ac_signed): Bug fix for A check.
1181 * src/ec_p256.c (ecdsa): Fix for constant time.
1183 * src/modp256.c (modp256_add, modp256_sub, modp256_reduce)
1184 (modp256_shift): Fix for constant time.
1185 (modp256_inv): Likewise (not fully constant time, yet).
1187 * src/mod.c (mod_reduce): Fix for constant time.
1188 (mod_inv): Likewise (not fully constant time, yet).
1190 * src/bn.h (bn256, bn512): words -> word.
1191 * src/ec_p256.h (naf4_257): Likewise.
1193 2014-01-20 Niibe Yutaka <gniibe@fsij.org>
1195 * src/fe25519.h, src/fe25519.c: New.
1197 2014-01-15 Niibe Yutaka <gniibe@fsij.org>
1199 * src/bn.c (bn256_is_zero, bn256_is_ge, bn256_cmp): Computation
1200 should be constant time.
1202 2013-12-25 Niibe Yutaka <gniibe@fsij.org>
1206 * tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__): Fix
1207 the argument of setAltInterface.
1208 * tool/gnuk_upgrade.py: Likewise.
1209 * tool/dfuse.py (DFU_STM32.__init__): Likewise.
1210 * tool/stlinkv2.py (stlinkv2.__init__): Likewise.
1212 2013-12-24 Niibe Yutaka <gniibe@fsij.org>
1214 * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE)
1215 (MULADDC_1024_LOOP): Use younger number registers more for shorter
1216 instructions and better performance.
1217 * polarssl/library/bignum.c (mpi_montsqr): Likewise. Change loop
1218 structure and conditional branch for better performance.
1220 2013-12-23 Niibe Yutaka <gniibe@fsij.org>
1222 * polarssl/library/bignum.c (mpi_montmul): Computation
1223 time should not depends on input.
1224 (mpi_montmul, mpi_montred, mpi_montsqr): Change the API.
1225 (mpi_exp_mod): Follow the change of the API. Allocate memory on
1226 stack instead of malloc.
1228 * src/gnuk.ld.in (__process3_stack_size__): Increase stack size.
1230 2013-12-20 Niibe Yutaka <gniibe@fsij.org>
1234 * src/usb_ctrl.c (USB_FSIJ_GNUK_CARD_CHANGE): New.
1235 (usb_cb_setup): Support USB_FSIJ_GNUK_CARD_CHANGE.
1236 * src/usb-icc.c (ccid_card_change_signal): New argument HOW.
1238 2013-12-20 Niibe Yutaka <gniibe@fsij.org>
1240 * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE)
1241 (MULADDC_CORE): Reorder instructions for more speed up.
1242 * polarssl/library/bignum.c (mpi_montsqr): Likewise.
1244 2013-12-19 Niibe Yutaka <gniibe@fsij.org>
1246 * src/configure (--enable-hid-card-change): New (experimental).
1247 * src/config.h.in (HID_CARD_CHANGE_DEFINE): New.
1248 * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface)
1249 (usb_cb_setup, usb_cb_ctrl_write_finish): Conditionalize
1250 HID_CARD_CHANGE_SUPPORT.
1251 * src/usb_desc.c (gnukDeviceDescriptor, usb_cb_get_descriptor):
1254 2013-12-19 Niibe Yutaka <gniibe@fsij.org>
1256 * src/openpgp.c (S2KCOUNT): It's now 192, as the threat model
1257 of Gnuk Token is different.
1259 2013-12-19 Niibe Yutaka <gniibe@fsij.org>
1261 * polarssl/library/bignum.c (mpi_montsqr): New.
1262 (mpi_exp_mod): Use mpi_montsqr.
1264 Note that this change introduces a vulnerability by the
1265 Yarom/Falkner flush+reload cache side-channel attack. When this
1266 code is used on general purpose computer where we can observe
1267 which code is executed (sqr or mul), it's not safe.
1269 2013-12-16 Niibe Yutaka <gniibe@fsij.org>
1271 * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE)
1272 (MULADDC_1024_LOOP, MULADDC_HUIT, MULADDC_INIT, MULADDC_CORE)
1273 (MULADDC_STOP) [__arm__]: The value of input B won't change.
1274 More acculate specification for asm statement.
1276 * polarssl/library/bignum.c (mpi_cmp_abs_limbs): New.
1277 (mpi_montmul): Change the signature and use the upper half of T.
1278 (mpi_montred): Likewise.
1279 (mpi_exp_mod): Use improved mpi_montmul and mpi_montred.
1280 (mpi_sub_hlp, mpi_mul_hlp): Add const qualifier for S.
1282 2013-12-13 Niibe Yutaka <gniibe@fsij.org>
1284 * polarssl/library/bignum.c (mpi_exp_mod): Initialize lower
1285 half of T with zero.
1286 (mpi_montmul): Don't need to clear lower half of
1287 T, as we keep zero. Call mpi_sub_hlp with upper half of T.
1288 (mpi_montred): Ditto.
1290 * polarssl/library/bignum.c (mpi_montmul, mpi_montred): Minimize
1291 number of limbs for T.
1292 (mpi_exp_mod): Only allocate N-n * 2 for T.
1293 Only allocate N->n for X, W[i], and RR.
1295 2013-12-13 Niibe Yutaka <gniibe@fsij.org>
1297 * tool/upgrade_by_passwd.py (main): Support -k to specify KEYNO.
1299 2013-12-13 Niibe Yutaka <gniibe@fsij.org>
1301 * src/usb_ctrl.c (HID_LED_STATUS_CARDCHANGE): Rename from
1302 HID_LED_STATUS_NUMLOCK.
1304 * tool/gnuk_token.py (gnuk_token.stop_gnuk): Detach kernel
1307 2013-12-12 Niibe Yutaka <gniibe@fsij.org>
1309 * src/openpgp-do.c (do_openpgpcard_aid): Coerce to volatile to
1310 force memory access at run time.
1312 2013-12-11 Niibe Yutaka <gniibe@fsij.org>
1314 * regnual/sys.c (entry): Fix relocation calculation.
1316 2013-11-27 Niibe Yutaka <gniibe@fsij.org>
1318 * src/stm32f103.h (AFIO_MAPR_SWJ_CFG_DISABLE): New.
1319 * src/sys.c: Likewise.
1321 2013-11-26 Niibe Yutaka <gniibe@fsij.org>
1323 * src/usb_desc.c (hid_report_desc): New.
1324 (ICC_TOTAL_LENGTH): Update.
1325 (HID_TOTAL_LENGTH, HID_NUM_INTERFACES): New.
1326 (W_TOTAL_LENGTH, NUM_INTERFACES): Update.
1327 (gnukConfigDescriptor): Add IN2 interrupt endpoint descriptor.
1328 Add HID interface descriptor.
1329 (usb_cb_get_descriptor): Handle HID.
1331 * src/usb_ctrl.c (NUM_INTERFACES, MSC_INTERFACE_NO): Add 1.
1332 (USB_HID_REQ_*, HID_LED_STATUS_NUMLOCK): New.
1333 (gnuk_setup_endpoints_for_interface): Add ENDP2 interrupt
1335 (usb_cb_setup): Handle HID requests.
1336 (usb_cb_ctrl_write_finish): Likewise.
1338 * src/usb-icc.c (ccid_card_change_signal): New.
1339 (ccid_thread): Handle card change.
1340 (icc_error, icc_send_status): Handle ICC_STATE_NOCARD state.
1341 (icc_handle_data): Add the case of ICC_STATE_NOCARD.
1342 (EP2_IN_Callback): New.
1344 2013-11-26 Niibe Yutaka <gniibe@fsij.org>
1346 * src/pin-dial.c: Remove.
1347 * src/configure: Remove pin-dial support.
1349 2013-11-25 Niibe Yutaka <gniibe@fsij.org>
1351 * src/Makefile.in (HEXOUTPUT_MAKE_OPTION): New.
1352 * src/configure (HEXOUTPUT_MAKE_OPTION): New.
1353 * src/main.c: Include board.h.
1354 * src/stm32f103.h (EXTI0_IRQ, EXTI1_IRQ): New.
1356 2013-11-18 Niibe Yutaka <gniibe@fsij.org>
1358 * regnual/sys.c (entry): Bug fix of clearing BSS.
1360 * src/usb_stm32f103.c: Update from NeuG.
1361 (usb_handle_transfer): Add argument ISTR_VALUE.
1363 * src/openpgp.c (card_thread): Add noinline attribute.
1365 * src/usb-icc.c (ccid_thread): Join the OpenPGP thread.
1366 Add noinline attribute.
1368 2013-11-15 Niibe Yutaka <gniibe@fsij.org>
1370 * src/configure (options): Add --enable-sys1-compat.
1372 2013-11-12 Niibe Yutaka <gniibe@fsij.org>
1374 * chopstx: Upgrade to 0.03.
1376 * src/usb_desc.c (usb_initial_feature): Remove.
1377 (USB_SELF_POWERED): Move to ...
1378 * src/usb_conf.h (USB_SELF_POWERED): ... here.
1379 * src/usb_ctrl.c (usb_cb_device_reset, usb_intr): Follow the
1382 2013-11-11 Niibe Yutaka <gniibe@fsij.org>
1384 * src/adc_stm32f103.c (adc_wait_completion): Update from NeuG 1.0.
1386 2013-11-03 Niibe Yutaka <gniibe@fsij.org>
1388 * regnual/regnual.c (usb_cb_get_descriptor): Update to new API.
1390 * src/usb_lld.h (usb_initial_feature): Remove.
1392 * chopstx: Update to 0.01.
1393 * src/pin-cir.c: Chatter fix to 200ms.
1394 * src/main.c: Fix bDeviceState.
1396 2013-11-02 Niibe Yutaka <gniibe@fsij.org>
1398 * src/usb_lld.h, src/usb_stm32f103.c (std_get_descriptor): Change
1399 the API of usb_cb_get_descriptor.
1400 * src/usb_desc.c: Follow the change.
1401 * src/usb_conf.h: Modify for CCID INT and HID usage.
1403 2013-11-02 Niibe Yutaka <gniibe@fsij.org>
1405 * src/pin-cir.c: Port to Chopstx.
1408 * src/configure (TIM_SIZE, EXT_SIZE): New.
1409 * src/gnuk.ld.in (__process6_stack_size__)
1410 (__process7_stack_size__): New.
1411 * src/main.c (main): Call cir_init.
1412 * src/openpgp.c (openpgp_card_thread): Rename from GPGthread.
1413 * src/usb-icc.c (icc_power_on): Follow the change.
1415 2013-11-01 Niibe Yutaka <gniibe@fsij.org>
1417 * src/sys.c: Update from Chopstx.
1418 * src/usb_lld.h: Remove interrupt definition.
1419 * src/stm32f103.h: Add AFIO, EXTI, and TIMER constants.
1421 2013-10-31 Niibe Yutaka <gniibe@fsij.org>
1423 * src/main.c (main): Call msc_init before USB interrupt thread.
1424 * src/gnuk.h, src/usb-msc.h, src/usb-msc.c, src/pin-dnd.c: Port to
1426 * src/openpgp.c (get_pinpad_input): Follow the change.
1427 * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface): Don't stall
1430 2013-10-24 Niibe Yutaka <gniibe@fsij.org>
1432 * src/Makefile.in (DEFS): Add -DCHX_PRIO_MAIN=5 for LED blink.
1433 * src/main.c (PRIO_CCID): It's now 3 (was: 2).
1435 2013-10-24 Niibe Yutaka <gniibe@fsij.org>
1437 * src/gnuk.ld.in (.gnuk_flash): Three pages for three keys.
1438 * src/flash.c (FLASH_KEYSTORE_SIZE): Likewise.
1439 (flash_keystore_release): Remove.
1440 (flash_key_fill_zero_as_released)
1441 (flash_check_all_other_keys_released, flash_key_release): New.
1442 (flash_init, flash_key_alloc): New method to handle free space.
1443 * src/openpgp-do.c (fetch_four_bytes): New.
1444 (gpg_do_load_prvkey, gpg_do_delete_prvkey, gpg_do_public_key): Use
1446 (gpg_do_delete_prvkey): Call flash_key_release.
1448 2013-10-23 Niibe Yutaka <gniibe@fsij.org>
1450 * test/features/010_setup_passphrase.feature
1451 * test/features/030_key_registration.feature
1452 * test/features/040_passphrase_change.feature
1453 * test/features/410_setup_passphrase.feature
1454 * test/features/430_key_registration.feature
1455 * test/features/201_keygen.feature
1456 * test/features/601_keygen.feature: Modified to support new way of
1457 pass phrase reset by key import / key generation.
1459 * test/features/201_keygen.feature
1460 * test/features/601_keygen.feature
1461 * test/features/202_setup_passphrase.feature
1462 * test/features/602_setup_passphrase.feature: Rename to change
1465 2013-10-23 Niibe Yutaka <gniibe@fsij.org>
1467 * src/openpgp-do.c (gpg_do_write_prvkey): Bug fix of adding
1470 2013-10-22 Niibe Yutaka <gniibe@fsij.org>
1472 * src/openpgp-do.c (gpg_do_write_prvkey): Bug fix.
1474 2013-10-15 Niibe Yutaka <gniibe@fsij.org>
1476 * src/openpgp.c (cmd_change_password, cmd_reset_user_password): It
1477 is now error to change User's pass phrase with no keys.
1479 * src/openpgp-do.c (proc_resetting_code): Likewise for resetting
1481 (gpg_do_delete_prvkey): New.
1482 (gpg_do_write_prvkey): Make sure to delete the key before writing.
1483 User's pass phrase is always the one of factory setting.
1484 (gpg_do_chks_prvkey): Support removing the key.
1485 (proc_key_import): Use gpg_do_delete_prvkey.
1486 (gpg_do_keygen): Use factory setting pass phrase.
1488 2013-10-11 Niibe Yutaka <gniibe@fsij.org>
1490 * src/ac.c (verify_user_0, verify_admin_00): Fix conditions.
1492 * src/openpgp-do.c (gpg_do_write_prvkey): Delete keystring
1493 information from data object of NR_DO_KEYSTRING_PW3.
1495 (gpg_do_keygen): Likewise.
1497 * src/openpgp.c (cmd_reset_user_password): Likewise.
1499 2013-10-10 Niibe Yutaka <gniibe@fsij.org>
1501 * src/gnuk.h (S2K_ITER): Remove. It's determined at compile time.
1503 * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey)
1504 (proc_key_import): Remove "iteration" field.
1506 * src/openpgp.c (cmd_change_password): Likewise.
1508 2013-10-10 Niibe Yutaka <gniibe@fsij.org>
1510 * src/openpgp-do.c (gpg_do_write_prvkey): Access of data object
1511 considering garbage collection.
1513 * src/openpgp.c (cmd_change_password): Call gpg_do_write_simple
1514 after accessing the data object (it may cause garbage collection).
1516 2013-10-10 Niibe Yutaka <gniibe@fsij.org>
1518 * polarssl/library/bignum.c (mpi_montred): Constant time for
1519 carry propagation. Bug fix for carry propagation.
1520 (mpi_exp_mod): Bug fix. Shrink the size of RR as same as X.
1522 2013-10-09 Niibe Yutaka <gniibe@fsij.org>
1524 * src/ac.c (verify_user_0, verify_admin_00, verify_admin_0): Add a
1525 flag to save into keystring_md_pw3. Add SALT handling.
1526 (decode_iterate_count, calc_md, gpg_set_pw3): Remove.
1528 * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey)
1529 (gpg_do_keygen): Add SALT handling.
1530 * src/openpgp.c (cmd_change_password, cmd_reset_user_password)
1532 * src/random.c (random_get_salt): Rename from get_salt.
1534 2013-10-09 Niibe Yutaka <gniibe@fsij.org>
1536 * src/openpgp-do.c (gpg_do_write_prvkey): Remove information (but
1537 pass phrase length) for admin from keystring data object.
1538 (proc_key_import): Recover admin keystring to DO when key deletion.
1540 2013-10-09 Niibe Yutaka <gniibe@fsij.org>
1542 * src/ac.c (verify_user_0, verify_admin_00): Handle PW_LEN_MASK.
1543 * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey):
1546 * src/openpgp.c (cmd_change_password, cmd_reset_user_password):
1547 Handle PW_LEN_KEYSTRING_BIT.
1549 2013-10-09 Niibe Yutaka <gniibe@fsij.org>
1551 * src/ac.c (verify_admin_00): New. Add authentication by loading
1553 (verify_admin_0): Use verify_admin_00.
1555 * src/openpgp.c (cmd_change_password): Admin keystring handling as
1558 2013-10-08 Niibe Yutaka <gniibe@fsij.org>
1560 * src/openpgp.c (modify_binary): Allow odd size of certificate.
1562 * polarssl/library/rsa.c: Update from PolarSSL 1.2.10.
1563 * polarssl/include/polarssl/rsa.h: Ditto.
1565 2013-10-07 Niibe Yutaka <gniibe@fsij.org>
1567 * polarssl/library/bignum.c (mpi_sub_hlp): Return CARRY.
1568 (mpi_sub_abs): Carry propagatoin is done here.
1569 (mpi_mul_hlp_mm): Remove.
1570 (mpi_mul_hlp): Return CARRY, computation in constant time.
1571 (mpi_mul_mpi): Change the order of computation not to propagate
1573 (mpi_montmul): Minimum zero-ing of D and reduce usage of temporary
1574 memory, by one word. Use carry of mpi_mul_hlp. Use
1575 NEED_SUBTRACTION against timing attack.
1576 (mpi_exp_mod): Minimum usage of temporary memory.
1578 2013-10-06 Niibe Yutaka <gniibe@fsij.org>
1580 * polarssl/library/bignum.c (mpi_mul_hlp_mm): New. Handle
1581 extra-carry in constant time to mitigate timing attack.
1582 (mpi_montmul): Use mpi_mul_hlp_mm.
1583 * src/call-rsa.c (rsa_sign, rsa_decrypt, rsa_verify): Don't
1586 2013-10-05 Niibe Yutaka <gniibe@fsij.org>
1588 * polarssl/include/polarssl/aes.h: Update from PolarSSL 1.2.9.
1589 * polarssl/include/polarssl/bignum.h: Ditto.
1590 * polarssl/include/polarssl/config.h: Ditto.
1591 * polarssl/include/polarssl/rsa.h: Ditto.
1592 * polarssl/library/aes.c, polarssl/library/bignum.c: Ditto.
1593 * polarssl/library/rsa.c: Ditto. Fix rsa_free.
1594 * src/call-rsa.c (rsa_sign, modulus_calc, rsa_decrypt)
1595 (rsa_verify): Follow changes of PolarSSL 1.2.9 with RSA blinding.
1596 Better error checking.
1598 2013-10-04 Niibe Yutaka <gniibe@fsij.org>
1600 * src/main.c (gnuk_malloc): Update ->neighbor field of a chunk on
1602 (gnuk_free): Access free list after getting the lock.
1604 2013-10-01 Niibe Yutaka <gniibe@fsij.org>
1606 * src/random.c (random_gen): Bug fix for INDEXed copy.
1608 * src/call-rsa.c (rsa_genkey): Call neug_flush and prng_seed.
1609 * polarssl/library/bignum.c (small_prime): More constants.
1610 (prng_seed, jkiss, mpi_fill_pseudo_random): New.
1611 (mpi_is_prime): Use mpi_fill_pseudo_random.
1613 2013-09-30 Niibe Yutaka <gniibe@fsij.org>
1615 * polarssl/library/bignum.c (mpi_is_prime): Enable trial divisions
1617 Add Fermat primality test.
1618 (mpi_gen_prime): Limit random value so that two MSBs of result will
1621 2013-09-27 Niibe Yutaka <gniibe@fsij.org>
1623 * polarssl/include/polarssl/bignum.h (mpi_is_prime): ifdef-out.
1624 * polarssl/library/bignum.c (mpi_is_prime): It's now internal
1625 function, assuming we already know its coprime to small primes.
1626 (M): New constant MPI. Multiply primes 2*...*691.
1627 (MAX_A): New constant MPI. 2^1024 / M - 1.
1628 (mpi_gen_prime): Specialize for 1024-bit, using Fouque-Tibouchi
1631 2013-09-25 Niibe Yutaka <gniibe@fsij.org>
1633 * src/sha256.h, src/adc.h
1634 * src/neug.c, src/adc_stm32f103.c: Update from NeuG 0.11.
1636 * chopstx: Upgrade to new Chopstx 0.00.
1638 * VERSION: New file.
1640 * src/configure (SERIALNO, SERIALNO_STR_LEN_DEFINE): New.
1641 (REVISION): Use the file VERSION if it doesn't have .git.
1642 Thanks to Sumedha Widyadharma for the bug report.
1644 * src/config.h.in (SERIALNO_STR_LEN_DEFINE): New.
1645 * src/main.c (ID_OFFSET): Use SERIALNO_STR_LEN.
1646 * src/usb_desc.c (gnukStringSerial): Remove. It's now
1647 generated in usb-strings.c.inc.
1649 * src/ec_p256.c (compute_kP): Fix for impossible cases.
1650 (point_is_on_the_curve): New.
1651 (coefficient_a, coefficient_b): New.
1653 2013-09-20 Niibe Yutaka <gniibe@fsij.org>
1655 * src/call-ec_p256.c (ecdsa_compute_public): Handle possible
1656 error (where key_data is the order).
1658 * src/ec_p256.c (compute_kG, compute_kP): Handle errors.
1660 * src/jpc.c (jpc_to_ac): Return -1 on error.
1661 (jpc_add_ac_signed): Handle the case where A=inf.
1663 * src/modp256.c (modp256_inv): Handle error case.
1665 * src/bn.c (bn256_cmp): New.
1667 2013-07-19 Niibe Yutaka <gniibe@fsij.org>
1669 * src/gnuk.ld.in: Layout change following NeuG.
1670 (_end): Add alignment of 16.
1672 * src/neug.c, src/adc.h, src/adc_stm32f103.c: Update from NeuG.
1674 * src/main.c [DFU_SUPPORT] (main): Fix calling
1675 flash_erase_all_and_exec.
1677 * src/openpgp-do.c (gpg_do_write_prvkey, gpg_do_keygen): Fix
1678 allocated memory handling. Clean up before free.
1679 * src/call-rsa.c (modulus_calc, rsa_genkey): Fix removing const.
1680 * src/call-ec_p256.c (ecdsa_compute_public): Likewise.
1682 2013-07-18 Niibe Yutaka <gniibe@fsij.org>
1685 * src/Makefile.in: Change for Chopstx.
1686 * src/configure: Likewise.
1687 * src/gnuk.h, src/gnuk.ld.in: Likewise.
1688 * src/ac.c: Include stdint.h and string.h, not ch.h.
1689 * src/call-rsa.c, src/debug.c, src/flash.c: Likewise.
1690 * src/call-ec_p256.c, src/usb_desc.c
1691 * src/openpgp-do.c, src/random.c: Likewise.
1692 * src/openpgp.c: Likewise. Use eventflag of Chopstx.
1693 * src/usb-icc.c: Likewise.
1694 * src/usb_ctrl.c: Update for Chopstx.
1696 * src/stdlib.h: Use gnuk_malloc and gnuk_free for malloc/free.
1697 * src/config.h.in: Move FLASH_PAGE_SIZE in board.h.
1698 * polarssl/library/aes.c (FT0, FT1, FT2): Export (for sys 2.0).
1699 * src/main.c (struct stdout, _write, EP3_IN_Callback)
1700 (EP5_OUT_Callback): Rewrite for Chopstx. No independent thread
1702 (display_fatal_code, emit_led, display_status_code, led_blink):
1703 Use primitives of Chopstx.
1704 (main): Changes for Chopstx.
1705 (gnuk_malloc_init, sbrk, gnuk_malloc, gnuk_free): New.
1707 2013-06-20 Niibe Yutaka <gniibe@fsij.org>
1709 * src/sys.c, src/sys.h, src/neug.c, src/adc.h
1710 * src/adc_stm32f103.c, src/usb_stm32f103.c: Update from NeuG 0.10.
1711 * src/stm32f103.h: New. From NeuG 0.10.
1713 2013-06-18 Niibe Yutaka <gniibe@fsij.org>
1715 * src/openpgp-do.c (gpg_do_write_prvkey, proc_key_import, gpg_do_table)
1716 (gpg_do_public_key) [RSA_AUTH]: Conditional compilation for RSA/ECDSA.
1717 * src/openpgp.c (cmd_internal_authenticate) [RSA_AUTH]: Likewise.
1719 * src/modp256.c (p256): Add const qualifier.
1721 2013-03-19 Niibe Yutaka <gniibe@fsij.org>
1723 * src/random.c (random_gen): New (was: random_byte).
1725 * src/call-rsa.c (rsa_sign): Follow change of API.
1726 (rsa_genkey): Use random_gen.
1727 (modulus_calc, rsa_decrypt, rsa_verify): Follow change of API.
1728 * src/openpgp-do.c (encrypt, decrypt): Likewise.
1730 * polarssl/include/polarssl/aes.h: Updated from PolarSSL 1.2.6.
1731 * polarssl/library/aes.c: Ditto.
1732 * polarssl/include/polarssl/rsa.h: Ditto.
1733 * polarssl/library/rsa.c: Ditto.
1734 * polarssl/include/polarssl/bignum.h: Ditto.
1735 * polarssl/library/bignum.c: Ditto.
1736 * polarssl: Move from polarssl-0.14.0, and needed files only.
1738 2013-03-15 Niibe Yutaka <gniibe@fsij.org>
1740 * regnual/regnual.ld (.bss): Put at RAM1. This makes reGNUal can
1741 be loaded on the lower address.
1743 * regnual/sys.c (entry): Don't change SP. Put alignment.
1745 * regnual/regnual.c (usb_cb_get_descriptor): Fix adding break.
1747 2013-03-14 Niibe Yutaka <gniibe@fsij.org>
1749 * tool/stlinkv2.py (stlinkv2.start): Call write_debug_reg to run
1752 2013-03-12 Niibe Yutaka <gniibe@fsij.org>
1754 * src/gnuk.ld.in (__process_stack_size__): Increase (was: 0x200).
1756 * tool/stlinkv2.py (stlinkv2.exit_from_debug_swd)
1757 (stlinkv2.exit_from_debug_swim): New.
1758 (stlinkv2.start): Call exit_from_debug_swd or
1759 exit_from_debug_swim.
1761 2013-03-09 Niibe Yutaka <gniibe@fsij.org>
1763 * src/openpgp-do.c (gpg_do_public_key): Add OID for ECDSA.
1764 (gpg_do_write_prvkey): Add PUBKEY_LEN for ECDSA.
1766 * src/flash.c (flash_key_write): Argument change for ECDSA key.
1768 * src/main.c (calculate_regnual_entry_address): New.
1769 (main): Use calculate_regnual_entry_address for entry point.
1771 * src/openpgp-do.c (gpg_do_write_prvkey): Coerce KDI.DATA to
1774 * src/usb_stm32f103.c (handle_setup0): Fix selecting handler.
1776 2013-03-08 Niibe Yutaka <gniibe@fsij.org>
1778 Relocatable reGNUal.
1780 * regnual/regnual.ld (MEMORY): 0x1400 was the value of Gnuk 1.0.1.
1782 (.text): Include .text.entry next to the .vectors.
1785 * regnual/sys.c (entry): Now, it's at .text.entry section.
1787 Don't use absolute values which causes relocations, but
1790 * regnual/Makefile (CFLAGS): Add -fpie.
1792 2013-03-07 Niibe Yutaka <gniibe@fsij.org>
1794 Follow the USB stack change.
1796 * regnual/regnual.c (usb_cb_device_reset): Rename from
1797 regnual_device_reset.
1798 (mem): Change type to uint32_t.
1799 (mem_info): Removed.
1800 (fetch): Avoid pointer punning.
1801 (usb_cb_ctrl_write_finish): Rename from regnual_ctrl_write_finish.
1802 (usb_cb_setup): Rename from regnual_setup.
1803 (usb_cb_get_descriptor): Rename from regnual_get_descriptor.
1804 (usb_cb_handle_event): Rename regnual_usb_event.
1805 (usb_cb_interface): Rename regnual_interface.
1806 (Device_Method): Remove.
1807 (usb_cb_get_descriptor): Not use struct Descriptor.
1809 2013-03-06 Niibe Yutaka <gniibe@fsij.org>
1811 USB stack implementation improvement.
1813 * src/usb_stm32f103.c (Device_Method, method_p): Remove.
1814 (usb_interrupt_handler): Call usb_cb_device_reset.
1815 (std_get_descriptor): Call usb_cb_get_descriptor.
1816 (std_set_configuration): Call usb_cb_handle_event.
1817 (std_get_status, std_get_interface, std_set_interface): Call
1819 (handle_setup0): Call usb_cb_setup.
1820 (handle_in0): Call usb_cb_handle_event and
1821 usb_cb_ctrl_write_finish.
1822 (request_handler): Remove.
1823 (handle_setup0): Call std_* directly, not indirectly by
1825 (ep_intr_handler_IN, ep_intr_handler_OUT): Remove.
1826 (usb_handle_transfer): Call EP*_Callback directly, not indirectly
1827 by ep_intr_handler_IN, ep_intr_handler_OUT.
1829 * src/usb_lld.h (struct usb_device_method, Device_Method): Remove.
1830 (usb_cb_device_reset, usb_cb_ctrl_write_finish)
1831 (usb_cb_setup, usb_cb_get_descriptor, usb_cb_handle_event)
1832 (usb_cb_interface): Define callbacks.
1833 (usb_initial_feature): New.
1834 (struct Descriptor): Move to ...
1835 * src/usb_desc.c: ... here.
1836 (usb_initial_feature): New.
1837 (usb_cb_get_descriptor): Rename from gnuk_get_descriptor and move
1840 * src/usb_ctrl.c (usb_cb_device_reset): Rename from
1842 (usb_cb_setup): Rename from gnuk_setup.
1843 (usb_cb_ctrl_write_finish): Rename from gnuk_ctrl_write_finish.
1844 (usb_cb_event): Rename from gnuk_usb_event.
1845 (usb_cb_interface): Rename from gnuk_interface.
1846 (Device_Method): Remove.
1848 * src/main.c (main): Use usb_initial_feature.
1850 2013-02-27 Niibe Yutaka <gniibe@fsij.org>
1852 * src/usb-icc.c (set_sw1sw2): Arguments are C and CHUNK_LEN.
1853 Fix reporting remaining bytes.
1854 (icc_send_data_block_gr): Follow the arguments change of
1857 2013-02-26 Niibe Yutaka <gniibe@fsij.org>
1859 * regnual/regnual.ld (MEMORY): Fix start address.
1861 * src/random.c (random_fini): New.
1862 * src/main.c (main): Call random_fini.
1864 2013-02-25 Niibe Yutaka <gniibe@fsij.org>
1866 * src/configure: Correct typo in help text.
1868 * src/gnuk.h (struct key_data_internal): Use uint32_t.
1869 * src/openpgp-do.c (do_openpgpcard_aid): Fix calculation of VID.
1870 (compute_key_data_checksum): Don't use type-punning pointer.
1871 (gpg_do_write_prvkey): Use coercing to char *.
1873 2013-02-22 Niibe Yutaka <gniibe@fsij.org>
1875 * src/openpgp-do.c (gpg_do_public_key): Add header of EC point.
1877 * src/openpgp-do.c (GPG_DO_DISCRETIONARY, cmp_discretionary): New.
1878 (cmp_app_data): Change to factor out GPG_DO_DISCRETIONARY.
1879 (gpg_do_table): Add GPG_DO_DISCRETIONARY.
1881 2013-02-21 Niibe Yutaka <gniibe@fsij.org>
1883 * src/gnuk.ld.in (MEMORY): Fix adding FLASH_SIZE unit.
1885 * src/call-ec_p256.c (ecdsa_sign): Fix secret key access.
1887 2013-02-20 Niibe Yutaka <gniibe@fsij.org>
1889 * src/openpgp.c (cmd_internal_authenticate): Support ECDSA for
1892 * src/openpgp-do.c (algorithm_attr_ecdsa): New.
1893 (algorithm_attr_rsa): Rename (was: algorithm_attr).
1894 (gpg_do_table): Change for GPG_DO_ALG_AUT.
1895 (gpg_do_write_prvkey): Support ECDSA key for authentication.
1896 (proc_key_import): Likewise.
1897 (gpg_do_public_key): Likewise.
1899 * src/call-ec_p256.c: New.
1900 * src/Makefile.in: Add call-ec_p256.c.
1901 * src/call-rsa.c (modulus_free): Remove.
1903 2013-02-19 Niibe Yutaka <gniibe@fsij.org>
1905 * regnual/regnual.ld (MEMORY): Fix address of regnual.
1907 * regnual/Makefile (MCFLAGS): Remove -mfix-cortex-m3-ldrd.
1908 (CFLAGS): Add output to .lst.
1909 * src/Makefile.in (MCFLAGS): Remove.
1911 * src/sha256.c: Update from NeuG 0.05.
1913 * ChibiOS_2.0.8: Remove.
1915 2013-02-18 Niibe Yutaka <gniibe@fsij.org>
1917 Changes for new ChibiOS/RT.
1918 * src/main.c: Include adc.h.
1919 (main): Call halInit, adc_init, and chSysInit (change for
1921 * src/random.h: New.
1922 * src/ac.c, src/bn.c, src/call-rsa.c, src/main.c: Include random.h.
1923 * src/openpgp.c, src/openpgp-do.c: Likewise.
1924 * src/configure, src/gnuk.ld.in: Add MEMORY_SIZE.
1925 * src/ec_p256.c: Fix call of bn256_add_uint.
1926 * boards/STM8S_DISCOVERY/*: Update for ChibiOS/RT 2.4.x.
1927 * boards/CQ_STARM/*: Likewise.
1928 * boards/FST_01_00/*: Likewise.
1929 * boards/OLIMEX_STM32_H103/*: Likewise.
1930 * boards/STBEE/*: Likewise.
1931 * boards/STBEE_MINI/*: Likewise.
1932 * boards/STM32_PRIMER2/*: Likewise.
1934 Merge ec_p256 branch.
1935 * src/Makefile.in: Add ECC files.
1936 * src/bn.h, src/bn.c: New.
1937 * src/jpc-ac.h, src/jpc.c: New.
1938 * src/ec_p256.h, src/ec_p256.c, src/ecc-cdh.c: New.
1939 * src/mod.h, src/mod.c, src/modp256.h, src/modp256.c: New.
1941 2013-02-17 Niibe Yutaka <gniibe@fsij.org>
1943 * chibios: New submodule for ChibioS/RT 2.4.x.
1944 * boards/FST_01/*: Update for ChibiOS/RT 2.4.x.
1945 * boards/common/mcuconf-common.h: Ditto.
1947 * src/chconf.h, src/halconf.h, src/Makefile.in, src/gnuk.ld.in:
1948 Update for ChibiOS/RT 2.4.x.
1950 * src/main.c, src/openpgp.c, src/usb-icc.c: Follow the change of
1952 * boards/common/board-common.c: Rename from hwinit.c.
1953 * src/usb_stm32f103.c: Rename from usb_lld.c.
1955 * src/neug.h, src/neug.c: Update NeuG 0.05.
1956 * src/adc_stm32f103.c, src/adc.h: New from NeuG 0.05.
1958 * src/random.c: Follow the change of NeuG 0.05.