mirror of
https://github.com/LedgerHQ/openpgp-card-app
synced 2024-11-09 07:10:30 +00:00
Activate Standard App Files; Add App manifest
This commit is contained in:
parent
bebae9bfa9
commit
ce190aa9c1
10
Makefile
10
Makefile
@ -52,7 +52,7 @@ DEFINES += SPEC_VERSION=$(SPECVERSION)
|
|||||||
APP_SOURCE_PATH += src
|
APP_SOURCE_PATH += src
|
||||||
APP_SOURCE_FILES += $(BOLOS_SDK)/lib_cxng/src/cx_rsa.c
|
APP_SOURCE_FILES += $(BOLOS_SDK)/lib_cxng/src/cx_rsa.c
|
||||||
APP_SOURCE_FILES += $(BOLOS_SDK)/lib_cxng/src/cx_pkcs1.c
|
APP_SOURCE_FILES += $(BOLOS_SDK)/lib_cxng/src/cx_pkcs1.c
|
||||||
APP_SOURCE_FILES += $(BOLOS_SDK)/lib_cxng/src/cx_utils.c
|
APP_SOURCE_FILES += ${BOLOS_SDK}/lib_cxng/src/cx_ram.c
|
||||||
|
|
||||||
INCLUDES_PATH += $(BOLOS_SDK)/lib_cxng/src
|
INCLUDES_PATH += $(BOLOS_SDK)/lib_cxng/src
|
||||||
|
|
||||||
@ -120,15 +120,13 @@ endif
|
|||||||
########################################
|
########################################
|
||||||
# These advanced settings allow to disable some feature that are by
|
# These advanced settings allow to disable some feature that are by
|
||||||
# default enabled in the SDK `Makefile.standard_app`.
|
# default enabled in the SDK `Makefile.standard_app`.
|
||||||
DISABLE_STANDARD_APP_FILES = 1
|
#DISABLE_STANDARD_APP_FILES = 1
|
||||||
#DISABLE_DEFAULT_IO_SEPROXY_BUFFER_SIZE = 1 # To allow custom size declaration
|
#DISABLE_DEFAULT_IO_SEPROXY_BUFFER_SIZE = 1 # To allow custom size declaration
|
||||||
#DISABLE_STANDARD_APP_DEFINES = 1 # Will set all the following disablers
|
#DISABLE_STANDARD_APP_DEFINES = 1 # Will set all the following disablers
|
||||||
#DISABLE_STANDARD_SNPRINTF = 1
|
#DISABLE_STANDARD_SNPRINTF = 1
|
||||||
#DISABLE_STANDARD_USB = 1
|
#DISABLE_STANDARD_USB = 1
|
||||||
DISABLE_STANDARD_WEBUSB = 1
|
DISABLE_STANDARD_WEBUSB = 1
|
||||||
ifeq ($(TARGET_NAME),TARGET_NANOS)
|
#DISABLE_STANDARD_BAGL_UX_FLOW = 1
|
||||||
DISABLE_STANDARD_BAGL_UX_FLOW = 1
|
|
||||||
endif
|
|
||||||
#DISABLE_DEBUG_LEDGER_ASSERT = 1
|
#DISABLE_DEBUG_LEDGER_ASSERT = 1
|
||||||
#DISABLE_DEBUG_THROW = 1
|
#DISABLE_DEBUG_THROW = 1
|
||||||
|
|
||||||
@ -138,12 +136,12 @@ endif
|
|||||||
|
|
||||||
DEFINES += GPG_MULTISLOT=$(GPG_MULTISLOT)
|
DEFINES += GPG_MULTISLOT=$(GPG_MULTISLOT)
|
||||||
DEFINES += CUSTOM_IO_APDU_BUFFER_SIZE=\(255+5+64\)
|
DEFINES += CUSTOM_IO_APDU_BUFFER_SIZE=\(255+5+64\)
|
||||||
DEFINES += HAVE_LEGACY_PID
|
|
||||||
DEFINES += HAVE_USB_CLASS_CCID
|
DEFINES += HAVE_USB_CLASS_CCID
|
||||||
DEFINES += HAVE_RSA
|
DEFINES += HAVE_RSA
|
||||||
|
|
||||||
ifeq ($(TARGET_NAME),TARGET_NANOS)
|
ifeq ($(TARGET_NAME),TARGET_NANOS)
|
||||||
DEFINES += UI_NANO_S
|
DEFINES += UI_NANO_S
|
||||||
|
DEFINES += HAVE_UX_LEGACY
|
||||||
else
|
else
|
||||||
DEFINES += UI_NANO_X
|
DEFINES += UI_NANO_X
|
||||||
DEFINES += GPG_SHAKE256
|
DEFINES += GPG_SHAKE256
|
||||||
|
8
ledger_app.toml
Normal file
8
ledger_app.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[app]
|
||||||
|
build_directory = "./"
|
||||||
|
sdk = "C"
|
||||||
|
devices = ["nanos", "nanox", "nanos+"]
|
||||||
|
|
||||||
|
[tests]
|
||||||
|
unit_directory = "./unit-tests/"
|
||||||
|
pytest_directory = "./tests/"
|
149
src/gpg_main.c
149
src/gpg_main.c
@ -14,16 +14,33 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gpg_vars.h"
|
#include "gpg_vars.h"
|
||||||
#include "gpg_ux_nanos.h"
|
#include "io.h"
|
||||||
#include "usbd_ccid_if.h"
|
#include "usbd_ccid_if.h"
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* --- Application Entry --- */
|
/* --- Application Entry --- */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
void gpg_main(void) {
|
void app_main(void) {
|
||||||
unsigned int io_flags;
|
unsigned int io_flags = 0;
|
||||||
io_flags = 0;
|
io_flags = 0;
|
||||||
|
|
||||||
|
// start communication with MCU
|
||||||
|
ui_CCID_reset();
|
||||||
|
|
||||||
|
// set up
|
||||||
|
io_init();
|
||||||
|
|
||||||
|
gpg_init();
|
||||||
|
|
||||||
|
// set up initial screen
|
||||||
|
ui_init();
|
||||||
|
|
||||||
|
// start the application
|
||||||
|
// the first exchange will:
|
||||||
|
// - display the initial screen
|
||||||
|
// - send the ATR
|
||||||
|
// - receive the first command
|
||||||
for (;;) {
|
for (;;) {
|
||||||
volatile unsigned short sw = 0;
|
volatile unsigned short sw = 0;
|
||||||
BEGIN_TRY {
|
BEGIN_TRY {
|
||||||
@ -52,129 +69,3 @@ void gpg_main(void) {
|
|||||||
END_TRY;
|
END_TRY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char io_event(unsigned char channel) {
|
|
||||||
UNUSED(channel);
|
|
||||||
// nothing done with the event, throw an error on the transport layer if
|
|
||||||
// needed
|
|
||||||
// can't have more than one tag in the reply, not supported yet.
|
|
||||||
switch (G_io_seproxyhal_spi_buffer[0]) {
|
|
||||||
case SEPROXYHAL_TAG_FINGER_EVENT:
|
|
||||||
UX_FINGER_EVENT(G_io_seproxyhal_spi_buffer);
|
|
||||||
break;
|
|
||||||
// power off if long push, else pass to the application callback if any
|
|
||||||
case SEPROXYHAL_TAG_BUTTON_PUSH_EVENT: // for Nano S
|
|
||||||
UX_BUTTON_PUSH_EVENT(G_io_seproxyhal_spi_buffer);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// other events are propagated to the UX just in case
|
|
||||||
default:
|
|
||||||
UX_DEFAULT_EVENT();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SEPROXYHAL_TAG_DISPLAY_PROCESSED_EVENT:
|
|
||||||
UX_DISPLAYED_EVENT({});
|
|
||||||
break;
|
|
||||||
case SEPROXYHAL_TAG_TICKER_EVENT:
|
|
||||||
UX_TICKER_EVENT(G_io_seproxyhal_spi_buffer, {
|
|
||||||
// only allow display when not locked of overlaid by an OS UX.
|
|
||||||
if (UX_ALLOWED) {
|
|
||||||
UX_REDISPLAY();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// close the event if not done previously (by a display or whatever)
|
|
||||||
if (!io_seproxyhal_spi_is_status_sent()) {
|
|
||||||
io_seproxyhal_general_status();
|
|
||||||
}
|
|
||||||
// command has been processed, DO NOT reset the current APDU transport
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned short io_exchange_al(unsigned char channel, unsigned short tx_len) {
|
|
||||||
switch (channel & ~(IO_FLAGS)) {
|
|
||||||
case CHANNEL_KEYBOARD:
|
|
||||||
break;
|
|
||||||
|
|
||||||
// multiplexed io exchange over a SPI channel and TLV encapsulated protocol
|
|
||||||
case CHANNEL_SPI:
|
|
||||||
if (tx_len) {
|
|
||||||
io_seproxyhal_spi_send(G_io_apdu_buffer, tx_len);
|
|
||||||
|
|
||||||
if (channel & IO_RESET_AFTER_REPLIED) {
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
return 0; // nothing received from the master so far (it's a tx
|
|
||||||
// transaction)
|
|
||||||
} else {
|
|
||||||
return io_seproxyhal_spi_recv(G_io_apdu_buffer, sizeof(G_io_apdu_buffer), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
THROW(INVALID_PARAMETER);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void app_exit(void) {
|
|
||||||
BEGIN_TRY_L(exit) {
|
|
||||||
TRY_L(exit) {
|
|
||||||
os_sched_exit(-1);
|
|
||||||
}
|
|
||||||
FINALLY_L(exit) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
END_TRY_L(exit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------- */
|
|
||||||
|
|
||||||
__attribute__((section(".boot"))) int main(void) {
|
|
||||||
// exit critical section
|
|
||||||
__asm volatile("cpsie i");
|
|
||||||
|
|
||||||
// ensure exception will work as planned
|
|
||||||
os_boot();
|
|
||||||
for (;;) {
|
|
||||||
UX_INIT();
|
|
||||||
|
|
||||||
BEGIN_TRY {
|
|
||||||
TRY {
|
|
||||||
// start communication with MCU
|
|
||||||
io_seproxyhal_init();
|
|
||||||
|
|
||||||
USB_power(1);
|
|
||||||
#if HAVE_USB_CLASS_CCID
|
|
||||||
io_usb_ccid_set_card_inserted(1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set up
|
|
||||||
gpg_init();
|
|
||||||
|
|
||||||
// set up initial screen
|
|
||||||
ui_init();
|
|
||||||
|
|
||||||
// start the application
|
|
||||||
// the first exchange will:
|
|
||||||
// - display the initial screen
|
|
||||||
// - send the ATR
|
|
||||||
// - receive the first command
|
|
||||||
gpg_main();
|
|
||||||
}
|
|
||||||
CATCH(EXCEPTION_IO_RESET) {
|
|
||||||
// reset IO and UX
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
CATCH_ALL {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
FINALLY {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
END_TRY;
|
|
||||||
}
|
|
||||||
app_exit();
|
|
||||||
}
|
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
/* Copyright 2017 Cedric Mesnil <cslashm@gmail.com>, Ledger SAS
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gpg_vars.h"
|
|
||||||
|
|
||||||
#ifndef TARGET_NANOS
|
|
||||||
#include "ux.h"
|
|
||||||
ux_state_t G_ux;
|
|
||||||
bolos_ux_params_t G_ux_params;
|
|
||||||
#else
|
|
||||||
ux_state_t ux;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];
|
|
||||||
|
|
||||||
gpg_v_state_t G_gpg_vstate;
|
|
||||||
|
|
||||||
#ifdef HAVE_RSA
|
|
||||||
union cx_u G_cx;
|
|
||||||
#endif // HAVE_RSA
|
|
@ -15,8 +15,7 @@
|
|||||||
|
|
||||||
#include "gpg_vars.h"
|
#include "gpg_vars.h"
|
||||||
|
|
||||||
#ifndef TARGET_NANOS
|
gpg_v_state_t G_gpg_vstate;
|
||||||
|
|
||||||
const gpg_nv_state_t N_state_pic;
|
const gpg_nv_state_t N_state_pic;
|
||||||
#else
|
|
||||||
gpg_nv_state_t N_state_pic;
|
|
||||||
#endif
|
|
@ -33,18 +33,7 @@ extern const unsigned char C_OID_cv25519[10];
|
|||||||
|
|
||||||
extern gpg_v_state_t G_gpg_vstate;
|
extern gpg_v_state_t G_gpg_vstate;
|
||||||
|
|
||||||
#ifndef TARGET_NANOS
|
|
||||||
extern const gpg_nv_state_t N_state_pic;
|
extern const gpg_nv_state_t N_state_pic;
|
||||||
#define N_gpg_pstate ((volatile gpg_nv_state_t *) PIC(&N_state_pic))
|
#define N_gpg_pstate ((volatile gpg_nv_state_t *) PIC(&N_state_pic))
|
||||||
#else
|
|
||||||
extern gpg_nv_state_t N_state_pic;
|
|
||||||
#define N_gpg_pstate ((WIDE gpg_nv_state_t *) PIC(&N_state_pic))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern ux_state_t ux;
|
|
||||||
|
|
||||||
#ifdef HAVE_RSA
|
|
||||||
#include "cx_ram.h"
|
|
||||||
extern union cx_u G_cx;
|
|
||||||
#endif // HAVE_RSA
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user