From cd082d4823895d4378e3028ed36c76d19965c535 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Mon, 25 Apr 2022 14:29:27 +0900 Subject: [PATCH] Merge rsa-removal branch. Signed-off-by: NIIBE Yutaka --- ChangeLog | 2864 +----------------------------------- ChangeLog-1_2 | 2823 +++++++++++++++++++++++++++++++++++ doc/note/firmware-update-2 | 10 +- src/Makefile | 4 +- src/call-rsa.c | 274 ---- src/crypt.mk | 5 +- src/flash.c | 21 - src/gnuk-malloc.h | 16 - src/gnuk.h | 15 - src/gnuk.ld.in | 3 - src/main.c | 191 --- src/openpgp-do.c | 167 +-- src/openpgp.c | 157 +- tests/rsa-aut.key | 4 - tests/rsa-dec.key | 4 - tests/rsa-sig.key | 4 - tool/gnuk_token.py | 10 +- tool/gnuk_upgrade.py | 52 +- tool/upgrade_by_passwd.py | 24 +- 19 files changed, 2931 insertions(+), 3717 deletions(-) create mode 100644 ChangeLog-1_2 delete mode 100644 src/call-rsa.c delete mode 100644 src/gnuk-malloc.h delete mode 100644 tests/rsa-aut.key delete mode 100644 tests/rsa-dec.key delete mode 100644 tests/rsa-sig.key diff --git a/ChangeLog b/ChangeLog index c3560fa..501f8f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,43 @@ +2022-04-25 NIIBE Yutaka + + Remove RSA support. + * src/Makefile (CSRC): Remove call-rsa.c, bignum.c and rsa.c. + * src/crypt.mk (CRYPTSRC): Remove rsa.c, bugnum.c and call-rsa.c. + * src/call-rsa.c: Remove. + * src/flash.c [FLASH_UPGRADE_SUPPORT] (flash_terminate): Remove + update key support. + [FLASH_UPGRADE_SUPPORT] (flash_write_binary): Remove + FILEID_UPDATE_KEY_* support. + * src/gnuk-malloc.h: Remove. + * src/gnuk.h: Remove FILEID_UPDATE_KEY_*. + (rsa_sign, modulus_calc, rsa_decrypt, rsa_verify, rsa_genkey): + Remove. + * src/gnuk.ld.in (_updatekey_store): Remove. + * src/main.c (main): Remove malloc initialization. + (gnuk_malloc_init, gnuk_sbrk, remove_from_free_list) + (gnuk_malloc, gnuk_free): Remove. + * src/openpgp-do.c (OPENPGP_ALGO_RSA): Remove. + (algorithm_attr_rsa2k, algorithm_attr_rsa4k): Remove. + (gpg_get_algo_attr): Remove RSA support. + (get_algo_attr_data_object, gpg_get_algo_attr_key_size): Likewise. + (do_alg_info, rw_algorithm_attr, gpg_do_write_prvkey): Likewise. + (proc_key_import, gpg_do_public_key, gpg_do_keygen): Likewise. + * src/openpgp.c (challenge): Remove. + (gpg_get_firmware_update_key): Remove. + (cmd_read_binary, modify_binary): Remove FILEID_UPDATE_KEY_* support. + (cmd_pso): Remove RSA support. + (cmd_internal_authenticate): Remove RSA support. + (cmd_external_authenticate): Remove RSA authentication. + (cmd_get_challenge): Work independently not related to + EXTERNAL_AUTHENTICATE. + * tests/rsa-aut.key, tests/rsa-dec.key, tests/rsa-sig.key: Remove. + * tool/gnuk_token.py (gnuk_token.cmd_external_authenticate): Now, + it does no authentication with FILEID_UPDATE_KEY_*. + * tool/gnuk_upgrade.py (gpg_sign): Remove. + (main): Remove support of specifying FILEID_UPDATE_KEY_*. + * tool/upgrade_by_passwd.py (main): Remove support of specifying + FILEID_UPDATE_KEY_*. + 2022-04-22 NIIBE Yutaka * src/gnuk.h (_regnual_start): Fix type. @@ -127,2827 +167,3 @@ * src/configure (kdf_do_required): Fix typo. * chopstx: Update to 2.2. - -2021-02-25 NIIBE Yutaka - - * VERSION: 1.2.17. - -2021-02-22 NIIBE Yutaka - - * src/config.h.in (@KDF_DO_REQUIRED_DEFINE@): New. - - * src/configure (KDF_DO_REQUIRED_DEFINE): New for GNU/Linux. - - * src/openpgp-do.c (gpg_do_kdf_check): When LEN==0, check if - KDO data object is available. - [KDF_DO_REQUIRED] (proc_key_import): Refuse the key import when - KDF data object is not available. - - * src/openpgp.c [KDF_DO_REQUIRED] (cmd_pgp_gakp): Refuse key - generation when KDF data object is not available. - -2021-02-19 NIIBE Yutaka - - * tool/gnuk-emulation-setup: Remove. - - * tool/upgrade_by_passwd.py (main): Use tobytes. - * tool/gnuk_get_random.py: Likewise. - * tool/gnuk_remove_keys_libusb.py (main): Likewise. - Switch to Python3. - * tool/gnuk_put_binary_libusb.py (main): Use tobytes. - Switch to Python3. - * tool/gnuk_upgrade.py (main): Use tobytes. - Switch to Python3. - - * chopstx: Update to 1.19. - -2021-02-18 Vincent Pelletier - - * test/features/202_setup_passphrase.feature: Fix. - * test/rsa_keys.py: Fix escape. - * tests/card_reader.py: Extend the timeout. - Handle no card. - * tests/rsa_keys.py: Fix escape. - * tool/gnuk_token.py: Avoid hard-coding the endpoints. - Longer timeout. - -2021-02-18 NIIBE Yutaka - - * src/configure [GNU_LINUX_EMULATION] (def_mhz): Define. - (output_vendor_product_serial_strings): Output ARCH. - - * GNUK_USB_DEVICE_ID: Use "Gnuk Token" for emulation, too. - - * src/main.c [GNU_LINUX_EMULATION] (main): Add initialization of - the .gnuk-flash-image file. - (gnuk_sbrk): Rename from sbrk. - -2020-09-10 NIIBE Yutaka - - * VERSION: 1.2.16. - -2020-09-09 NIIBE Yutaka - - * src/modp256k1.c (modp256k1_add, modp256k1_sub): Use memcpy with - dummy memory area. - * src/modp256r1.c (modp256r1_add, modp256r1_sub) - (modp256r1_reduce): Likewise. - -2020-09-08 NIIBE Yutaka - - * src/modp256k1.c (modp256k1_add, modp256k1_reduce): Avoid - optimization to remove call of memmove. - * src/modp256r1.c (modp256r1_add, modp256r1_sub) - (modp256r1_reduce): Likewise. - -2020-09-07 NIIBE Yutaka - - * src/openpgp.c (gpg_get_firmware_update_key): Use an array. - - * src/modp256k1.c (modp256k1_add, modp256k1_sub): Use memmove. - * src/modp256r1.c (modp256r1_add, modp256r1_sub) - (modp256r1_reduce): Likewise. - -2020-09-04 NIIBE Yutaka - - * src/openpgp-do.c (GPG_DO_ALG_INFO): New. - (do_fp_all, do_cafp_all, do_kgtime_all, do_openpgpcard_aid) - (do_ds_count): Return nothing. - (copy_do): Change the API for DO_PROC_READ. - (do_alg_info): New for GPG_DO_ALG_INFO. - (gpg_do_table): Add an entry for GPG_DO_ALG_INFO. - -2020-09-03 NIIBE Yutaka - - * src/openpgp.c (cmd_internal_authenticate): Remove checking - against EDDSA_HASH_LEN_MAX. - (cmd_pso): Likewise. - -2020-08-28 NIIBE Yutaka - - * src/openpgp.c (cmd_reset_user_password): Add passphrase length - check. - -2020-08-26 NIIBE Yutaka - - * src/ac.c (verify_user_0): Fix for a use case of having - signing key only. - (verify_admin_00): Clean up. - - * tests/test_000_empty_card.py (test_name_lang_sex): Support - OpenPGP card version 3.3. - -2020-01-24 NIIBE Yutaka - - * VERSION: 1.2.15. - -2020-01-11 Bertrand Jacquin - - * tool/add_openpgp_authkey_from_gpgssh.py: Switch to Python3. - * tool/calc_precompute_table_ecc.py: Likewise. - * tool/dfuse.py: Likewise. - * tool/dump_mem.py: Likewise. - * tool/get_raw_public_key.py: Likewise. - * tool/pageant_proxy_to_gpg.py: Likewise. - -2019-12-30 NIIBE Yutaka - - * chopstx: Update to 1.18. - -2019-06-18 NIIBE Yutaka - - * src/bn.c (bn256_random): More portable. - -2019-04-03 NIIBE Yutaka - - * tests: Factor out tests into classes. - -2019-03-04 NIIBE Yutaka - - * VERSION: 1.2.14. - - * chopstx: Update to 1.14. - - * tool/gnuk_token.py: Add 1209:2440. - -2019-02-24 NIIBE Yutaka - - * src/usb-ccid.c (ccid_thread): Clean up the ack button state - at reset (by SET_INTERFACE). - - * tool/gnuk_token.py (gnuk_token.__init__): Add back - setAltInterface to issue SET_INTERFACE control transfer. - -2019-02-22 NIIBE Yutaka - - * tool/gnuk_get_random.py: New. - - * src/openpgp.c (cmd_external_authenticate): move - ACKBTN_SUPPORT to... - (cmd_get_challenge): ... here. - - * src/gnuk.h (EV_*): Change the values. - - * src/usb-ccid.c (GPG_ACK_TIMEOUT): New. - (ccid_thread): Implement timout for the user interaction. - -2019-02-21 NIIBE Yutaka - - * GNUK_USB_DEVICE_ID: Add 1209:2440. - -2018-12-26 NIIBE Yutaka - - * VERSION: 1.2.13. - -2018-12-22 Peter Lebbing - - * src/main.c (device_initialize_once): Fill the stack address and - reset vector of Gnuk application (was the one of old SYS). - Reset the board after updating the first five pages of flash. - -2018-12-21 Peter Lebbing - - * src/main.c [DFU_SUPPORT] (flash_write_any): New. - (device_initialize_once): Overwrite DFU bootloader by SYS. - (main): Use SYS at ORIGIN_REAL. - - * src/stdaln-sys.ld.in: New. - - * src/Makefile [USE_DFU] (OBJS_ADD): Add standalone SYS object. - Add rules for stdaln-sys-bin.o and src/stdaln-sys.ld. - - * src/configure: Generate stdaln-sys.ld. - [MAPLE_MINI]: Tweak ORIGIN and FLASH_SIZE. - (ORIGIN_DEFINE, ORIGIN_REAL_DEFINE): New macros. - (USE_DFU): New make variable. - - * src/config.h.in (ORIGIN_DEFINE, ORIGIN_REAL_DEFINE): New. - -2018-12-20 NIIBE Yutaka - - * chopstx: Update to 1.13. - -2018-12-07 NIIBE Yutaka - - * src/gnuk.h (EV_EXEC_ACK_REQUIRED): Have precedence - than EV_EXEC_FINISHED. - -2018-12-06 NIIBE Yutaka - - * src/usb-ccid.c (ccid_thread): Priority of handling - EV_TX_FINISHED is most important. Don't handle - Ack button event when c->tx_busy = 1. - -2018-12-05 NIIBE Yutaka - - * src/openpgp.c (cmd_external_authenticate): Support - ACK button for firmware update. - -2018-12-04 NIIBE Yutaka - - * src/openpgp-do.c (gpg_data_copy): Fix for NR_DO_UIF_SIG. - -2018-11-25 NIIBE Yutaka - - * VERSION: 1.2.12. - -2018-11-21 NIIBE Yutaka - - * src/usb-ccid.c (ccid_thread): Fix a race condition sending - result APDU by ack button, time out, sending time extension block - again while tx_busy=1. - -2018-11-17 NIIBE Yutaka - - * src/main.c (device_initialize_once): Depends on MHZ to - distinguish GD32F103. - * src/openpgp-do.c (do_openpgpcard_aid): Ditto. - -2018-11-12 NIIBE Yutaka - - * VERSION: 1.2.11. - - * chopstx: Update to 1.12. - * src/configure (ackbtn_support): Always yes. - * src/usb-ccid.c: Fix comma separator. - -2018-11-09 NIIBE Yutaka - - * tool/kdf_calc.py (kdf_calc): Use libgcrypt.so.20. - -2018-11-09 NIIBE Yutaka - - * src/openpgp.c (cmd_pso, cmd_internal_authenticate): Use - ccid_comm. - - * src/usb-ccid.c (struct ccid): New field tx_busy. - (ccid_error, ccid_power_on, ccid_send_status, ccid_power_off) - (ccid_send_data_block_internal, ccid_send_data_block_0x9000) - (ccid_send_data_block_gr, ccid_send_params): Set c->tx_busy. - (ccid_state_p): Remove. - (ccid_get_ccid_state): New. - (ccid_thread): Only handle EV_TX_FINISHED event when c->tx_busy. - - * src/usb_ctrl.c (usb_setup, usb_ctrl_write_finish): Use - ccid_get_ccid_state. - * src/main.c (display_status_code): Likewise. - -2018-11-09 NIIBE Yutaka - - * src/usb-ccid.c (ccid_handle_data): Set c->state for pinpad input. - (ccid_send_data_block_internal): Fix the case of len == 0. - - * src/main.c (display_status_code): There is - no case where ccid_state == CCID_STATE_RECEIVE. - * src/gnuk.h (CCID_STATE_RECEIVE): Remove. - (CCID_STATE_SEND): Remove. - -2018-10-12 NIIBE Yutaka - - * src/usb-ccid.c (ccid_thread): Notify host about ack button. - -2018-10-02 NIIBE Yutaka - - * src/stack-def.h (SIZE_0): Increase. - - * chopstx: Update to 1.11. - -2018-10-01 NIIBE Yutaka - - * src/gnuk.h (EV_EXEC_ACK_REQUIRED): New. - (EV_EXEC_FINISHED_ACK): Remove. - (CCID_STATE_CONFIRM_ACK): Remove. - (CCID_STATE_ACK_REQUIRED_0, CCID_STATE_ACK_REQUIRED_1): New. - * src/openpgp.c (cmd_pso): Send EV_EXEC_ACK_REQUIRED, if needed. - (cmd_internal_authenticate): Likewise. - (process_command_apdu): No return value. - (openpgp_card_thread): Always send EV_EXEC_FINISHED. - * src/usb-ccid.c (ccid_send_data_block_time_extension): Follow the - change of state. - (ccid_handle_data, ccid_handle_timeout): Likewise. - (ccid_thread): Handle EV_EXEC_ACK_REQUIRED. - Change for LED blink. - * src/main.c (main): LED blink during waiting ACK. - -2018-09-27 NIIBE Yutaka - - * src/gnuk.h (NR_DO_UIF_SIG, NR_DO_UIF_DEC, NR_DO_UIF_AUT): New. - * src/openpgp-do.c (rw_uif) [ACKBTN_SUPPORT]: New. - (GPG_DO_UIF_SIG, GPG_DO_UIF_DEC, GPG_DO_UIF_AUT): New. - (feature_mngmnt) [ACKBTN_SUPPORT]: New. - (cmp_app_data, cmp_discretionary): Add ACKBTN_SUPPORT. - (gpg_do_table): Add for GPG_DO_UIF_SIG, GPG_DO_UIF_DEC, - GPG_DO_UIF_AUT, and GPG_DO_FEATURE_MNGMNT. - (gpg_do_get_uif) [ACKBTN_SUPPORT]: New. - (gpg_data_scan): Handle uif_flags. - * src/openpgp.c (process_command_apdu) [ACKBTN_SUPPORT]: Add user - interaction handling. - -2018-09-27 NIIBE Yutaka - - * src/gnuk.h (LED_WAIT_FOR_BUTTON): New. - * src/main.c (main): Blink rapidly when asking ACK. - * src/usb-ccid.c (ccid_thread): Use LED_WAIT_FOR_BUTTON. - -2018-09-27 NIIBE Yutaka - - * src/config.h.in: Add @ACKBTN_DEFINE@. - * src/configure: Add ACKBTN_SUPPORT. - * src/gnuk.h (EV_EXEC_FINISHED_ACK): New. - (CCID_STATE_CONFIRM_ACK): New. - * src/openpgp.c (process_command_apdu): Change for cmd_pso, and - cmd_internal_authenticate. - * src/usb-ccid.c (ccid_send_data_block_time_extension): Report - time extension differently when waiting ack button. - (ccid_handle_data): Support case of CCID_STATE_CONFIRM_ACK. - (ccid_handle_timeout): Likewise. - (ack_intr) [ACKBTN_SUPPORT]: New. - (ccid_thread) [ACKBTN_SUPPORT]: Add ack button handling. - -2018-09-26 NIIBE Yutaka - - * chopstx: Update. - * src/usb-ccid.c (usb_event_handle): Fix for chopstx_intr_done. - * src/pin-cir.c (tim_main, ext_main): Likewise. - - * src/configure (FST_01SZ): Set MHZ=96. - -2018-07-04 Szczepan Zalega - - * tool/upgrade_by_passwd.py: Catch exception, when no KDF data is - found. - Output 'second' for 1 second. - -2018-05-10 NIIBE Yutaka - - * VERSION: 1.2.10. - - * src/Makefile (build/gnuk.elf): New target. - (build/gnuk-vidpid.elf): Remove. - - * chopstx: Update to 1.9. - -2018-04-26 NIIBE Yutaka - - * src/usb_ctrl.c (usb_device_reset): Don't stop the endpoints. - - * src/configure (MHZ, def_mhz): New. - -2018-04-05 NIIBE Yutaka - - * VERSION: 1.2.9. - - * tests: Add test cases for admin-less mode. - - * src/openpgp.c (cmd_change_password): Care admin-less mode. - -2018-04-04 NIIBE Yutaka - - * tests: Add more tests, key generation and KDF support. - - * src/openpgp.c (cmd_reset_user_password): Check length of - new passphrase. - - * src/openpgp-do.c (proc_resetting_code): Support removal. - (gpg_do_kdf_check): Fix for the case of resetting PW3. - - * tests/test_004_reset_pw3.py: New. - -2018-04-03 NIIBE Yutaka - - * src/openpgp-do.c (rw_kdf): Clear all auth state. - - * tool/upgrade_by_passwd.py (main): Fix for byte compare. - * tool/gnuk_remove_keys_libusb.py (main): Likewise. - -2018-04-02 NIIBE Yutaka - - * tool/gnuk_token.py (parse_kdf_data): New. - * tool/kdf_calc.py: New. - - * tool/gnuk_remove_keys_libusb.py (main): Support KDF auth. - * tool/upgrade_by_passwd.py (main): Likewise. - -2018-03-30 NIIBE Yutaka - - * src/openpgp-do.c (rw_kdf): Support single-salt KDF. - (gpg_do_get_initial_pw_setting): Likewise. - (gpg_do_kdf_check): Likewise. - -2018-03-22 NIIBE Yutaka - - * src/openpgp-do.c (rw_kdf): Do format validation earlier. - -2018-03-13 NIIBE Yutaka - - * src/flash.c [FLASH_UPGRADE_SUPPORT] (flash_terminate): Erase - the page for upgrade public keys. - -2018-02-12 NIIBE Yutaka - - * src/openpgp-do.c (rw_kdf): Return 0 when NULL. - -2018-01-23 NIIBE Yutaka - - * VERSION: 1.2.8. - - * src/Makefile (build/gnuk-vidpid.elf): Supply FILE here. - * src/configure (output_vendor_product_serial_strings): For - generating put-vid-pid-ver.sh, don't set FILE. - - * regnual/regnual.c (regnual_device_desc): Make this array as a - template. - * regnual/Makefile (regnual.elf): Substitute VID:PID. - -2018-01-22 NIIBE Yutaka - - * src/openpgp.c (USER_PASSWD_MINLEN): New. - (cmd_change_password): Check passphrase length. - -2018-01-22 NIIBE Yutaka - - * src/openpgp.c (cmd_change_password): Remove access to private - key with BY_ADMIN when it's becoming admin-less mode. - -2018-01-19 NIIBE Yutaka - - * src/binary-edit.sh: Copied from NeuG 1.0.8. Exclude FILE. - * src/configure (output_vid_pid_version): Generate a shell script. - * src/Makefile (build/gnuk-vidpid.elf): New target. - * src/usb_desc.c (device_desc): Make this array as a template. - - * chopstx: Update to 1.8. - -2018-01-18 NIIBE Yutaka - - * src/neug.c: Update from NeuG. - -2018-01-09 NIIBE Yutaka - - * tests/card_reader.py (CardReader.ccid_power_on): Fix for - other card readers for Gemalto's. - -2017-12-19 NIIBE Yutaka - - * chopstx: Update to 1.7. - -2017-11-26 NIIBE Yutaka - - * src/openpgp.c (cmd_change_password): Bug fix for admin-less - mode. - -2017-11-26 NIIBE Yutaka - - * VERSION: 1.2.7. - -2017-11-24 NIIBE Yutaka - - * regnual/regnual.c (calc_crc32): Enable CRC module fix. - - * chopstx: Update to 1.6. - -2017-11-17 NIIBE Yutaka - - * src/stack-def.h (SIZE_0): Decrease. - - * src/main.c (emit_led, display_status_code, main): Use - chopstx_poll instead of eventflag_wait_timeout. - -2017-11-17 NIIBE Yutaka - - * src/stack-def.h (SIZE_0): Increase. - - * src/main.c (emit_led, display_status_code, main): Use - eventflag_wait_timeout instead of chopstx_usec_wait. - -2017-11-17 NIIBE Yutaka - - * regnual/regnual.c (calc_crc32): Enable CRC module. - - * src/neug.c (crc32_rv_stop): New. - (neug_fini): Call crc32_rv_stop. - - * src/main.c (main): Call chopstx_conf_idle. - - * src/usb-ccid.c (usb_event_handle): Use 2 for call of - chopstx_conf_idle on suspend. Call random_fini on suspend - to stop ADC module. Call random_init on wakeup. - Sleep a bit to switch main thread. - -2017-11-16 NIIBE Yutaka - - * src/gnuk.h (LED_OFF): New. - - * src/usb-ccid.c (usb_event_handle): LED off on sleep. - (ccid_thread): Use constant pointer for chopstx_poll. - (poll_event_intr): Remove. - -2017-11-15 NIIBE Yutaka - - * src/usb-ccid.c (usb_event_handle): Allow sleep on suspend. - - * src/usb_ctrl.c (usb_device_reset): Fix device state. - -2017-11-14 NIIBE Yutaka - - * src/usb-ccid.c (ccid_usb_reset): Remove - (usb_event_handle): Return value change to notify - caller about needs for going out of the loop. - Support USB suspend/resume. - (ccid_thread): Supporting USB suspend, sleep forever with - timeout_p = NULL. - - * src/main.c (main): Add USB_DEVICE_STATE_ prefix. - * src/usb_ctrl.c: Likewise. - (usb_device_reset): Don't call ccid_usb_reset. - (usb_set_configuration, usb_set_interface): Likewise. - - * src/usb_desc.c (device_desc): bcdUSB = 2.0, supporting - suspend/resume. - -2017-11-13 NIIBE Yutaka - - * src/usb_ctrl.c: Use new const USB_DEVICE_STATE_* - * src/main.c (main): Likewise. - * src/usb-ccid.c: Likewise. - (INTR_REQ_USB): Remove. Use the definition - in usb-lld.h. - -2017-11-08 NIIBE Yutaka - - * src/openpgp-do.c (gpg_do_kdf_check): New. - (proc_resetting_code): Use gpg_do_kdf_check. - * src/openpgp.c (cmd_verify, cmd_change_password) - (cmd_reset_user_password): Likewise. - -2017-11-07 NIIBE Yutaka - - * src/openpgp-do.c (proc_resetting_code): Error when - it's not pass-hash. - - * src/openpgp.c (cmd_verify, cmd_change_password) - (cmd_reset_user_password): Avoid authentication error - by old GnuPG which doesn't support KDF. - -2017-11-06 NIIBE Yutaka - - * tests/test_empty_card.py (test_extended_capabilities): Support - KDF-DO. - * test/features/802_get_data_static.feature: Likewise. - * test/features/402_get_data_static.feature: Likewise. - * test/features/002_get_data_static.feature: Likewise. - -2017-11-02 NIIBE Yutaka - - * src/openpgp-do.c (rw_kdf): Only writable when no keys. - (gpg_do_get_initial_pw_setting): New. - (gpg_do_write_prvkey): Use gpg_do_get_initial_pw_setting. - (gpg_do_keygen): Likewise. - (extended_capabilities): Enable KDF-DO available bit. - - * src/openpgp.c (cmd_change_password): Use - gpg_do_get_initial_pw_setting. - * src/ac.c (verify_user_0, verify_admin_0): Likewise. - -2017-11-01 NIIBE Yutaka - - * src/openpgp-do.c (GPG_DO_KDF): New. - (GPG_DO_FEATURE_MNGMNT): New. - (do_tag_to_nr): Support GPG_DO_KDF. - (GPG_DO_UIF_SIG, GPG_DO_UIF_DEC, GPG_DO_UIF_AUT): New. - (rw_kdf): New. - (gpg_do_table): Add an entry for GPG_DO_KDF. - - * src/gnuk.h (NR_DO_KDF): New. - -2017-10-31 NIIBE Yutaka - - * src/openpgp-do.c (gpg_do_keygen): Bug fix for memory alignment. - -2017-10-24 NIIBE Yutaka - - * tests/card_reader.py (CardReader.ccid_power_on): Setting - PPS only for Gemalto GemPC reader. - -2017-10-18 Aurelien Jarno - - * src/gnuk.ld.in: Fix keystore_pool size. - -2017-10-12 Aurelien Jarno - - * polarssl/include/polarssl/bn_mul.h (MULADDC_HUIT_DEAD): Rename - from MULADDC_HUIT. - [__ARM_FEATURE_DSP] (MULADDC_1024_CORE, MULADDC_1024_LOOP) - (MULADDC_INIT, MULADDC_CORE, MULADDC_HUIT, MULADDC_STOP): New. - - * polarssl/library/bignum.c (mpi_montsqr): Check on - POLARSSL_HAVE_ASM and __arm__. - [__ARM_FEATURE_DSP] (mpi_montsqr): New. - (MAX_WSIZE): New. - (mpi_exp_mod): Use MAX_WSIZE. - - * src/Makefile (DEFS): Remove BIGNUM_C_IMPLEMENTATION. - - * src/main.c (HEAP_SIZE): Rename from MEMORY_SIZE. - (HEAP_END, HEAP_ALIGNMENT, HEAP_ALIGN): Likewise. - - * src/stack-def.h (SIZE_3): Depend on MEMORY_SIZE. - * src/configure: Emit DEFS with MEMORY_SIZE. - -2017-10-11 NIIBE Yutaka - - * VERSION: 1.2.6. - - * regnual/Makefile (LDSCRIPT): Move after include. - * regnual/types.h: Add uintptr_t. - - * test/features/002_get_data_static.feature (data object AID): Fix - for any binary value. - * 402_get_data_static.feature: Likewise. - * 802_get_data_static.feature: Likewise. - -2017-10-10 NIIBE Yutaka - - * src/main.c (main): Support --debug option. - * chopstx: Update to 1.5. - -2017-10-06 NIIBE Yutaka - - * src/configure (flash_override): Fix suggested by Jeremy Drake. - (help): STM8S_DISCOVERY is supported again. - -2017-10-06 NIIBE Yutaka - - * src/gnuk.ld.in (.stacks): Specify NOLOAD type. - - * src/configure: Allow not specifying VIDPID. - - * src/main.c [GNU_LINUX_EMULATION] (main): Handle "--vidpid" - option to assign vendor ID and product ID of USB. - - * src/usb_desc.c [GNU_LINUX_EMULATION] (device_desc): Export. - - * GNUK_USB_DEVICE_ID (0000:0000): New. - -2017-10-05 NIIBE Yutaka - - * src/stack-def.h (SIZE_1, SIZE_3): Tweak the size. - - * src/call-rsa.c (rsa_genkey): Single step. - * src/openpgp-do.c (gpg_do_keygen): Do RSA key generation in single - step, using APDU buffer. - * src/openpgp.c (cmd_pgp_gakp): Supply the APDU as a buffer. - - * src/Makefile (install): New target. - - * src/configure (prefix. exec_prefix, libexecdir): Add. - - * src/main.c [GNU_LINUX_EMULATION] (main): Option handling. - - * tool/gnuk-emulation-setup: New. - - * polarssl/library/bignum.c (M_LIMBS, limbs_M, MAX_A_LIMBS) - (limbs_MAX_A, mpi_gen_prime): Fix for 64-bit machine. - -2017-10-04 NIIBE Yutaka - - * src/configure (output_vendor_product_serial_strings): Support - GNU/Linux emulation. - - * polarssl/library/bignum.c (mpi_div_mpi): Fix for 64-bit machine. - - * src/main.c (gnuk_malloc, gnuk_free): Fix for 64-bit machine. - - * src/stack-def.h (SIZE_3): Tweak the size. - - * src/openpgp-do.c (gpg_do_keygen): Do RSA key generation in two - steps. - - * src/call-rsa.c (rsa_genkey_start, rsa_genkey_finish): New. - (rsa_genkey): Remove. - -2017-10-03 NIIBE Yutaka - - * src/call-ec.c (ecc_compute_public): No use of malloc. - * src/call-rsa.c (modulus_calc, rsa_genkey): Likewise. - * src/ecc-edwards.c (eddsa_compute_public_25519): Likewise. - * src/ecc-mont.c (ecdh_compute_public_25519): Likewise. - * src/openpgp-do.c (gpg_do_write_prvkey, gpg_do_chks_prvkey) - (proc_key_import, gpg_do_keygen): Likewise. - - * polarssl/library/rsa.c: Don't include stdlib.h. - * src/gnuk-malloc.h: Rename from stdlib.h. - * polarssl/library/bignum.c: Include gnuk-malloc.h. - - * src/Makefile (build/flash.data): Generate. - - * src/main.c (flash_addr_key_storage_start) - (flash_addr_data_storage_start): New. - (main): Determine flash address. - - * src/flash.c (FLASH_ADDR_KEY_STORAGE_START) - (FLASH_ADDR_DATA_STORAGE_START): New. - (flash_do_storage_init, flash_terminate, flash_activate) - (flash_key_storage_init, flash_copying_gc, flash_do_release) - (flash_key_getpage): Use new macros. - -2017-10-02 NIIBE Yutaka - - * src/main.c (device_initialize_once): Not for GNU/Linux. - - * src/openpgp.c, src/flash.c: Distinguish FLASH_UPGRADE_SUPPORT. - - * src/main.c [GNU_LINUX_EMULATION]: Use emulated_main. - (MEMORY_SIZE, MEMORY_END): Fix for GNU/Linux. - - * src/usb-ccid.c (INTR_REQ_USB): Fix for GNU/Linux. - - * polarssl/library/bignum.c (mpi_montsqr): Easy C implementation. - -2017-09-30 NIIBE Yutaka - - * src/flash.c (flash_terminate, flash_activate) - (flash_copying_gc, flash_do_write_internal, flash_do_release) - (flash_key_write, flash_check_all_other_keys_released) - (flash_key_fill_zero_as_released, flash_key_release) - (flash_key_release_page, flash_clear_halfword) - (flash_put_data_internal, flash_put_data, flash_bool_clear) - (flash_bool_write_internal, flash_bool_write) - (flash_enum_write_internal, flash_enum_write) - (flash_cnt123_write_internal, flash_cnt123_increment) - (flash_cnt123_clear, flash_erase_binary, flash_write_binary): Fix - for GNU/Linux. - - * src/usb-ccid.c (ccid_tx_done): Rename from EP1_IN_Callback. - (ccid_rx_ready): Rename from EP1_OUT_Callback. - -2017-09-29 NIIBE Yutaka - - * src/usb-ccid.c (epo_init, epi_init, ccid_thread): Simplify. - (EP1_IN_Callback, ccid_prepare_receive, EP1_OUT_Callback) - (usb_rx_ready, ccid_error, ccid_power_on, ccid_send_status) - (ccid_send_data_block_internal, ccid_send_data_block_0x9000) - (ccid_send_data_block_gr, ccid_send_params) - (ccid_notify_slot_change, _write) [GNU_LINUX_EMULATION]: Use - different usb driver API. - - * src/usb_ctrl.c (usb_device_reset): Fix control endpoint init. - (gnuk_setup_endpoints_for_interface): Add DEV - argument. - (usb_device_reset) [GNU_LINUX_EMULATION]: Use usb_lld_setup_endp. - -2017-09-29 NIIBE Yutaka - - * src/main.c [FLASH_UPGRADE_SUPPORT] (main): Factor out flash ROM - upgrade support. - (calculate_regnual_entry_address): Likewise. - * src/usb_ctrl.c (usb_setup, download_check_crc32): Likewise. - - * src/openpgp.c (modify_binary): Fix for 64-bit machine. - * src/openpgp-do.c (encrypt, decrypt): Likewise. - (gpg_data_scan): Likewise. - (gpg_do_chks_prvkey): Fix error return path. - - * src/stack-def.h: New. - - * src/gnuk.ld.in: Remove stack definitions. - * src/configure: Remove stack size modifications. - - * src/main.c (STACK_MAIN, STACK_PROCESS_1): Use stack-def.h. - * src/usb-ccid.c (STACK_PROCESS_3): Likewise. - * src/usb-msc.c (STACK_PROCESS_5): Likewise. - * src/pin-cir.c (STACK_PROCESS_6, STACK_PROCESS_7): Likewise. - - * src/usb_ctrl.c (download_check_crc32): Use chrc32_rv_ functions. - - * src/mcu-stm32f103.c (rbit, check_crc32): Remove. - - * src/neug.c: Update from NeuG. - * src/neug.h: Ditto. - -2017-09-28 NIIBE Yutaka - - * src/ec_p256k1.c (coefficient_a): Remove. - - * polarssl/library/bignum.c (mpi_fill_pseudo_random): Fix for - 64-bit machine. - - * src/call-rsa.c (rsa_decrypt): Fix for 64-bit machine. - - * src/flash.c (flash_do_storage_init): Rename from flash_init. - (flash_key_storage_init): Rename from flash_init_keys. - * src/openpgp.c (gpg_init): Use new function names. - - * src/stdlib.h: Update for GNU/Linux emulation. - - * src/Makefile: Support GNU/Linux emulation. - * src/configure: Support GNU/Linux emulation. - * emulation: Remove. - -2017-08-11 NIIBE Yutaka - - * VERSION: 1.2.5. - * chopstx: Update to 1.4. - - * src/gnuk.ld.in (__process3_stack_size__): Tweak the size. - - * src/configure: Define STM32F103_OVERRIDE_FLASH_SIZE_KB for - BULE_PILL. - - * src/configure: Let generate src/config.mk. - * src/Makefile: Rename from src/Makefile.in. - * regnual/Makefile: Use src/config.mk. - -2017-08-03 NIIBE Yutaka - - * src/openpgp.c (cmd_terminate_df): Fix for admin-less mode. - -2017-08-03 Jeremy Drake - - * regnual/regnual.c (main): Allow compile time - flash size definition by STM32F103_OVERRIDE_FLASH_SIZE_KB. - -2017-08-02 Jeremy Drake - - * src/flash.c (flash_terminate): Erase Certificate DO, too. - -2017-08-01 NIIBE Yutaka - - * src/openpgp.c (FILE_CARD_TERMINATED_OPENPGP): Remove. - (cmd_select_file): Don't change file_selection. - -2017-07-19 NIIBE Yutaka - - * src/mod.c (mod_inv): Clear TMP. - - * src/configure (REVISION): Generate even when no git. - - * polarssl/library/bignum.c (mpi_exp_mod): Call mpi_grow for X - after the initialization of RR. - -2017-07-18 NIIBE Yutaka - - * src/configure: Bark when no git available. - -2017-07-18 Anthony Romano - - * docker: New. - -2017-07-18 Anthony Romano - - * src/main.c (MEMORY_SIZE, MEM_HEAD_IS_CORRUPT, MEM_HEAD_CHECK): - New. - (gnuk_malloc, gnuk_free): Add calls to MEM_HEAD_CHECK. - - * src/gnuk.h (FATAL_HEAP): New. - -2017-07-18 Anthony Romano - - * src/openpgp-do.c (gpg_reset_algo_attr): New. - (rw_algorithm_attr): Use gpg_reset_algo_attr. - Fix null dereference. - -2017-07-18 Anthony Romano - - * src/mod.c (mod_reduce): Clean up unused code. - -2017-07-18 Anthony Romano - - * src/call-rsa.c (modulus_calc): Free modulus on error. - (rsa_genkey): Remove bogus check, and call chopstx_cleanup_pop - with 1 to release p_q_modulus on error. Assign NULL to clp.arg - when it's goes with no error. - - * src/main.c (gnuk_free): Allow NULL. - -2017-07-18 NIIBE Yutaka - - * Update chopstx (with USBIP emulation). - -2017-05-12 NIIBE Yutaka - - * VERSION: 1.2.4. - -2017-04-28 NIIBE Yutaka - - * src/mcu-stm32f103.c: New. - (check_crc32, sram_address): New. - - * src/usb_ctrl.c (download_check_crc32): Use check_crc32 and - sram_address. - - * src/openpgp-do.c (gpg_write_digital_signature_counter): Fix - writing lower 10-bit. - -2017-04-27 NIIBE Yutaka - - * src/gnuk.ld.in (_data_pool): Move to the end. - - * src/flash.c (flash_init): Return address of end of data object. - * src/openpgp.c (gpg_init): Get address of end of data object. - * src/openpgp-do.c (gpg_data_scan): Check the end address. - -2017-02-02 NIIBE Yutaka - - * VERSION: 1.2.3. - - * src/gnuk.ld.in (__process1_stack_size__): Increase by 0x20. - * chopstx: Update to 1.3. - * src/configure: Add BLUE_PILL in the help message. - -2017-02-01 NIIBE Yutaka - - * README: Update README. Thanks to Paul Fertser. - -2017-01-02 Szczepan Zalega - - * tool/upgrade_by_passwd.py: Add file extention check. - -2017-02-01 NIIBE Yutaka - - * tool/upgrade_by_passwd.py (main): More verbose messages - suggested by Szczepan Zalega . - - * tool/gnuk_token.py (USB_PRODUCT_LIST): New. - (gnuk_devices_by_vidpid): Support searching by USB_PRODUCT_LIST. - Thanks to Szczepan Zalega . - - * tool/usb_strings.py: Use gnuk_token.py. - -2016-10-21 Niibe Yutaka - - * src/ecc.c (check_secret): Fix condition. - -2016-10-15 NIIBE Yutaka - - * VERSION: 1.2.2. - - * tool/gnuk_put_binary_libusb.py (main): Likewise. - * tool/upgrade_by_passwd.py (main): Add call of cmd_select_openpgp - method. - - * src/openpgp.c (gpg_init): flash_init_keys shoule be after - gpg_data_scan since flash_init_keys accesses Data Object for - key attributes. - - * src/usb-ccid.c (ccid_power_on): Don't waste stack. - -2016-10-14 Niibe Yutaka - - * src/usb-ccid.c (ccid_power_on) [LIFE_CYCLE_MANAGEMENT_SUPPORT]: - Change LCS value in ATR at run time. - - * src/openpgp.c (gpg_init): Handle FILE_CARD_TERMINATED. - (cmd_select_file): Don't return AID. - (cmd_activate_file, cmd_terminate_df): New. - (process_command_apdu): Let return GPG_NO_RECORD() when - not selected. - - * src/openpgp-do.c (gpg_do_terminate): New. - (gpg_data_scan): Handle p_start is NULL. - (do_hist_bytes): Remove. - - * src/flash.c (flash_data): Change the value from 0x0000. - (flash_init): Support termination state. Fix handling - of the boundary case where gen0 is 0xfffe. - (flash_terminate, flash_activate): New. - (flash_copying_gc): Skip 0xffff for generation number. - -2016-10-13 Niibe Yutaka - - * src/status-code.h: Rename from openpgp.h. - - * chopstx: Update to 1.2. - - * tests: New test suite for OpenPGP card with PyTest. - - * src/configure (factory_reset): New. - - * src/usb-ccid.c (ccid_power_on): Use ATR_head and historical - bytes. - - * src/openpgp-do.c (rw_algorithm_attr): Clear fingerprint, timestamp, - and possibly ds_counter. - -2016-10-12 Niibe Yutaka - - * test/features/steps.py (cmd_reset_retry_counter): Fix. - * tool/gnuk_token.py (gnuk_token.cmd_reset_retry_counter): Fix. - (gnuk_token.cmd_select_openpgp): Fix P2. - -2016-09-02 Niibe Yutaka - - * src/configure (REVISION): Fix the detection of .git. - It may be a regular file (if it's created by worktree). - -2016-08-24 Niibe Yutaka - - * test/features/steps.py (ini): Use GLC (the global context), - instead of FTC (the feature context), so that token only is - opened once. - -2016-08-03 Niibe Yutaka - - * tool/hub_ctrl.py: Port to Python 3. - -2016-07-11 NIIBE Yutaka - - * VERSION: 1.2.1. - - * src/usb-ccid.c (ccid_power_on): Fix call of chopstx_create. - * src/usb-msc.c (msc_init): Ditto. - * src/pin-cir.c (cir_init): Ditto. - * src/neug.c (neug_init): Ditto. - * src/main.c (main): Ditto. - - * src/usb-ccid.c (struct ccid): Arrange for smaller footprint. - * src/gnuk.h (struct apdu): Likewise. - - * src/usb-ccid.c (ccid_card_change_signal): Don't touch ccid_state_p. - (ccid_state_p): This is constant. - - * src/configure (output_vendor_product_serial_strings): Add const - qualifier. - - * src/usb-ccid.c (epo_init, epi_init): Simplify without notify method. - (EP1_IN_Callback, EP1_OUT_Callback): Call notify_tx and notify_icc - directly. - -2016-07-09 NIIBE Yutaka - - * src/openpgp.c (openpgp_card_thread): Don't need to get SELF. - -2016-07-06 NIIBE Yutaka - - * src/pin-cir.c (cir_getchar): Use chopstx_poll. - * src/usb-ccid.c (usb_tx_done): Fix ifdef condition. - * src/usb_ctrl.c (usb_ctrl_write_finish): Fix ifdef nesting. - -2016-07-04 NIIBE Yutaka - - * doc/conf.py: Remove 'sphinx.ext.pngmath' and 'sphinx.ext.mathjax'. - Reported by Kenji Rikitake. - -2016-07-01 NIIBE Yutaka - - * chopstx: Update to 1.1. - * src/usb-ccid.c (poll_event_intr, ccid_thread): Follow the - change. - -2016-06-21 Niibe Yutaka - - * doc/index.rst: Update documentation by an example - Ed25519/cv25519. - -2016-06-17 Niibe Yutaka - - * chopstx: Update to 1.0. - -2016-06-15 NIIBE Yutaka - - * src/gnuk.ld.in (__process2_stack_size__): Update - thread size for rng by examining NeuG. - - * src/usb-ccid.c (poll_event_intr): New. - -2016-06-14 Niibe Yutaka - - * regnual/regnual.c (usb_device_reset): Rename from - usb_cb_device_reset. - (usb_ctrl_write_finish): Rename from usb_cb_ctrl_write_finish. - (usb_setup): Rename from usb_cb_setup. - (usb_get_descriptor): Rename from usb_cb_get_descriptor. - (usb_set_configuration): New. - (usb_interrupt_handler): New. - - * src/usb-ccid.c (usb_tx_done): Rename from usb_cb_tx_done. - (usb_rx_ready): Rename from usb_cb_rx_ready. - (usb_event_handle): New. - (ccid_thread): Use usb_event_handle. - - * src/usb-msc.c (EP6_IN_Callback): Update to new USB API. - (EP6_OUT_Callback): Likewise. - - * src/usb_ctrl.c (usb_device_reset): Rename from - usb_cb_device_reset. - (vcom_port_data_setup): Update to new USB API. - (usb_ctrl_write_finish): Rename from usb_cb_ctrl_write_finish. - (usb_setup): Rename from usb_cb_setup. - (usb_set_configuration): New, based on usb_cb_handle_event. - (usb_set_interface): Rename from usb_cb_interface. - (usb_get_interface): New. - (usb_get_status_interface): New. - - * src/usb_desc.c (usb_get_descriptor): Rename from - usb_cb_get_descriptor. - -2016-06-02 Niibe Yutaka - - * regnual/regnual.c (usb_cb_tx_done): Follow the change of USB - API. - - * regnual/reset.c: Rename from sys.c. - -2016-06-01 Niibe Yutaka - - * tool/stlinkv2.py (stlinkv2.__init__): Don't - call setConfiguration. - - * tool/gnuk_token.py (gnuk_token, regnual): Don't - call setAltInterface, it's not needed. - - * src/usb-ccid.c (ccid_notify_slot_change): New. - (ccid_thread): Call ccid_notify_slot_change at - interface_reset and EV_CARD_CHANGE. - -2016-05-31 NIIBE Yutaka - - * src/usb_stm32f103.c, src/stm32f103.h: Remove. - * src/adc_stm32f103.c, src/sys.c: Remove. - - * src/usb_ctrl.c (usb_cb_interface): call ccid_usb_reset. - (usb_cb_handle_event): Likewise. - - * src/usb-ccid.c (ccid_thread): Handle RESET->CONFIGURE process - correctly. - (ccid_thread): Handle SET_INTERFACE correctly. - - * polarssl/library/aes.c (FT0, FT1, FT2): Add "weak" flag. - - * src/neug.c: Update from NeuG. - - * src/usb_desc.c (usb_cb_get_descriptor): Only valid if USE_SYS3. - - * src/Makefile.in (USE_SYS, USE_USB, USE_ADC): Enabled. - (CHIP): Add. - - * src/sys.c, src/sys.h: Remove. - * src/usb_stm32f103.c, src/usb_lld.h: Remove. - * src/adc_stm32f103.c, src/adc.h: Remove. - - * chopstx: Update to 0.12. - -2016-05-21 Niibe Yutaka - - * src/main.c (led_blink, main): Fix LED blink protocol. - -2016-05-20 NIIBE Yutaka - - * VERSION: 1.2.0. - * src/usb-ccid.c (ccid_thread): Fix timeout. - (icc_handle_timeout, icc_send_status): Tweak. - -2016-05-19 Niibe Yutaka - - * src/usb_ctrl.c (usb_cb_ctrl_write_finish): Set bDeviceState. - - * src/usb-ccid.c: Rename from usb-icc.c. - (ccid_thread): Handle reGNUal upgrade. - - * src/Makefile.in (CSRC): Follow the change. - - * chopstx: Update to 0.11. - -2016-05-18 Niibe Yutaka - - * src/gnuk.ld.in: Tweak thread size. - * src/main.c (main): Use chopstx_setpriority. - * src/usb-icc.c (ccid_init): Use new eventflag API. - - * regnual/regnual.c (nvic_enable_intr): New. - (main): Call nvic_enable_intr. - - * chopstx: Update. - -2016-05-16 Niibe Yutaka - - * regnual/regnual.c (usb_cb_rx_ready, usb_cb_tx_done) - (usb_cb_device_reset): Follow the change of USB API. - - * chopstx: Update. - * src/sys.c: Update from Chopstx. - -2016-05-13 Niibe Yutaka - - * src/neug.c (rng): Call chopstx_claim_irq before adc_start. - Remove call of chopstx_release_irq. - -2016-05-12 Niibe Yutaka - - * chopstx: Update. - * src/sys.c: Update from Chopstx. - * src/usb_lld.h: Likewise. - * src/usb_stm32f103.c: Likewise. - - * src/usb_ctrl.c (usb_intr): Follow the change of USB API. - (usb_cb_rx_ready, usb_cb_tx_done): Likewise. - - * src/adc.h: Remove unused declarations. - -2016-03-08 Niibe Yutaka - - * tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__): - Don't call setConfiguration method. - - * src/usb_lld.h (usb_cb_ctrl_write_finish): Change the API of - callback, which possibly needs INDEX, VALUE, and LEN parameters. - (usb_lld_set_data_to_recv): Fix the type of P. - (USB_DEVICE_DESCRIPTOR_TYPE, USB_CONFIGURATION_DESCRIPTOR_TYPE) - (USB_STRING_DESCRIPTOR_TYPE, USB_INTERFACE_DESCRIPTOR_TYPE) - (USB_ENDPOINT_DESCRIPTOR_TYPE): Remove, as we have the enumeration - values for same things. - - * src/usb_stm32f103.c (handle_in0): Follow the change. - * src/usb_ctrl.c (usb_cb_ctrl_write_finish): Likewise. - - * src/usb_desc.c (usb_cb_get_descriptor): Use HID_INTERFACE. - (device_desc, config_desc, string_descriptors) - (usb_cb_get_descriptor): Use the enumeration types. - * src/configure: Use the enumeration types. - - * regnual/regnual.c: Follow the change of usb_lld.h. - -2016-02-09 Niibe Yutaka - - * src/openpgp.c (cmd_verify): Support VERIFY reset, which is - described in the specification V2.2 and V3.1. - - * polarssl/library/bignum.c (mpi_exp_mod): Fix to our local - change. Thanks to Aidan Thornton for the failure test case. - - Fix of mpi_div_mpi from upstream. - * polarssl/library/bignum.c (int_clz, int_div_int): New. - (mpi_div_mpi): Use int_div_int. - -2016-02-09 Niibe Yutaka - - * src/openpgp.c (s2k): Include the unique ID of MCU into the - computation of S2K function. - -2016-02-08 Niibe Yutaka - - * src/modp256r1.c (modp256r1_add, modp256r1_sub): Keep the result - less than P256R1. - (modp256r1_reduce): Fix wrong calculation. - * src/modp256k1.c (modp256k1_add, modp256k1_sub): Likewise. - Thanks to Aidan Thornton. - -2016-02-05 Niibe Yutaka - - * src/configure: Add submodule check suggested by Elliott - Mitchell. - -2015-11-30 perillamint - - * src/openpgp.c (card_thread): Fix offset of bConfirmPIN. - -2015-09-18 Niibe Yutaka - - * VERSION: 1.1.9. - - * src/openpgp-do.c (proc_key_import): Fix error return. - (rw_algorithm_attr): Check it's not ALGO_RSA2K. - -2015-09-17 Niibe Yutaka - - * VERSION: 1.1.8. - -2015-09-15 Niibe Yutaka - - * chopstx: Update to 0.10. - - * src/main.c (main): Don't join after calling ccid_usb_reset. - * src/usb-icc.c (ccid_thread): Don't finish on reset, but - keep running. - - * src/usb_ctrl.c (usb_cb_device_reset): Stop the interface. - - * src/usb_stm32f103.c (std_set_interface): Bug fix for conf. - - * src/gnuk.ld.in (__process3_stack_size__): Increase stack size of - GPG thread. - (__process2_stack_size__): Increase stack size of RNG. - (__process4_stack_size__): Increase stack size of USB. - (__main_stack_size__): Decrease stack size of exception handlers. - (__process1_stack_size__): Decrease stack size of CCID. - -2015-09-14 Niibe Yutaka - - * src/gnuk.h (LED_GNUK_EXEC): New. - * src/main.c, src/usb-icc.c, src/usb_ctrl.c: icc_state_p access - clean up. - -2015-09-11 Niibe Yutaka - - * tool/upgrade_by_passwd.py (main): Loop until finding reGNUal - device. - -2015-09-10 Niibe Yutaka - - * src/call-rsa.c (rsa_cleanup): New. - (rsa_sign, rsa_decrypt, rsa_genkey): Allow cancellation. - * src/openpgp.c (cmd_pso, cmd_internal_authenticate): Cancellation - is handled by each functions in case of RSA. - -2015-09-09 Niibe Yutaka - - * src/sys.h: Update from Chopstx. - * src/adc_stm32f103.c: Update from NeuG. - - * src/openpgp.c (process_command_apdu): Protect command execution - against cancelling the execution thread. - (cmd_pso, cmd_internal_authenticate): Allow cancellation. - - * src/main.c (main): Handle LED_USB_RESET. - - * src/usb-icc.c (ccid_usb_reset): New. - (ccid_thread): Upon receival of EV_USB_RESET, finish - the thread, canceling the card thread. - -2015-09-08 Niibe Yutaka - - * src/gnuk.h (EV_USB_RESET, LED_USB_RESET): New. - - * src/usb_ctrl.c (CDC_CTRL_DTR): New. - (vcom_port_data_setup): Distinguish detail->value for DTR. - - * src/configure (help): Add ST_DONGLE and ST_NUCLEO_F103. - -2015-09-04 Niibe Yutaka - - * src/openpgp-do.c (do_openpgpcard_aid): Use upper bytes of unique - ID of MCU; same as USB serial number. - - * src/configure (help): Add NITROKEY_START. - -2015-08-26 Mateusz Zalega - - * GNUK_USB_DEVICE_ID: Add Nitrokey Start. - -2015-08-05 Niibe Yutaka - - * VERSION: 1.1.7. - -2015-08-04 Niibe Yutaka - - * src/adc_stm32f103.c: Update from NeuG 1.0.3. - - * chopstx: Update to 0.08. - * src/sys.h: Update. - -2015-08-03 Niibe Yutaka - - * test/features/steps.py (set_msg): Python3 fix. - * test/generate_keys.py: Likewise. - * test/rsa_keys.py: Likewise. - - * tool/gnuk_token.py (gnuk_token.download, gnuk_token.execute) - (regnual.download): Python3 fix. - (list_to_string): Remove. - - * tool/upgrade_by_passwd.py (maian): Python3 fix. - * tool/usb_strings.py (main): Python3 fix. - -2015-07-31 Niibe Yutaka - - * src/configure (output_vendor_product_serial_strings): Fix sed - script when string is short. Remove empty line. - - * regnual/regnual.c (usb_cb_ctrl_write_finish, usb_cb_setup) - (usb_cb_get_descriptor, usb_cb_interface): Follow the change - of USB API. - - * tool/stlinkv2.py: Support ST-Link/V2-1. - -2015-07-28 Niibe Yutaka - - * tool/stlinkv2.py: Fix for Python3. Thanks to Bertrand Jacquin. - - * tool/gpg_agent.py: Fix for Python3. - - * src/usb-msc.c: Update from Fraucheky. - - * src/usb_stm32f103.c (struct DATA_INFO): Remove offset. - (struct DEVICE_INFO): Integrate CONTROL_INFO. - -2015-07-27 Niibe Yutaka - - * src/usb_stm32f103.c (usb_lld_reply_request): New. - (usb_lld_set_data_to_send): Remove. - (usb_lld_set_data_to_recv): Not a macro but a function. - (std_get_status): Don't use statically allocated memory. - (std_get_configuration): Use usb_lld_reply_request. - (handle_setup0): Follow the change. - * src/usb_ctrl.c (vcom_port_data_setup, usb_cb_setup) - (usb_cb_interface): Use usb_lld_reply_request. - * src/usb_desc.c (usb_cb_get_descriptor): Likewise. - -2015-07-24 Niibe Yutaka - - * tool/gnuk_put_binary.py: Remove. - * tool/gnuk_remove_keys.py: Remove. - -2015-07-23 Niibe Yutaka - - * src/configure (nl): New. Follow the change of NeuG. - -2015-07-21 Niibe Yutaka - - * VERSION: 1.1.6. - -2015-07-20 Niibe Yutaka - - * src/openpgp-do.c (gpg_do_keygen): Support ECC. - * src/call-ec.c (ecc_check_secret): New. - * src/ecc.c (check_secret): New. - -2015-07-18 Niibe Yutaka - - * src/configure (keygen): It's always enabled. - * src/openpgp-do.c (gpg_do_keygen): Support key generation. - * src/openpgp.c (cmd_pgp_gakp): Likewise. - * src/call-rsa.c (rsa_genkey): Likewise. - * src/random.c (random_gen): Likewise. - * src/Makefile.in (KEYGEN_SUPPORT): Remove. - * polarssl/include/polarssl/config.h (POLARSSL_GENPRIME): Define. - -2015-07-16 Niibe Yutaka - - * src/configure (FLASH_PAGE_SIZE, FLASH_SIZE, MEMORY_SIZE) - [sys1_compat]: Use safe values for common binary. - (TARGET_DEFINE): Remove. - -2015-07-15 Niibe Yutaka - - * tool/usb_strings.py (field): Add 'Board'. - - * regnual/regnual.c (usb_cb_get_descriptor): Update. - * src/usb_ctrl.c (usb_cb_interface): Call usb_lld_write. - * src/usb_desc.c (usb_cb_get_descriptor): Support sys_board_name, - using usb_lld_write. - * src/usb_lld.h (usb_cb_get_descriptor): Add last argument length - for asked length. - * src/usb_stm32f103.c (handle_setup0): Allow setup callback to - call usb_lld_write with ENDP0. - * src/usb_conf.h (NUM_STRING_DESC): Remove. - - * src/configure [!sys1_compat] (CONFIG): Don't include target - board name. - - * src/flash.c: Detect flash_page_size at runtime. - - * src/main.c: Remove dependency to board.h. - - * src/neug.c: Update from NeuG 1.0.2. - * src/adc_stm32f103.c: Update. - - * chopstx: Update to 0.07. - * src/sys.c: Update. - * src/sys.h: Update. - * src/gnuk.ld.in: Update. - - * tool/stlinkv2.py (stlinkv2.get_chip_id): New. Detect flash - size, too. - (main): Call stlinkv2.get_chip_id after MCU reset and stop. - Verify read out fix. - -2015-07-11 Niibe Yutaka - - * src/configure (help): Add STM32_PRIMER2 and CQ_STARM. - - * chopstx: Update to 0.06. - - * tool/stlinkv2.py: Support 512kB version of STM32F103. - The size of executable file should be even. - -2015-07-07 Niibe Yutaka - - * src/Makefile.in (CSRC): Add ecc-mont.c. - - * src/ecc-mont.c (mod25638_mul_121665): Fix. - (ecdh_compute_public_25519, ecdh_decrypt_curve25519): New. - - * src/openpgp.c (cmd_pso): Support ALGO_CURVE25519. - - * src/openpgp-do.c (algorithm_attr_cv25519): New. - (rw_algorithm_attr, get_algo_attr_data_object) - (gpg_get_algo_attr_key_size, gpg_do_write_prvkey) - (proc_key_import, gpg_do_public_key): Support ALGO_CURVE25519. - - * src/gnuk.h (ALGO_CURVE25519): New. - -2015-07-06 Niibe Yutaka - - Enhancement for FSM-55. - * tool/stlinkv2.py (stlinkv2.control_nrst): New. - (stlinkv2.get_rdp_key,has_spi_flash,has_protection): New. - (stlinkv2.get_core_id): Rename. - (stlinkv2.blank_check): Use self.flash_size. - (stlinkv2.start): Call control_nrst. Call get_core_id. - Distinguishing chip, and set rdp_key, flash_size and require_nrst. - (stlinkv2.flash_write): Use self.flash_block_size. - (main): Call control_nrst. - (prog_flash_write_body, prog_option_bytes_write_body) - (prog_blank_check_body): Support Cortex-M0. - (main): Call API V2 halt twice. - * tool/asm-thumb/*.S: Updated for Cortex-M0. - -2015-06-30 Niibe Yutaka - - * src/sys.c: Update from chopstx/example-cdc/sys.c. - - * src/main.c (device_initialize_once): Apply change of NeuG. - -2015-06-03 Niibe Yutaka - - * VERSION: 1.1.5. - - * test/ecc_nistp256_keys.py: New. - - * tool/upgrade_by_passwd.py: Remove -p option and add -f option. - - * tool/gnuk_token.py (gnuk_token.download): Add verbose flag. - (regnual.download): Ditto. - - * tool/gnuk_upgrade.py: Use gnuk_token module. - -2015-06-02 Niibe Yutaka - - * src/openpgp.c (cmd_pso): Support OpenPGPcard spec v3.0. - -2015-04-20 Niibe Yutaka - - * chopstx: Upgrade to 0.05. - -2015-04-19 Niibe Yutaka - - * src/gnuk.h (CCID_CARD_INIT): New. - * src/usb_desc.c (gnukConfigDescriptor): Update dwDefaultClock, - dwMaximumClock, dwFeatures, and bClassEnvelope. - * src/usb_ctrl.c (freq_table): Change the value to 4000MHz. - (usb_cb_handle_event): Call ccid_card_change_signal after configure. - * src/usb-icc.c (ccid_thread): Change EV_CARD_CHANGE handling. - -2015-04-18 Niibe Yutaka - - * src/main.c (main): Call chopstx_main_init. - * src/Makefile.in (DEFS): Remove CHX_PRIO_MAIN. - -2015-04-17 Niibe Yutaka - - * src/configure: Fix shell syntax. - -2015-03-31 Niibe Yutaka - - * src/usb_conf.h (ICC_NUM_INTERFACES, HID_NUM_INTERFACES) - (HID_NUM_INTERFACES, VCOM_NUM_INTERFACES, MSC_NUM_INTERFACES) - (NUM_INTERFACES): Define here (moved from usb_desc.c). - (ICC_INTERFACE, HID_INTERFACE, VCOM_INTERFACE_0, VCOM_INTERFACE_1) - (MSC_INTERFACE): New. - * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface) - (usb_cb_setup, usb_cb_ctrl_write_finish): Use *_INTERFACE. - * src/usb_desc.c (gnukConfigDescriptor): Likewise. - -2015-03-06 Niibe Yutaka - - * src/ecc-edwards.c (eddsa_sign_25519): Return 0. - -2015-02-25 Niibe Yutaka - - * src/openpgp.c (cmd_internal_authenticate): Fix storing to - res_APDU_size. - -2015-02-10 Niibe Yutaka - - * src/openpgp.c (cmd_pso): Fix counter update for EdDSA. Thanks - to Jonathan Schleifer. - - * src/call-rsa.c (rsa_sign): Don't set res_APDU_len. - (rsa_decrypt): Likewise, but get OUTPUT_LEN_P as an argument. - -2015-02-09 Niibe Yutaka - - * src/openpgp.c (cmd_pso): Fix EdDSA. Use GPG_KEY_FOR_SIGNING. - -2014-12-15 Niibe Yutaka - - * VERSION: 1.1.4. - -2014-12-13 Niibe Yutaka - - * src/flash.c (flash_key_getpage, flash_key_release_page): New. - - * src/openpgp-do.c (gpg_do_delete_prvkey): New arg. - (rw_algorithm_attr): Call gpg_do_delete_prvkey with CLEAN_PAGE_FULL. - -2014-12-12 Niibe Yutaka - - * src/Makefile.in (build/bignum.o): Specific OPT for this target. - - * src/configure (target): Default is FST-01. - (--with-dfu): FST-01 doesn't have DFU. If set, it must be - mistake. - - * boards/STBEE_MINI: Remove, since it is now supported by Chopstx. - - * test/features/802_get_data_static.feature: Reflect the change - of extended capabilities. - * test/features/402_get_data_static.feature: Ditto. - * test/features/002_get_data_static.feature: Ditto. - - * test/features/003_keyattr_change.feature: New test. - - * src/usb_lld.h: Don't use 'extern' for function declarations. - * src/usb-icc.c (end_cmd_apdu_data): Fix Le handling. - -2014-12-11 Niibe Yutaka - - * chopstx: Upgrade to 0.04. - * src/syc.c: Update from 0.04. - -2014-12-10 Niibe Yutaka - - * src/ecc-cdh.c: Remove as smartcard only does - a part of ECDH computation as gpg-agent does. - - * src/chconf.h, src/halconf.h: Remove files needed for ChibiOS/RT. - -2014-12-09 Niibe Yutaka - - * src/call-ec.c (ecc_compute_public): Rename, as we share - same routine among ECDSA and ECDH. - (ecdh_decrypt): New. - -2014-12-09 Niibe Yutaka - - * src/ecc.c (compute_kP): Bug fix. It's P, not G. - (point_is_on_the_curve): Bug fix. - -2014-12-03 Niibe Yutaka - - Changes for RSA-4096. - - * src/gnuk.h (MAX_CMD_APDU_DATA_SIZE, MAX_RES_APDU_DATA_SIZE): - Send/Recv buffer should be bigger. - * polarssl/library/bignum.c (mpi_exp_mod): Don't consume much. - * polarssl/library/rsa.c (rsa_rsaes_pkcs1_v15_decrypt): buffer - allocation size should be variable. - -2014-12-01 Niibe Yutaka - - * src/Makefile.in (DEFS): Don't define compile time preference of - key algo attributes. - - * src/openpgp-do.c (proc_key_import): Support modifiable key algo - attributes. - -2014-11-21 Niibe Yutaka - - * src/gnuk.h (ALGO_RSA4K, ALGO_NISTP256R1, ALGO_SECP256K1) - (ALGO_ED25519, ALGO_RSA2K): New. - (struct key_data_internal): Move to ... - * src/openpgp-do.c (struct key_data_internal): ... here. - (CHECKSUM_ADDR, kdi_len): New. - (CKDC_CALC, CKDC_CHECK): New. - (compute_key_data_checksum): Add arg PRVKEY_LEN. - (gpg_do_load_prvkey, gpg_do_delete_prvkey): Support modifiable key - algo attributes. - (gpg_do_write_prvkey, gpg_do_public_key, gpg_do_keygen): Likewise. - (gpg_do_clear_prvkey): Use MAX_PRVKEY_LEN. - - * src/openpgp.c (gpg_init): Call flash_init_keys after - gpg_data_scan. - (cmd_pso): Support modifiable key algo attributes. - (cmd_internal_authenticate): Likewise. - -2014-11-21 Niibe Yutaka - - * src/openpgp-do.c (algorithm_attr_rsa2k): Rename from *_rsa. - (algorithm_attr_rsa4k): New. - (get_algo_attr_pointer, kk_to_nr, gpg_get_algo_attr) - (get_algo_attr_data_object, gpg_get_algo_attr_key_size): New. - (rw_algorithm_attr): New. - (gpg_do_table): Register rw_algorithm_attr for GPG_DO_ALG_*. - (gpg_data_scan, gpg_data_copy): Handle algo attributes. - - (rw_pw_status): Fix checking against redundant write. - -2014-11-20 Niibe Yutaka - - * src/openpgp-do.c (extended_capabilities): Key attributes can be - modifid now. - -2014-11-20 Niibe Yutaka - - * src/gnuk.h (NR_NONE, NR_DO__FIRST__): Remove. - (NR_DO_*): Redefine. - (NR_KEY_ALGO_ATTR_SIG, NR_KEY_ALGO_ATTR_DEC) - (NR_KEY_ALGO_ATTR_AUT): New. - - * src/openpgp-do.c (gpg_do_load_prvkey, gpg_do_delete_prvkey) - (gpg_do_write_prvkey, gpg_do_chks_prvkey, gpg_data_scan) - (gpg_data_copy, gpg_do_read_simple) - (gpg_do_write_simple): Don't use NR_DO__FIRST__. - (gpg_do_put_data): Don't use NR_NONE any more. - (do_tag_to_nr): Use -1 to specify NONE. - - * src/flash.c (flash_enum_clear, flash_enum_write_internal) - (flash_enum_write): New. - -2014-11-19 Niibe Yutaka - - * src/gnuk.h (FIRMWARE_UPDATE_KEY_CONTENT_LEN): New. - (size_of_key): New enum. - - * src/openpgp.c (gpg_get_firmware_update_key) - (cmd_read_binary, cmd_external_authenticate): Use - FIRMWARE_UPDATE_KEY_CONTENT_LEN. - - * src/flash.c (KEY_SIZE): Remove. - (key_available_at): Add new arg as KEY_SIZE. - (flash_check_all_other_keys_released): Likewise. - (flash_key_fill_zero_as_released, flash_key_release): Likewise. - - (flash_init): Move initializing keys into another function. - (flash_init_keys): New function. - - (flash_key_alloc): Use gpg_get_algo_attr_key_size. - (flash_key_write): Add new arg as KEY_DATA_LEN. - - (flash_write_binary): Use FIRMWARE_UPDATE_KEY_CONTENT_LEN. - -2014-09-16 Niibe Yutaka - - * src/gnuk.h (MAX_PRVKEY_LEN): New. - (KEY_CONTENT_LEN): Remove. - - * src/call-rsa.c (RSA_SIGNATURE_LENGTH): Remove. - (rsa_sign, rsa_verify, rsa_genkey): Add new arg: PUBKEY_LEN. - (rsa_decrypt): Don't use KEY_CONTENT_LEN. - -2014-06-19 Niibe Yutaka - - * src/ecc-mont.c (compute_nQ): Add comment. - - * src/mod.c (mod_inv): Fix comment. X^-1 = 0 when X=0 - is important for Montgomery curve computation. - -2014-06-05 Niibe Yutaka - - * tool/add_openpgp_authkey_from_gpgssh.py: New. - -2014-04-17 Niibe Yutaka - - * src/muladd_256.h (MULADD_256_ASM): New. - (MULADD_256): Use MULADD_256_ASM. - * src/ecc-mont.c (mod25638_mul_121665): Add asm implementation. - - * src/bn.c (bn256_add_uint, bn256_sub_uint): Simplify. - * src/mod25638.c (mod25638_add, mod25638_sub): Simplify. - (n25638, add19): Remove. - (ADDWORD_256): Add s_ as source pointer. - (mod25519_reduce): Remove a call to memcpy. Use bn256_add_uint. - * src/ecc-edwards.c (point_double): Simplify. - -2014-04-16 Niibe Yutaka - - * VERSION: 1.1.3. - -2014-04-15 Niibe Yutaka - - * src/ecc-mont.c: New. - - * src/mod25638.c (p25519): Move from ecc-edwards.c. - (mod25519_reduce, add19): Likewise. - (mod25638_reduce) [!ASM_IMPLEMENTATION]: Use bn256_add_uint. - -2014-04-14 Niibe Yutaka - - * src/jpc.c (jpc_to_ac): Error check before mod_inv. - - * src/mod.c (mod_inv): No return value (if N==0 returns ZERO). - - * src/bn.c [BN256_NO_RANDOM]: Only include "random.h" if needed. - -2014-04-08 Niibe Yutaka - - * src/mod.c (mod_inv): Use MAX_GCD_STEPS_BN256. - Return failure or success. - * src/jpc.c (jpc_to_ac): Use mod_inv. - * src/modp256k1.c (modp256k1_inv): Remove. - * src/modp256r1.c (modp256r1_inv): Remove. - -2014-04-07 Niibe Yutaka - - * src/openpgp-do.c (algorithm_attr_ed25519): It's OID only. - -2014-04-03 Niibe Yutaka - - * src/ecc-edwards.c (eddsa_sign_25519): Change type of OUT. - * src/openpgp.c (cmd_internal_authenticate): Have a buffer. - - * src/flash.c (flash_init): Fix key address finder. - -2014-04-02 Niibe Yutaka - - * src/openpgp-do.c (proc_key_import): Handle EdDSA. - (algorithm_attr_ed25519): Fix OID and add ID for SHA512. - -2014-04-01 Niibe Yutaka - - * src/ecc-edwards.c (eddsa_compute_public_25519): New. - - * src/openpgp-do.c (algorithm_attr_ed25519): New. - (gpg_do_write_prvkey, proc_key_import, gpg_do_public_key): Add - EdDSA handling. - -2014-03-31 Niibe Yutaka - - * src/ecc-edwards.c (eddsa_sign_25519): Rename and API change. - - * src/openpgp-do.c (gpg_do_load_prvkey, gpg_do_delete_prvkey) - (gpg_do_write_prvkey, gpg_do_public_key, gpg_do_keygen): Follow - the change of PRVKEY_DATA and KEY_DATA. - - * src/flash.c (key_available_at): New. - (flash_init): Initilize KD. - - * src/gnuk.h (struct prvkey_data): Remove member KEY_ADDR. - (struct key_data): Addd member KEY_ADDR. - - * src/openpgp-do.c (gpg_do_keygen): Bug fix. Reset the signature - counter when new key is generated. - - * src/flash.c (flash_key_alloc): Change API, supply KK. - -2014-03-29 Niibe Yutaka - - * src/ecc-edwards.c (point_double, point_add): Rename. - (mod25519_reduce): New. - -2014-03-28 Niibe Yutaka - - * misc/t-eddsa.c (main): Update for new API of eddsa_25519. - - * src/ecc-edwards.c (compute_kG_25519): Tune for 252-bit. - (eddsa_25519): Public key should be provided by caller. - (eddsa_public_key_25519): New. - -2014-03-27 Niibe Yutaka - - * src/ecc-edwards.c (ed_add_25638): Remove the third argument. - (compute_kG_25519): The curve is complete, we don't need to avoid - identity element as NIST curve or secp256k1 curve. - (eddsa_25519): Change the API, with A and the seed. - -2014-03-26 Niibe Yutaka - - * src/mod25638.c (mod25638_reduce): New. - (mod25638_mul, mod25638_sqr): Use mod25638_reduce. - - * src/ecc-edwards.c (ptc_to_ac_25519): No need to subtract p25519. - -2014-03-25 Niibe Yutaka - - * misc/t-eddsa.c: New. - - * src/ecc-edwards.c (bnX_mul_C, mod_reduce_M): New. - (eddsa_25519): New. - -2014-03-20 Niibe Yutaka - - * src/ecc-edwards.c (ed_add_25638): Fix for X == A. - (main): Compute pre-computed tables. - (precomputed_KG, precomputed_2E_KG): Add. - (compute_kG_25519): New. - -2014-03-19 Niibe Yutaka - - * src/bn.c (bn256_add): Fix for X == B. - (bn256_sub): Likewise. - - * src/ecc-edwards.c: New. - -2014-03-18 Niibe Yutaka - - * src/mod25638.c (mod25638_add, mod25638_sub, mod25638_sqr) - (mod25638_shift): New. - -2014-03-13 Niibe Yutaka - - * src/mod25638.c: Rename from fe25519.c. - * src/mod25638.h: Likewise. - -2014-03-07 Niibe Yutaka - - * VERSION: 1.1.2. - -2014-02-25 Niibe Yutaka - - * src/openpgp-do.c (gpg_do_public_key): Don't put OID. - - * src/configure [certdo] (gnuk.ld): Add TIM_SIZE and EXT_SIZE. - Thanks to Vasily Evseenko for the bug report. - -2014-02-21 Niibe Yutaka - - * src/ecc.c (compute_kG): Compute higer index at first. - (point_is_on_the_curve): Don't use coefficient_a if it's zero. - - * src/jpc.c (jpc_double): Care coefficient A. - - * src/ec_p256r1.c (COEFFICIENT_A_IS_MINUS_3): New. - * src/ec_p256k1.c (COEFFICIENT_A_IS_ZERO): New. - * src/jpc_p256r1.c (COEFFICIENT_A_IS_MINUS_3): Likewise. - * src/jpc_p256k1.c (COEFFICIENT_A_IS_MINUS_3): Likewise. - - * src/modp256k1.c (modp256k1_shift): Bug fix. - -2014-02-20 Niibe Yutaka - - * src/Makefile.in (CSRC): Add files of p256k1. - - * src/openpgp.c (cmd_pso): Support p256k1 for signature. - - * src/openpgp-do.c (algorithm_attr_p256k1): New. - (gpg_do_write_prvkey): Support p256k1 for signature. - (proc_key_import, gpg_do_table, gpg_do_public_key): Likewise. - - * src/Makefile.in (DEFS): Add -DRSA_SIG. - - * src/openpgp-do.c (gpg_do_write_prvkey): Use _p256r1. - * src/openpgp.c (cmd_internal_authenticate): Likewise. - - * src/call-ec_p256k1.c: New. Use call-ec.c. - * src/call-ec_p256r1.c: Use call-ec.c. - * src/call-ec.c: New. - (ecdsa_sign): Change the signature. - -2014-02-19 Niibe Yutaka - - * tool/calc_precompute_table_ecc.py: New. - - * src/ec_p256k1.c: New. Use ecc.c. - * src/ec_p256k1.h: New. - * src/ec_p256r1.c: Use ecc.c. - * src/ecc.c: New. - -2014-02-18 Niibe Yutaka - - * src/jpc_p256k1.c: New. Use jpc.c. - * src/jpc_p256r1.c: Use jpc.c. - * src/jpc.c: New. - - * src/sha256.c (memcpy_output_bswap32): Bug fix. - - * src/modp256k1.h, src/modp256k1.c: New. - -2014-02-17 Niibe Yutaka - - * src/Makefile.in (CSRC): Follow the changes of filenames. - - * src/modp256r1.c (modp256r1_add, modp256r1_sub, S3) - (modp256r1_mul, modp256r1_sqr, modp256r1_inv, modp256r1_shift): - Use new function names. - * src/jpc_p256r1.c (jpc_double_p256r1, jpc_add_ac_signed_p256r1) - (jpc_to_ac_p256r1): Likewise. - * src/ec_p256r1.c (point_is_on_the_curve) - (compute_kG_p256r1, compute_kP_p256r1): Likewise. - * src/call-ec_p256r1.c (ecdsa_sign): Likewise. - - * src/modp256r1.h: Rename from modp256.h. - * src/jpc-ac_p256r1.h: Rename from jpc-ac.h. - * src/ec_p256r1.h: Rename from ec_p256.h. - - * src/modp256r1.c: Rename from modp256.c. - * src/jpc_p256r1.c: Rename from jpc.c. - * src/ec_p256r1.c: Rename from ec_p256.c. - * src/call-ec_p256r1.c: Rename from call-ec_p256.c. - -2014-02-05 NIIBE Yutaka - - * src/sha512.h, src/sha512.c: New. - - * src/sha256.c (initial_state): Don't export, it's internal. - (memcpy_output_bswap32): Rename and remove last argument. - -2014-01-28 Niibe Yutaka - - * src/muladd_256.h: New. - * src/bn.c (bn256_mul, bn256_sqr): Assembler implementation. - - * src/ec_p256.c (get_vk_kP): Bug fix. - (compute_kP): Bug fix for index table. - -2014-01-27 Niibe Yutaka - - * src/ec_p256.c (get_vk_kP): New. - (naf4_257_set, naf4_257_get, compute_naf4_257): Remove. - (compute_kP): Change the argument, fixing for constant time. - -2014-01-24 Niibe Yutaka - - * src/ec_p256.c (get_vk): New. - (compute_kG): Fix for constant time. - (compute_kP): Simplify. - -2014-01-23 Niibe Yutaka - - * src/jpc.c (jpc_add_ac_signed): Fix for constant time. - - * src/ec_p256.c (ecdsa): Bug fix for k selection. - -2014-01-22 Niibe Yutaka - - * src/modp256.c (modp256_inv): Fix for constant time. - - * src/bn.c (bn256_sqr): Fix for constant time. - - * src/mod.c (mod_inv): Fix for constant time. - - * src/ec_p256.c (compute_kG): Simplify. - - * src/jpc.c (jpc_double): Support calling with A = infinity. - -2014-01-21 Niibe Yutaka - - * src/jpc.c (jpc_add_ac_signed): Bug fix for A check. - - * src/ec_p256.c (ecdsa): Fix for constant time. - - * src/modp256.c (modp256_add, modp256_sub, modp256_reduce) - (modp256_shift): Fix for constant time. - (modp256_inv): Likewise (not fully constant time, yet). - - * src/mod.c (mod_reduce): Fix for constant time. - (mod_inv): Likewise (not fully constant time, yet). - - * src/bn.h (bn256, bn512): words -> word. - * src/ec_p256.h (naf4_257): Likewise. - -2014-01-20 Niibe Yutaka - - * src/fe25519.h, src/fe25519.c: New. - -2014-01-15 Niibe Yutaka - - * src/bn.c (bn256_is_zero, bn256_is_ge, bn256_cmp): Computation - should be constant time. - -2013-12-25 Niibe Yutaka - - * VERSION: 1.1.1. - - * tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__): Fix - the argument of setAltInterface. - * tool/gnuk_upgrade.py: Likewise. - * tool/dfuse.py (DFU_STM32.__init__): Likewise. - * tool/stlinkv2.py (stlinkv2.__init__): Likewise. - -2013-12-24 Niibe Yutaka - - * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE) - (MULADDC_1024_LOOP): Use younger number registers more for shorter - instructions and better performance. - * polarssl/library/bignum.c (mpi_montsqr): Likewise. Change loop - structure and conditional branch for better performance. - -2013-12-23 Niibe Yutaka - - * polarssl/library/bignum.c (mpi_montmul): Computation - time should not depends on input. - (mpi_montmul, mpi_montred, mpi_montsqr): Change the API. - (mpi_exp_mod): Follow the change of the API. Allocate memory on - stack instead of malloc. - - * src/gnuk.ld.in (__process3_stack_size__): Increase stack size. - -2013-12-20 Niibe Yutaka - - * Version 1.1.0. - - * src/usb_ctrl.c (USB_FSIJ_GNUK_CARD_CHANGE): New. - (usb_cb_setup): Support USB_FSIJ_GNUK_CARD_CHANGE. - * src/usb-icc.c (ccid_card_change_signal): New argument HOW. - -2013-12-20 Niibe Yutaka - - * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE) - (MULADDC_CORE): Reorder instructions for more speed up. - * polarssl/library/bignum.c (mpi_montsqr): Likewise. - -2013-12-19 Niibe Yutaka - - * src/configure (--enable-hid-card-change): New (experimental). - * src/config.h.in (HID_CARD_CHANGE_DEFINE): New. - * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface) - (usb_cb_setup, usb_cb_ctrl_write_finish): Conditionalize - HID_CARD_CHANGE_SUPPORT. - * src/usb_desc.c (gnukDeviceDescriptor, usb_cb_get_descriptor): - Likewise. - -2013-12-19 Niibe Yutaka - - * src/openpgp.c (S2KCOUNT): It's now 192, as the threat model - of Gnuk Token is different. - -2013-12-19 Niibe Yutaka - - * polarssl/library/bignum.c (mpi_montsqr): New. - (mpi_exp_mod): Use mpi_montsqr. - - Note that this change introduces a vulnerability by the - Yarom/Falkner flush+reload cache side-channel attack. When this - code is used on general purpose computer where we can observe - which code is executed (sqr or mul), it's not safe. - -2013-12-16 Niibe Yutaka - - * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE) - (MULADDC_1024_LOOP, MULADDC_HUIT, MULADDC_INIT, MULADDC_CORE) - (MULADDC_STOP) [__arm__]: The value of input B won't change. - More acculate specification for asm statement. - - * polarssl/library/bignum.c (mpi_cmp_abs_limbs): New. - (mpi_montmul): Change the signature and use the upper half of T. - (mpi_montred): Likewise. - (mpi_exp_mod): Use improved mpi_montmul and mpi_montred. - (mpi_sub_hlp, mpi_mul_hlp): Add const qualifier for S. - -2013-12-13 Niibe Yutaka - - * polarssl/library/bignum.c (mpi_exp_mod): Initialize lower - half of T with zero. - (mpi_montmul): Don't need to clear lower half of - T, as we keep zero. Call mpi_sub_hlp with upper half of T. - (mpi_montred): Ditto. - - * polarssl/library/bignum.c (mpi_montmul, mpi_montred): Minimize - number of limbs for T. - (mpi_exp_mod): Only allocate N-n * 2 for T. - Only allocate N->n for X, W[i], and RR. - -2013-12-13 Niibe Yutaka - - * tool/upgrade_by_passwd.py (main): Support -k to specify KEYNO. - -2013-12-13 Niibe Yutaka - - * src/usb_ctrl.c (HID_LED_STATUS_CARDCHANGE): Rename from - HID_LED_STATUS_NUMLOCK. - - * tool/gnuk_token.py (gnuk_token.stop_gnuk): Detach kernel - driver of HID. - -2013-12-12 Niibe Yutaka - - * src/openpgp-do.c (do_openpgpcard_aid): Coerce to volatile to - force memory access at run time. - -2013-12-11 Niibe Yutaka - - * regnual/sys.c (entry): Fix relocation calculation. - -2013-11-27 Niibe Yutaka - - * src/stm32f103.h (AFIO_MAPR_SWJ_CFG_DISABLE): New. - * src/sys.c: Likewise. - -2013-11-26 Niibe Yutaka - - * src/usb_desc.c (hid_report_desc): New. - (ICC_TOTAL_LENGTH): Update. - (HID_TOTAL_LENGTH, HID_NUM_INTERFACES): New. - (W_TOTAL_LENGTH, NUM_INTERFACES): Update. - (gnukConfigDescriptor): Add IN2 interrupt endpoint descriptor. - Add HID interface descriptor. - (usb_cb_get_descriptor): Handle HID. - - * src/usb_ctrl.c (NUM_INTERFACES, MSC_INTERFACE_NO): Add 1. - (USB_HID_REQ_*, HID_LED_STATUS_NUMLOCK): New. - (gnuk_setup_endpoints_for_interface): Add ENDP2 interrupt - endpoint. - (usb_cb_setup): Handle HID requests. - (usb_cb_ctrl_write_finish): Likewise. - - * src/usb-icc.c (ccid_card_change_signal): New. - (ccid_thread): Handle card change. - (icc_error, icc_send_status): Handle ICC_STATE_NOCARD state. - (icc_handle_data): Add the case of ICC_STATE_NOCARD. - (EP2_IN_Callback): New. - -2013-11-26 Niibe Yutaka - - * src/pin-dial.c: Remove. - * src/configure: Remove pin-dial support. - -2013-11-25 Niibe Yutaka - - * src/Makefile.in (HEXOUTPUT_MAKE_OPTION): New. - * src/configure (HEXOUTPUT_MAKE_OPTION): New. - * src/main.c: Include board.h. - * src/stm32f103.h (EXTI0_IRQ, EXTI1_IRQ): New. - -2013-11-18 Niibe Yutaka - - * regnual/sys.c (entry): Bug fix of clearing BSS. - - * src/usb_stm32f103.c: Update from NeuG. - (usb_handle_transfer): Add argument ISTR_VALUE. - - * src/openpgp.c (card_thread): Add noinline attribute. - - * src/usb-icc.c (ccid_thread): Join the OpenPGP thread. - Add noinline attribute. - -2013-11-15 Niibe Yutaka - - * src/configure (options): Add --enable-sys1-compat. - -2013-11-12 Niibe Yutaka - - * chopstx: Upgrade to 0.03. - - * src/usb_desc.c (usb_initial_feature): Remove. - (USB_SELF_POWERED): Move to ... - * src/usb_conf.h (USB_SELF_POWERED): ... here. - * src/usb_ctrl.c (usb_cb_device_reset, usb_intr): Follow the - change. - -2013-11-11 Niibe Yutaka - - * src/adc_stm32f103.c (adc_wait_completion): Update from NeuG 1.0. - -2013-11-03 Niibe Yutaka - - * regnual/regnual.c (usb_cb_get_descriptor): Update to new API. - - * src/usb_lld.h (usb_initial_feature): Remove. - - * chopstx: Update to 0.01. - * src/pin-cir.c: Chatter fix to 200ms. - * src/main.c: Fix bDeviceState. - -2013-11-02 Niibe Yutaka - - * src/usb_lld.h, src/usb_stm32f103.c (std_get_descriptor): Change - the API of usb_cb_get_descriptor. - * src/usb_desc.c: Follow the change. - * src/usb_conf.h: Modify for CCID INT and HID usage. - -2013-11-02 Niibe Yutaka - - * src/pin-cir.c: Port to Chopstx. - - * chopstx: Update. - * src/configure (TIM_SIZE, EXT_SIZE): New. - * src/gnuk.ld.in (__process6_stack_size__) - (__process7_stack_size__): New. - * src/main.c (main): Call cir_init. - * src/openpgp.c (openpgp_card_thread): Rename from GPGthread. - * src/usb-icc.c (icc_power_on): Follow the change. - -2013-11-01 Niibe Yutaka - - * src/sys.c: Update from Chopstx. - * src/usb_lld.h: Remove interrupt definition. - * src/stm32f103.h: Add AFIO, EXTI, and TIMER constants. - -2013-10-31 Niibe Yutaka - - * src/main.c (main): Call msc_init before USB interrupt thread. - * src/gnuk.h, src/usb-msc.h, src/usb-msc.c, src/pin-dnd.c: Port to - Chipstx. - * src/openpgp.c (get_pinpad_input): Follow the change. - * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface): Don't stall - RX of ENDP6. - -2013-10-24 Niibe Yutaka - - * src/Makefile.in (DEFS): Add -DCHX_PRIO_MAIN=5 for LED blink. - * src/main.c (PRIO_CCID): It's now 3 (was: 2). - -2013-10-24 Niibe Yutaka - - * src/gnuk.ld.in (.gnuk_flash): Three pages for three keys. - * src/flash.c (FLASH_KEYSTORE_SIZE): Likewise. - (flash_keystore_release): Remove. - (flash_key_fill_zero_as_released) - (flash_check_all_other_keys_released, flash_key_release): New. - (flash_init, flash_key_alloc): New method to handle free space. - * src/openpgp-do.c (fetch_four_bytes): New. - (gpg_do_load_prvkey, gpg_do_delete_prvkey, gpg_do_public_key): Use - fetch_four_bytes. - (gpg_do_delete_prvkey): Call flash_key_release. - -2013-10-23 Niibe Yutaka - - * test/features/010_setup_passphrase.feature - * test/features/030_key_registration.feature - * test/features/040_passphrase_change.feature - * test/features/410_setup_passphrase.feature - * test/features/430_key_registration.feature - * test/features/201_keygen.feature - * test/features/601_keygen.feature: Modified to support new way of - pass phrase reset by key import / key generation. - - * test/features/201_keygen.feature - * test/features/601_keygen.feature - * test/features/202_setup_passphrase.feature - * test/features/602_setup_passphrase.feature: Rename to change - order of execution. - -2013-10-23 Niibe Yutaka - - * src/openpgp-do.c (gpg_do_write_prvkey): Bug fix of adding - num_prv_keys. - -2013-10-22 Niibe Yutaka - - * src/openpgp-do.c (gpg_do_write_prvkey): Bug fix. - -2013-10-15 Niibe Yutaka - - * src/openpgp.c (cmd_change_password, cmd_reset_user_password): It - is now error to change User's pass phrase with no keys. - - * src/openpgp-do.c (proc_resetting_code): Likewise for resetting - code. - (gpg_do_delete_prvkey): New. - (gpg_do_write_prvkey): Make sure to delete the key before writing. - User's pass phrase is always the one of factory setting. - (gpg_do_chks_prvkey): Support removing the key. - (proc_key_import): Use gpg_do_delete_prvkey. - (gpg_do_keygen): Use factory setting pass phrase. - -2013-10-11 Niibe Yutaka - - * src/ac.c (verify_user_0, verify_admin_00): Fix conditions. - - * src/openpgp-do.c (gpg_do_write_prvkey): Delete keystring - information from data object of NR_DO_KEYSTRING_PW3. - Fix conditions. - (gpg_do_keygen): Likewise. - - * src/openpgp.c (cmd_reset_user_password): Likewise. - -2013-10-10 Niibe Yutaka - - * src/gnuk.h (S2K_ITER): Remove. It's determined at compile time. - - * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey) - (proc_key_import): Remove "iteration" field. - - * src/openpgp.c (cmd_change_password): Likewise. - -2013-10-10 Niibe Yutaka - - * src/openpgp-do.c (gpg_do_write_prvkey): Access of data object - considering garbage collection. - - * src/openpgp.c (cmd_change_password): Call gpg_do_write_simple - after accessing the data object (it may cause garbage collection). - -2013-10-10 Niibe Yutaka - - * polarssl/library/bignum.c (mpi_montred): Constant time for - carry propagation. Bug fix for carry propagation. - (mpi_exp_mod): Bug fix. Shrink the size of RR as same as X. - -2013-10-09 Niibe Yutaka - - * src/ac.c (verify_user_0, verify_admin_00, verify_admin_0): Add a - flag to save into keystring_md_pw3. Add SALT handling. - (decode_iterate_count, calc_md, gpg_set_pw3): Remove. - - * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey) - (gpg_do_keygen): Add SALT handling. - * src/openpgp.c (cmd_change_password, cmd_reset_user_password) - (s2k): Ditto. - * src/random.c (random_get_salt): Rename from get_salt. - -2013-10-09 Niibe Yutaka - - * src/openpgp-do.c (gpg_do_write_prvkey): Remove information (but - pass phrase length) for admin from keystring data object. - (proc_key_import): Recover admin keystring to DO when key deletion. - -2013-10-09 Niibe Yutaka - - * src/ac.c (verify_user_0, verify_admin_00): Handle PW_LEN_MASK. - * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey): - Likewise. - - * src/openpgp.c (cmd_change_password, cmd_reset_user_password): - Handle PW_LEN_KEYSTRING_BIT. - -2013-10-09 Niibe Yutaka - - * src/ac.c (verify_admin_00): New. Add authentication by loading - signature key. - (verify_admin_0): Use verify_admin_00. - - * src/openpgp.c (cmd_change_password): Admin keystring handling as - same as user's. - -2013-10-08 Niibe Yutaka - - * src/openpgp.c (modify_binary): Allow odd size of certificate. - - * polarssl/library/rsa.c: Update from PolarSSL 1.2.10. - * polarssl/include/polarssl/rsa.h: Ditto. - -2013-10-07 Niibe Yutaka - - * polarssl/library/bignum.c (mpi_sub_hlp): Return CARRY. - (mpi_sub_abs): Carry propagatoin is done here. - (mpi_mul_hlp_mm): Remove. - (mpi_mul_hlp): Return CARRY, computation in constant time. - (mpi_mul_mpi): Change the order of computation not to propagate - carry. - (mpi_montmul): Minimum zero-ing of D and reduce usage of temporary - memory, by one word. Use carry of mpi_mul_hlp. Use - NEED_SUBTRACTION against timing attack. - (mpi_exp_mod): Minimum usage of temporary memory. - -2013-10-06 Niibe Yutaka - - * polarssl/library/bignum.c (mpi_mul_hlp_mm): New. Handle - extra-carry in constant time to mitigate timing attack. - (mpi_montmul): Use mpi_mul_hlp_mm. - * src/call-rsa.c (rsa_sign, rsa_decrypt, rsa_verify): Don't - use RSA blinding. - -2013-10-05 Niibe Yutaka - - * polarssl/include/polarssl/aes.h: Update from PolarSSL 1.2.9. - * polarssl/include/polarssl/bignum.h: Ditto. - * polarssl/include/polarssl/config.h: Ditto. - * polarssl/include/polarssl/rsa.h: Ditto. - * polarssl/library/aes.c, polarssl/library/bignum.c: Ditto. - * polarssl/library/rsa.c: Ditto. Fix rsa_free. - * src/call-rsa.c (rsa_sign, modulus_calc, rsa_decrypt) - (rsa_verify): Follow changes of PolarSSL 1.2.9 with RSA blinding. - Better error checking. - -2013-10-04 Niibe Yutaka - - * src/main.c (gnuk_malloc): Update ->neighbor field of a chunk on - the free list. - (gnuk_free): Access free list after getting the lock. - -2013-10-01 Niibe Yutaka - - * src/random.c (random_gen): Bug fix for INDEXed copy. - - * src/call-rsa.c (rsa_genkey): Call neug_flush and prng_seed. - * polarssl/library/bignum.c (small_prime): More constants. - (prng_seed, jkiss, mpi_fill_pseudo_random): New. - (mpi_is_prime): Use mpi_fill_pseudo_random. - -2013-09-30 Niibe Yutaka - - * polarssl/library/bignum.c (mpi_is_prime): Enable trial divisions - by small integers. - Add Fermat primality test. - (mpi_gen_prime): Limit random value so that two MSBs of result will - be 0x11. - -2013-09-27 Niibe Yutaka - - * polarssl/include/polarssl/bignum.h (mpi_is_prime): ifdef-out. - * polarssl/library/bignum.c (mpi_is_prime): It's now internal - function, assuming we already know its coprime to small primes. - (M): New constant MPI. Multiply primes 2*...*691. - (MAX_A): New constant MPI. 2^1024 / M - 1. - (mpi_gen_prime): Specialize for 1024-bit, using Fouque-Tibouchi - method. - -2013-09-25 Niibe Yutaka - - * src/sha256.h, src/adc.h - * src/neug.c, src/adc_stm32f103.c: Update from NeuG 0.11. - - * chopstx: Upgrade to new Chopstx 0.00. - - * VERSION: New file. - - * src/configure (SERIALNO, SERIALNO_STR_LEN_DEFINE): New. - (REVISION): Use the file VERSION if it doesn't have .git. - Thanks to Sumedha Widyadharma for the bug report. - - * src/config.h.in (SERIALNO_STR_LEN_DEFINE): New. - * src/main.c (ID_OFFSET): Use SERIALNO_STR_LEN. - * src/usb_desc.c (gnukStringSerial): Remove. It's now - generated in usb-strings.c.inc. - - * src/ec_p256.c (compute_kP): Fix for impossible cases. - (point_is_on_the_curve): New. - (coefficient_a, coefficient_b): New. - -2013-09-20 Niibe Yutaka - - * src/call-ec_p256.c (ecdsa_compute_public): Handle possible - error (where key_data is the order). - - * src/ec_p256.c (compute_kG, compute_kP): Handle errors. - - * src/jpc.c (jpc_to_ac): Return -1 on error. - (jpc_add_ac_signed): Handle the case where A=inf. - - * src/modp256.c (modp256_inv): Handle error case. - - * src/bn.c (bn256_cmp): New. - -2013-07-19 Niibe Yutaka - - * src/gnuk.ld.in: Layout change following NeuG. - (_end): Add alignment of 16. - - * src/neug.c, src/adc.h, src/adc_stm32f103.c: Update from NeuG. - - * src/main.c [DFU_SUPPORT] (main): Fix calling - flash_erase_all_and_exec. - - * src/openpgp-do.c (gpg_do_write_prvkey, gpg_do_keygen): Fix - allocated memory handling. Clean up before free. - * src/call-rsa.c (modulus_calc, rsa_genkey): Fix removing const. - * src/call-ec_p256.c (ecdsa_compute_public): Likewise. - -2013-07-18 Niibe Yutaka - - Port to Chopstx. - * src/Makefile.in: Change for Chopstx. - * src/configure: Likewise. - * src/gnuk.h, src/gnuk.ld.in: Likewise. - * src/ac.c: Include stdint.h and string.h, not ch.h. - * src/call-rsa.c, src/debug.c, src/flash.c: Likewise. - * src/call-ec_p256.c, src/usb_desc.c - * src/openpgp-do.c, src/random.c: Likewise. - * src/openpgp.c: Likewise. Use eventflag of Chopstx. - * src/usb-icc.c: Likewise. - * src/usb_ctrl.c: Update for Chopstx. - * src/debug.h: New. - * src/stdlib.h: Use gnuk_malloc and gnuk_free for malloc/free. - * src/config.h.in: Move FLASH_PAGE_SIZE in board.h. - * polarssl/library/aes.c (FT0, FT1, FT2): Export (for sys 2.0). - * src/main.c (struct stdout, _write, EP3_IN_Callback) - (EP5_OUT_Callback): Rewrite for Chopstx. No independent thread - any more. - (display_fatal_code, emit_led, display_status_code, led_blink): - Use primitives of Chopstx. - (main): Changes for Chopstx. - (gnuk_malloc_init, sbrk, gnuk_malloc, gnuk_free): New. - -2013-06-20 Niibe Yutaka - - * src/sys.c, src/sys.h, src/neug.c, src/adc.h - * src/adc_stm32f103.c, src/usb_stm32f103.c: Update from NeuG 0.10. - * src/stm32f103.h: New. From NeuG 0.10. - -2013-06-18 Niibe Yutaka - - * src/openpgp-do.c (gpg_do_write_prvkey, proc_key_import, gpg_do_table) - (gpg_do_public_key) [RSA_AUTH]: Conditional compilation for RSA/ECDSA. - * src/openpgp.c (cmd_internal_authenticate) [RSA_AUTH]: Likewise. - - * src/modp256.c (p256): Add const qualifier. - -2013-03-19 Niibe Yutaka - - * src/random.c (random_gen): New (was: random_byte). - - * src/call-rsa.c (rsa_sign): Follow change of API. - (rsa_genkey): Use random_gen. - (modulus_calc, rsa_decrypt, rsa_verify): Follow change of API. - * src/openpgp-do.c (encrypt, decrypt): Likewise. - - * polarssl/include/polarssl/aes.h: Updated from PolarSSL 1.2.6. - * polarssl/library/aes.c: Ditto. - * polarssl/include/polarssl/rsa.h: Ditto. - * polarssl/library/rsa.c: Ditto. - * polarssl/include/polarssl/bignum.h: Ditto. - * polarssl/library/bignum.c: Ditto. - * polarssl: Move from polarssl-0.14.0, and needed files only. - -2013-03-15 Niibe Yutaka - - * regnual/regnual.ld (.bss): Put at RAM1. This makes reGNUal can - be loaded on the lower address. - - * regnual/sys.c (entry): Don't change SP. Put alignment. - - * regnual/regnual.c (usb_cb_get_descriptor): Fix adding break. - -2013-03-14 Niibe Yutaka - - * tool/stlinkv2.py (stlinkv2.start): Call write_debug_reg to run - the core again. - -2013-03-12 Niibe Yutaka - - * src/gnuk.ld.in (__process_stack_size__): Increase (was: 0x200). - - * tool/stlinkv2.py (stlinkv2.exit_from_debug_swd) - (stlinkv2.exit_from_debug_swim): New. - (stlinkv2.start): Call exit_from_debug_swd or - exit_from_debug_swim. - -2013-03-09 Niibe Yutaka - - * src/openpgp-do.c (gpg_do_public_key): Add OID for ECDSA. - (gpg_do_write_prvkey): Add PUBKEY_LEN for ECDSA. - - * src/flash.c (flash_key_write): Argument change for ECDSA key. - - * src/main.c (calculate_regnual_entry_address): New. - (main): Use calculate_regnual_entry_address for entry point. - - * src/openpgp-do.c (gpg_do_write_prvkey): Coerce KDI.DATA to - uint8_t *. - - * src/usb_stm32f103.c (handle_setup0): Fix selecting handler. - -2013-03-08 Niibe Yutaka - - Relocatable reGNUal. - - * regnual/regnual.ld (MEMORY): 0x1400 was the value of Gnuk 1.0.1. - Keep this value. - (.text): Include .text.entry next to the .vectors. - (.got): New. - - * regnual/sys.c (entry): Now, it's at .text.entry section. - Do relocations. - Don't use absolute values which causes relocations, but - access at GOT. - - * regnual/Makefile (CFLAGS): Add -fpie. - -2013-03-07 Niibe Yutaka - - Follow the USB stack change. - - * regnual/regnual.c (usb_cb_device_reset): Rename from - regnual_device_reset. - (mem): Change type to uint32_t. - (mem_info): Removed. - (fetch): Avoid pointer punning. - (usb_cb_ctrl_write_finish): Rename from regnual_ctrl_write_finish. - (usb_cb_setup): Rename from regnual_setup. - (usb_cb_get_descriptor): Rename from regnual_get_descriptor. - (usb_cb_handle_event): Rename regnual_usb_event. - (usb_cb_interface): Rename regnual_interface. - (Device_Method): Remove. - (usb_cb_get_descriptor): Not use struct Descriptor. - -2013-03-06 Niibe Yutaka - - USB stack implementation improvement. - - * src/usb_stm32f103.c (Device_Method, method_p): Remove. - (usb_interrupt_handler): Call usb_cb_device_reset. - (std_get_descriptor): Call usb_cb_get_descriptor. - (std_set_configuration): Call usb_cb_handle_event. - (std_get_status, std_get_interface, std_set_interface): Call - usb_cb_interface. - (handle_setup0): Call usb_cb_setup. - (handle_in0): Call usb_cb_handle_event and - usb_cb_ctrl_write_finish. - (request_handler): Remove. - (handle_setup0): Call std_* directly, not indirectly by - request_handler. - (ep_intr_handler_IN, ep_intr_handler_OUT): Remove. - (usb_handle_transfer): Call EP*_Callback directly, not indirectly - by ep_intr_handler_IN, ep_intr_handler_OUT. - - * src/usb_lld.h (struct usb_device_method, Device_Method): Remove. - (usb_cb_device_reset, usb_cb_ctrl_write_finish) - (usb_cb_setup, usb_cb_get_descriptor, usb_cb_handle_event) - (usb_cb_interface): Define callbacks. - (usb_initial_feature): New. - (struct Descriptor): Move to ... - * src/usb_desc.c: ... here. - (usb_initial_feature): New. - (usb_cb_get_descriptor): Rename from gnuk_get_descriptor and move - from usb_ctrl.c. - - * src/usb_ctrl.c (usb_cb_device_reset): Rename from - gnuk_device_reset. - (usb_cb_setup): Rename from gnuk_setup. - (usb_cb_ctrl_write_finish): Rename from gnuk_ctrl_write_finish. - (usb_cb_event): Rename from gnuk_usb_event. - (usb_cb_interface): Rename from gnuk_interface. - (Device_Method): Remove. - - * src/main.c (main): Use usb_initial_feature. - -2013-02-27 Niibe Yutaka - - * src/usb-icc.c (set_sw1sw2): Arguments are C and CHUNK_LEN. - Fix reporting remaining bytes. - (icc_send_data_block_gr): Follow the arguments change of - set_sw1sw2. - -2013-02-26 Niibe Yutaka - - * regnual/regnual.ld (MEMORY): Fix start address. - - * src/random.c (random_fini): New. - * src/main.c (main): Call random_fini. - -2013-02-25 Niibe Yutaka - - * src/configure: Correct typo in help text. - - * src/gnuk.h (struct key_data_internal): Use uint32_t. - * src/openpgp-do.c (do_openpgpcard_aid): Fix calculation of VID. - (compute_key_data_checksum): Don't use type-punning pointer. - (gpg_do_write_prvkey): Use coercing to char *. - -2013-02-22 Niibe Yutaka - - * src/openpgp-do.c (gpg_do_public_key): Add header of EC point. - - * src/openpgp-do.c (GPG_DO_DISCRETIONARY, cmp_discretionary): New. - (cmp_app_data): Change to factor out GPG_DO_DISCRETIONARY. - (gpg_do_table): Add GPG_DO_DISCRETIONARY. - -2013-02-21 Niibe Yutaka - - * src/gnuk.ld.in (MEMORY): Fix adding FLASH_SIZE unit. - - * src/call-ec_p256.c (ecdsa_sign): Fix secret key access. - -2013-02-20 Niibe Yutaka - - * src/openpgp.c (cmd_internal_authenticate): Support ECDSA for - authentication. - - * src/openpgp-do.c (algorithm_attr_ecdsa): New. - (algorithm_attr_rsa): Rename (was: algorithm_attr). - (gpg_do_table): Change for GPG_DO_ALG_AUT. - (gpg_do_write_prvkey): Support ECDSA key for authentication. - (proc_key_import): Likewise. - (gpg_do_public_key): Likewise. - - * src/call-ec_p256.c: New. - * src/Makefile.in: Add call-ec_p256.c. - * src/call-rsa.c (modulus_free): Remove. - -2013-02-19 Niibe Yutaka - - * regnual/regnual.ld (MEMORY): Fix address of regnual. - - * regnual/Makefile (MCFLAGS): Remove -mfix-cortex-m3-ldrd. - (CFLAGS): Add output to .lst. - * src/Makefile.in (MCFLAGS): Remove. - - * src/sha256.c: Update from NeuG 0.05. - - * ChibiOS_2.0.8: Remove. - -2013-02-18 Niibe Yutaka - - Changes for new ChibiOS/RT. - * src/main.c: Include adc.h. - (main): Call halInit, adc_init, and chSysInit (change for - ChibiOS/RT 2.4.x). - * src/random.h: New. - * src/ac.c, src/bn.c, src/call-rsa.c, src/main.c: Include random.h. - * src/openpgp.c, src/openpgp-do.c: Likewise. - * src/configure, src/gnuk.ld.in: Add MEMORY_SIZE. - * src/ec_p256.c: Fix call of bn256_add_uint. - * boards/STM8S_DISCOVERY/*: Update for ChibiOS/RT 2.4.x. - * boards/CQ_STARM/*: Likewise. - * boards/FST_01_00/*: Likewise. - * boards/OLIMEX_STM32_H103/*: Likewise. - * boards/STBEE/*: Likewise. - * boards/STBEE_MINI/*: Likewise. - * boards/STM32_PRIMER2/*: Likewise. - - Merge ec_p256 branch. - * src/Makefile.in: Add ECC files. - * src/bn.h, src/bn.c: New. - * src/jpc-ac.h, src/jpc.c: New. - * src/ec_p256.h, src/ec_p256.c, src/ecc-cdh.c: New. - * src/mod.h, src/mod.c, src/modp256.h, src/modp256.c: New. - -2013-02-17 Niibe Yutaka - - * chibios: New submodule for ChibioS/RT 2.4.x. - * boards/FST_01/*: Update for ChibiOS/RT 2.4.x. - * boards/common/mcuconf-common.h: Ditto. - - * src/chconf.h, src/halconf.h, src/Makefile.in, src/gnuk.ld.in: - Update for ChibiOS/RT 2.4.x. - - * src/main.c, src/openpgp.c, src/usb-icc.c: Follow the change of - ChibiOS/RT 2.4.x. - * boards/common/board-common.c: Rename from hwinit.c. - * src/usb_stm32f103.c: Rename from usb_lld.c. - - * src/neug.h, src/neug.c: Update NeuG 0.05. - * src/adc_stm32f103.c, src/adc.h: New from NeuG 0.05. - - * src/random.c: Follow the change of NeuG 0.05. diff --git a/ChangeLog-1_2 b/ChangeLog-1_2 new file mode 100644 index 0000000..b91b5ae --- /dev/null +++ b/ChangeLog-1_2 @@ -0,0 +1,2823 @@ +2021-02-25 NIIBE Yutaka + + * VERSION: 1.2.17. + +2021-02-22 NIIBE Yutaka + + * src/config.h.in (@KDF_DO_REQUIRED_DEFINE@): New. + + * src/configure (KDF_DO_REQUIRED_DEFINE): New for GNU/Linux. + + * src/openpgp-do.c (gpg_do_kdf_check): When LEN==0, check if + KDO data object is available. + [KDF_DO_REQUIRED] (proc_key_import): Refuse the key import when + KDF data object is not available. + + * src/openpgp.c [KDF_DO_REQUIRED] (cmd_pgp_gakp): Refuse key + generation when KDF data object is not available. + +2021-02-19 NIIBE Yutaka + + * tool/gnuk-emulation-setup: Remove. + + * tool/upgrade_by_passwd.py (main): Use tobytes. + * tool/gnuk_get_random.py: Likewise. + * tool/gnuk_remove_keys_libusb.py (main): Likewise. + Switch to Python3. + * tool/gnuk_put_binary_libusb.py (main): Use tobytes. + Switch to Python3. + * tool/gnuk_upgrade.py (main): Use tobytes. + Switch to Python3. + + * chopstx: Update to 1.19. + +2021-02-18 Vincent Pelletier + + * test/features/202_setup_passphrase.feature: Fix. + * test/rsa_keys.py: Fix escape. + * tests/card_reader.py: Extend the timeout. + Handle no card. + * tests/rsa_keys.py: Fix escape. + * tool/gnuk_token.py: Avoid hard-coding the endpoints. + Longer timeout. + +2021-02-18 NIIBE Yutaka + + * src/configure [GNU_LINUX_EMULATION] (def_mhz): Define. + (output_vendor_product_serial_strings): Output ARCH. + + * GNUK_USB_DEVICE_ID: Use "Gnuk Token" for emulation, too. + + * src/main.c [GNU_LINUX_EMULATION] (main): Add initialization of + the .gnuk-flash-image file. + (gnuk_sbrk): Rename from sbrk. + +2020-09-10 NIIBE Yutaka + + * VERSION: 1.2.16. + +2020-09-09 NIIBE Yutaka + + * src/modp256k1.c (modp256k1_add, modp256k1_sub): Use memcpy with + dummy memory area. + * src/modp256r1.c (modp256r1_add, modp256r1_sub) + (modp256r1_reduce): Likewise. + +2020-09-08 NIIBE Yutaka + + * src/modp256k1.c (modp256k1_add, modp256k1_reduce): Avoid + optimization to remove call of memmove. + * src/modp256r1.c (modp256r1_add, modp256r1_sub) + (modp256r1_reduce): Likewise. + +2020-09-07 NIIBE Yutaka + + * src/openpgp.c (gpg_get_firmware_update_key): Use an array. + + * src/modp256k1.c (modp256k1_add, modp256k1_sub): Use memmove. + * src/modp256r1.c (modp256r1_add, modp256r1_sub) + (modp256r1_reduce): Likewise. + +2020-09-04 NIIBE Yutaka + + * src/openpgp-do.c (GPG_DO_ALG_INFO): New. + (do_fp_all, do_cafp_all, do_kgtime_all, do_openpgpcard_aid) + (do_ds_count): Return nothing. + (copy_do): Change the API for DO_PROC_READ. + (do_alg_info): New for GPG_DO_ALG_INFO. + (gpg_do_table): Add an entry for GPG_DO_ALG_INFO. + +2020-09-03 NIIBE Yutaka + + * src/openpgp.c (cmd_internal_authenticate): Remove checking + against EDDSA_HASH_LEN_MAX. + (cmd_pso): Likewise. + +2020-08-28 NIIBE Yutaka + + * src/openpgp.c (cmd_reset_user_password): Add passphrase length + check. + +2020-08-26 NIIBE Yutaka + + * src/ac.c (verify_user_0): Fix for a use case of having + signing key only. + (verify_admin_00): Clean up. + + * tests/test_000_empty_card.py (test_name_lang_sex): Support + OpenPGP card version 3.3. + +2020-01-24 NIIBE Yutaka + + * VERSION: 1.2.15. + +2020-01-11 Bertrand Jacquin + + * tool/add_openpgp_authkey_from_gpgssh.py: Switch to Python3. + * tool/calc_precompute_table_ecc.py: Likewise. + * tool/dfuse.py: Likewise. + * tool/dump_mem.py: Likewise. + * tool/get_raw_public_key.py: Likewise. + * tool/pageant_proxy_to_gpg.py: Likewise. + +2019-12-30 NIIBE Yutaka + + * chopstx: Update to 1.18. + +2019-06-18 NIIBE Yutaka + + * src/bn.c (bn256_random): More portable. + +2019-04-03 NIIBE Yutaka + + * tests: Factor out tests into classes. + +2019-03-04 NIIBE Yutaka + + * VERSION: 1.2.14. + + * chopstx: Update to 1.14. + + * tool/gnuk_token.py: Add 1209:2440. + +2019-02-24 NIIBE Yutaka + + * src/usb-ccid.c (ccid_thread): Clean up the ack button state + at reset (by SET_INTERFACE). + + * tool/gnuk_token.py (gnuk_token.__init__): Add back + setAltInterface to issue SET_INTERFACE control transfer. + +2019-02-22 NIIBE Yutaka + + * tool/gnuk_get_random.py: New. + + * src/openpgp.c (cmd_external_authenticate): move + ACKBTN_SUPPORT to... + (cmd_get_challenge): ... here. + + * src/gnuk.h (EV_*): Change the values. + + * src/usb-ccid.c (GPG_ACK_TIMEOUT): New. + (ccid_thread): Implement timout for the user interaction. + +2019-02-21 NIIBE Yutaka + + * GNUK_USB_DEVICE_ID: Add 1209:2440. + +2018-12-26 NIIBE Yutaka + + * VERSION: 1.2.13. + +2018-12-22 Peter Lebbing + + * src/main.c (device_initialize_once): Fill the stack address and + reset vector of Gnuk application (was the one of old SYS). + Reset the board after updating the first five pages of flash. + +2018-12-21 Peter Lebbing + + * src/main.c [DFU_SUPPORT] (flash_write_any): New. + (device_initialize_once): Overwrite DFU bootloader by SYS. + (main): Use SYS at ORIGIN_REAL. + + * src/stdaln-sys.ld.in: New. + + * src/Makefile [USE_DFU] (OBJS_ADD): Add standalone SYS object. + Add rules for stdaln-sys-bin.o and src/stdaln-sys.ld. + + * src/configure: Generate stdaln-sys.ld. + [MAPLE_MINI]: Tweak ORIGIN and FLASH_SIZE. + (ORIGIN_DEFINE, ORIGIN_REAL_DEFINE): New macros. + (USE_DFU): New make variable. + + * src/config.h.in (ORIGIN_DEFINE, ORIGIN_REAL_DEFINE): New. + +2018-12-20 NIIBE Yutaka + + * chopstx: Update to 1.13. + +2018-12-07 NIIBE Yutaka + + * src/gnuk.h (EV_EXEC_ACK_REQUIRED): Have precedence + than EV_EXEC_FINISHED. + +2018-12-06 NIIBE Yutaka + + * src/usb-ccid.c (ccid_thread): Priority of handling + EV_TX_FINISHED is most important. Don't handle + Ack button event when c->tx_busy = 1. + +2018-12-05 NIIBE Yutaka + + * src/openpgp.c (cmd_external_authenticate): Support + ACK button for firmware update. + +2018-12-04 NIIBE Yutaka + + * src/openpgp-do.c (gpg_data_copy): Fix for NR_DO_UIF_SIG. + +2018-11-25 NIIBE Yutaka + + * VERSION: 1.2.12. + +2018-11-21 NIIBE Yutaka + + * src/usb-ccid.c (ccid_thread): Fix a race condition sending + result APDU by ack button, time out, sending time extension block + again while tx_busy=1. + +2018-11-17 NIIBE Yutaka + + * src/main.c (device_initialize_once): Depends on MHZ to + distinguish GD32F103. + * src/openpgp-do.c (do_openpgpcard_aid): Ditto. + +2018-11-12 NIIBE Yutaka + + * VERSION: 1.2.11. + + * chopstx: Update to 1.12. + * src/configure (ackbtn_support): Always yes. + * src/usb-ccid.c: Fix comma separator. + +2018-11-09 NIIBE Yutaka + + * tool/kdf_calc.py (kdf_calc): Use libgcrypt.so.20. + +2018-11-09 NIIBE Yutaka + + * src/openpgp.c (cmd_pso, cmd_internal_authenticate): Use + ccid_comm. + + * src/usb-ccid.c (struct ccid): New field tx_busy. + (ccid_error, ccid_power_on, ccid_send_status, ccid_power_off) + (ccid_send_data_block_internal, ccid_send_data_block_0x9000) + (ccid_send_data_block_gr, ccid_send_params): Set c->tx_busy. + (ccid_state_p): Remove. + (ccid_get_ccid_state): New. + (ccid_thread): Only handle EV_TX_FINISHED event when c->tx_busy. + + * src/usb_ctrl.c (usb_setup, usb_ctrl_write_finish): Use + ccid_get_ccid_state. + * src/main.c (display_status_code): Likewise. + +2018-11-09 NIIBE Yutaka + + * src/usb-ccid.c (ccid_handle_data): Set c->state for pinpad input. + (ccid_send_data_block_internal): Fix the case of len == 0. + + * src/main.c (display_status_code): There is + no case where ccid_state == CCID_STATE_RECEIVE. + * src/gnuk.h (CCID_STATE_RECEIVE): Remove. + (CCID_STATE_SEND): Remove. + +2018-10-12 NIIBE Yutaka + + * src/usb-ccid.c (ccid_thread): Notify host about ack button. + +2018-10-02 NIIBE Yutaka + + * src/stack-def.h (SIZE_0): Increase. + + * chopstx: Update to 1.11. + +2018-10-01 NIIBE Yutaka + + * src/gnuk.h (EV_EXEC_ACK_REQUIRED): New. + (EV_EXEC_FINISHED_ACK): Remove. + (CCID_STATE_CONFIRM_ACK): Remove. + (CCID_STATE_ACK_REQUIRED_0, CCID_STATE_ACK_REQUIRED_1): New. + * src/openpgp.c (cmd_pso): Send EV_EXEC_ACK_REQUIRED, if needed. + (cmd_internal_authenticate): Likewise. + (process_command_apdu): No return value. + (openpgp_card_thread): Always send EV_EXEC_FINISHED. + * src/usb-ccid.c (ccid_send_data_block_time_extension): Follow the + change of state. + (ccid_handle_data, ccid_handle_timeout): Likewise. + (ccid_thread): Handle EV_EXEC_ACK_REQUIRED. + Change for LED blink. + * src/main.c (main): LED blink during waiting ACK. + +2018-09-27 NIIBE Yutaka + + * src/gnuk.h (NR_DO_UIF_SIG, NR_DO_UIF_DEC, NR_DO_UIF_AUT): New. + * src/openpgp-do.c (rw_uif) [ACKBTN_SUPPORT]: New. + (GPG_DO_UIF_SIG, GPG_DO_UIF_DEC, GPG_DO_UIF_AUT): New. + (feature_mngmnt) [ACKBTN_SUPPORT]: New. + (cmp_app_data, cmp_discretionary): Add ACKBTN_SUPPORT. + (gpg_do_table): Add for GPG_DO_UIF_SIG, GPG_DO_UIF_DEC, + GPG_DO_UIF_AUT, and GPG_DO_FEATURE_MNGMNT. + (gpg_do_get_uif) [ACKBTN_SUPPORT]: New. + (gpg_data_scan): Handle uif_flags. + * src/openpgp.c (process_command_apdu) [ACKBTN_SUPPORT]: Add user + interaction handling. + +2018-09-27 NIIBE Yutaka + + * src/gnuk.h (LED_WAIT_FOR_BUTTON): New. + * src/main.c (main): Blink rapidly when asking ACK. + * src/usb-ccid.c (ccid_thread): Use LED_WAIT_FOR_BUTTON. + +2018-09-27 NIIBE Yutaka + + * src/config.h.in: Add @ACKBTN_DEFINE@. + * src/configure: Add ACKBTN_SUPPORT. + * src/gnuk.h (EV_EXEC_FINISHED_ACK): New. + (CCID_STATE_CONFIRM_ACK): New. + * src/openpgp.c (process_command_apdu): Change for cmd_pso, and + cmd_internal_authenticate. + * src/usb-ccid.c (ccid_send_data_block_time_extension): Report + time extension differently when waiting ack button. + (ccid_handle_data): Support case of CCID_STATE_CONFIRM_ACK. + (ccid_handle_timeout): Likewise. + (ack_intr) [ACKBTN_SUPPORT]: New. + (ccid_thread) [ACKBTN_SUPPORT]: Add ack button handling. + +2018-09-26 NIIBE Yutaka + + * chopstx: Update. + * src/usb-ccid.c (usb_event_handle): Fix for chopstx_intr_done. + * src/pin-cir.c (tim_main, ext_main): Likewise. + + * src/configure (FST_01SZ): Set MHZ=96. + +2018-07-04 Szczepan Zalega + + * tool/upgrade_by_passwd.py: Catch exception, when no KDF data is + found. + Output 'second' for 1 second. + +2018-05-10 NIIBE Yutaka + + * VERSION: 1.2.10. + + * src/Makefile (build/gnuk.elf): New target. + (build/gnuk-vidpid.elf): Remove. + + * chopstx: Update to 1.9. + +2018-04-26 NIIBE Yutaka + + * src/usb_ctrl.c (usb_device_reset): Don't stop the endpoints. + + * src/configure (MHZ, def_mhz): New. + +2018-04-05 NIIBE Yutaka + + * VERSION: 1.2.9. + + * tests: Add test cases for admin-less mode. + + * src/openpgp.c (cmd_change_password): Care admin-less mode. + +2018-04-04 NIIBE Yutaka + + * tests: Add more tests, key generation and KDF support. + + * src/openpgp.c (cmd_reset_user_password): Check length of + new passphrase. + + * src/openpgp-do.c (proc_resetting_code): Support removal. + (gpg_do_kdf_check): Fix for the case of resetting PW3. + + * tests/test_004_reset_pw3.py: New. + +2018-04-03 NIIBE Yutaka + + * src/openpgp-do.c (rw_kdf): Clear all auth state. + + * tool/upgrade_by_passwd.py (main): Fix for byte compare. + * tool/gnuk_remove_keys_libusb.py (main): Likewise. + +2018-04-02 NIIBE Yutaka + + * tool/gnuk_token.py (parse_kdf_data): New. + * tool/kdf_calc.py: New. + + * tool/gnuk_remove_keys_libusb.py (main): Support KDF auth. + * tool/upgrade_by_passwd.py (main): Likewise. + +2018-03-30 NIIBE Yutaka + + * src/openpgp-do.c (rw_kdf): Support single-salt KDF. + (gpg_do_get_initial_pw_setting): Likewise. + (gpg_do_kdf_check): Likewise. + +2018-03-22 NIIBE Yutaka + + * src/openpgp-do.c (rw_kdf): Do format validation earlier. + +2018-03-13 NIIBE Yutaka + + * src/flash.c [FLASH_UPGRADE_SUPPORT] (flash_terminate): Erase + the page for upgrade public keys. + +2018-02-12 NIIBE Yutaka + + * src/openpgp-do.c (rw_kdf): Return 0 when NULL. + +2018-01-23 NIIBE Yutaka + + * VERSION: 1.2.8. + + * src/Makefile (build/gnuk-vidpid.elf): Supply FILE here. + * src/configure (output_vendor_product_serial_strings): For + generating put-vid-pid-ver.sh, don't set FILE. + + * regnual/regnual.c (regnual_device_desc): Make this array as a + template. + * regnual/Makefile (regnual.elf): Substitute VID:PID. + +2018-01-22 NIIBE Yutaka + + * src/openpgp.c (USER_PASSWD_MINLEN): New. + (cmd_change_password): Check passphrase length. + +2018-01-22 NIIBE Yutaka + + * src/openpgp.c (cmd_change_password): Remove access to private + key with BY_ADMIN when it's becoming admin-less mode. + +2018-01-19 NIIBE Yutaka + + * src/binary-edit.sh: Copied from NeuG 1.0.8. Exclude FILE. + * src/configure (output_vid_pid_version): Generate a shell script. + * src/Makefile (build/gnuk-vidpid.elf): New target. + * src/usb_desc.c (device_desc): Make this array as a template. + + * chopstx: Update to 1.8. + +2018-01-18 NIIBE Yutaka + + * src/neug.c: Update from NeuG. + +2018-01-09 NIIBE Yutaka + + * tests/card_reader.py (CardReader.ccid_power_on): Fix for + other card readers for Gemalto's. + +2017-12-19 NIIBE Yutaka + + * chopstx: Update to 1.7. + +2017-11-26 NIIBE Yutaka + + * src/openpgp.c (cmd_change_password): Bug fix for admin-less + mode. + +2017-11-26 NIIBE Yutaka + + * VERSION: 1.2.7. + +2017-11-24 NIIBE Yutaka + + * regnual/regnual.c (calc_crc32): Enable CRC module fix. + + * chopstx: Update to 1.6. + +2017-11-17 NIIBE Yutaka + + * src/stack-def.h (SIZE_0): Decrease. + + * src/main.c (emit_led, display_status_code, main): Use + chopstx_poll instead of eventflag_wait_timeout. + +2017-11-17 NIIBE Yutaka + + * src/stack-def.h (SIZE_0): Increase. + + * src/main.c (emit_led, display_status_code, main): Use + eventflag_wait_timeout instead of chopstx_usec_wait. + +2017-11-17 NIIBE Yutaka + + * regnual/regnual.c (calc_crc32): Enable CRC module. + + * src/neug.c (crc32_rv_stop): New. + (neug_fini): Call crc32_rv_stop. + + * src/main.c (main): Call chopstx_conf_idle. + + * src/usb-ccid.c (usb_event_handle): Use 2 for call of + chopstx_conf_idle on suspend. Call random_fini on suspend + to stop ADC module. Call random_init on wakeup. + Sleep a bit to switch main thread. + +2017-11-16 NIIBE Yutaka + + * src/gnuk.h (LED_OFF): New. + + * src/usb-ccid.c (usb_event_handle): LED off on sleep. + (ccid_thread): Use constant pointer for chopstx_poll. + (poll_event_intr): Remove. + +2017-11-15 NIIBE Yutaka + + * src/usb-ccid.c (usb_event_handle): Allow sleep on suspend. + + * src/usb_ctrl.c (usb_device_reset): Fix device state. + +2017-11-14 NIIBE Yutaka + + * src/usb-ccid.c (ccid_usb_reset): Remove + (usb_event_handle): Return value change to notify + caller about needs for going out of the loop. + Support USB suspend/resume. + (ccid_thread): Supporting USB suspend, sleep forever with + timeout_p = NULL. + + * src/main.c (main): Add USB_DEVICE_STATE_ prefix. + * src/usb_ctrl.c: Likewise. + (usb_device_reset): Don't call ccid_usb_reset. + (usb_set_configuration, usb_set_interface): Likewise. + + * src/usb_desc.c (device_desc): bcdUSB = 2.0, supporting + suspend/resume. + +2017-11-13 NIIBE Yutaka + + * src/usb_ctrl.c: Use new const USB_DEVICE_STATE_* + * src/main.c (main): Likewise. + * src/usb-ccid.c: Likewise. + (INTR_REQ_USB): Remove. Use the definition + in usb-lld.h. + +2017-11-08 NIIBE Yutaka + + * src/openpgp-do.c (gpg_do_kdf_check): New. + (proc_resetting_code): Use gpg_do_kdf_check. + * src/openpgp.c (cmd_verify, cmd_change_password) + (cmd_reset_user_password): Likewise. + +2017-11-07 NIIBE Yutaka + + * src/openpgp-do.c (proc_resetting_code): Error when + it's not pass-hash. + + * src/openpgp.c (cmd_verify, cmd_change_password) + (cmd_reset_user_password): Avoid authentication error + by old GnuPG which doesn't support KDF. + +2017-11-06 NIIBE Yutaka + + * tests/test_empty_card.py (test_extended_capabilities): Support + KDF-DO. + * test/features/802_get_data_static.feature: Likewise. + * test/features/402_get_data_static.feature: Likewise. + * test/features/002_get_data_static.feature: Likewise. + +2017-11-02 NIIBE Yutaka + + * src/openpgp-do.c (rw_kdf): Only writable when no keys. + (gpg_do_get_initial_pw_setting): New. + (gpg_do_write_prvkey): Use gpg_do_get_initial_pw_setting. + (gpg_do_keygen): Likewise. + (extended_capabilities): Enable KDF-DO available bit. + + * src/openpgp.c (cmd_change_password): Use + gpg_do_get_initial_pw_setting. + * src/ac.c (verify_user_0, verify_admin_0): Likewise. + +2017-11-01 NIIBE Yutaka + + * src/openpgp-do.c (GPG_DO_KDF): New. + (GPG_DO_FEATURE_MNGMNT): New. + (do_tag_to_nr): Support GPG_DO_KDF. + (GPG_DO_UIF_SIG, GPG_DO_UIF_DEC, GPG_DO_UIF_AUT): New. + (rw_kdf): New. + (gpg_do_table): Add an entry for GPG_DO_KDF. + + * src/gnuk.h (NR_DO_KDF): New. + +2017-10-31 NIIBE Yutaka + + * src/openpgp-do.c (gpg_do_keygen): Bug fix for memory alignment. + +2017-10-24 NIIBE Yutaka + + * tests/card_reader.py (CardReader.ccid_power_on): Setting + PPS only for Gemalto GemPC reader. + +2017-10-18 Aurelien Jarno + + * src/gnuk.ld.in: Fix keystore_pool size. + +2017-10-12 Aurelien Jarno + + * polarssl/include/polarssl/bn_mul.h (MULADDC_HUIT_DEAD): Rename + from MULADDC_HUIT. + [__ARM_FEATURE_DSP] (MULADDC_1024_CORE, MULADDC_1024_LOOP) + (MULADDC_INIT, MULADDC_CORE, MULADDC_HUIT, MULADDC_STOP): New. + + * polarssl/library/bignum.c (mpi_montsqr): Check on + POLARSSL_HAVE_ASM and __arm__. + [__ARM_FEATURE_DSP] (mpi_montsqr): New. + (MAX_WSIZE): New. + (mpi_exp_mod): Use MAX_WSIZE. + + * src/Makefile (DEFS): Remove BIGNUM_C_IMPLEMENTATION. + + * src/main.c (HEAP_SIZE): Rename from MEMORY_SIZE. + (HEAP_END, HEAP_ALIGNMENT, HEAP_ALIGN): Likewise. + + * src/stack-def.h (SIZE_3): Depend on MEMORY_SIZE. + * src/configure: Emit DEFS with MEMORY_SIZE. + +2017-10-11 NIIBE Yutaka + + * VERSION: 1.2.6. + + * regnual/Makefile (LDSCRIPT): Move after include. + * regnual/types.h: Add uintptr_t. + + * test/features/002_get_data_static.feature (data object AID): Fix + for any binary value. + * 402_get_data_static.feature: Likewise. + * 802_get_data_static.feature: Likewise. + +2017-10-10 NIIBE Yutaka + + * src/main.c (main): Support --debug option. + * chopstx: Update to 1.5. + +2017-10-06 NIIBE Yutaka + + * src/configure (flash_override): Fix suggested by Jeremy Drake. + (help): STM8S_DISCOVERY is supported again. + +2017-10-06 NIIBE Yutaka + + * src/gnuk.ld.in (.stacks): Specify NOLOAD type. + + * src/configure: Allow not specifying VIDPID. + + * src/main.c [GNU_LINUX_EMULATION] (main): Handle "--vidpid" + option to assign vendor ID and product ID of USB. + + * src/usb_desc.c [GNU_LINUX_EMULATION] (device_desc): Export. + + * GNUK_USB_DEVICE_ID (0000:0000): New. + +2017-10-05 NIIBE Yutaka + + * src/stack-def.h (SIZE_1, SIZE_3): Tweak the size. + + * src/call-rsa.c (rsa_genkey): Single step. + * src/openpgp-do.c (gpg_do_keygen): Do RSA key generation in single + step, using APDU buffer. + * src/openpgp.c (cmd_pgp_gakp): Supply the APDU as a buffer. + + * src/Makefile (install): New target. + + * src/configure (prefix. exec_prefix, libexecdir): Add. + + * src/main.c [GNU_LINUX_EMULATION] (main): Option handling. + + * tool/gnuk-emulation-setup: New. + + * polarssl/library/bignum.c (M_LIMBS, limbs_M, MAX_A_LIMBS) + (limbs_MAX_A, mpi_gen_prime): Fix for 64-bit machine. + +2017-10-04 NIIBE Yutaka + + * src/configure (output_vendor_product_serial_strings): Support + GNU/Linux emulation. + + * polarssl/library/bignum.c (mpi_div_mpi): Fix for 64-bit machine. + + * src/main.c (gnuk_malloc, gnuk_free): Fix for 64-bit machine. + + * src/stack-def.h (SIZE_3): Tweak the size. + + * src/openpgp-do.c (gpg_do_keygen): Do RSA key generation in two + steps. + + * src/call-rsa.c (rsa_genkey_start, rsa_genkey_finish): New. + (rsa_genkey): Remove. + +2017-10-03 NIIBE Yutaka + + * src/call-ec.c (ecc_compute_public): No use of malloc. + * src/call-rsa.c (modulus_calc, rsa_genkey): Likewise. + * src/ecc-edwards.c (eddsa_compute_public_25519): Likewise. + * src/ecc-mont.c (ecdh_compute_public_25519): Likewise. + * src/openpgp-do.c (gpg_do_write_prvkey, gpg_do_chks_prvkey) + (proc_key_import, gpg_do_keygen): Likewise. + + * polarssl/library/rsa.c: Don't include stdlib.h. + * src/gnuk-malloc.h: Rename from stdlib.h. + * polarssl/library/bignum.c: Include gnuk-malloc.h. + + * src/Makefile (build/flash.data): Generate. + + * src/main.c (flash_addr_key_storage_start) + (flash_addr_data_storage_start): New. + (main): Determine flash address. + + * src/flash.c (FLASH_ADDR_KEY_STORAGE_START) + (FLASH_ADDR_DATA_STORAGE_START): New. + (flash_do_storage_init, flash_terminate, flash_activate) + (flash_key_storage_init, flash_copying_gc, flash_do_release) + (flash_key_getpage): Use new macros. + +2017-10-02 NIIBE Yutaka + + * src/main.c (device_initialize_once): Not for GNU/Linux. + + * src/openpgp.c, src/flash.c: Distinguish FLASH_UPGRADE_SUPPORT. + + * src/main.c [GNU_LINUX_EMULATION]: Use emulated_main. + (MEMORY_SIZE, MEMORY_END): Fix for GNU/Linux. + + * src/usb-ccid.c (INTR_REQ_USB): Fix for GNU/Linux. + + * polarssl/library/bignum.c (mpi_montsqr): Easy C implementation. + +2017-09-30 NIIBE Yutaka + + * src/flash.c (flash_terminate, flash_activate) + (flash_copying_gc, flash_do_write_internal, flash_do_release) + (flash_key_write, flash_check_all_other_keys_released) + (flash_key_fill_zero_as_released, flash_key_release) + (flash_key_release_page, flash_clear_halfword) + (flash_put_data_internal, flash_put_data, flash_bool_clear) + (flash_bool_write_internal, flash_bool_write) + (flash_enum_write_internal, flash_enum_write) + (flash_cnt123_write_internal, flash_cnt123_increment) + (flash_cnt123_clear, flash_erase_binary, flash_write_binary): Fix + for GNU/Linux. + + * src/usb-ccid.c (ccid_tx_done): Rename from EP1_IN_Callback. + (ccid_rx_ready): Rename from EP1_OUT_Callback. + +2017-09-29 NIIBE Yutaka + + * src/usb-ccid.c (epo_init, epi_init, ccid_thread): Simplify. + (EP1_IN_Callback, ccid_prepare_receive, EP1_OUT_Callback) + (usb_rx_ready, ccid_error, ccid_power_on, ccid_send_status) + (ccid_send_data_block_internal, ccid_send_data_block_0x9000) + (ccid_send_data_block_gr, ccid_send_params) + (ccid_notify_slot_change, _write) [GNU_LINUX_EMULATION]: Use + different usb driver API. + + * src/usb_ctrl.c (usb_device_reset): Fix control endpoint init. + (gnuk_setup_endpoints_for_interface): Add DEV + argument. + (usb_device_reset) [GNU_LINUX_EMULATION]: Use usb_lld_setup_endp. + +2017-09-29 NIIBE Yutaka + + * src/main.c [FLASH_UPGRADE_SUPPORT] (main): Factor out flash ROM + upgrade support. + (calculate_regnual_entry_address): Likewise. + * src/usb_ctrl.c (usb_setup, download_check_crc32): Likewise. + + * src/openpgp.c (modify_binary): Fix for 64-bit machine. + * src/openpgp-do.c (encrypt, decrypt): Likewise. + (gpg_data_scan): Likewise. + (gpg_do_chks_prvkey): Fix error return path. + + * src/stack-def.h: New. + + * src/gnuk.ld.in: Remove stack definitions. + * src/configure: Remove stack size modifications. + + * src/main.c (STACK_MAIN, STACK_PROCESS_1): Use stack-def.h. + * src/usb-ccid.c (STACK_PROCESS_3): Likewise. + * src/usb-msc.c (STACK_PROCESS_5): Likewise. + * src/pin-cir.c (STACK_PROCESS_6, STACK_PROCESS_7): Likewise. + + * src/usb_ctrl.c (download_check_crc32): Use chrc32_rv_ functions. + + * src/mcu-stm32f103.c (rbit, check_crc32): Remove. + + * src/neug.c: Update from NeuG. + * src/neug.h: Ditto. + +2017-09-28 NIIBE Yutaka + + * src/ec_p256k1.c (coefficient_a): Remove. + + * polarssl/library/bignum.c (mpi_fill_pseudo_random): Fix for + 64-bit machine. + + * src/call-rsa.c (rsa_decrypt): Fix for 64-bit machine. + + * src/flash.c (flash_do_storage_init): Rename from flash_init. + (flash_key_storage_init): Rename from flash_init_keys. + * src/openpgp.c (gpg_init): Use new function names. + + * src/stdlib.h: Update for GNU/Linux emulation. + + * src/Makefile: Support GNU/Linux emulation. + * src/configure: Support GNU/Linux emulation. + * emulation: Remove. + +2017-08-11 NIIBE Yutaka + + * VERSION: 1.2.5. + * chopstx: Update to 1.4. + + * src/gnuk.ld.in (__process3_stack_size__): Tweak the size. + + * src/configure: Define STM32F103_OVERRIDE_FLASH_SIZE_KB for + BULE_PILL. + + * src/configure: Let generate src/config.mk. + * src/Makefile: Rename from src/Makefile.in. + * regnual/Makefile: Use src/config.mk. + +2017-08-03 NIIBE Yutaka + + * src/openpgp.c (cmd_terminate_df): Fix for admin-less mode. + +2017-08-03 Jeremy Drake + + * regnual/regnual.c (main): Allow compile time + flash size definition by STM32F103_OVERRIDE_FLASH_SIZE_KB. + +2017-08-02 Jeremy Drake + + * src/flash.c (flash_terminate): Erase Certificate DO, too. + +2017-08-01 NIIBE Yutaka + + * src/openpgp.c (FILE_CARD_TERMINATED_OPENPGP): Remove. + (cmd_select_file): Don't change file_selection. + +2017-07-19 NIIBE Yutaka + + * src/mod.c (mod_inv): Clear TMP. + + * src/configure (REVISION): Generate even when no git. + + * polarssl/library/bignum.c (mpi_exp_mod): Call mpi_grow for X + after the initialization of RR. + +2017-07-18 NIIBE Yutaka + + * src/configure: Bark when no git available. + +2017-07-18 Anthony Romano + + * docker: New. + +2017-07-18 Anthony Romano + + * src/main.c (MEMORY_SIZE, MEM_HEAD_IS_CORRUPT, MEM_HEAD_CHECK): + New. + (gnuk_malloc, gnuk_free): Add calls to MEM_HEAD_CHECK. + + * src/gnuk.h (FATAL_HEAP): New. + +2017-07-18 Anthony Romano + + * src/openpgp-do.c (gpg_reset_algo_attr): New. + (rw_algorithm_attr): Use gpg_reset_algo_attr. + Fix null dereference. + +2017-07-18 Anthony Romano + + * src/mod.c (mod_reduce): Clean up unused code. + +2017-07-18 Anthony Romano + + * src/call-rsa.c (modulus_calc): Free modulus on error. + (rsa_genkey): Remove bogus check, and call chopstx_cleanup_pop + with 1 to release p_q_modulus on error. Assign NULL to clp.arg + when it's goes with no error. + + * src/main.c (gnuk_free): Allow NULL. + +2017-07-18 NIIBE Yutaka + + * Update chopstx (with USBIP emulation). + +2017-05-12 NIIBE Yutaka + + * VERSION: 1.2.4. + +2017-04-28 NIIBE Yutaka + + * src/mcu-stm32f103.c: New. + (check_crc32, sram_address): New. + + * src/usb_ctrl.c (download_check_crc32): Use check_crc32 and + sram_address. + + * src/openpgp-do.c (gpg_write_digital_signature_counter): Fix + writing lower 10-bit. + +2017-04-27 NIIBE Yutaka + + * src/gnuk.ld.in (_data_pool): Move to the end. + + * src/flash.c (flash_init): Return address of end of data object. + * src/openpgp.c (gpg_init): Get address of end of data object. + * src/openpgp-do.c (gpg_data_scan): Check the end address. + +2017-02-02 NIIBE Yutaka + + * VERSION: 1.2.3. + + * src/gnuk.ld.in (__process1_stack_size__): Increase by 0x20. + * chopstx: Update to 1.3. + * src/configure: Add BLUE_PILL in the help message. + +2017-02-01 NIIBE Yutaka + + * README: Update README. Thanks to Paul Fertser. + +2017-01-02 Szczepan Zalega + + * tool/upgrade_by_passwd.py: Add file extention check. + +2017-02-01 NIIBE Yutaka + + * tool/upgrade_by_passwd.py (main): More verbose messages + suggested by Szczepan Zalega . + + * tool/gnuk_token.py (USB_PRODUCT_LIST): New. + (gnuk_devices_by_vidpid): Support searching by USB_PRODUCT_LIST. + Thanks to Szczepan Zalega . + + * tool/usb_strings.py: Use gnuk_token.py. + +2016-10-21 Niibe Yutaka + + * src/ecc.c (check_secret): Fix condition. + +2016-10-15 NIIBE Yutaka + + * VERSION: 1.2.2. + + * tool/gnuk_put_binary_libusb.py (main): Likewise. + * tool/upgrade_by_passwd.py (main): Add call of cmd_select_openpgp + method. + + * src/openpgp.c (gpg_init): flash_init_keys shoule be after + gpg_data_scan since flash_init_keys accesses Data Object for + key attributes. + + * src/usb-ccid.c (ccid_power_on): Don't waste stack. + +2016-10-14 Niibe Yutaka + + * src/usb-ccid.c (ccid_power_on) [LIFE_CYCLE_MANAGEMENT_SUPPORT]: + Change LCS value in ATR at run time. + + * src/openpgp.c (gpg_init): Handle FILE_CARD_TERMINATED. + (cmd_select_file): Don't return AID. + (cmd_activate_file, cmd_terminate_df): New. + (process_command_apdu): Let return GPG_NO_RECORD() when + not selected. + + * src/openpgp-do.c (gpg_do_terminate): New. + (gpg_data_scan): Handle p_start is NULL. + (do_hist_bytes): Remove. + + * src/flash.c (flash_data): Change the value from 0x0000. + (flash_init): Support termination state. Fix handling + of the boundary case where gen0 is 0xfffe. + (flash_terminate, flash_activate): New. + (flash_copying_gc): Skip 0xffff for generation number. + +2016-10-13 Niibe Yutaka + + * src/status-code.h: Rename from openpgp.h. + + * chopstx: Update to 1.2. + + * tests: New test suite for OpenPGP card with PyTest. + + * src/configure (factory_reset): New. + + * src/usb-ccid.c (ccid_power_on): Use ATR_head and historical + bytes. + + * src/openpgp-do.c (rw_algorithm_attr): Clear fingerprint, timestamp, + and possibly ds_counter. + +2016-10-12 Niibe Yutaka + + * test/features/steps.py (cmd_reset_retry_counter): Fix. + * tool/gnuk_token.py (gnuk_token.cmd_reset_retry_counter): Fix. + (gnuk_token.cmd_select_openpgp): Fix P2. + +2016-09-02 Niibe Yutaka + + * src/configure (REVISION): Fix the detection of .git. + It may be a regular file (if it's created by worktree). + +2016-08-24 Niibe Yutaka + + * test/features/steps.py (ini): Use GLC (the global context), + instead of FTC (the feature context), so that token only is + opened once. + +2016-08-03 Niibe Yutaka + + * tool/hub_ctrl.py: Port to Python 3. + +2016-07-11 NIIBE Yutaka + + * VERSION: 1.2.1. + + * src/usb-ccid.c (ccid_power_on): Fix call of chopstx_create. + * src/usb-msc.c (msc_init): Ditto. + * src/pin-cir.c (cir_init): Ditto. + * src/neug.c (neug_init): Ditto. + * src/main.c (main): Ditto. + + * src/usb-ccid.c (struct ccid): Arrange for smaller footprint. + * src/gnuk.h (struct apdu): Likewise. + + * src/usb-ccid.c (ccid_card_change_signal): Don't touch ccid_state_p. + (ccid_state_p): This is constant. + + * src/configure (output_vendor_product_serial_strings): Add const + qualifier. + + * src/usb-ccid.c (epo_init, epi_init): Simplify without notify method. + (EP1_IN_Callback, EP1_OUT_Callback): Call notify_tx and notify_icc + directly. + +2016-07-09 NIIBE Yutaka + + * src/openpgp.c (openpgp_card_thread): Don't need to get SELF. + +2016-07-06 NIIBE Yutaka + + * src/pin-cir.c (cir_getchar): Use chopstx_poll. + * src/usb-ccid.c (usb_tx_done): Fix ifdef condition. + * src/usb_ctrl.c (usb_ctrl_write_finish): Fix ifdef nesting. + +2016-07-04 NIIBE Yutaka + + * doc/conf.py: Remove 'sphinx.ext.pngmath' and 'sphinx.ext.mathjax'. + Reported by Kenji Rikitake. + +2016-07-01 NIIBE Yutaka + + * chopstx: Update to 1.1. + * src/usb-ccid.c (poll_event_intr, ccid_thread): Follow the + change. + +2016-06-21 Niibe Yutaka + + * doc/index.rst: Update documentation by an example + Ed25519/cv25519. + +2016-06-17 Niibe Yutaka + + * chopstx: Update to 1.0. + +2016-06-15 NIIBE Yutaka + + * src/gnuk.ld.in (__process2_stack_size__): Update + thread size for rng by examining NeuG. + + * src/usb-ccid.c (poll_event_intr): New. + +2016-06-14 Niibe Yutaka + + * regnual/regnual.c (usb_device_reset): Rename from + usb_cb_device_reset. + (usb_ctrl_write_finish): Rename from usb_cb_ctrl_write_finish. + (usb_setup): Rename from usb_cb_setup. + (usb_get_descriptor): Rename from usb_cb_get_descriptor. + (usb_set_configuration): New. + (usb_interrupt_handler): New. + + * src/usb-ccid.c (usb_tx_done): Rename from usb_cb_tx_done. + (usb_rx_ready): Rename from usb_cb_rx_ready. + (usb_event_handle): New. + (ccid_thread): Use usb_event_handle. + + * src/usb-msc.c (EP6_IN_Callback): Update to new USB API. + (EP6_OUT_Callback): Likewise. + + * src/usb_ctrl.c (usb_device_reset): Rename from + usb_cb_device_reset. + (vcom_port_data_setup): Update to new USB API. + (usb_ctrl_write_finish): Rename from usb_cb_ctrl_write_finish. + (usb_setup): Rename from usb_cb_setup. + (usb_set_configuration): New, based on usb_cb_handle_event. + (usb_set_interface): Rename from usb_cb_interface. + (usb_get_interface): New. + (usb_get_status_interface): New. + + * src/usb_desc.c (usb_get_descriptor): Rename from + usb_cb_get_descriptor. + +2016-06-02 Niibe Yutaka + + * regnual/regnual.c (usb_cb_tx_done): Follow the change of USB + API. + + * regnual/reset.c: Rename from sys.c. + +2016-06-01 Niibe Yutaka + + * tool/stlinkv2.py (stlinkv2.__init__): Don't + call setConfiguration. + + * tool/gnuk_token.py (gnuk_token, regnual): Don't + call setAltInterface, it's not needed. + + * src/usb-ccid.c (ccid_notify_slot_change): New. + (ccid_thread): Call ccid_notify_slot_change at + interface_reset and EV_CARD_CHANGE. + +2016-05-31 NIIBE Yutaka + + * src/usb_stm32f103.c, src/stm32f103.h: Remove. + * src/adc_stm32f103.c, src/sys.c: Remove. + + * src/usb_ctrl.c (usb_cb_interface): call ccid_usb_reset. + (usb_cb_handle_event): Likewise. + + * src/usb-ccid.c (ccid_thread): Handle RESET->CONFIGURE process + correctly. + (ccid_thread): Handle SET_INTERFACE correctly. + + * polarssl/library/aes.c (FT0, FT1, FT2): Add "weak" flag. + + * src/neug.c: Update from NeuG. + + * src/usb_desc.c (usb_cb_get_descriptor): Only valid if USE_SYS3. + + * src/Makefile.in (USE_SYS, USE_USB, USE_ADC): Enabled. + (CHIP): Add. + + * src/sys.c, src/sys.h: Remove. + * src/usb_stm32f103.c, src/usb_lld.h: Remove. + * src/adc_stm32f103.c, src/adc.h: Remove. + + * chopstx: Update to 0.12. + +2016-05-21 Niibe Yutaka + + * src/main.c (led_blink, main): Fix LED blink protocol. + +2016-05-20 NIIBE Yutaka + + * VERSION: 1.2.0. + * src/usb-ccid.c (ccid_thread): Fix timeout. + (icc_handle_timeout, icc_send_status): Tweak. + +2016-05-19 Niibe Yutaka + + * src/usb_ctrl.c (usb_cb_ctrl_write_finish): Set bDeviceState. + + * src/usb-ccid.c: Rename from usb-icc.c. + (ccid_thread): Handle reGNUal upgrade. + + * src/Makefile.in (CSRC): Follow the change. + + * chopstx: Update to 0.11. + +2016-05-18 Niibe Yutaka + + * src/gnuk.ld.in: Tweak thread size. + * src/main.c (main): Use chopstx_setpriority. + * src/usb-icc.c (ccid_init): Use new eventflag API. + + * regnual/regnual.c (nvic_enable_intr): New. + (main): Call nvic_enable_intr. + + * chopstx: Update. + +2016-05-16 Niibe Yutaka + + * regnual/regnual.c (usb_cb_rx_ready, usb_cb_tx_done) + (usb_cb_device_reset): Follow the change of USB API. + + * chopstx: Update. + * src/sys.c: Update from Chopstx. + +2016-05-13 Niibe Yutaka + + * src/neug.c (rng): Call chopstx_claim_irq before adc_start. + Remove call of chopstx_release_irq. + +2016-05-12 Niibe Yutaka + + * chopstx: Update. + * src/sys.c: Update from Chopstx. + * src/usb_lld.h: Likewise. + * src/usb_stm32f103.c: Likewise. + + * src/usb_ctrl.c (usb_intr): Follow the change of USB API. + (usb_cb_rx_ready, usb_cb_tx_done): Likewise. + + * src/adc.h: Remove unused declarations. + +2016-03-08 Niibe Yutaka + + * tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__): + Don't call setConfiguration method. + + * src/usb_lld.h (usb_cb_ctrl_write_finish): Change the API of + callback, which possibly needs INDEX, VALUE, and LEN parameters. + (usb_lld_set_data_to_recv): Fix the type of P. + (USB_DEVICE_DESCRIPTOR_TYPE, USB_CONFIGURATION_DESCRIPTOR_TYPE) + (USB_STRING_DESCRIPTOR_TYPE, USB_INTERFACE_DESCRIPTOR_TYPE) + (USB_ENDPOINT_DESCRIPTOR_TYPE): Remove, as we have the enumeration + values for same things. + + * src/usb_stm32f103.c (handle_in0): Follow the change. + * src/usb_ctrl.c (usb_cb_ctrl_write_finish): Likewise. + + * src/usb_desc.c (usb_cb_get_descriptor): Use HID_INTERFACE. + (device_desc, config_desc, string_descriptors) + (usb_cb_get_descriptor): Use the enumeration types. + * src/configure: Use the enumeration types. + + * regnual/regnual.c: Follow the change of usb_lld.h. + +2016-02-09 Niibe Yutaka + + * src/openpgp.c (cmd_verify): Support VERIFY reset, which is + described in the specification V2.2 and V3.1. + + * polarssl/library/bignum.c (mpi_exp_mod): Fix to our local + change. Thanks to Aidan Thornton for the failure test case. + + Fix of mpi_div_mpi from upstream. + * polarssl/library/bignum.c (int_clz, int_div_int): New. + (mpi_div_mpi): Use int_div_int. + +2016-02-09 Niibe Yutaka + + * src/openpgp.c (s2k): Include the unique ID of MCU into the + computation of S2K function. + +2016-02-08 Niibe Yutaka + + * src/modp256r1.c (modp256r1_add, modp256r1_sub): Keep the result + less than P256R1. + (modp256r1_reduce): Fix wrong calculation. + * src/modp256k1.c (modp256k1_add, modp256k1_sub): Likewise. + Thanks to Aidan Thornton. + +2016-02-05 Niibe Yutaka + + * src/configure: Add submodule check suggested by Elliott + Mitchell. + +2015-11-30 perillamint + + * src/openpgp.c (card_thread): Fix offset of bConfirmPIN. + +2015-09-18 Niibe Yutaka + + * VERSION: 1.1.9. + + * src/openpgp-do.c (proc_key_import): Fix error return. + (rw_algorithm_attr): Check it's not ALGO_RSA2K. + +2015-09-17 Niibe Yutaka + + * VERSION: 1.1.8. + +2015-09-15 Niibe Yutaka + + * chopstx: Update to 0.10. + + * src/main.c (main): Don't join after calling ccid_usb_reset. + * src/usb-icc.c (ccid_thread): Don't finish on reset, but + keep running. + + * src/usb_ctrl.c (usb_cb_device_reset): Stop the interface. + + * src/usb_stm32f103.c (std_set_interface): Bug fix for conf. + + * src/gnuk.ld.in (__process3_stack_size__): Increase stack size of + GPG thread. + (__process2_stack_size__): Increase stack size of RNG. + (__process4_stack_size__): Increase stack size of USB. + (__main_stack_size__): Decrease stack size of exception handlers. + (__process1_stack_size__): Decrease stack size of CCID. + +2015-09-14 Niibe Yutaka + + * src/gnuk.h (LED_GNUK_EXEC): New. + * src/main.c, src/usb-icc.c, src/usb_ctrl.c: icc_state_p access + clean up. + +2015-09-11 Niibe Yutaka + + * tool/upgrade_by_passwd.py (main): Loop until finding reGNUal + device. + +2015-09-10 Niibe Yutaka + + * src/call-rsa.c (rsa_cleanup): New. + (rsa_sign, rsa_decrypt, rsa_genkey): Allow cancellation. + * src/openpgp.c (cmd_pso, cmd_internal_authenticate): Cancellation + is handled by each functions in case of RSA. + +2015-09-09 Niibe Yutaka + + * src/sys.h: Update from Chopstx. + * src/adc_stm32f103.c: Update from NeuG. + + * src/openpgp.c (process_command_apdu): Protect command execution + against cancelling the execution thread. + (cmd_pso, cmd_internal_authenticate): Allow cancellation. + + * src/main.c (main): Handle LED_USB_RESET. + + * src/usb-icc.c (ccid_usb_reset): New. + (ccid_thread): Upon receival of EV_USB_RESET, finish + the thread, canceling the card thread. + +2015-09-08 Niibe Yutaka + + * src/gnuk.h (EV_USB_RESET, LED_USB_RESET): New. + + * src/usb_ctrl.c (CDC_CTRL_DTR): New. + (vcom_port_data_setup): Distinguish detail->value for DTR. + + * src/configure (help): Add ST_DONGLE and ST_NUCLEO_F103. + +2015-09-04 Niibe Yutaka + + * src/openpgp-do.c (do_openpgpcard_aid): Use upper bytes of unique + ID of MCU; same as USB serial number. + + * src/configure (help): Add NITROKEY_START. + +2015-08-26 Mateusz Zalega + + * GNUK_USB_DEVICE_ID: Add Nitrokey Start. + +2015-08-05 Niibe Yutaka + + * VERSION: 1.1.7. + +2015-08-04 Niibe Yutaka + + * src/adc_stm32f103.c: Update from NeuG 1.0.3. + + * chopstx: Update to 0.08. + * src/sys.h: Update. + +2015-08-03 Niibe Yutaka + + * test/features/steps.py (set_msg): Python3 fix. + * test/generate_keys.py: Likewise. + * test/rsa_keys.py: Likewise. + + * tool/gnuk_token.py (gnuk_token.download, gnuk_token.execute) + (regnual.download): Python3 fix. + (list_to_string): Remove. + + * tool/upgrade_by_passwd.py (maian): Python3 fix. + * tool/usb_strings.py (main): Python3 fix. + +2015-07-31 Niibe Yutaka + + * src/configure (output_vendor_product_serial_strings): Fix sed + script when string is short. Remove empty line. + + * regnual/regnual.c (usb_cb_ctrl_write_finish, usb_cb_setup) + (usb_cb_get_descriptor, usb_cb_interface): Follow the change + of USB API. + + * tool/stlinkv2.py: Support ST-Link/V2-1. + +2015-07-28 Niibe Yutaka + + * tool/stlinkv2.py: Fix for Python3. Thanks to Bertrand Jacquin. + + * tool/gpg_agent.py: Fix for Python3. + + * src/usb-msc.c: Update from Fraucheky. + + * src/usb_stm32f103.c (struct DATA_INFO): Remove offset. + (struct DEVICE_INFO): Integrate CONTROL_INFO. + +2015-07-27 Niibe Yutaka + + * src/usb_stm32f103.c (usb_lld_reply_request): New. + (usb_lld_set_data_to_send): Remove. + (usb_lld_set_data_to_recv): Not a macro but a function. + (std_get_status): Don't use statically allocated memory. + (std_get_configuration): Use usb_lld_reply_request. + (handle_setup0): Follow the change. + * src/usb_ctrl.c (vcom_port_data_setup, usb_cb_setup) + (usb_cb_interface): Use usb_lld_reply_request. + * src/usb_desc.c (usb_cb_get_descriptor): Likewise. + +2015-07-24 Niibe Yutaka + + * tool/gnuk_put_binary.py: Remove. + * tool/gnuk_remove_keys.py: Remove. + +2015-07-23 Niibe Yutaka + + * src/configure (nl): New. Follow the change of NeuG. + +2015-07-21 Niibe Yutaka + + * VERSION: 1.1.6. + +2015-07-20 Niibe Yutaka + + * src/openpgp-do.c (gpg_do_keygen): Support ECC. + * src/call-ec.c (ecc_check_secret): New. + * src/ecc.c (check_secret): New. + +2015-07-18 Niibe Yutaka + + * src/configure (keygen): It's always enabled. + * src/openpgp-do.c (gpg_do_keygen): Support key generation. + * src/openpgp.c (cmd_pgp_gakp): Likewise. + * src/call-rsa.c (rsa_genkey): Likewise. + * src/random.c (random_gen): Likewise. + * src/Makefile.in (KEYGEN_SUPPORT): Remove. + * polarssl/include/polarssl/config.h (POLARSSL_GENPRIME): Define. + +2015-07-16 Niibe Yutaka + + * src/configure (FLASH_PAGE_SIZE, FLASH_SIZE, MEMORY_SIZE) + [sys1_compat]: Use safe values for common binary. + (TARGET_DEFINE): Remove. + +2015-07-15 Niibe Yutaka + + * tool/usb_strings.py (field): Add 'Board'. + + * regnual/regnual.c (usb_cb_get_descriptor): Update. + * src/usb_ctrl.c (usb_cb_interface): Call usb_lld_write. + * src/usb_desc.c (usb_cb_get_descriptor): Support sys_board_name, + using usb_lld_write. + * src/usb_lld.h (usb_cb_get_descriptor): Add last argument length + for asked length. + * src/usb_stm32f103.c (handle_setup0): Allow setup callback to + call usb_lld_write with ENDP0. + * src/usb_conf.h (NUM_STRING_DESC): Remove. + + * src/configure [!sys1_compat] (CONFIG): Don't include target + board name. + + * src/flash.c: Detect flash_page_size at runtime. + + * src/main.c: Remove dependency to board.h. + + * src/neug.c: Update from NeuG 1.0.2. + * src/adc_stm32f103.c: Update. + + * chopstx: Update to 0.07. + * src/sys.c: Update. + * src/sys.h: Update. + * src/gnuk.ld.in: Update. + + * tool/stlinkv2.py (stlinkv2.get_chip_id): New. Detect flash + size, too. + (main): Call stlinkv2.get_chip_id after MCU reset and stop. + Verify read out fix. + +2015-07-11 Niibe Yutaka + + * src/configure (help): Add STM32_PRIMER2 and CQ_STARM. + + * chopstx: Update to 0.06. + + * tool/stlinkv2.py: Support 512kB version of STM32F103. + The size of executable file should be even. + +2015-07-07 Niibe Yutaka + + * src/Makefile.in (CSRC): Add ecc-mont.c. + + * src/ecc-mont.c (mod25638_mul_121665): Fix. + (ecdh_compute_public_25519, ecdh_decrypt_curve25519): New. + + * src/openpgp.c (cmd_pso): Support ALGO_CURVE25519. + + * src/openpgp-do.c (algorithm_attr_cv25519): New. + (rw_algorithm_attr, get_algo_attr_data_object) + (gpg_get_algo_attr_key_size, gpg_do_write_prvkey) + (proc_key_import, gpg_do_public_key): Support ALGO_CURVE25519. + + * src/gnuk.h (ALGO_CURVE25519): New. + +2015-07-06 Niibe Yutaka + + Enhancement for FSM-55. + * tool/stlinkv2.py (stlinkv2.control_nrst): New. + (stlinkv2.get_rdp_key,has_spi_flash,has_protection): New. + (stlinkv2.get_core_id): Rename. + (stlinkv2.blank_check): Use self.flash_size. + (stlinkv2.start): Call control_nrst. Call get_core_id. + Distinguishing chip, and set rdp_key, flash_size and require_nrst. + (stlinkv2.flash_write): Use self.flash_block_size. + (main): Call control_nrst. + (prog_flash_write_body, prog_option_bytes_write_body) + (prog_blank_check_body): Support Cortex-M0. + (main): Call API V2 halt twice. + * tool/asm-thumb/*.S: Updated for Cortex-M0. + +2015-06-30 Niibe Yutaka + + * src/sys.c: Update from chopstx/example-cdc/sys.c. + + * src/main.c (device_initialize_once): Apply change of NeuG. + +2015-06-03 Niibe Yutaka + + * VERSION: 1.1.5. + + * test/ecc_nistp256_keys.py: New. + + * tool/upgrade_by_passwd.py: Remove -p option and add -f option. + + * tool/gnuk_token.py (gnuk_token.download): Add verbose flag. + (regnual.download): Ditto. + + * tool/gnuk_upgrade.py: Use gnuk_token module. + +2015-06-02 Niibe Yutaka + + * src/openpgp.c (cmd_pso): Support OpenPGPcard spec v3.0. + +2015-04-20 Niibe Yutaka + + * chopstx: Upgrade to 0.05. + +2015-04-19 Niibe Yutaka + + * src/gnuk.h (CCID_CARD_INIT): New. + * src/usb_desc.c (gnukConfigDescriptor): Update dwDefaultClock, + dwMaximumClock, dwFeatures, and bClassEnvelope. + * src/usb_ctrl.c (freq_table): Change the value to 4000MHz. + (usb_cb_handle_event): Call ccid_card_change_signal after configure. + * src/usb-icc.c (ccid_thread): Change EV_CARD_CHANGE handling. + +2015-04-18 Niibe Yutaka + + * src/main.c (main): Call chopstx_main_init. + * src/Makefile.in (DEFS): Remove CHX_PRIO_MAIN. + +2015-04-17 Niibe Yutaka + + * src/configure: Fix shell syntax. + +2015-03-31 Niibe Yutaka + + * src/usb_conf.h (ICC_NUM_INTERFACES, HID_NUM_INTERFACES) + (HID_NUM_INTERFACES, VCOM_NUM_INTERFACES, MSC_NUM_INTERFACES) + (NUM_INTERFACES): Define here (moved from usb_desc.c). + (ICC_INTERFACE, HID_INTERFACE, VCOM_INTERFACE_0, VCOM_INTERFACE_1) + (MSC_INTERFACE): New. + * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface) + (usb_cb_setup, usb_cb_ctrl_write_finish): Use *_INTERFACE. + * src/usb_desc.c (gnukConfigDescriptor): Likewise. + +2015-03-06 Niibe Yutaka + + * src/ecc-edwards.c (eddsa_sign_25519): Return 0. + +2015-02-25 Niibe Yutaka + + * src/openpgp.c (cmd_internal_authenticate): Fix storing to + res_APDU_size. + +2015-02-10 Niibe Yutaka + + * src/openpgp.c (cmd_pso): Fix counter update for EdDSA. Thanks + to Jonathan Schleifer. + + * src/call-rsa.c (rsa_sign): Don't set res_APDU_len. + (rsa_decrypt): Likewise, but get OUTPUT_LEN_P as an argument. + +2015-02-09 Niibe Yutaka + + * src/openpgp.c (cmd_pso): Fix EdDSA. Use GPG_KEY_FOR_SIGNING. + +2014-12-15 Niibe Yutaka + + * VERSION: 1.1.4. + +2014-12-13 Niibe Yutaka + + * src/flash.c (flash_key_getpage, flash_key_release_page): New. + + * src/openpgp-do.c (gpg_do_delete_prvkey): New arg. + (rw_algorithm_attr): Call gpg_do_delete_prvkey with CLEAN_PAGE_FULL. + +2014-12-12 Niibe Yutaka + + * src/Makefile.in (build/bignum.o): Specific OPT for this target. + + * src/configure (target): Default is FST-01. + (--with-dfu): FST-01 doesn't have DFU. If set, it must be + mistake. + + * boards/STBEE_MINI: Remove, since it is now supported by Chopstx. + + * test/features/802_get_data_static.feature: Reflect the change + of extended capabilities. + * test/features/402_get_data_static.feature: Ditto. + * test/features/002_get_data_static.feature: Ditto. + + * test/features/003_keyattr_change.feature: New test. + + * src/usb_lld.h: Don't use 'extern' for function declarations. + * src/usb-icc.c (end_cmd_apdu_data): Fix Le handling. + +2014-12-11 Niibe Yutaka + + * chopstx: Upgrade to 0.04. + * src/syc.c: Update from 0.04. + +2014-12-10 Niibe Yutaka + + * src/ecc-cdh.c: Remove as smartcard only does + a part of ECDH computation as gpg-agent does. + + * src/chconf.h, src/halconf.h: Remove files needed for ChibiOS/RT. + +2014-12-09 Niibe Yutaka + + * src/call-ec.c (ecc_compute_public): Rename, as we share + same routine among ECDSA and ECDH. + (ecdh_decrypt): New. + +2014-12-09 Niibe Yutaka + + * src/ecc.c (compute_kP): Bug fix. It's P, not G. + (point_is_on_the_curve): Bug fix. + +2014-12-03 Niibe Yutaka + + Changes for RSA-4096. + + * src/gnuk.h (MAX_CMD_APDU_DATA_SIZE, MAX_RES_APDU_DATA_SIZE): + Send/Recv buffer should be bigger. + * polarssl/library/bignum.c (mpi_exp_mod): Don't consume much. + * polarssl/library/rsa.c (rsa_rsaes_pkcs1_v15_decrypt): buffer + allocation size should be variable. + +2014-12-01 Niibe Yutaka + + * src/Makefile.in (DEFS): Don't define compile time preference of + key algo attributes. + + * src/openpgp-do.c (proc_key_import): Support modifiable key algo + attributes. + +2014-11-21 Niibe Yutaka + + * src/gnuk.h (ALGO_RSA4K, ALGO_NISTP256R1, ALGO_SECP256K1) + (ALGO_ED25519, ALGO_RSA2K): New. + (struct key_data_internal): Move to ... + * src/openpgp-do.c (struct key_data_internal): ... here. + (CHECKSUM_ADDR, kdi_len): New. + (CKDC_CALC, CKDC_CHECK): New. + (compute_key_data_checksum): Add arg PRVKEY_LEN. + (gpg_do_load_prvkey, gpg_do_delete_prvkey): Support modifiable key + algo attributes. + (gpg_do_write_prvkey, gpg_do_public_key, gpg_do_keygen): Likewise. + (gpg_do_clear_prvkey): Use MAX_PRVKEY_LEN. + + * src/openpgp.c (gpg_init): Call flash_init_keys after + gpg_data_scan. + (cmd_pso): Support modifiable key algo attributes. + (cmd_internal_authenticate): Likewise. + +2014-11-21 Niibe Yutaka + + * src/openpgp-do.c (algorithm_attr_rsa2k): Rename from *_rsa. + (algorithm_attr_rsa4k): New. + (get_algo_attr_pointer, kk_to_nr, gpg_get_algo_attr) + (get_algo_attr_data_object, gpg_get_algo_attr_key_size): New. + (rw_algorithm_attr): New. + (gpg_do_table): Register rw_algorithm_attr for GPG_DO_ALG_*. + (gpg_data_scan, gpg_data_copy): Handle algo attributes. + + (rw_pw_status): Fix checking against redundant write. + +2014-11-20 Niibe Yutaka + + * src/openpgp-do.c (extended_capabilities): Key attributes can be + modifid now. + +2014-11-20 Niibe Yutaka + + * src/gnuk.h (NR_NONE, NR_DO__FIRST__): Remove. + (NR_DO_*): Redefine. + (NR_KEY_ALGO_ATTR_SIG, NR_KEY_ALGO_ATTR_DEC) + (NR_KEY_ALGO_ATTR_AUT): New. + + * src/openpgp-do.c (gpg_do_load_prvkey, gpg_do_delete_prvkey) + (gpg_do_write_prvkey, gpg_do_chks_prvkey, gpg_data_scan) + (gpg_data_copy, gpg_do_read_simple) + (gpg_do_write_simple): Don't use NR_DO__FIRST__. + (gpg_do_put_data): Don't use NR_NONE any more. + (do_tag_to_nr): Use -1 to specify NONE. + + * src/flash.c (flash_enum_clear, flash_enum_write_internal) + (flash_enum_write): New. + +2014-11-19 Niibe Yutaka + + * src/gnuk.h (FIRMWARE_UPDATE_KEY_CONTENT_LEN): New. + (size_of_key): New enum. + + * src/openpgp.c (gpg_get_firmware_update_key) + (cmd_read_binary, cmd_external_authenticate): Use + FIRMWARE_UPDATE_KEY_CONTENT_LEN. + + * src/flash.c (KEY_SIZE): Remove. + (key_available_at): Add new arg as KEY_SIZE. + (flash_check_all_other_keys_released): Likewise. + (flash_key_fill_zero_as_released, flash_key_release): Likewise. + + (flash_init): Move initializing keys into another function. + (flash_init_keys): New function. + + (flash_key_alloc): Use gpg_get_algo_attr_key_size. + (flash_key_write): Add new arg as KEY_DATA_LEN. + + (flash_write_binary): Use FIRMWARE_UPDATE_KEY_CONTENT_LEN. + +2014-09-16 Niibe Yutaka + + * src/gnuk.h (MAX_PRVKEY_LEN): New. + (KEY_CONTENT_LEN): Remove. + + * src/call-rsa.c (RSA_SIGNATURE_LENGTH): Remove. + (rsa_sign, rsa_verify, rsa_genkey): Add new arg: PUBKEY_LEN. + (rsa_decrypt): Don't use KEY_CONTENT_LEN. + +2014-06-19 Niibe Yutaka + + * src/ecc-mont.c (compute_nQ): Add comment. + + * src/mod.c (mod_inv): Fix comment. X^-1 = 0 when X=0 + is important for Montgomery curve computation. + +2014-06-05 Niibe Yutaka + + * tool/add_openpgp_authkey_from_gpgssh.py: New. + +2014-04-17 Niibe Yutaka + + * src/muladd_256.h (MULADD_256_ASM): New. + (MULADD_256): Use MULADD_256_ASM. + * src/ecc-mont.c (mod25638_mul_121665): Add asm implementation. + + * src/bn.c (bn256_add_uint, bn256_sub_uint): Simplify. + * src/mod25638.c (mod25638_add, mod25638_sub): Simplify. + (n25638, add19): Remove. + (ADDWORD_256): Add s_ as source pointer. + (mod25519_reduce): Remove a call to memcpy. Use bn256_add_uint. + * src/ecc-edwards.c (point_double): Simplify. + +2014-04-16 Niibe Yutaka + + * VERSION: 1.1.3. + +2014-04-15 Niibe Yutaka + + * src/ecc-mont.c: New. + + * src/mod25638.c (p25519): Move from ecc-edwards.c. + (mod25519_reduce, add19): Likewise. + (mod25638_reduce) [!ASM_IMPLEMENTATION]: Use bn256_add_uint. + +2014-04-14 Niibe Yutaka + + * src/jpc.c (jpc_to_ac): Error check before mod_inv. + + * src/mod.c (mod_inv): No return value (if N==0 returns ZERO). + + * src/bn.c [BN256_NO_RANDOM]: Only include "random.h" if needed. + +2014-04-08 Niibe Yutaka + + * src/mod.c (mod_inv): Use MAX_GCD_STEPS_BN256. + Return failure or success. + * src/jpc.c (jpc_to_ac): Use mod_inv. + * src/modp256k1.c (modp256k1_inv): Remove. + * src/modp256r1.c (modp256r1_inv): Remove. + +2014-04-07 Niibe Yutaka + + * src/openpgp-do.c (algorithm_attr_ed25519): It's OID only. + +2014-04-03 Niibe Yutaka + + * src/ecc-edwards.c (eddsa_sign_25519): Change type of OUT. + * src/openpgp.c (cmd_internal_authenticate): Have a buffer. + + * src/flash.c (flash_init): Fix key address finder. + +2014-04-02 Niibe Yutaka + + * src/openpgp-do.c (proc_key_import): Handle EdDSA. + (algorithm_attr_ed25519): Fix OID and add ID for SHA512. + +2014-04-01 Niibe Yutaka + + * src/ecc-edwards.c (eddsa_compute_public_25519): New. + + * src/openpgp-do.c (algorithm_attr_ed25519): New. + (gpg_do_write_prvkey, proc_key_import, gpg_do_public_key): Add + EdDSA handling. + +2014-03-31 Niibe Yutaka + + * src/ecc-edwards.c (eddsa_sign_25519): Rename and API change. + + * src/openpgp-do.c (gpg_do_load_prvkey, gpg_do_delete_prvkey) + (gpg_do_write_prvkey, gpg_do_public_key, gpg_do_keygen): Follow + the change of PRVKEY_DATA and KEY_DATA. + + * src/flash.c (key_available_at): New. + (flash_init): Initilize KD. + + * src/gnuk.h (struct prvkey_data): Remove member KEY_ADDR. + (struct key_data): Addd member KEY_ADDR. + + * src/openpgp-do.c (gpg_do_keygen): Bug fix. Reset the signature + counter when new key is generated. + + * src/flash.c (flash_key_alloc): Change API, supply KK. + +2014-03-29 Niibe Yutaka + + * src/ecc-edwards.c (point_double, point_add): Rename. + (mod25519_reduce): New. + +2014-03-28 Niibe Yutaka + + * misc/t-eddsa.c (main): Update for new API of eddsa_25519. + + * src/ecc-edwards.c (compute_kG_25519): Tune for 252-bit. + (eddsa_25519): Public key should be provided by caller. + (eddsa_public_key_25519): New. + +2014-03-27 Niibe Yutaka + + * src/ecc-edwards.c (ed_add_25638): Remove the third argument. + (compute_kG_25519): The curve is complete, we don't need to avoid + identity element as NIST curve or secp256k1 curve. + (eddsa_25519): Change the API, with A and the seed. + +2014-03-26 Niibe Yutaka + + * src/mod25638.c (mod25638_reduce): New. + (mod25638_mul, mod25638_sqr): Use mod25638_reduce. + + * src/ecc-edwards.c (ptc_to_ac_25519): No need to subtract p25519. + +2014-03-25 Niibe Yutaka + + * misc/t-eddsa.c: New. + + * src/ecc-edwards.c (bnX_mul_C, mod_reduce_M): New. + (eddsa_25519): New. + +2014-03-20 Niibe Yutaka + + * src/ecc-edwards.c (ed_add_25638): Fix for X == A. + (main): Compute pre-computed tables. + (precomputed_KG, precomputed_2E_KG): Add. + (compute_kG_25519): New. + +2014-03-19 Niibe Yutaka + + * src/bn.c (bn256_add): Fix for X == B. + (bn256_sub): Likewise. + + * src/ecc-edwards.c: New. + +2014-03-18 Niibe Yutaka + + * src/mod25638.c (mod25638_add, mod25638_sub, mod25638_sqr) + (mod25638_shift): New. + +2014-03-13 Niibe Yutaka + + * src/mod25638.c: Rename from fe25519.c. + * src/mod25638.h: Likewise. + +2014-03-07 Niibe Yutaka + + * VERSION: 1.1.2. + +2014-02-25 Niibe Yutaka + + * src/openpgp-do.c (gpg_do_public_key): Don't put OID. + + * src/configure [certdo] (gnuk.ld): Add TIM_SIZE and EXT_SIZE. + Thanks to Vasily Evseenko for the bug report. + +2014-02-21 Niibe Yutaka + + * src/ecc.c (compute_kG): Compute higer index at first. + (point_is_on_the_curve): Don't use coefficient_a if it's zero. + + * src/jpc.c (jpc_double): Care coefficient A. + + * src/ec_p256r1.c (COEFFICIENT_A_IS_MINUS_3): New. + * src/ec_p256k1.c (COEFFICIENT_A_IS_ZERO): New. + * src/jpc_p256r1.c (COEFFICIENT_A_IS_MINUS_3): Likewise. + * src/jpc_p256k1.c (COEFFICIENT_A_IS_MINUS_3): Likewise. + + * src/modp256k1.c (modp256k1_shift): Bug fix. + +2014-02-20 Niibe Yutaka + + * src/Makefile.in (CSRC): Add files of p256k1. + + * src/openpgp.c (cmd_pso): Support p256k1 for signature. + + * src/openpgp-do.c (algorithm_attr_p256k1): New. + (gpg_do_write_prvkey): Support p256k1 for signature. + (proc_key_import, gpg_do_table, gpg_do_public_key): Likewise. + + * src/Makefile.in (DEFS): Add -DRSA_SIG. + + * src/openpgp-do.c (gpg_do_write_prvkey): Use _p256r1. + * src/openpgp.c (cmd_internal_authenticate): Likewise. + + * src/call-ec_p256k1.c: New. Use call-ec.c. + * src/call-ec_p256r1.c: Use call-ec.c. + * src/call-ec.c: New. + (ecdsa_sign): Change the signature. + +2014-02-19 Niibe Yutaka + + * tool/calc_precompute_table_ecc.py: New. + + * src/ec_p256k1.c: New. Use ecc.c. + * src/ec_p256k1.h: New. + * src/ec_p256r1.c: Use ecc.c. + * src/ecc.c: New. + +2014-02-18 Niibe Yutaka + + * src/jpc_p256k1.c: New. Use jpc.c. + * src/jpc_p256r1.c: Use jpc.c. + * src/jpc.c: New. + + * src/sha256.c (memcpy_output_bswap32): Bug fix. + + * src/modp256k1.h, src/modp256k1.c: New. + +2014-02-17 Niibe Yutaka + + * src/Makefile.in (CSRC): Follow the changes of filenames. + + * src/modp256r1.c (modp256r1_add, modp256r1_sub, S3) + (modp256r1_mul, modp256r1_sqr, modp256r1_inv, modp256r1_shift): + Use new function names. + * src/jpc_p256r1.c (jpc_double_p256r1, jpc_add_ac_signed_p256r1) + (jpc_to_ac_p256r1): Likewise. + * src/ec_p256r1.c (point_is_on_the_curve) + (compute_kG_p256r1, compute_kP_p256r1): Likewise. + * src/call-ec_p256r1.c (ecdsa_sign): Likewise. + + * src/modp256r1.h: Rename from modp256.h. + * src/jpc-ac_p256r1.h: Rename from jpc-ac.h. + * src/ec_p256r1.h: Rename from ec_p256.h. + + * src/modp256r1.c: Rename from modp256.c. + * src/jpc_p256r1.c: Rename from jpc.c. + * src/ec_p256r1.c: Rename from ec_p256.c. + * src/call-ec_p256r1.c: Rename from call-ec_p256.c. + +2014-02-05 NIIBE Yutaka + + * src/sha512.h, src/sha512.c: New. + + * src/sha256.c (initial_state): Don't export, it's internal. + (memcpy_output_bswap32): Rename and remove last argument. + +2014-01-28 Niibe Yutaka + + * src/muladd_256.h: New. + * src/bn.c (bn256_mul, bn256_sqr): Assembler implementation. + + * src/ec_p256.c (get_vk_kP): Bug fix. + (compute_kP): Bug fix for index table. + +2014-01-27 Niibe Yutaka + + * src/ec_p256.c (get_vk_kP): New. + (naf4_257_set, naf4_257_get, compute_naf4_257): Remove. + (compute_kP): Change the argument, fixing for constant time. + +2014-01-24 Niibe Yutaka + + * src/ec_p256.c (get_vk): New. + (compute_kG): Fix for constant time. + (compute_kP): Simplify. + +2014-01-23 Niibe Yutaka + + * src/jpc.c (jpc_add_ac_signed): Fix for constant time. + + * src/ec_p256.c (ecdsa): Bug fix for k selection. + +2014-01-22 Niibe Yutaka + + * src/modp256.c (modp256_inv): Fix for constant time. + + * src/bn.c (bn256_sqr): Fix for constant time. + + * src/mod.c (mod_inv): Fix for constant time. + + * src/ec_p256.c (compute_kG): Simplify. + + * src/jpc.c (jpc_double): Support calling with A = infinity. + +2014-01-21 Niibe Yutaka + + * src/jpc.c (jpc_add_ac_signed): Bug fix for A check. + + * src/ec_p256.c (ecdsa): Fix for constant time. + + * src/modp256.c (modp256_add, modp256_sub, modp256_reduce) + (modp256_shift): Fix for constant time. + (modp256_inv): Likewise (not fully constant time, yet). + + * src/mod.c (mod_reduce): Fix for constant time. + (mod_inv): Likewise (not fully constant time, yet). + + * src/bn.h (bn256, bn512): words -> word. + * src/ec_p256.h (naf4_257): Likewise. + +2014-01-20 Niibe Yutaka + + * src/fe25519.h, src/fe25519.c: New. + +2014-01-15 Niibe Yutaka + + * src/bn.c (bn256_is_zero, bn256_is_ge, bn256_cmp): Computation + should be constant time. + +2013-12-25 Niibe Yutaka + + * VERSION: 1.1.1. + + * tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__): Fix + the argument of setAltInterface. + * tool/gnuk_upgrade.py: Likewise. + * tool/dfuse.py (DFU_STM32.__init__): Likewise. + * tool/stlinkv2.py (stlinkv2.__init__): Likewise. + +2013-12-24 Niibe Yutaka + + * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE) + (MULADDC_1024_LOOP): Use younger number registers more for shorter + instructions and better performance. + * polarssl/library/bignum.c (mpi_montsqr): Likewise. Change loop + structure and conditional branch for better performance. + +2013-12-23 Niibe Yutaka + + * polarssl/library/bignum.c (mpi_montmul): Computation + time should not depends on input. + (mpi_montmul, mpi_montred, mpi_montsqr): Change the API. + (mpi_exp_mod): Follow the change of the API. Allocate memory on + stack instead of malloc. + + * src/gnuk.ld.in (__process3_stack_size__): Increase stack size. + +2013-12-20 Niibe Yutaka + + * Version 1.1.0. + + * src/usb_ctrl.c (USB_FSIJ_GNUK_CARD_CHANGE): New. + (usb_cb_setup): Support USB_FSIJ_GNUK_CARD_CHANGE. + * src/usb-icc.c (ccid_card_change_signal): New argument HOW. + +2013-12-20 Niibe Yutaka + + * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE) + (MULADDC_CORE): Reorder instructions for more speed up. + * polarssl/library/bignum.c (mpi_montsqr): Likewise. + +2013-12-19 Niibe Yutaka + + * src/configure (--enable-hid-card-change): New (experimental). + * src/config.h.in (HID_CARD_CHANGE_DEFINE): New. + * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface) + (usb_cb_setup, usb_cb_ctrl_write_finish): Conditionalize + HID_CARD_CHANGE_SUPPORT. + * src/usb_desc.c (gnukDeviceDescriptor, usb_cb_get_descriptor): + Likewise. + +2013-12-19 Niibe Yutaka + + * src/openpgp.c (S2KCOUNT): It's now 192, as the threat model + of Gnuk Token is different. + +2013-12-19 Niibe Yutaka + + * polarssl/library/bignum.c (mpi_montsqr): New. + (mpi_exp_mod): Use mpi_montsqr. + + Note that this change introduces a vulnerability by the + Yarom/Falkner flush+reload cache side-channel attack. When this + code is used on general purpose computer where we can observe + which code is executed (sqr or mul), it's not safe. + +2013-12-16 Niibe Yutaka + + * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE) + (MULADDC_1024_LOOP, MULADDC_HUIT, MULADDC_INIT, MULADDC_CORE) + (MULADDC_STOP) [__arm__]: The value of input B won't change. + More acculate specification for asm statement. + + * polarssl/library/bignum.c (mpi_cmp_abs_limbs): New. + (mpi_montmul): Change the signature and use the upper half of T. + (mpi_montred): Likewise. + (mpi_exp_mod): Use improved mpi_montmul and mpi_montred. + (mpi_sub_hlp, mpi_mul_hlp): Add const qualifier for S. + +2013-12-13 Niibe Yutaka + + * polarssl/library/bignum.c (mpi_exp_mod): Initialize lower + half of T with zero. + (mpi_montmul): Don't need to clear lower half of + T, as we keep zero. Call mpi_sub_hlp with upper half of T. + (mpi_montred): Ditto. + + * polarssl/library/bignum.c (mpi_montmul, mpi_montred): Minimize + number of limbs for T. + (mpi_exp_mod): Only allocate N-n * 2 for T. + Only allocate N->n for X, W[i], and RR. + +2013-12-13 Niibe Yutaka + + * tool/upgrade_by_passwd.py (main): Support -k to specify KEYNO. + +2013-12-13 Niibe Yutaka + + * src/usb_ctrl.c (HID_LED_STATUS_CARDCHANGE): Rename from + HID_LED_STATUS_NUMLOCK. + + * tool/gnuk_token.py (gnuk_token.stop_gnuk): Detach kernel + driver of HID. + +2013-12-12 Niibe Yutaka + + * src/openpgp-do.c (do_openpgpcard_aid): Coerce to volatile to + force memory access at run time. + +2013-12-11 Niibe Yutaka + + * regnual/sys.c (entry): Fix relocation calculation. + +2013-11-27 Niibe Yutaka + + * src/stm32f103.h (AFIO_MAPR_SWJ_CFG_DISABLE): New. + * src/sys.c: Likewise. + +2013-11-26 Niibe Yutaka + + * src/usb_desc.c (hid_report_desc): New. + (ICC_TOTAL_LENGTH): Update. + (HID_TOTAL_LENGTH, HID_NUM_INTERFACES): New. + (W_TOTAL_LENGTH, NUM_INTERFACES): Update. + (gnukConfigDescriptor): Add IN2 interrupt endpoint descriptor. + Add HID interface descriptor. + (usb_cb_get_descriptor): Handle HID. + + * src/usb_ctrl.c (NUM_INTERFACES, MSC_INTERFACE_NO): Add 1. + (USB_HID_REQ_*, HID_LED_STATUS_NUMLOCK): New. + (gnuk_setup_endpoints_for_interface): Add ENDP2 interrupt + endpoint. + (usb_cb_setup): Handle HID requests. + (usb_cb_ctrl_write_finish): Likewise. + + * src/usb-icc.c (ccid_card_change_signal): New. + (ccid_thread): Handle card change. + (icc_error, icc_send_status): Handle ICC_STATE_NOCARD state. + (icc_handle_data): Add the case of ICC_STATE_NOCARD. + (EP2_IN_Callback): New. + +2013-11-26 Niibe Yutaka + + * src/pin-dial.c: Remove. + * src/configure: Remove pin-dial support. + +2013-11-25 Niibe Yutaka + + * src/Makefile.in (HEXOUTPUT_MAKE_OPTION): New. + * src/configure (HEXOUTPUT_MAKE_OPTION): New. + * src/main.c: Include board.h. + * src/stm32f103.h (EXTI0_IRQ, EXTI1_IRQ): New. + +2013-11-18 Niibe Yutaka + + * regnual/sys.c (entry): Bug fix of clearing BSS. + + * src/usb_stm32f103.c: Update from NeuG. + (usb_handle_transfer): Add argument ISTR_VALUE. + + * src/openpgp.c (card_thread): Add noinline attribute. + + * src/usb-icc.c (ccid_thread): Join the OpenPGP thread. + Add noinline attribute. + +2013-11-15 Niibe Yutaka + + * src/configure (options): Add --enable-sys1-compat. + +2013-11-12 Niibe Yutaka + + * chopstx: Upgrade to 0.03. + + * src/usb_desc.c (usb_initial_feature): Remove. + (USB_SELF_POWERED): Move to ... + * src/usb_conf.h (USB_SELF_POWERED): ... here. + * src/usb_ctrl.c (usb_cb_device_reset, usb_intr): Follow the + change. + +2013-11-11 Niibe Yutaka + + * src/adc_stm32f103.c (adc_wait_completion): Update from NeuG 1.0. + +2013-11-03 Niibe Yutaka + + * regnual/regnual.c (usb_cb_get_descriptor): Update to new API. + + * src/usb_lld.h (usb_initial_feature): Remove. + + * chopstx: Update to 0.01. + * src/pin-cir.c: Chatter fix to 200ms. + * src/main.c: Fix bDeviceState. + +2013-11-02 Niibe Yutaka + + * src/usb_lld.h, src/usb_stm32f103.c (std_get_descriptor): Change + the API of usb_cb_get_descriptor. + * src/usb_desc.c: Follow the change. + * src/usb_conf.h: Modify for CCID INT and HID usage. + +2013-11-02 Niibe Yutaka + + * src/pin-cir.c: Port to Chopstx. + + * chopstx: Update. + * src/configure (TIM_SIZE, EXT_SIZE): New. + * src/gnuk.ld.in (__process6_stack_size__) + (__process7_stack_size__): New. + * src/main.c (main): Call cir_init. + * src/openpgp.c (openpgp_card_thread): Rename from GPGthread. + * src/usb-icc.c (icc_power_on): Follow the change. + +2013-11-01 Niibe Yutaka + + * src/sys.c: Update from Chopstx. + * src/usb_lld.h: Remove interrupt definition. + * src/stm32f103.h: Add AFIO, EXTI, and TIMER constants. + +2013-10-31 Niibe Yutaka + + * src/main.c (main): Call msc_init before USB interrupt thread. + * src/gnuk.h, src/usb-msc.h, src/usb-msc.c, src/pin-dnd.c: Port to + Chipstx. + * src/openpgp.c (get_pinpad_input): Follow the change. + * src/usb_ctrl.c (gnuk_setup_endpoints_for_interface): Don't stall + RX of ENDP6. + +2013-10-24 Niibe Yutaka + + * src/Makefile.in (DEFS): Add -DCHX_PRIO_MAIN=5 for LED blink. + * src/main.c (PRIO_CCID): It's now 3 (was: 2). + +2013-10-24 Niibe Yutaka + + * src/gnuk.ld.in (.gnuk_flash): Three pages for three keys. + * src/flash.c (FLASH_KEYSTORE_SIZE): Likewise. + (flash_keystore_release): Remove. + (flash_key_fill_zero_as_released) + (flash_check_all_other_keys_released, flash_key_release): New. + (flash_init, flash_key_alloc): New method to handle free space. + * src/openpgp-do.c (fetch_four_bytes): New. + (gpg_do_load_prvkey, gpg_do_delete_prvkey, gpg_do_public_key): Use + fetch_four_bytes. + (gpg_do_delete_prvkey): Call flash_key_release. + +2013-10-23 Niibe Yutaka + + * test/features/010_setup_passphrase.feature + * test/features/030_key_registration.feature + * test/features/040_passphrase_change.feature + * test/features/410_setup_passphrase.feature + * test/features/430_key_registration.feature + * test/features/201_keygen.feature + * test/features/601_keygen.feature: Modified to support new way of + pass phrase reset by key import / key generation. + + * test/features/201_keygen.feature + * test/features/601_keygen.feature + * test/features/202_setup_passphrase.feature + * test/features/602_setup_passphrase.feature: Rename to change + order of execution. + +2013-10-23 Niibe Yutaka + + * src/openpgp-do.c (gpg_do_write_prvkey): Bug fix of adding + num_prv_keys. + +2013-10-22 Niibe Yutaka + + * src/openpgp-do.c (gpg_do_write_prvkey): Bug fix. + +2013-10-15 Niibe Yutaka + + * src/openpgp.c (cmd_change_password, cmd_reset_user_password): It + is now error to change User's pass phrase with no keys. + + * src/openpgp-do.c (proc_resetting_code): Likewise for resetting + code. + (gpg_do_delete_prvkey): New. + (gpg_do_write_prvkey): Make sure to delete the key before writing. + User's pass phrase is always the one of factory setting. + (gpg_do_chks_prvkey): Support removing the key. + (proc_key_import): Use gpg_do_delete_prvkey. + (gpg_do_keygen): Use factory setting pass phrase. + +2013-10-11 Niibe Yutaka + + * src/ac.c (verify_user_0, verify_admin_00): Fix conditions. + + * src/openpgp-do.c (gpg_do_write_prvkey): Delete keystring + information from data object of NR_DO_KEYSTRING_PW3. + Fix conditions. + (gpg_do_keygen): Likewise. + + * src/openpgp.c (cmd_reset_user_password): Likewise. + +2013-10-10 Niibe Yutaka + + * src/gnuk.h (S2K_ITER): Remove. It's determined at compile time. + + * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey) + (proc_key_import): Remove "iteration" field. + + * src/openpgp.c (cmd_change_password): Likewise. + +2013-10-10 Niibe Yutaka + + * src/openpgp-do.c (gpg_do_write_prvkey): Access of data object + considering garbage collection. + + * src/openpgp.c (cmd_change_password): Call gpg_do_write_simple + after accessing the data object (it may cause garbage collection). + +2013-10-10 Niibe Yutaka + + * polarssl/library/bignum.c (mpi_montred): Constant time for + carry propagation. Bug fix for carry propagation. + (mpi_exp_mod): Bug fix. Shrink the size of RR as same as X. + +2013-10-09 Niibe Yutaka + + * src/ac.c (verify_user_0, verify_admin_00, verify_admin_0): Add a + flag to save into keystring_md_pw3. Add SALT handling. + (decode_iterate_count, calc_md, gpg_set_pw3): Remove. + + * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey) + (gpg_do_keygen): Add SALT handling. + * src/openpgp.c (cmd_change_password, cmd_reset_user_password) + (s2k): Ditto. + * src/random.c (random_get_salt): Rename from get_salt. + +2013-10-09 Niibe Yutaka + + * src/openpgp-do.c (gpg_do_write_prvkey): Remove information (but + pass phrase length) for admin from keystring data object. + (proc_key_import): Recover admin keystring to DO when key deletion. + +2013-10-09 Niibe Yutaka + + * src/ac.c (verify_user_0, verify_admin_00): Handle PW_LEN_MASK. + * src/openpgp-do.c (proc_resetting_code, gpg_do_write_prvkey): + Likewise. + + * src/openpgp.c (cmd_change_password, cmd_reset_user_password): + Handle PW_LEN_KEYSTRING_BIT. + +2013-10-09 Niibe Yutaka + + * src/ac.c (verify_admin_00): New. Add authentication by loading + signature key. + (verify_admin_0): Use verify_admin_00. + + * src/openpgp.c (cmd_change_password): Admin keystring handling as + same as user's. + +2013-10-08 Niibe Yutaka + + * src/openpgp.c (modify_binary): Allow odd size of certificate. + + * polarssl/library/rsa.c: Update from PolarSSL 1.2.10. + * polarssl/include/polarssl/rsa.h: Ditto. + +2013-10-07 Niibe Yutaka + + * polarssl/library/bignum.c (mpi_sub_hlp): Return CARRY. + (mpi_sub_abs): Carry propagatoin is done here. + (mpi_mul_hlp_mm): Remove. + (mpi_mul_hlp): Return CARRY, computation in constant time. + (mpi_mul_mpi): Change the order of computation not to propagate + carry. + (mpi_montmul): Minimum zero-ing of D and reduce usage of temporary + memory, by one word. Use carry of mpi_mul_hlp. Use + NEED_SUBTRACTION against timing attack. + (mpi_exp_mod): Minimum usage of temporary memory. + +2013-10-06 Niibe Yutaka + + * polarssl/library/bignum.c (mpi_mul_hlp_mm): New. Handle + extra-carry in constant time to mitigate timing attack. + (mpi_montmul): Use mpi_mul_hlp_mm. + * src/call-rsa.c (rsa_sign, rsa_decrypt, rsa_verify): Don't + use RSA blinding. + +2013-10-05 Niibe Yutaka + + * polarssl/include/polarssl/aes.h: Update from PolarSSL 1.2.9. + * polarssl/include/polarssl/bignum.h: Ditto. + * polarssl/include/polarssl/config.h: Ditto. + * polarssl/include/polarssl/rsa.h: Ditto. + * polarssl/library/aes.c, polarssl/library/bignum.c: Ditto. + * polarssl/library/rsa.c: Ditto. Fix rsa_free. + * src/call-rsa.c (rsa_sign, modulus_calc, rsa_decrypt) + (rsa_verify): Follow changes of PolarSSL 1.2.9 with RSA blinding. + Better error checking. + +2013-10-04 Niibe Yutaka + + * src/main.c (gnuk_malloc): Update ->neighbor field of a chunk on + the free list. + (gnuk_free): Access free list after getting the lock. + +2013-10-01 Niibe Yutaka + + * src/random.c (random_gen): Bug fix for INDEXed copy. + + * src/call-rsa.c (rsa_genkey): Call neug_flush and prng_seed. + * polarssl/library/bignum.c (small_prime): More constants. + (prng_seed, jkiss, mpi_fill_pseudo_random): New. + (mpi_is_prime): Use mpi_fill_pseudo_random. + +2013-09-30 Niibe Yutaka + + * polarssl/library/bignum.c (mpi_is_prime): Enable trial divisions + by small integers. + Add Fermat primality test. + (mpi_gen_prime): Limit random value so that two MSBs of result will + be 0x11. + +2013-09-27 Niibe Yutaka + + * polarssl/include/polarssl/bignum.h (mpi_is_prime): ifdef-out. + * polarssl/library/bignum.c (mpi_is_prime): It's now internal + function, assuming we already know its coprime to small primes. + (M): New constant MPI. Multiply primes 2*...*691. + (MAX_A): New constant MPI. 2^1024 / M - 1. + (mpi_gen_prime): Specialize for 1024-bit, using Fouque-Tibouchi + method. + +2013-09-25 Niibe Yutaka + + * src/sha256.h, src/adc.h + * src/neug.c, src/adc_stm32f103.c: Update from NeuG 0.11. + + * chopstx: Upgrade to new Chopstx 0.00. + + * VERSION: New file. + + * src/configure (SERIALNO, SERIALNO_STR_LEN_DEFINE): New. + (REVISION): Use the file VERSION if it doesn't have .git. + Thanks to Sumedha Widyadharma for the bug report. + + * src/config.h.in (SERIALNO_STR_LEN_DEFINE): New. + * src/main.c (ID_OFFSET): Use SERIALNO_STR_LEN. + * src/usb_desc.c (gnukStringSerial): Remove. It's now + generated in usb-strings.c.inc. + + * src/ec_p256.c (compute_kP): Fix for impossible cases. + (point_is_on_the_curve): New. + (coefficient_a, coefficient_b): New. + +2013-09-20 Niibe Yutaka + + * src/call-ec_p256.c (ecdsa_compute_public): Handle possible + error (where key_data is the order). + + * src/ec_p256.c (compute_kG, compute_kP): Handle errors. + + * src/jpc.c (jpc_to_ac): Return -1 on error. + (jpc_add_ac_signed): Handle the case where A=inf. + + * src/modp256.c (modp256_inv): Handle error case. + + * src/bn.c (bn256_cmp): New. + +2013-07-19 Niibe Yutaka + + * src/gnuk.ld.in: Layout change following NeuG. + (_end): Add alignment of 16. + + * src/neug.c, src/adc.h, src/adc_stm32f103.c: Update from NeuG. + + * src/main.c [DFU_SUPPORT] (main): Fix calling + flash_erase_all_and_exec. + + * src/openpgp-do.c (gpg_do_write_prvkey, gpg_do_keygen): Fix + allocated memory handling. Clean up before free. + * src/call-rsa.c (modulus_calc, rsa_genkey): Fix removing const. + * src/call-ec_p256.c (ecdsa_compute_public): Likewise. + +2013-07-18 Niibe Yutaka + + Port to Chopstx. + * src/Makefile.in: Change for Chopstx. + * src/configure: Likewise. + * src/gnuk.h, src/gnuk.ld.in: Likewise. + * src/ac.c: Include stdint.h and string.h, not ch.h. + * src/call-rsa.c, src/debug.c, src/flash.c: Likewise. + * src/call-ec_p256.c, src/usb_desc.c + * src/openpgp-do.c, src/random.c: Likewise. + * src/openpgp.c: Likewise. Use eventflag of Chopstx. + * src/usb-icc.c: Likewise. + * src/usb_ctrl.c: Update for Chopstx. + * src/debug.h: New. + * src/stdlib.h: Use gnuk_malloc and gnuk_free for malloc/free. + * src/config.h.in: Move FLASH_PAGE_SIZE in board.h. + * polarssl/library/aes.c (FT0, FT1, FT2): Export (for sys 2.0). + * src/main.c (struct stdout, _write, EP3_IN_Callback) + (EP5_OUT_Callback): Rewrite for Chopstx. No independent thread + any more. + (display_fatal_code, emit_led, display_status_code, led_blink): + Use primitives of Chopstx. + (main): Changes for Chopstx. + (gnuk_malloc_init, sbrk, gnuk_malloc, gnuk_free): New. + +2013-06-20 Niibe Yutaka + + * src/sys.c, src/sys.h, src/neug.c, src/adc.h + * src/adc_stm32f103.c, src/usb_stm32f103.c: Update from NeuG 0.10. + * src/stm32f103.h: New. From NeuG 0.10. + +2013-06-18 Niibe Yutaka + + * src/openpgp-do.c (gpg_do_write_prvkey, proc_key_import, gpg_do_table) + (gpg_do_public_key) [RSA_AUTH]: Conditional compilation for RSA/ECDSA. + * src/openpgp.c (cmd_internal_authenticate) [RSA_AUTH]: Likewise. + + * src/modp256.c (p256): Add const qualifier. + +2013-03-19 Niibe Yutaka + + * src/random.c (random_gen): New (was: random_byte). + + * src/call-rsa.c (rsa_sign): Follow change of API. + (rsa_genkey): Use random_gen. + (modulus_calc, rsa_decrypt, rsa_verify): Follow change of API. + * src/openpgp-do.c (encrypt, decrypt): Likewise. + + * polarssl/include/polarssl/aes.h: Updated from PolarSSL 1.2.6. + * polarssl/library/aes.c: Ditto. + * polarssl/include/polarssl/rsa.h: Ditto. + * polarssl/library/rsa.c: Ditto. + * polarssl/include/polarssl/bignum.h: Ditto. + * polarssl/library/bignum.c: Ditto. + * polarssl: Move from polarssl-0.14.0, and needed files only. + +2013-03-15 Niibe Yutaka + + * regnual/regnual.ld (.bss): Put at RAM1. This makes reGNUal can + be loaded on the lower address. + + * regnual/sys.c (entry): Don't change SP. Put alignment. + + * regnual/regnual.c (usb_cb_get_descriptor): Fix adding break. + +2013-03-14 Niibe Yutaka + + * tool/stlinkv2.py (stlinkv2.start): Call write_debug_reg to run + the core again. + +2013-03-12 Niibe Yutaka + + * src/gnuk.ld.in (__process_stack_size__): Increase (was: 0x200). + + * tool/stlinkv2.py (stlinkv2.exit_from_debug_swd) + (stlinkv2.exit_from_debug_swim): New. + (stlinkv2.start): Call exit_from_debug_swd or + exit_from_debug_swim. + +2013-03-09 Niibe Yutaka + + * src/openpgp-do.c (gpg_do_public_key): Add OID for ECDSA. + (gpg_do_write_prvkey): Add PUBKEY_LEN for ECDSA. + + * src/flash.c (flash_key_write): Argument change for ECDSA key. + + * src/main.c (calculate_regnual_entry_address): New. + (main): Use calculate_regnual_entry_address for entry point. + + * src/openpgp-do.c (gpg_do_write_prvkey): Coerce KDI.DATA to + uint8_t *. + + * src/usb_stm32f103.c (handle_setup0): Fix selecting handler. + +2013-03-08 Niibe Yutaka + + Relocatable reGNUal. + + * regnual/regnual.ld (MEMORY): 0x1400 was the value of Gnuk 1.0.1. + Keep this value. + (.text): Include .text.entry next to the .vectors. + (.got): New. + + * regnual/sys.c (entry): Now, it's at .text.entry section. + Do relocations. + Don't use absolute values which causes relocations, but + access at GOT. + + * regnual/Makefile (CFLAGS): Add -fpie. + +2013-03-07 Niibe Yutaka + + Follow the USB stack change. + + * regnual/regnual.c (usb_cb_device_reset): Rename from + regnual_device_reset. + (mem): Change type to uint32_t. + (mem_info): Removed. + (fetch): Avoid pointer punning. + (usb_cb_ctrl_write_finish): Rename from regnual_ctrl_write_finish. + (usb_cb_setup): Rename from regnual_setup. + (usb_cb_get_descriptor): Rename from regnual_get_descriptor. + (usb_cb_handle_event): Rename regnual_usb_event. + (usb_cb_interface): Rename regnual_interface. + (Device_Method): Remove. + (usb_cb_get_descriptor): Not use struct Descriptor. + +2013-03-06 Niibe Yutaka + + USB stack implementation improvement. + + * src/usb_stm32f103.c (Device_Method, method_p): Remove. + (usb_interrupt_handler): Call usb_cb_device_reset. + (std_get_descriptor): Call usb_cb_get_descriptor. + (std_set_configuration): Call usb_cb_handle_event. + (std_get_status, std_get_interface, std_set_interface): Call + usb_cb_interface. + (handle_setup0): Call usb_cb_setup. + (handle_in0): Call usb_cb_handle_event and + usb_cb_ctrl_write_finish. + (request_handler): Remove. + (handle_setup0): Call std_* directly, not indirectly by + request_handler. + (ep_intr_handler_IN, ep_intr_handler_OUT): Remove. + (usb_handle_transfer): Call EP*_Callback directly, not indirectly + by ep_intr_handler_IN, ep_intr_handler_OUT. + + * src/usb_lld.h (struct usb_device_method, Device_Method): Remove. + (usb_cb_device_reset, usb_cb_ctrl_write_finish) + (usb_cb_setup, usb_cb_get_descriptor, usb_cb_handle_event) + (usb_cb_interface): Define callbacks. + (usb_initial_feature): New. + (struct Descriptor): Move to ... + * src/usb_desc.c: ... here. + (usb_initial_feature): New. + (usb_cb_get_descriptor): Rename from gnuk_get_descriptor and move + from usb_ctrl.c. + + * src/usb_ctrl.c (usb_cb_device_reset): Rename from + gnuk_device_reset. + (usb_cb_setup): Rename from gnuk_setup. + (usb_cb_ctrl_write_finish): Rename from gnuk_ctrl_write_finish. + (usb_cb_event): Rename from gnuk_usb_event. + (usb_cb_interface): Rename from gnuk_interface. + (Device_Method): Remove. + + * src/main.c (main): Use usb_initial_feature. + +2013-02-27 Niibe Yutaka + + * src/usb-icc.c (set_sw1sw2): Arguments are C and CHUNK_LEN. + Fix reporting remaining bytes. + (icc_send_data_block_gr): Follow the arguments change of + set_sw1sw2. + +2013-02-26 Niibe Yutaka + + * regnual/regnual.ld (MEMORY): Fix start address. + + * src/random.c (random_fini): New. + * src/main.c (main): Call random_fini. + +2013-02-25 Niibe Yutaka + + * src/configure: Correct typo in help text. + + * src/gnuk.h (struct key_data_internal): Use uint32_t. + * src/openpgp-do.c (do_openpgpcard_aid): Fix calculation of VID. + (compute_key_data_checksum): Don't use type-punning pointer. + (gpg_do_write_prvkey): Use coercing to char *. + +2013-02-22 Niibe Yutaka + + * src/openpgp-do.c (gpg_do_public_key): Add header of EC point. + + * src/openpgp-do.c (GPG_DO_DISCRETIONARY, cmp_discretionary): New. + (cmp_app_data): Change to factor out GPG_DO_DISCRETIONARY. + (gpg_do_table): Add GPG_DO_DISCRETIONARY. + +2013-02-21 Niibe Yutaka + + * src/gnuk.ld.in (MEMORY): Fix adding FLASH_SIZE unit. + + * src/call-ec_p256.c (ecdsa_sign): Fix secret key access. + +2013-02-20 Niibe Yutaka + + * src/openpgp.c (cmd_internal_authenticate): Support ECDSA for + authentication. + + * src/openpgp-do.c (algorithm_attr_ecdsa): New. + (algorithm_attr_rsa): Rename (was: algorithm_attr). + (gpg_do_table): Change for GPG_DO_ALG_AUT. + (gpg_do_write_prvkey): Support ECDSA key for authentication. + (proc_key_import): Likewise. + (gpg_do_public_key): Likewise. + + * src/call-ec_p256.c: New. + * src/Makefile.in: Add call-ec_p256.c. + * src/call-rsa.c (modulus_free): Remove. + +2013-02-19 Niibe Yutaka + + * regnual/regnual.ld (MEMORY): Fix address of regnual. + + * regnual/Makefile (MCFLAGS): Remove -mfix-cortex-m3-ldrd. + (CFLAGS): Add output to .lst. + * src/Makefile.in (MCFLAGS): Remove. + + * src/sha256.c: Update from NeuG 0.05. + + * ChibiOS_2.0.8: Remove. + +2013-02-18 Niibe Yutaka + + Changes for new ChibiOS/RT. + * src/main.c: Include adc.h. + (main): Call halInit, adc_init, and chSysInit (change for + ChibiOS/RT 2.4.x). + * src/random.h: New. + * src/ac.c, src/bn.c, src/call-rsa.c, src/main.c: Include random.h. + * src/openpgp.c, src/openpgp-do.c: Likewise. + * src/configure, src/gnuk.ld.in: Add MEMORY_SIZE. + * src/ec_p256.c: Fix call of bn256_add_uint. + * boards/STM8S_DISCOVERY/*: Update for ChibiOS/RT 2.4.x. + * boards/CQ_STARM/*: Likewise. + * boards/FST_01_00/*: Likewise. + * boards/OLIMEX_STM32_H103/*: Likewise. + * boards/STBEE/*: Likewise. + * boards/STBEE_MINI/*: Likewise. + * boards/STM32_PRIMER2/*: Likewise. + + Merge ec_p256 branch. + * src/Makefile.in: Add ECC files. + * src/bn.h, src/bn.c: New. + * src/jpc-ac.h, src/jpc.c: New. + * src/ec_p256.h, src/ec_p256.c, src/ecc-cdh.c: New. + * src/mod.h, src/mod.c, src/modp256.h, src/modp256.c: New. + +2013-02-17 Niibe Yutaka + + * chibios: New submodule for ChibioS/RT 2.4.x. + * boards/FST_01/*: Update for ChibiOS/RT 2.4.x. + * boards/common/mcuconf-common.h: Ditto. + + * src/chconf.h, src/halconf.h, src/Makefile.in, src/gnuk.ld.in: + Update for ChibiOS/RT 2.4.x. + + * src/main.c, src/openpgp.c, src/usb-icc.c: Follow the change of + ChibiOS/RT 2.4.x. + * boards/common/board-common.c: Rename from hwinit.c. + * src/usb_stm32f103.c: Rename from usb_lld.c. + + * src/neug.h, src/neug.c: Update NeuG 0.05. + * src/adc_stm32f103.c, src/adc.h: New from NeuG 0.05. + + * src/random.c: Follow the change of NeuG 0.05. diff --git a/doc/note/firmware-update-2 b/doc/note/firmware-update-2 index 90022d8..2f7f026 100644 --- a/doc/note/firmware-update-2 +++ b/doc/note/firmware-update-2 @@ -105,8 +105,8 @@ itself is needed before compiling reGNUal. upgrade_by_passwd.py -------------------- -In the source code distribution of 1.0.4 (or current development -version) of Gnuk, there is a tool named 'upgrade_by_passwd.py'. +Since the source code distribution of 1.0.4 of Gnuk, there is a tool +named 'upgrade_by_passwd.py'. This is an easy tool to hide lengthy steps from user and to allow user firmware upgrade only by password of Gnuk Token. @@ -122,15 +122,11 @@ your environment for Gnuk Token. How to run the script: :: $ cd tool - $ ./upgrade_by_passwd.py ../regnual/regnual.bin ../src/build/gnuk.bin + $ ./upgrade_by_passwd.py Then, the script on your host PC invoke the steps described above, and you will get new version of Gnuk installed. You can also specify -f option to skip entering your password (it assumes the factory setting). - -If you already have configured another upgrade key installed, you can -specify different slot by -k ```` option. SLOT_NO can be 0 -to 3. -- diff --git a/src/Makefile b/src/Makefile index 9c064a7..08f3c68 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,7 +5,7 @@ PROJECT = gnuk CHOPSTX = ../chopstx -CSRC = main.c call-rsa.c \ +CSRC = main.c \ usb_desc.c usb_ctrl.c \ usb-ccid.c openpgp.c ac.c openpgp-do.c flash.c \ bn.c mod.c \ @@ -20,7 +20,7 @@ INCDIR = CRYPTDIR = ../polarssl CRYPTSRCDIR = $(CRYPTDIR)/library CRYPTINCDIR = $(CRYPTDIR)/include -CRYPTSRC = $(CRYPTSRCDIR)/bignum.c $(CRYPTSRCDIR)/rsa.c $(CRYPTSRCDIR)/aes.c +CRYPTSRC = $(CRYPTSRCDIR)/aes.c CSRC += $(CRYPTSRC) INCDIR += $(CRYPTINCDIR) diff --git a/src/call-rsa.c b/src/call-rsa.c deleted file mode 100644 index 57b7c9e..0000000 --- a/src/call-rsa.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * call-rsa.c -- Glue code between RSA computation and OpenPGP card protocol - * - * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2017 - * Free Software Initiative of Japan - * Author: NIIBE Yutaka - * - * This file is a part of Gnuk, a GnuPG USB Token implementation. - * - * Gnuk is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Gnuk is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include -#include - -#include "config.h" - -#include "gnuk.h" -#include "status-code.h" -#include "random.h" -#include "polarssl/config.h" -#include "polarssl/rsa.h" - -static rsa_context rsa_ctx; -static struct chx_cleanup clp; - -static void -rsa_cleanup (void *arg) -{ - (void)arg; - rsa_free (&rsa_ctx); -} - - -int -rsa_sign (const uint8_t *raw_message, uint8_t *output, int msg_len, - struct key_data *kd, int pubkey_len) -{ - mpi P1, Q1, H; - int ret = 0; - unsigned char temp[pubkey_len]; - - rsa_init (&rsa_ctx, RSA_PKCS_V15, 0); - - mpi_init (&P1); mpi_init (&Q1); mpi_init (&H); - - rsa_ctx.len = pubkey_len; - MPI_CHK( mpi_lset (&rsa_ctx.E, 0x10001) ); - MPI_CHK( mpi_read_binary (&rsa_ctx.P, &kd->data[0], pubkey_len / 2) ); - MPI_CHK( mpi_read_binary (&rsa_ctx.Q, &kd->data[pubkey_len / 2], - pubkey_len / 2) ); -#if 0 - MPI_CHK( mpi_mul_mpi (&rsa_ctx.N, &rsa_ctx.P, &rsa_ctx.Q) ); -#endif - MPI_CHK( mpi_sub_int (&P1, &rsa_ctx.P, 1) ); - MPI_CHK( mpi_sub_int (&Q1, &rsa_ctx.Q, 1) ); - MPI_CHK( mpi_mul_mpi (&H, &P1, &Q1) ); - MPI_CHK( mpi_inv_mod (&rsa_ctx.D , &rsa_ctx.E, &H) ); - MPI_CHK( mpi_mod_mpi (&rsa_ctx.DP, &rsa_ctx.D, &P1) ); - MPI_CHK( mpi_mod_mpi (&rsa_ctx.DQ, &rsa_ctx.D, &Q1) ); - MPI_CHK( mpi_inv_mod (&rsa_ctx.QP, &rsa_ctx.Q, &rsa_ctx.P) ); - cleanup: - mpi_free (&P1); mpi_free (&Q1); mpi_free (&H); - if (ret == 0) - { - int cs; - - DEBUG_INFO ("RSA sign..."); - clp.next = NULL; - clp.routine = rsa_cleanup; - clp.arg = NULL; - chopstx_cleanup_push (&clp); - cs = chopstx_setcancelstate (0); /* Allow cancellation. */ - ret = rsa_rsassa_pkcs1_v15_sign (&rsa_ctx, NULL, NULL, - RSA_PRIVATE, SIG_RSA_RAW, - msg_len, raw_message, temp); - memcpy (output, temp, pubkey_len); - chopstx_setcancelstate (cs); - chopstx_cleanup_pop (0); - } - - rsa_free (&rsa_ctx); - if (ret != 0) - { - DEBUG_INFO ("fail:"); - DEBUG_SHORT (ret); - return -1; - } - else - { - DEBUG_INFO ("done.\r\n"); - GPG_SUCCESS (); - return 0; - } -} - -/* - * LEN: length in byte - */ -int -modulus_calc (const uint8_t *p, int len, uint8_t *pubkey) -{ - mpi P, Q, N; - int ret; - - mpi_init (&P); mpi_init (&Q); mpi_init (&N); - MPI_CHK( mpi_read_binary (&P, p, len / 2) ); - MPI_CHK( mpi_read_binary (&Q, p + len / 2, len / 2) ); - MPI_CHK( mpi_mul_mpi (&N, &P, &Q) ); - MPI_CHK( mpi_write_binary (&N, pubkey, len) ); - cleanup: - mpi_free (&P); mpi_free (&Q); mpi_free (&N); - if (ret != 0) - return -1; - - return 0; -} - - -int -rsa_decrypt (const uint8_t *input, uint8_t *output, int msg_len, - struct key_data *kd, unsigned int *output_len_p) -{ - mpi P1, Q1, H; - int ret; -#ifdef GNU_LINUX_EMULATION - size_t output_len; -#endif - - DEBUG_INFO ("RSA decrypt:"); - DEBUG_WORD ((uint32_t)&ret); - - rsa_init (&rsa_ctx, RSA_PKCS_V15, 0); - mpi_init (&P1); mpi_init (&Q1); mpi_init (&H); - - rsa_ctx.len = msg_len; - DEBUG_WORD (msg_len); - - MPI_CHK( mpi_lset (&rsa_ctx.E, 0x10001) ); - MPI_CHK( mpi_read_binary (&rsa_ctx.P, &kd->data[0], msg_len / 2) ); - MPI_CHK( mpi_read_binary (&rsa_ctx.Q, &kd->data[msg_len / 2], msg_len / 2) ); -#if 0 - MPI_CHK( mpi_mul_mpi (&rsa_ctx.N, &rsa_ctx.P, &rsa_ctx.Q) ); -#endif - MPI_CHK( mpi_sub_int (&P1, &rsa_ctx.P, 1) ); - MPI_CHK( mpi_sub_int (&Q1, &rsa_ctx.Q, 1) ); - MPI_CHK( mpi_mul_mpi (&H, &P1, &Q1) ); - MPI_CHK( mpi_inv_mod (&rsa_ctx.D , &rsa_ctx.E, &H) ); - MPI_CHK( mpi_mod_mpi (&rsa_ctx.DP, &rsa_ctx.D, &P1) ); - MPI_CHK( mpi_mod_mpi (&rsa_ctx.DQ, &rsa_ctx.D, &Q1) ); - MPI_CHK( mpi_inv_mod (&rsa_ctx.QP, &rsa_ctx.Q, &rsa_ctx.P) ); - cleanup: - mpi_free (&P1); mpi_free (&Q1); mpi_free (&H); - if (ret == 0) - { - int cs; - - DEBUG_INFO ("RSA decrypt ..."); - clp.next = NULL; - clp.routine = rsa_cleanup; - clp.arg = NULL; - chopstx_cleanup_push (&clp); - cs = chopstx_setcancelstate (0); /* Allow cancellation. */ -#ifdef GNU_LINUX_EMULATION - ret = rsa_rsaes_pkcs1_v15_decrypt (&rsa_ctx, NULL, NULL, - RSA_PRIVATE, &output_len, input, - output, MAX_RES_APDU_DATA_SIZE); - *output_len_p = (unsigned int)output_len; -#else - ret = rsa_rsaes_pkcs1_v15_decrypt (&rsa_ctx, NULL, NULL, - RSA_PRIVATE, output_len_p, input, - output, MAX_RES_APDU_DATA_SIZE); -#endif - chopstx_setcancelstate (cs); - chopstx_cleanup_pop (0); - } - - rsa_free (&rsa_ctx); - if (ret != 0) - { - DEBUG_INFO ("fail:"); - DEBUG_SHORT (ret); - return -1; - } - else - { - DEBUG_INFO ("done.\r\n"); - GPG_SUCCESS (); - return 0; - } -} - -int -rsa_verify (const uint8_t *pubkey, int pubkey_len, - const uint8_t *hash, const uint8_t *sig) -{ - int ret; - - rsa_init (&rsa_ctx, RSA_PKCS_V15, 0); - rsa_ctx.len = pubkey_len; - MPI_CHK( mpi_lset (&rsa_ctx.E, 0x10001) ); - MPI_CHK( mpi_read_binary (&rsa_ctx.N, pubkey, pubkey_len) ); - - DEBUG_INFO ("RSA verify..."); - - MPI_CHK( rsa_rsassa_pkcs1_v15_verify (&rsa_ctx, NULL, NULL, - RSA_PUBLIC, SIG_RSA_SHA256, 32, - hash, sig) ); - cleanup: - rsa_free (&rsa_ctx); - if (ret != 0) - { - DEBUG_INFO ("fail:"); - DEBUG_SHORT (ret); - return -1; - } - else - { - DEBUG_INFO ("verified.\r\n"); - return 0; - } -} - -#define RSA_EXPONENT 0x10001 - -int -rsa_genkey (int pubkey_len, uint8_t *pubkey, uint8_t *p_q) -{ - int ret; - uint8_t index = 0; - uint8_t *p = p_q; - uint8_t *q = p_q + pubkey_len / 2; - int cs; - - extern int prng_seed (int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng); - extern void neug_flush (void); - - neug_flush (); - prng_seed (random_gen, &index); - rsa_init (&rsa_ctx, RSA_PKCS_V15, 0); - - clp.next = NULL; - clp.routine = rsa_cleanup; - clp.arg = NULL; - chopstx_cleanup_push (&clp); - cs = chopstx_setcancelstate (0); /* Allow cancellation. */ - MPI_CHK( rsa_gen_key (&rsa_ctx, random_gen, &index, pubkey_len * 8, - RSA_EXPONENT) ); - MPI_CHK( mpi_write_binary (&rsa_ctx.P, p, pubkey_len / 2) ); - MPI_CHK( mpi_write_binary (&rsa_ctx.Q, q, pubkey_len / 2) ); - MPI_CHK( mpi_write_binary (&rsa_ctx.N, pubkey, pubkey_len) ); - - cleanup: - chopstx_setcancelstate (cs); - chopstx_cleanup_pop (1); - if (ret != 0) - return -1; - else - return 0; -} diff --git a/src/crypt.mk b/src/crypt.mk index 999b774..c0e5e07 100644 --- a/src/crypt.mk +++ b/src/crypt.mk @@ -1,6 +1,5 @@ CRYPTDIR = ../polarssl CRYPTSRCDIR = $(CRYPTDIR)/library CRYPTINCDIR = $(CRYPTDIR)/include -CRYPTSRC = $(CRYPTSRCDIR)/bignum.c $(CRYPTSRCDIR)/rsa.c \ - $(CRYPTSRCDIR)/aes.c \ - sha256.c call-rsa.c +CRYPTSRC = $(CRYPTSRCDIR)/aes.c \ + sha256.c diff --git a/src/flash.c b/src/flash.c index fca70a1..bee5e20 100644 --- a/src/flash.c +++ b/src/flash.c @@ -57,8 +57,6 @@ * _keystore_pool * Three flash pages for keystore * a page contains a key data of: - * For RSA-2048: 512-byte (p, q and N) - * For RSA-4096: 1024-byte (p, q and N) * For ECDSA/ECDH and EdDSA, there are padding after public key * _data_pool * @@ -158,12 +156,6 @@ flash_terminate (void) { int i; -#ifdef FLASH_UPGRADE_SUPPORT - const uint8_t *p; - - p = gpg_get_firmware_update_key (0); - flash_erase_page ((uintptr_t)p); -#endif for (i = 0; i < 3; i++) flash_erase_page ((uintptr_t)flash_key_getpage (i)); flash_erase_page ((uintptr_t)FLASH_ADDR_DATA_STORAGE_START); @@ -711,19 +703,6 @@ flash_write_binary (uint8_t file_id, const uint8_t *data, maxsize = 6; p = &openpgpcard_aid[8]; } -#ifdef FLASH_UPGRADE_SUPPORT - else if (file_id >= FILEID_UPDATE_KEY_0 && file_id <= FILEID_UPDATE_KEY_3) - { - maxsize = FIRMWARE_UPDATE_KEY_CONTENT_LEN; - p = gpg_get_firmware_update_key (file_id - FILEID_UPDATE_KEY_0); - if (len == 0 && offset == 0) - { /* This means removal of update key. */ - if (flash_program_halfword ((uintptr_t)p, 0) != 0) - flash_warning ("DO WRITE ERROR"); - return 0; - } - } -#endif #if defined(CERTDO_SUPPORT) else if (file_id == FILEID_CH_CERTIFICATE) { diff --git a/src/gnuk-malloc.h b/src/gnuk-malloc.h deleted file mode 100644 index e9c55d2..0000000 --- a/src/gnuk-malloc.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Gnuk uses its own malloc functions. - * - * The intention is no-dependency to C library. But, we provide - * malloc and free here, since RSA routines uses malloc/free - * internally. - * - */ - -#include /* NULL and size_t */ - -#define malloc(size) gnuk_malloc (size) -#define free(p) gnuk_free (p) - -void *gnuk_malloc (size_t); -void gnuk_free (void *); diff --git a/src/gnuk.h b/src/gnuk.h index beccc82..f9aab1a 100644 --- a/src/gnuk.h +++ b/src/gnuk.h @@ -112,8 +112,6 @@ void gpg_do_put_data (uint16_t tag, const uint8_t *data, int len); void gpg_do_public_key (uint8_t kk_byte); void gpg_do_keygen (uint8_t *buf); -const uint8_t *gpg_get_firmware_update_key (uint8_t keyno); - /* Constants: algo+size */ #define ALGO_RSA4K 0 /* #define ALGO_NISTP256R1 1 */ @@ -157,10 +155,6 @@ void flash_increment_counter (uint8_t counter_tag_nr); void flash_reset_counter (uint8_t counter_tag_nr); #define FILEID_SERIAL_NO 0 -#define FILEID_UPDATE_KEY_0 1 -#define FILEID_UPDATE_KEY_1 2 -#define FILEID_UPDATE_KEY_2 3 -#define FILEID_UPDATE_KEY_3 4 #define FILEID_CH_CERTIFICATE 5 int flash_erase_binary (uint8_t file_id); int flash_write_binary (uint8_t file_id, const uint8_t *data, @@ -171,8 +165,6 @@ int flash_write_binary (uint8_t file_id, const uint8_t *data, /* Linker set these two symbols */ extern uint8_t ch_certificate_start; -#define FIRMWARE_UPDATE_KEY_CONTENT_LEN 256 /* RSA-2048 (p and q) */ - #define INITIAL_VECTOR_SIZE 16 #define DATA_ENCRYPTION_KEY_SIZE 16 @@ -264,13 +256,6 @@ void put_binary (const char *s, int len); #define DEBUG_BINARY(s,len) #endif -int rsa_sign (const uint8_t *, uint8_t *, int, struct key_data *, int); -int modulus_calc (const uint8_t *, int, uint8_t *); -int rsa_decrypt (const uint8_t *, uint8_t *, int, struct key_data *, - unsigned int *); -int rsa_verify (const uint8_t *, int, const uint8_t *, const uint8_t *); -int rsa_genkey (int, uint8_t *, uint8_t *); - int ecdsa_sign_p256k1 (const uint8_t *hash, uint8_t *output, const uint8_t *key_data); int ecc_compute_public_p256k1 (const uint8_t *key_data, uint8_t *); diff --git a/src/gnuk.ld.in b/src/gnuk.ld.in index 70042c5..255527b 100644 --- a/src/gnuk.ld.in +++ b/src/gnuk.ld.in @@ -141,9 +141,6 @@ SECTIONS . = ALIGN(@FLASH_PAGE_SIZE@); . += 1024; . = ALIGN(@FLASH_PAGE_SIZE@); - _updatekey_store = .; - . += 1024; - . = ALIGN(@FLASH_PAGE_SIZE@); _data_pool = .; KEEP(*(.gnuk_data)) . = ALIGN(@FLASH_PAGE_SIZE@); diff --git a/src/main.c b/src/main.c index a3c2de2..be7a62e 100644 --- a/src/main.c +++ b/src/main.c @@ -294,9 +294,6 @@ calculate_regnual_entry_address (const uint8_t *addr) extern void *ccid_thread (void *arg); -static void gnuk_malloc_init (void); - - extern uint32_t bDeviceState; /* @@ -318,8 +315,6 @@ main (int argc, const char *argv[]) chopstx_conf_idle (1); - gnuk_malloc_init (); - #ifdef GNU_LINUX_EMULATION #define FLASH_IMAGE_NAME ".gnuk-flash-image" @@ -538,189 +533,3 @@ fatal (uint8_t code) _write ("fatal\r\n", 7); for (;;); } - -/* - * Malloc for Gnuk. - * - * Each memory chunk has header with size information. - * The size of chunk is at least 16. - * - * Free memory is managed by FREE_LIST. - * - * When it is managed in FREE_LIST, three pointers, ->NEXT, ->PREV, - * and ->NEIGHBOR is used. NEXT and PREV is to implement doubly - * linked list. NEIGHBOR is to link adjacent memory chunk to be - * reclaimed to system. - */ - -#ifdef GNU_LINUX_EMULATION -#define HEAP_SIZE (32*1024) -uint8_t __heap_base__[HEAP_SIZE]; - -#define HEAP_START __heap_base__ -#define HEAP_END (__heap_base__ + HEAP_SIZE) -#define HEAP_ALIGNMENT 32 -#else -extern uint8_t __heap_base__[]; -extern uint8_t __heap_end__[]; - -#define HEAP_START __heap_base__ -#define HEAP_END (__heap_end__) -#define HEAP_ALIGNMENT 16 -#define HEAP_SIZE ((uintptr_t)__heap_end__ - (uintptr_t)__heap_base__) -#endif - -#define HEAP_ALIGN(n) (((n) + HEAP_ALIGNMENT - 1) & ~(HEAP_ALIGNMENT - 1)) - -static uint8_t *heap_p; -static chopstx_mutex_t malloc_mtx; - -struct mem_head { - uintptr_t size; - /**/ - struct mem_head *next, *prev; /* free list chain */ - struct mem_head *neighbor; /* backlink to neighbor */ -}; - -#define MEM_HEAD_IS_CORRUPT(x) \ - ((x)->size != HEAP_ALIGN((x)->size) || (x)->size > HEAP_SIZE) -#define MEM_HEAD_CHECK(x) if (MEM_HEAD_IS_CORRUPT(x)) fatal (FATAL_HEAP) - -static struct mem_head *free_list; - -static void -gnuk_malloc_init (void) -{ - chopstx_mutex_init (&malloc_mtx); - heap_p = HEAP_START; - free_list = NULL; -} - -static void * -gnuk_sbrk (intptr_t size) -{ - void *p = (void *)heap_p; - - if ((HEAP_END - heap_p) < size) - return NULL; - - heap_p += size; - return p; -} - -static void -remove_from_free_list (struct mem_head *m) -{ - if (m->prev) - m->prev->next = m->next; - else - free_list = m->next; - if (m->next) - m->next->prev = m->prev; -} - - -void * -gnuk_malloc (size_t size) -{ - struct mem_head *m; - struct mem_head *m0; - - size = HEAP_ALIGN (size + sizeof (uintptr_t)); - - chopstx_mutex_lock (&malloc_mtx); - DEBUG_INFO ("malloc: "); - DEBUG_SHORT (size); - m = free_list; - - while (1) - { - if (m == NULL) - { - m = (struct mem_head *)gnuk_sbrk (size); - if (m) - m->size = size; - break; - } - MEM_HEAD_CHECK (m); - if (m->size == size) - { - remove_from_free_list (m); - m0 = free_list; - while (m0) - if (m0->neighbor == m) - m0->neighbor = NULL; - else - m0 = m0->next; - break; - } - - m = m->next; - } - - chopstx_mutex_unlock (&malloc_mtx); - if (m == NULL) - { - DEBUG_WORD (0); - return m; - } - else - { - DEBUG_WORD ((uintptr_t)m + sizeof (uintptr_t)); - return (void *)m + sizeof (uintptr_t); - } -} - - -void -gnuk_free (void *p) -{ - struct mem_head *m = (struct mem_head *)((void *)p - sizeof (uintptr_t)); - struct mem_head *m0; - - if (p == NULL) - return; - - chopstx_mutex_lock (&malloc_mtx); - m0 = free_list; - DEBUG_INFO ("free: "); - DEBUG_SHORT (m->size); - DEBUG_WORD ((uintptr_t)p); - - MEM_HEAD_CHECK (m); - m->neighbor = NULL; - while (m0) - { - MEM_HEAD_CHECK (m0); - if ((void *)m + m->size == (void *)m0) - m0->neighbor = m; - else if ((void *)m0 + m0->size == (void *)m) - m->neighbor = m0; - - m0 = m0->next; - } - - if ((void *)m + m->size == heap_p) - { - struct mem_head *mn = m->neighbor; - - heap_p -= m->size; - while (mn) - { - MEM_HEAD_CHECK (mn); - heap_p -= mn->size; - remove_from_free_list (mn); - mn = mn->neighbor; - } - } - else - { - m->next = free_list; - m->prev = NULL; - if (free_list) - free_list->prev = m; - free_list = m; - } - - chopstx_mutex_unlock (&malloc_mtx); -} diff --git a/src/openpgp-do.c b/src/openpgp-do.c index d532d05..b2f3492 100644 --- a/src/openpgp-do.c +++ b/src/openpgp-do.c @@ -2,7 +2,7 @@ * openpgp-do.c -- OpenPGP card Data Objects (DO) handling * * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, - * 2020, 2021 + * 2020, 2021, 2022 * Free Software Initiative of Japan * Author: NIIBE Yutaka * @@ -146,7 +146,6 @@ static const uint8_t feature_mngmnt[] __attribute__ ((aligned (1))) = { #endif /* Algorithm Attributes */ -#define OPENPGP_ALGO_RSA 0x01 #define OPENPGP_ALGO_ECDH 0x12 #define OPENPGP_ALGO_ECDSA 0x13 #define OPENPGP_ALGO_EDDSA 0x16 /* It catches 22, finally. */ @@ -165,22 +164,6 @@ static const uint8_t algorithm_attr_x448[] __attribute__ ((aligned (1))) = { 0x2b, 0x65, 0x6f }; -static const uint8_t algorithm_attr_rsa2k[] __attribute__ ((aligned (1))) = { - 6, - OPENPGP_ALGO_RSA, - 0x08, 0x00, /* Length modulus (in bit): 2048 */ - 0x00, 0x20, /* Length exponent (in bit): 32 */ - 0x00 /* 0: Acceptable format is: P and Q */ -}; - -static const uint8_t algorithm_attr_rsa4k[] __attribute__ ((aligned (1))) = { - 6, - OPENPGP_ALGO_RSA, - 0x10, 0x00, /* Length modulus (in bit): 4096 */ - 0x00, 0x20, /* Length exponent (in bit): 32 */ - 0x00 /* 0: Acceptable format is: P and Q */ -}; - static const uint8_t algorithm_attr_p256k1[] __attribute__ ((aligned (1))) = { 6, OPENPGP_ALGO_ECDSA, @@ -264,7 +247,12 @@ gpg_get_algo_attr (enum kind_of_key kk) const uint8_t *algo_attr_p = *get_algo_attr_pointer (kk); if (algo_attr_p == NULL) - return ALGO_RSA2K; + { + if (kk == GPG_KEY_FOR_DECRYPTION) + return ALGO_CURVE25519; + else + return ALGO_ED25519; + } return algo_attr_p[1]; } @@ -297,12 +285,15 @@ get_algo_attr_data_object (enum kind_of_key kk) const uint8_t *algo_attr_p = *get_algo_attr_pointer (kk); if (algo_attr_p == NULL) - return algorithm_attr_rsa2k; + { + if (kk == GPG_KEY_FOR_DECRYPTION) + return algorithm_attr_cv25519; + else + return algorithm_attr_ed25519; + } switch (algo_attr_p[1]) { - case ALGO_RSA4K: - return algorithm_attr_rsa4k; case ALGO_SECP256K1: return algorithm_attr_p256k1; case ALGO_CURVE25519: @@ -314,7 +305,7 @@ get_algo_attr_data_object (enum kind_of_key kk) case ALGO_X448: return algorithm_attr_x448; default: - return algorithm_attr_rsa2k; + return algorithm_attr_ed25519; } } @@ -323,16 +314,16 @@ gpg_get_algo_attr_key_size (enum kind_of_key kk, enum size_of_key s) { const uint8_t *algo_attr_p = *get_algo_attr_pointer (kk); - if (algo_attr_p == NULL) /* RSA-2048 */ - goto rsa2k; + if (algo_attr_p == NULL) + { + if (kk == GPG_KEY_FOR_DECRYPTION) + goto cv25519; + else + goto ed25519; + } switch (algo_attr_p[1]) { - case ALGO_RSA4K: - if (s == GPG_KEY_STORAGE) - return 1024; - else - return 512; case ALGO_SECP256K1: if (s == GPG_KEY_STORAGE) return 128; @@ -340,18 +331,12 @@ gpg_get_algo_attr_key_size (enum kind_of_key kk, enum size_of_key s) return 64; else return 32; + cv25519: case ALGO_CURVE25519: if (s == GPG_KEY_STORAGE) return 64; else return 32; - case ALGO_ED25519: - if (s == GPG_KEY_STORAGE) - return 128; - else if (s == GPG_KEY_PUBLIC) - return 32; - else - return 64; case ALGO_ED448: if (s == GPG_KEY_STORAGE) return 256; @@ -364,12 +349,15 @@ gpg_get_algo_attr_key_size (enum kind_of_key kk, enum size_of_key s) return 112; else return 56; + ed25519: default: - rsa2k: + case ALGO_ED25519: if (s == GPG_KEY_STORAGE) - return 512; + return 128; + else if (s == GPG_KEY_PUBLIC) + return 32; else - return 256; + return 64; } } @@ -733,8 +721,6 @@ do_alg_info (uint16_t tag, int with_tag) { uint16_t tag_algo = GPG_DO_ALG_SIG + i; - copy_do_1 (tag_algo, algorithm_attr_rsa2k, 1); - copy_do_1 (tag_algo, algorithm_attr_rsa4k, 1); copy_do_1 (tag_algo, algorithm_attr_p256k1, 1); if (i == 0 || i == 2) { @@ -823,11 +809,7 @@ rw_algorithm_attr (uint16_t tag, int with_tag, } if (len == 6) { - if (memcmp (data, algorithm_attr_rsa2k+1, 6) == 0) - algo = ALGO_RSA2K; - else if (memcmp (data, algorithm_attr_rsa4k+1, 6) == 0) - algo = ALGO_RSA4K; - else if ((tag != GPG_DO_ALG_DEC + if ((tag != GPG_DO_ALG_DEC && memcmp (data, algorithm_attr_p256k1+1, 6) == 0) || (tag == GPG_DO_ALG_DEC && data[0]==OPENPGP_ALGO_ECDH && memcmp (data+1, algorithm_attr_p256k1+2, 5) == 0)) @@ -840,7 +822,7 @@ rw_algorithm_attr (uint16_t tag, int with_tag, if (algo < 0) return 0; /* Error. */ - else if (algo == ALGO_RSA2K && *algo_attr_pp != NULL) + else if (algo == ALGO_ED25519 && *algo_attr_pp != NULL) { gpg_reset_algo_attr (kk); /* Read it again, since GC may occur. */ @@ -849,7 +831,7 @@ rw_algorithm_attr (uint16_t tag, int with_tag, if (*algo_attr_pp != NULL) return 0; } - else if ((algo != ALGO_RSA2K && *algo_attr_pp == NULL) || + else if ((algo != ALGO_ED25519 && *algo_attr_pp == NULL) || (*algo_attr_pp != NULL && (*algo_attr_pp)[1] != algo)) { gpg_reset_algo_attr (kk); @@ -1239,7 +1221,7 @@ struct key_data_internal { uint32_t data[(MAX_PRVKEY_LEN+DATA_ENCRYPTION_KEY_SIZE) / sizeof (uint32_t)]; /* * Secret key data. - * RSA: p and q, ECDSA/ECDH: d, EdDSA: a+seed + * ECDSA/ECDH: d, EdDSA: a+seed */ /* Checksum */ }; @@ -1444,14 +1426,8 @@ gpg_do_write_prvkey (enum kind_of_key kk, const uint8_t *key_data, if (prvkey_len != 56) return -1; } - else /* RSA */ - { - int key_size = gpg_get_algo_attr_key_size (kk, GPG_KEY_STORAGE); - - pubkey_len = prvkey_len; - if (prvkey_len + pubkey_len != key_size) - return -1; - } + else + return -1; DEBUG_INFO ("Getting keystore address...\r\n"); key_addr = flash_key_alloc (kk); @@ -1620,26 +1596,6 @@ kkb_to_kk (uint8_t kk_byte) } /* - * RSA-2048: - * 4d, xx, xx, xx: Extended Header List - * b6 00 (SIG) / b8 00 (DEC) / a4 00 (AUT) - * 7f48, xx: cardholder private key template - * 91 L: 91=tag of E, L: length of E - * 92 Lh

Ll

: 92=tag of P, L

: length of P - * 93 Lh Ll: 93=tag of Q, L: length of Q - * 5f48, xx xx xx: cardholder private key - * , , - * - * RSA-4096: - * 4d, 82, 02, 18: Extended Header List - * b6 00 (SIG) / b8 00 (DEC) / a4 00 (AUT) - * 7f48, 0a: cardholder private key template - * 91 L: 91=tag of E, L: length of E - * 92 82 Lh

Ll

: 92=tag of P, L

: length of P - * 93 82 Lh Ll: 93=tag of Q, L: length of Q - * 5f48, 82 02 04: cardholder private key - * , , - * * ECDSA / ECDH / EdDSA: * 4d, 2a: Extended Header List * b6 00 (SIG) / b8 00 (DEC) / a4 00 (AUT) @@ -1696,30 +1652,13 @@ proc_key_import (const uint8_t *data, int len) if ((len <= 12 && (attr == ALGO_SECP256K1 || attr == ALGO_CURVE25519 || attr == ALGO_ED25519 || attr == ALGO_ED448 - || attr == ALGO_X448)) - || (len <= 22 && attr == ALGO_RSA2K) || (len <= 24 && attr == ALGO_RSA4K)) + || attr == ALGO_X448))) { /* Deletion of the key */ gpg_do_delete_prvkey (kk, CLEAN_SINGLE); return 1; } - if (attr == ALGO_RSA2K) - { - /* It should starts with 00 01 00 01 (E), skiping E (4-byte) */ - r = modulus_calc (&data[26], len - 26, pubkey); - if (r >= 0) - r = gpg_do_write_prvkey (kk, &data[26], len - 26, keystring_admin, - pubkey); - } - else if (attr == ALGO_RSA4K) - { - /* It should starts with 00 01 00 01 (E), skiping E (4-byte) */ - r = modulus_calc (&data[28], len - 28, pubkey); - if (r >= 0) - r = gpg_do_write_prvkey (kk, &data[28], len - 28, keystring_admin, - pubkey); - } - else if (attr == ALGO_SECP256K1) + if (attr == ALGO_SECP256K1) { r = ecc_compute_public_p256k1 (&data[12], pubkey); if (r >= 0) @@ -2355,7 +2294,6 @@ gpg_do_public_key (uint8_t kk_byte) { enum kind_of_key kk = kkb_to_kk (kk_byte); int attr = gpg_get_algo_attr (kk); - int pubkey_len = gpg_get_algo_attr_key_size (kk, GPG_KEY_PUBLIC); const uint8_t *pubkey = kd[kk].pubkey; DEBUG_INFO ("Public key\r\n"); @@ -2423,24 +2361,9 @@ gpg_do_public_key (uint8_t kk_byte) } } else - { /* RSA */ - /* LEN = 9+256or512 */ - *res_p++ = 0x82; *res_p++ = pubkey_len > 256? 0x02: 0x01; *res_p++ = 0x09; - - { - /*TAG*/ /* LEN = 256or512 */ - *res_p++ = 0x81; - *res_p++ = 0x82; *res_p++ = pubkey_len > 256? 0x02: 0x01;*res_p++ = 0x00; - /* PUBKEY_LEN-byte binary (big endian) */ - memcpy (res_p, pubkey, pubkey_len); - res_p += pubkey_len; - } - { - /*TAG*/ /* LEN= 3 */ - *res_p++ = 0x82; *res_p++ = 3; - /* 3-byte E=0x10001 (big endian) */ - *res_p++ = 0x01; *res_p++ = 0x00; *res_p++ = 0x01; - } + { + GPG_CONDITION_NOT_SATISFIED (); + return; } /* Success */ @@ -2501,17 +2424,7 @@ gpg_do_keygen (uint8_t *buf) DEBUG_INFO ("Keygen\r\n"); DEBUG_BYTE (kk_byte); - if (attr == ALGO_RSA2K || attr == ALGO_RSA4K) - { - if (rsa_genkey (prvkey_len, pubkey, p_q) < 0) - { - GPG_MEMORY_FAILURE (); - return; - } - - prv = p_q; - } - else if (attr == ALGO_SECP256K1) + if (attr == ALGO_SECP256K1) { const uint8_t *p; int i; diff --git a/src/openpgp.c b/src/openpgp.c index 4213218..a850950 100644 --- a/src/openpgp.c +++ b/src/openpgp.c @@ -2,7 +2,7 @@ * openpgp.c -- OpenPGP card protocol support * * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 - * 2019, 2021 + * 2019, 2021, 2022 * Free Software Initiative of Japan * Author: NIIBE Yutaka * @@ -64,8 +64,6 @@ static struct eventflag *openpgp_comm; #define INS_PUT_DATA_ODD 0xdb /* For key import */ #define INS_TERMINATE_DF 0xe6 -static const uint8_t *challenge; /* Random bytes */ - static const uint8_t select_file_TOP_result[] __attribute__ ((aligned (1))) = { 0x00, 0x00, /* unused */ @@ -747,18 +745,6 @@ cmd_pgp_gakp (struct eventflag *ccid_comm) } } -#ifdef FLASH_UPGRADE_SUPPORT -const uint8_t * -gpg_get_firmware_update_key (uint8_t keyno) -{ - extern uint8_t _updatekey_store[1024]; - const uint8_t *p; - - p = _updatekey_store + keyno * FIRMWARE_UPDATE_KEY_CONTENT_LEN; - return p; -} -#endif - #ifdef CERTDO_SUPPORT #define FILEID_CH_CERTIFICATE_IS_VALID 1 #else @@ -799,22 +785,6 @@ cmd_read_binary (struct eventflag *ccid_comm) } return; } -#ifdef FLASH_UPGRADE_SUPPORT - else if (file_id >= FILEID_UPDATE_KEY_0 && file_id <= FILEID_UPDATE_KEY_3) - { - if (offset != 0) - GPG_MEMORY_FAILURE (); - else - { - const uint8_t *p; - - p = gpg_get_firmware_update_key (file_id - FILEID_UPDATE_KEY_0); - res_APDU_size = FIRMWARE_UPDATE_KEY_CONTENT_LEN; - memcpy (res_APDU, p, FIRMWARE_UPDATE_KEY_CONTENT_LEN); - GPG_SUCCESS (); - } - } -#endif #if defined(CERTDO_SUPPORT) else if (file_id == FILEID_CH_CERTIFICATE) { @@ -939,7 +909,6 @@ cmd_pso (struct eventflag *ccid_comm) int len = apdu.cmd_apdu_data_len; int r = -1; int attr; - int pubkey_len; unsigned int result_len = 0; int cs; @@ -951,9 +920,6 @@ cmd_pso (struct eventflag *ccid_comm) if (P1 (apdu) == 0x9e && P2 (apdu) == 0x9a) { attr = gpg_get_algo_attr (GPG_KEY_FOR_SIGNING); - pubkey_len = gpg_get_algo_attr_key_size (GPG_KEY_FOR_SIGNING, - GPG_KEY_PUBLIC); - if (!ac_check_status (AC_PSO_CDS_AUTHORIZED)) { DEBUG_INFO ("security error."); @@ -966,28 +932,7 @@ cmd_pso (struct eventflag *ccid_comm) eventflag_signal (ccid_comm, EV_EXEC_ACK_REQUIRED); #endif - if (attr == ALGO_RSA2K || attr == ALGO_RSA4K) - { - /* Check size of digestInfo */ - if (len != 34 /* MD5 */ - && len != 35 /* SHA1 / RIPEMD-160 */ - && len != 47 /* SHA224 */ - && len != 51 /* SHA256 */ - && len != 67 /* SHA384 */ - && len != 83) /* SHA512 */ - { - DEBUG_INFO (" wrong length"); - GPG_CONDITION_NOT_SATISFIED (); - return; - } - - DEBUG_BINARY (kd[GPG_KEY_FOR_SIGNING].data, pubkey_len); - - result_len = pubkey_len; - r = rsa_sign (apdu.cmd_apdu_data, res_APDU, len, - &kd[GPG_KEY_FOR_SIGNING], pubkey_len); - } - else if (attr == ALGO_SECP256K1) + if (attr == ALGO_SECP256K1) { /* ECDSA with p256r1/p256k1 for signature */ if (len != ECDSA_HASH_LEN) @@ -1044,11 +989,6 @@ cmd_pso (struct eventflag *ccid_comm) else if (P1 (apdu) == 0x80 && P2 (apdu) == 0x86) { attr = gpg_get_algo_attr (GPG_KEY_FOR_DECRYPTION); - pubkey_len = gpg_get_algo_attr_key_size (GPG_KEY_FOR_DECRYPTION, - GPG_KEY_PUBLIC); - - DEBUG_BINARY (kd[GPG_KEY_FOR_DECRYPTION].data, pubkey_len); - if (!ac_check_status (AC_OTHER_AUTHORIZED)) { DEBUG_INFO ("security error."); @@ -1063,19 +1003,7 @@ cmd_pso (struct eventflag *ccid_comm) (void)ccid_comm; #endif - if (attr == ALGO_RSA2K || attr == ALGO_RSA4K) - { - /* Skip padding 0x00 */ - len--; - if (len != pubkey_len) - { - GPG_CONDITION_NOT_SATISFIED (); - return; - } - r = rsa_decrypt (apdu.cmd_apdu_data+1, res_APDU, len, - &kd[GPG_KEY_FOR_DECRYPTION], &result_len); - } - else if (attr == ALGO_SECP256K1) + if (attr == ALGO_SECP256K1) { int header = ECC_CIPHER_DO_HEADER_SIZE; @@ -1149,13 +1077,10 @@ cmd_pso (struct eventflag *ccid_comm) } -#define MAX_RSA_DIGEST_INFO_LEN 102 /* 40% */ static void cmd_internal_authenticate (struct eventflag *ccid_comm) { int attr = gpg_get_algo_attr (GPG_KEY_FOR_AUTHENTICATION); - int pubkey_len = gpg_get_algo_attr_key_size (GPG_KEY_FOR_AUTHENTICATION, - GPG_KEY_PUBLIC); int len = apdu.cmd_apdu_data_len; int r = -1; unsigned int result_len = 0; @@ -1188,20 +1113,7 @@ cmd_internal_authenticate (struct eventflag *ccid_comm) (void)ccid_comm; #endif - if (attr == ALGO_RSA2K || attr == ALGO_RSA4K) - { - if (len > MAX_RSA_DIGEST_INFO_LEN) - { - DEBUG_INFO ("input is too long."); - GPG_CONDITION_NOT_SATISFIED (); - return; - } - - result_len = pubkey_len; - r = rsa_sign (apdu.cmd_apdu_data, res_APDU, len, - &kd[GPG_KEY_FOR_AUTHENTICATION], pubkey_len); - } - else if (attr == ALGO_SECP256K1) + if (attr == ALGO_SECP256K1) { if (len != ECDSA_HASH_LEN) { @@ -1324,28 +1236,6 @@ modify_binary (uint8_t op, uint8_t p1, uint8_t p2, int len) return; } -#ifdef FLASH_UPGRADE_SUPPORT - if (file_id >= FILEID_UPDATE_KEY_0 && file_id <= FILEID_UPDATE_KEY_3 - && len == 0 && offset == 0) - { - int i; - const uint8_t *p; - - for (i = 0; i < 4; i++) - { - p = gpg_get_firmware_update_key (i); - if (p[0] != 0x00 || p[1] != 0x00) /* still valid */ - break; - } - - if (i == 4) /* all update keys are removed */ - { - p = gpg_get_firmware_update_key (0); - flash_erase_page ((uintptr_t)p); - } - } -#endif - GPG_SUCCESS (); } @@ -1380,36 +1270,10 @@ cmd_write_binary (struct eventflag *ccid_comm) static void cmd_external_authenticate (struct eventflag *ccid_comm) { - const uint8_t *pubkey; - const uint8_t *signature = apdu.cmd_apdu_data; - int len = apdu.cmd_apdu_data_len; - uint8_t keyno = P2 (apdu); - int r; - (void)ccid_comm; DEBUG_INFO (" - EXTERNAL AUTHENTICATE\r\n"); - if (keyno >= 4) - { - GPG_CONDITION_NOT_SATISFIED (); - return; - } - - pubkey = gpg_get_firmware_update_key (keyno); - if (len != 256 - || (pubkey[0] == 0xff && pubkey[1] == 0xff) /* not registered */ - || (pubkey[0] == 0x00 && pubkey[1] == 0x00) /* removed */) - { - GPG_CONDITION_NOT_SATISFIED (); - return; - } - - r = rsa_verify (pubkey, FIRMWARE_UPDATE_KEY_CONTENT_LEN, - challenge, signature); - random_bytes_free (challenge); - challenge = NULL; - - if (r < 0) + if (!ac_check_status (AC_ADMIN_AUTHORIZED)) { GPG_SECURITY_FAILURE (); return; @@ -1425,6 +1289,7 @@ static void cmd_get_challenge (struct eventflag *ccid_comm) { int len = apdu.expected_res_size; + const uint8_t *challenge; (void)ccid_comm; DEBUG_INFO (" - GET CHALLENGE\r\n"); @@ -1438,9 +1303,6 @@ cmd_get_challenge (struct eventflag *ccid_comm) /* Le is not specified. Return full-sized challenge by GET_RESPONSE. */ len = CHALLENGE_LEN; - if (challenge) - random_bytes_free (challenge); - #ifdef ACKBTN_SUPPORT if (gpg_do_get_uif (GPG_KEY_FOR_SIGNING) || gpg_do_get_uif (GPG_KEY_FOR_DECRYPTION) @@ -1450,6 +1312,7 @@ cmd_get_challenge (struct eventflag *ccid_comm) challenge = random_bytes_get (); memcpy (res_APDU, challenge, len); + random_bytes_free (challenge); res_APDU_size = len; GPG_SUCCESS (); DEBUG_INFO ("GET CHALLENGE done.\r\n"); @@ -1488,13 +1351,13 @@ cmd_terminate_df (struct eventflag *ccid_comm) if (p1 != 0 || p2 != 0) { - GPG_BAD_P1_P2(); + GPG_BAD_P1_P2 (); return; } if (apdu.cmd_apdu_data_len != 0) { - GPG_WRONG_LENGTH(); + GPG_WRONG_LENGTH (); return; } @@ -1505,7 +1368,7 @@ cmd_terminate_df (struct eventflag *ccid_comm) || (ks_pw3 == NULL && gpg_pw_locked (PW_ERR_PW1)))) { /* Only allow the case admin authorized, or, admin pass is locked. */ - GPG_SECURITY_FAILURE(); + GPG_SECURITY_FAILURE (); return; } diff --git a/tests/rsa-aut.key b/tests/rsa-aut.key deleted file mode 100644 index cdf2d5e..0000000 --- a/tests/rsa-aut.key +++ /dev/null @@ -1,4 +0,0 @@ -9cf7192b51a574d1ad3ccb08ba09b87f228573893eee355529ff243e90fd4b86f79a82097cc7922c0485bed1616b1656a9b0b19ef78ea8ec34c384019adc5d5bf4db2d2a0a2d9cf14277bdcb7056f48b81214e3f7f7742231e29673966f9b1106862112cc798dba8d4a138bb5abfc6d4c12d53a5d39b2f783da916da20852ee139bbafda61d429caf2a4f30847ce7e7ae32ab4061e27dd9e4d00d60910249db8d8559dd85f7ca59659ef400c8f6318700f4e97f0c6f4165de80641490433c88da8682befe68eb311f54af2b07d97ac74edb5399cf054764211694fbb8d1d333f3269f235abe025067f811ff83a2224826219b309ea3e6c968f42b3e52f245dc9 -010001 -b5ab7b159220b18e363258f61ebde08bae83d6ce2dbfe4adc143628c527887acde9de09bf9b49f438019004d71855f30c2d69b6c29bb9882ab641b3387409fe9199464a7faa4b5230c56d9e17cd9ed074bc00180ebed62bae3af28e6ff2ac2654ad968834c5d5c88f8d9d3cc5e167b10453b049d4e454a5761fb0ac717185907 -dd2fffa9814296156a6926cd17b65564187e424dcadce9b032246ad7e46448bb0f9e0ff3c64f987424b1a40bc694e2e9ac4fb1930d163582d7acf20653a1c44b97846c1c5fd8a7b19bb225fb39c30e25410483deaf8c2538d222b748c4d8103b11cec04f666a5c0dbcbf5d5f625f158f65746c3fafe6418145f7cffa5fadeeaf diff --git a/tests/rsa-dec.key b/tests/rsa-dec.key deleted file mode 100644 index 8c2aa47..0000000 --- a/tests/rsa-dec.key +++ /dev/null @@ -1,4 +0,0 @@ -d392714c29738aac6372f2c8654a08c25a1299fed7004bd512cd2452b503ebad6301130816ac525ba528dc155be6347a5c70407fb4fbdaed751dfc0a7cd5e3910272ff236c4ed1ce5de6620b191a172e5b247347b8cab73a43d79221708755c959a2f83f486439da30917384554331532aabc8326db48866f8c91198834a86ab94679f6175db737bdf399e3f0b737dcb1f4208279d3e1cc694e78686785e4f363a377dec912b7c2f757b1422d866fb9fa85c96b83adfd6a223989a9a02988bdee81ad17eff6385e7b38cec8611fdf367ba4ac8e90d5f48ac7715c5f47aea06a4a37cdaa3029ce59d29bc66853bf6758ef4a7da5a5953f5e557a5a22f67c368c3 -010001 -dae085952c5beee38f25f09bc37a4ca2434c31f78055469d0d5f0bf3337e3a70ba6c91734f195b742e211a5fe283befdf66820008e6ef2c8ca54a91922838fce07d9e33a331ce20dac36803e777d5ee2195ed28d6a4045e28623a6a60b0661e45f7c4f84ae2b1dfad0cf1ec30605158323382a819e730c09a33fad704dd67501 -f774be43ea198aa2f089274e4fffd7d0092ee7b35a1d2f854cdb166f698caab72fdeb099e690e78438b2e043e452d4d2f19d7f44ba6b286642f0ce5204966ff98ecd9e3b448877324631365dc860797429b9414a21a7e166d504cace156588b9a145657eeb1afb43b8ff65d8d6d93cea2ba4ef8aab047885c4de64ffef0b49c3 diff --git a/tests/rsa-sig.key b/tests/rsa-sig.key deleted file mode 100644 index c83179a..0000000 --- a/tests/rsa-sig.key +++ /dev/null @@ -1,4 +0,0 @@ -c6c877dfd3b441f8fb1b8dc504093a51c2efe4883fe0a6379205acc6e673709905e4d767ddf46143c535cc6d7f10b616f520d8346320ef69ff4a2c4f4a148edc65f7ad24ed7d4fe23bb862a0ae71f4f7904abac0397abf3213df91326b1a25554b3b18cf54584d8bf220169fc92b2aa511e8313983e72b4c9110b3a1aea087aebef95873865608e8faea9ef10e7f7f3a66ca8def2d499c3149c127491e0e4339fd6abe10bfc6c13e43d522004f1485767328eabe35d6ffa8df4c15f0fbcd4eb1c07cc6d85e275139ac69e2962273ae987236926dd6c1144fce3e7ae567fa58ea60620dfafc52f95299fea601739fce27ee71eea978d0074f21e7086f60ba8331 -010001 -cc365b5702714bf203e8c49b0b8afa8dad586e929cf5edca38ad07fa45efd5c2d89022d29f40283a57e50ca24c5f28c8e911a74faaf796f112e7e48195956f9a4df7668a5342523b27179cec958f363211ee11d0ec0e0e1b92ca007a61e8c9ac14e00229b9a7624850199e6667afa1a44db8f3c5de0a8eef0e6de050ac0ac633 -f931a3c12f0e3a5276f712b7706590ba02e14a97ff9b8ce3152af0fc4d9cdc690ea9bc4c82cb16c7d23136cbdab58fbec69880a88bca85c4214df01045082cbe9f4192e3e39c79896533c37dad9eb9e73c2643b9c0a704a4f93d81573537963d6b6e5140a24c702d9f26e06a2095de906daa8824172a6b39f563b7153907050b diff --git a/tool/gnuk_token.py b/tool/gnuk_token.py index 27082e3..2c44750 100644 --- a/tool/gnuk_token.py +++ b/tool/gnuk_token.py @@ -468,14 +468,8 @@ class gnuk_token(object): raise ValueError("%02x%02x" % (sw[0], sw[1])) return self.cmd_get_response(sw[1]) - def cmd_external_authenticate(self, keyno, signed): - cmd_data = iso7816_compose(0x82, 0x00, keyno, signed[0:128], cls=0x10) - sw = self.icc_send_cmd(cmd_data) - if len(sw) != 2: - raise ValueError(sw) - if not (sw[0] == 0x90 and sw[1] == 0x00): - raise ValueError("%02x%02x" % (sw[0], sw[1])) - cmd_data = iso7816_compose(0x82, 0x00, keyno, signed[128:]) + def cmd_external_authenticate(self): + cmd_data = iso7816_compose(0x82, 0x00, 0x00, b"", cls=0x10) sw = self.icc_send_cmd(cmd_data) if len(sw) != 2: raise ValueError(sw) diff --git a/tool/gnuk_upgrade.py b/tool/gnuk_upgrade.py index 02dab0e..b813489 100755 --- a/tool/gnuk_upgrade.py +++ b/tool/gnuk_upgrade.py @@ -3,7 +3,8 @@ """ gnuk_upgrade.py - a tool to upgrade firmware of Gnuk Token -Copyright (C) 2012, 2015, 2021 Free Software Initiative of Japan +Copyright (C) 2012, 2015, 2021, 2022 + Free Software Initiative of Japan Author: NIIBE Yutaka This file is a part of Gnuk, a GnuPG USB Token implementation. @@ -35,42 +36,7 @@ from gnuk_token import * from subprocess import check_output -SHA256_OID_PREFIX="3031300d060960864801650304020105000420" - -# When user specify KEYGRIP, use it. Or else, connect to SCD directly. -def gpg_sign(keygrip, hash): - if keygrip: - result = check_output(["gpg-connect-agent", - "SIGKEY %s" % keygrip, - "SETHASH --hash=sha256 %s" % hash, - "PKSIGN --hash=sha256", "/bye"]) - else: - result = check_output(["gpg-connect-agent", - "SCD SETDATA " + SHA256_OID_PREFIX + hash, - "SCD PKAUTH OPENPGP.3", - "/bye"]) - signed = "" - while True: - i = result.find('%') - if i < 0: - signed += result - break - hex_str = result[i+1:i+3] - signed += result[0:i] - signed += chr(int(hex_str,16)) - result = result[i+3:] - - if keygrip: - pos = signed.index("D (7:sig-val(3:rsa(1:s256:") + 26 - signed = signed[pos:-7] - else: - pos = signed.index("D ") + 2 - signed = signed[pos:-4] # \nOK\n - if len(signed) != 256: - raise ValueError(binascii.hexlify(signed)) - return signed - -def main(keyno, keygrip, data_regnual, data_upgrade): +def main(data_regnual, data_upgrade): l = len(data_regnual) if (l & 0x03) != 0: data_regnual = data_regnual.ljust(l + 4 - (l & 0x03), b'\x00') @@ -91,9 +57,7 @@ def main(keyno, keygrip, data_regnual, data_upgrade): elif icc.icc_get_status() == 1: icc.icc_power_on() icc.cmd_select_openpgp() - challenge = icc.cmd_get_challenge().tobytes() - signed = gpg_sign(keygrip, binascii.hexlify(challenge)) - icc.cmd_external_authenticate(keyno, signed) + icc.cmd_external_authenticate() icc.stop_gnuk() mem_info = icc.mem_info() print("%08x:%08x" % mem_info) @@ -131,12 +95,6 @@ def main(keyno, keygrip, data_regnual, data_upgrade): if __name__ == '__main__': - keyno = 0 - keygrip = None - if sys.argv[1] == '-k': - sys.argv.pop(1) - keygrip = sys.argv[1] - sys.argv.pop(1) filename_regnual = sys.argv[1] filename_upgrade = sys.argv[2] f = open(filename_regnual, "rb") @@ -147,4 +105,4 @@ if __name__ == '__main__': data_upgrade = f.read() f.close() print("%s: %d" % (filename_upgrade, len(data_upgrade))) - main(keyno, keygrip, data_regnual, data_upgrade[4096:]) + main(data_regnual, data_upgrade[4096:]) diff --git a/tool/upgrade_by_passwd.py b/tool/upgrade_by_passwd.py index 00ca4e2..d1a88d4 100755 --- a/tool/upgrade_by_passwd.py +++ b/tool/upgrade_by_passwd.py @@ -4,7 +4,7 @@ upgrade_by_passwd.py - a tool to install another firmware for Gnuk Token which is just shipped from factory -Copyright (C) 2012, 2013, 2015, 2018, 2021 +Copyright (C) 2012, 2013, 2015, 2018, 2021, 2022 Free Software Initiative of Japan Author: NIIBE Yutaka @@ -29,15 +29,12 @@ from gnuk_token import get_gnuk_device, gnuk_devices_by_vidpid, \ from kdf_calc import kdf_calc import sys, binascii, time, os -import rsa from struct import pack DEFAULT_PW3 = "12345678" BY_ADMIN = 3 -KEYNO_FOR_AUTH=2 - -def main(wait_e, keyno, passwd, data_regnual, data_upgrade): +def main(wait_e, passwd, data_regnual, data_upgrade): l = len(data_regnual) if (l & 0x03) != 0: data_regnual = data_regnual.ljust(l + 4 - (l & 0x03), chr(0)) @@ -45,9 +42,6 @@ def main(wait_e, keyno, passwd, data_regnual, data_upgrade): print("CRC32: %04x\n" % crc32code) data_regnual += pack('