Compatibility with 1.6.0.1-og SDK

This commit is contained in:
cslashm 2019-11-12 14:12:55 +01:00
parent 0892d3704a
commit f6766c4441
8 changed files with 810 additions and 584 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
* text eol=lf

View File

@ -1,6 +1,6 @@
#*******************************************************************************
# Ledger App
# (c) 2016-2018 Ledger
# (c) 2016-2019 Ledger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -21,7 +21,7 @@ $(error Environment variable BOLOS_SDK is not set)
endif
include $(BOLOS_SDK)/Makefile.defines
APP_LOAD_PARAMS=--appFlags 0x240 --path "2152157255'" --curve secp256k1 $(COMMON_LOAD_PARAMS)
APP_LOAD_PARAMS=--appFlags 0x240 --path "2152157255'" --curve secp256k1 $(COMMON_LOAD_PARAMS)
ifeq ($(APPNAME),)
APPNAME = OpenPGP
@ -31,7 +31,7 @@ GPG_MULTISLOT:=0
else ifeq ($(APPNAME),OpenPGP.XL)
GPG_MULTISLOT:=1
APPNAME:=OpenPGP.XL
else
else
$(error APPNAME ($(APPNAME)) is not set or unknown)
endif
@ -45,7 +45,7 @@ endif
APPVERSION_M:=1
APPVERSION_N:=3
APPVERSION_P:=2
APPVERSION_P:=3
APPVERSION:=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
SPECVERSION:="3.3.1"
@ -54,7 +54,9 @@ DEFINES += OPENPGP_VERSION_MAJOR=$(APPVERSION_M) OPENPGP_VERSION_MINOR=$(APPVE
DEFINES += OPENPGP_VERSION=$(APPVERSION)
DEFINES += OPENPGP_NAME=$(APPNAME)
DEFINES += SPEC_VERSION=$(SPECVERSION)
DEFINES += GPG_MULTISLOT=$(GPG_MULTISLOT)
DEFINES += GPG_MULTISLOT=$(GPG_MULTISLOT)
ifeq ($(TARGET_NAME),TARGET_NANOX)
DEFINES += UI_NANO_X
@ -66,11 +68,12 @@ DEFINES += UI_NANO_S
endif
################
# Default rule #
################
.PHONY: allvariants listvariants
.PHONY: allvariants listvariants
all: default
mkdir -p release
@ -98,8 +101,9 @@ endif
DEFINES += OS_IO_SEPROXYHAL
DEFINES += HAVE_BAGL HAVE_SPRINTF
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=6 IO_HID_EP_LENGTH=64 HAVE_USB_APDU
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=4 IO_HID_EP_LENGTH=64 HAVE_USB_APDU
DEFINES += CUSTOM_IO_APDU_BUFFER_SIZE=\(255+5+64\)
DEFINES += HAVE_LEGACY_PID
DEFINES += USB_SEGMENT_SIZE=64
DEFINES += U2F_PROXY_MAGIC=\"MOON\"
@ -123,6 +127,8 @@ DEFINES += HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX
DEFINES += HAVE_UX_FLOW
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000
DEFINES += HAVE_BLE_APDU # basic ledger apdu transport over BLE
else
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
endif
@ -136,20 +142,33 @@ ifneq ($(DEBUG),0)
else
DEFINES += HAVE_PRINTF PRINTF=screen_printf
endif
DEFINES += PLINE="PRINTF(\"FILE:%s..LINE:%d\n\",__FILE__,__LINE__)"
else
DEFINES += PRINTF\(...\)=
DEFINES += PLINE\(...\)=
endif
##############
# Compiler #
##############
#GCCPATH := $(BOLOS_ENV)/gcc-arm-none-eabi-5_3-2016q1/bin/
#CLANGPATH := $(BOLOS_ENV)/clang-arm-fropi/bin/
CC := $(CLANGPATH)clang
ifneq ($(BOLOS_ENV),)
$(info BOLOS_ENV=$(BOLOS_ENV))
CLANGPATH := $(BOLOS_ENV)/clang-arm-fropi/bin/
GCCPATH := $(BOLOS_ENV)/gcc-arm-none-eabi-5_3-2016q1/bin/
else
$(info BOLOS_ENV is not set: falling back to CLANGPATH and GCCPATH)
endif
ifeq ($(CLANGPATH),)
$(info CLANGPATH is not set: clang will be used from PATH)
endif
ifeq ($(GCCPATH),)
$(info GCCPATH is not set: arm-none-eabi-* will be used from PATH)
endif
CC := $(CLANGPATH)clang
#CFLAGS += -O0 -gdwarf-2 -gstrict-dwarf
CFLAGS += -O3 -Os
CFLAGS += -O3 -Os
#CFLAGS += -fno-jump-tables -fno-lookup-tables -fsave-optimization-record
#$(info $(CFLAGS))
@ -158,17 +177,18 @@ AS := $(GCCPATH)arm-none-eabi-gcc
LD := $(GCCPATH)arm-none-eabi-gcc
#LDFLAGS += -O0 -gdwarf-2 -gstrict-dwarf
LDFLAGS += -O3 -Os
LDLIBS += -lm -lgcc -lc
LDLIBS += -lm -lgcc -lc
# import rules to compile glyphs(/pone)
include $(BOLOS_SDK)/Makefile.glyphs
### variables processed by the common makefile.rules of the SDK to grab source files and include dirs
APP_SOURCE_PATH += src
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl
#SDK_SOURCE_PATH += lib_u2f
ifeq ($(TARGET_NAME),TARGET_NANOX)
SDK_SOURCE_PATH += lib_ux
SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
endif
@ -176,25 +196,26 @@ cformat:
clang-format -i src/*.c src/*.h
load: all
cp -a release/$(APPNAME).elf bin/app.elf
cp -a release/$(APPNAME).hex bin/app.hex
cp -a release/$(APPNAME).asm debug/app.asm
cp -a release/$(APPNAME).map debug/app.map
cp -a release/$(APPNAME).elf bin/app.elf
cp -a release/$(APPNAME).hex bin/app.hex
cp -a release/$(APPNAME).asm debug/app.asm
cp -a release/$(APPNAME).map debug/app.map
python -m ledgerblue.loadApp $(APP_LOAD_PARAMS)
run:
python -m ledgerblue.runApp --appName $(APPNAME)
exit:
echo -e "0020008206313233343536\n0002000000" |scriptor -r "Ledger Nano S [Nano S] (0001) 01 00"
echo -e "0020008206313233343536\n0002000000" |scriptor -r "Ledger Nano S [Nano S] (0001) 01 00"
delete:
python -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)
# import generic rules from the sdk
include Makefile.rules
# import generic rules from the user and SDK
-include Makefile.rules
#include $(BOLOS_SDK)/Makefile.rules
#add dependency on custom makefile filename
dep/%.d: %.c Makefile

View File

@ -1,36 +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.
*/
#ifndef SDK_COMPAT_H
#define SDK_COMPAT_H
#include "bolos_target.h"
#if (TARGET_ID == 0x33000004) || ((TARGET_ID == 0x31100004) && (CX_APILEVEL >= 10))
#include "os_io_usb.h"
// from NanoX 1.2.4 remap G_io_apdu_xx
#define G_io_apdu_state G_io_app.apdu_state
#define G_io_apdu_length G_io_app.apdu_length
#define G_io_apdu_state G_io_app.apdu_state
#elif TARGET_ID == 0x31100004
//Use original naming of NanoS 1.5.5
#else
//Unknown
#error Target Not Supported
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
* @author MCD Application Team
* @version V1.0.1
* @date 31-January-2014
* @brief This file provides all the functions for USB Interface for CCID
* @brief This file provides all the functions for USB Interface for CCID
******************************************************************************
* @attention
*
@ -16,20 +16,19 @@
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*
******************************************************************************
*/
*/
#pragma message "Override SDK source file :" __FILE__
#pragma message "Override SDK source file :" __FILE__
/* Includes ------------------------------------------------------------------*/
#include "os.h"
#include "sdk_compat.h"
#ifdef HAVE_USB_CLASS_CCID
@ -46,8 +45,8 @@
usb_class_ccid_t G_io_ccid;
/* Private function prototypes -----------------------------------------------*/
static void CCID_Response_SendData (USBD_HandleTypeDef *pdev,
uint8_t* pbuf,
static void CCID_Response_SendData (USBD_HandleTypeDef *pdev,
uint8_t* pbuf,
uint16_t len);
/* Private function ----------------------------------------------------------*/
/**
@ -65,9 +64,9 @@ void CCID_Init (USBD_HandleTypeDef *pdev)
CCID_SetIntrTransferStatus(1); /* Transfer Complete Status */
#endif // HAVE_CCID_INTERRUPT
CCID_UpdSlotChange(1);
SC_InitParams();
SC_InitParams();
/* Prepare Out endpoint to receive 1st packet */
/* Prepare Out endpoint to receive 1st packet */
G_io_ccid.Ccid_BulkState = CCID_STATE_IDLE;
USBD_LL_PrepareReceive(pdev, CCID_BULK_OUT_EP, CCID_BULK_EPOUT_SIZE);
@ -89,19 +88,19 @@ void CCID_DeInit (USBD_HandleTypeDef *pdev)
/**
* @brief CCID_Message_In
* Handle Bulk IN & Intr IN data stage
* Handle Bulk IN & Intr IN data stage
* @param pdev: device instance
* @param uint8_t epnum: endpoint index
* @retval None
*/
void CCID_BulkMessage_In (USBD_HandleTypeDef *pdev,
void CCID_BulkMessage_In (USBD_HandleTypeDef *pdev,
uint8_t epnum)
{
{
if (epnum == (CCID_BULK_IN_EP & 0x7F))
{/* Filter the epnum by masking with 0x7f (mask of IN Direction) */
/*************** Handle Bulk Transfer IN data completion *****************/
switch (G_io_ccid.Ccid_BulkState)
{
case CCID_STATE_SEND_RESP: {
@ -120,14 +119,14 @@ void CCID_BulkMessage_In (USBD_HandleTypeDef *pdev,
// if remaining length is > EPIN_SIZE: send a filled bulk packet
if (G_io_ccid.UsbMessageLength >= CCID_BULK_EPIN_SIZE) {
CCID_Response_SendData(pdev, G_io_ccid.pUsbMessageBuffer,
CCID_Response_SendData(pdev, G_io_ccid.pUsbMessageBuffer,
// use the header declared size packet must be well formed
CCID_BULK_EPIN_SIZE);
}
// if remaining length is 0; send an empty packet and prepare to receive a new command
else if (G_io_ccid.UsbMessageLength == 0 && remLen == CCID_BULK_EPIN_SIZE) {
CCID_Response_SendData(pdev, G_io_ccid.pUsbMessageBuffer,
CCID_Response_SendData(pdev, G_io_ccid.pUsbMessageBuffer,
// use the header declared size packet must be well formed
0);
goto last_xfer; // won't wait ack to avoid missing a command
@ -136,17 +135,17 @@ void CCID_BulkMessage_In (USBD_HandleTypeDef *pdev,
else if (G_io_ccid.UsbMessageLength == 0) { // robustness only
last_xfer:
G_io_ccid.Ccid_BulkState = CCID_STATE_IDLE;
/* Prepare EP to Receive First Cmd */
// not timeout compliant // USBD_LL_PrepareReceive(pdev, CCID_BULK_OUT_EP, CCID_BULK_EPOUT_SIZE);
// mark transfer as completed
G_io_apdu_state = APDU_IDLE;
G_io_app.apdu_state = APDU_IDLE;
}
// if remaining length is < EPIN_SIZE: send packet and prepare to receive a new command
else if (G_io_ccid.UsbMessageLength < CCID_BULK_EPIN_SIZE) {
CCID_Response_SendData(pdev, G_io_ccid.pUsbMessageBuffer,
CCID_Response_SendData(pdev, G_io_ccid.pUsbMessageBuffer,
// use the header declared size packet must be well formed
G_io_ccid.UsbMessageLength);
goto last_xfer; // won't wait ack to avoid missing a command
@ -154,7 +153,7 @@ void CCID_BulkMessage_In (USBD_HandleTypeDef *pdev,
break;
}
default:
break;
}
@ -169,11 +168,11 @@ void CCID_BulkMessage_In (USBD_HandleTypeDef *pdev,
}
void CCID_Send_Reply(USBD_HandleTypeDef *pdev) {
/********** Decide for all commands ***************/
/********** Decide for all commands ***************/
if (G_io_ccid.Ccid_BulkState == CCID_STATE_SEND_RESP)
{
G_io_ccid.UsbMessageLength = G_io_ccid.bulk_header.bulkin.dwLength+CCID_HEADER_SIZE; /* Store for future use */
/* Expected Data Length Packet Received */
G_io_ccid.pUsbMessageBuffer = (uint8_t*) &G_io_ccid.bulk_header;
@ -184,7 +183,7 @@ void CCID_Send_Reply(USBD_HandleTypeDef *pdev) {
os_memmove(G_io_usb_ep_buffer+CCID_HEADER_SIZE, G_io_ccid_data_buffer, MIN(CCID_BULK_EPIN_SIZE, G_io_ccid.UsbMessageLength)-CCID_HEADER_SIZE);
}
// send the first mixed source chunk
CCID_Response_SendData(pdev, G_io_usb_ep_buffer,
CCID_Response_SendData(pdev, G_io_usb_ep_buffer,
// use the header declared size packet must be well formed
MIN(CCID_BULK_EPIN_SIZE, G_io_ccid.UsbMessageLength));
}
@ -197,7 +196,7 @@ void CCID_Send_Reply(USBD_HandleTypeDef *pdev) {
* @param uint8_t epnum: endpoint index
* @retval None
*/
void CCID_BulkMessage_Out (USBD_HandleTypeDef *pdev,
void CCID_BulkMessage_Out (USBD_HandleTypeDef *pdev,
uint8_t epnum, uint8_t* buffer, uint16_t dataLen)
{
if (epnum == (CCID_BULK_OUT_EP & 0x7F)) {
@ -220,23 +219,23 @@ void CCID_BulkMessage_Out (USBD_HandleTypeDef *pdev,
else if (dataLen >= CCID_HEADER_SIZE)
{
G_io_ccid.UsbMessageLength = dataLen; /* Store for future use */
/* Expected Data Length Packet Received */
// endianness is little :) useful for our ARM convention
G_io_ccid.pUsbMessageBuffer = (uint8_t*) &G_io_ccid.bulk_header;
// copy the ccid bulk header only
os_memmove(G_io_ccid.pUsbMessageBuffer, buffer, CCID_HEADER_SIZE);
os_memmove(G_io_ccid.pUsbMessageBuffer, buffer, CCID_HEADER_SIZE);
// copy remaining part in the data buffer (split from the ccid to allow for overlaying with another ressource buffer)
if (dataLen>CCID_HEADER_SIZE) {
os_memmove(G_io_ccid_data_buffer, buffer+CCID_HEADER_SIZE, dataLen-CCID_HEADER_SIZE);
// we're now receiving in the data buffer (all subsequent calls)
G_io_ccid.pUsbMessageBuffer = G_io_ccid_data_buffer;
}
if (G_io_ccid.bulk_header.bulkout.dwLength > IO_CCID_DATA_BUFFER_SIZE)
{ /* Check if length of data to be sent by host is > buffer size */
/* Too long data received.... Error ! */
G_io_ccid.Ccid_BulkState = CCID_STATE_UNCORRECT_LENGTH;
}
@ -244,48 +243,48 @@ void CCID_BulkMessage_Out (USBD_HandleTypeDef *pdev,
// everything received in the first packet
if (G_io_ccid.UsbMessageLength == (G_io_ccid.bulk_header.bulkout.dwLength + CCID_HEADER_SIZE)) {
/* Short message, less than the EP Out Size, execute the command,
if parameter like dwLength is too big, the appropriate command will
if parameter like dwLength is too big, the appropriate command will
give an error */
CCID_CmdDecode(pdev);
CCID_CmdDecode(pdev);
}
else
{ /* Long message, receive additional data with command */
G_io_ccid.Ccid_BulkState = CCID_STATE_RECEIVE_DATA;
G_io_ccid.pUsbMessageBuffer += dataLen-CCID_HEADER_SIZE; /* Point to new offset */
G_io_ccid.pUsbMessageBuffer += dataLen-CCID_HEADER_SIZE; /* Point to new offset */
}
}
break;
case CCID_STATE_RECEIVE_DATA:
USBD_LL_PrepareReceive(pdev, CCID_BULK_OUT_EP, CCID_BULK_EPOUT_SIZE);
G_io_ccid.UsbMessageLength += dataLen;
if (dataLen < CCID_BULK_EPOUT_SIZE)
{/* Short message, less than the EP Out Size, execute the command,
if parameter like dwLength is too big, the appropriate command will
if parameter like dwLength is too big, the appropriate command will
give an error */
/* Full command is received, process the Command */
os_memmove(G_io_ccid.pUsbMessageBuffer, buffer, dataLen);
CCID_CmdDecode(pdev);
os_memmove(G_io_ccid.pUsbMessageBuffer, buffer, dataLen);
CCID_CmdDecode(pdev);
}
else //if (dataLen == CCID_BULK_EPOUT_SIZE)
{
{
if (G_io_ccid.UsbMessageLength < (G_io_ccid.bulk_header.bulkout.dwLength + CCID_HEADER_SIZE))
{
os_memmove(G_io_ccid.pUsbMessageBuffer, buffer, dataLen);
G_io_ccid.pUsbMessageBuffer += dataLen;
os_memmove(G_io_ccid.pUsbMessageBuffer, buffer, dataLen);
G_io_ccid.pUsbMessageBuffer += dataLen;
/* Increment the pointer to receive more data */
/* Prepare EP to Receive next Cmd */
// not timeout compliant // USBD_LL_PrepareReceive(pdev, CCID_BULK_OUT_EP, CCID_BULK_EPOUT_SIZE);
}
else if (G_io_ccid.UsbMessageLength == (G_io_ccid.bulk_header.bulkout.dwLength + CCID_HEADER_SIZE))
{
{
/* Full command is received, process the Command */
os_memmove(G_io_ccid.pUsbMessageBuffer, buffer, dataLen);
os_memmove(G_io_ccid.pUsbMessageBuffer, buffer, dataLen);
CCID_CmdDecode(pdev);
}
else
@ -294,14 +293,14 @@ void CCID_BulkMessage_Out (USBD_HandleTypeDef *pdev,
G_io_ccid.Ccid_BulkState = CCID_STATE_UNCORRECT_LENGTH;
}
}
break;
/*
case CCID_STATE_UNCORRECT_LENGTH:
G_io_ccid.Ccid_BulkState = CCID_STATE_IDLE;
break;
default:
break;
@ -319,7 +318,7 @@ void CCID_BulkMessage_Out (USBD_HandleTypeDef *pdev,
void CCID_CmdDecode(USBD_HandleTypeDef *pdev)
{
uint8_t errorCode;
switch (G_io_ccid.bulk_header.bulkout.bMessageType)
{
case PC_TO_RDR_ICCPOWERON:
@ -369,7 +368,7 @@ void CCID_CmdDecode(USBD_HandleTypeDef *pdev)
case PC_TO_RDR_MECHANICAL:
errorCode = PC_TO_RDR_Mechanical();
RDR_to_PC_SlotStatus(errorCode);
break;
break;
case PC_TO_RDR_SETDATARATEANDCLOCKFREQUENCY:
errorCode = PC_TO_RDR_SetDataRateAndClockFrequency();
RDR_to_PC_DataRateAndClockFrequency(errorCode);
@ -382,7 +381,7 @@ void CCID_CmdDecode(USBD_HandleTypeDef *pdev)
RDR_to_PC_SlotStatus(SLOTERROR_CMD_NOT_SUPPORTED);
break;
}
CCID_Send_Reply(pdev);
}
@ -396,22 +395,22 @@ void CCID_CmdDecode(USBD_HandleTypeDef *pdev)
void Transfer_Data_Request(void)
{
/********** Update Global Variables ***************/
G_io_ccid.Ccid_BulkState = CCID_STATE_SEND_RESP;
}
G_io_ccid.Ccid_BulkState = CCID_STATE_SEND_RESP;
}
/**
* @brief CCID_Response_SendData
* Send the data on bulk-in EP
* Send the data on bulk-in EP
* @param pdev: device instance
* @param uint8_t* buf: pointer to data buffer
* @param uint16_t len: Data Length
* @retval None
*/
static void CCID_Response_SendData(USBD_HandleTypeDef *pdev,
uint8_t* buf,
uint8_t* buf,
uint16_t len)
{
{
UNUSED(pdev);
// don't ask the MCU to perform bulk split, we could quickly get into a buffer overflow
if (len > CCID_BULK_EPIN_SIZE) {
@ -438,17 +437,17 @@ static void CCID_Response_SendData(USBD_HandleTypeDef *pdev,
void CCID_IntMessage(USBD_HandleTypeDef *pdev)
{
UNUSED(pdev);
/* Check if there us change in Smartcard Slot status */
/* Check if there us change in Smartcard Slot status */
if ( CCID_IsSlotStatusChange() && CCID_IsIntrTransferComplete() )
{
#ifdef HAVE_CCID_INTERRUPT
/* Check Slot Status is changed. Card is Removed/ Fitted */
RDR_to_PC_NotifySlotChange();
#endif // HAVE_CCID_INTERRUPT
CCID_SetIntrTransferStatus(0); /* Reset the Status */
CCID_UpdSlotChange(0); /* Reset the Status of Slot Change */
G_io_seproxyhal_spi_buffer[0] = SEPROXYHAL_TAG_USB_EP_PREPARE;
G_io_seproxyhal_spi_buffer[1] = (3+2)>>8;
G_io_seproxyhal_spi_buffer[2] = (3+2);
@ -458,12 +457,12 @@ void CCID_IntMessage(USBD_HandleTypeDef *pdev)
io_seproxyhal_spi_send(G_io_seproxyhal_spi_buffer, 6);
io_seproxyhal_spi_send(G_io_ccid.UsbIntMessageBuffer, 2);
}
}
}
/**
* @brief CCID_IsIntrTransferComplete
* Provides the status of previous Interrupt transfer status
* @param None
* @param None
* @retval uint8_t PrevXferComplete_IntrIn: Value of the previous transfer status
*/
uint8_t CCID_IsIntrTransferComplete (void)
@ -473,9 +472,9 @@ uint8_t CCID_IsIntrTransferComplete (void)
/**
* @brief CCID_IsIntrTransferComplete
* Set the value of the Interrupt transfer status
* Set the value of the Interrupt transfer status
* @param uint8_t xfer_Status: Value of the Interrupt transfer status to set
* @retval None
* @retval None
*/
void CCID_SetIntrTransferStatus (uint8_t xfer_Status)
{
@ -509,7 +508,7 @@ uint8_t SC_SetClock (uint8_t bClockCommand) {
uint8_t SC_Request_GetClockFrequencies(uint8_t* pbuf, uint16_t* len);
uint8_t SC_Request_GetDataRates(uint8_t* pbuf, uint16_t* len);
uint8_t SC_T0Apdu(uint8_t bmChanges, uint8_t bClassGetResponse,
uint8_t SC_T0Apdu(uint8_t bmChanges, uint8_t bClassGetResponse,
uint8_t bClassEnvelope) {
UNUSED(bmChanges);
UNUSED(bClassGetResponse);
@ -520,13 +519,13 @@ uint8_t SC_Mechanical(uint8_t bFunction) {
UNUSED(bFunction);
return SLOTERROR_CMD_NOT_SUPPORTED;
}
uint8_t SC_SetDataRateAndClockFrequency(uint32_t dwClockFrequency,
uint8_t SC_SetDataRateAndClockFrequency(uint32_t dwClockFrequency,
uint32_t dwDataRate) {
UNUSED(dwClockFrequency);
UNUSED(dwDataRate);
return SLOT_NO_ERROR;
}
uint8_t SC_Secure(uint32_t dwLength, uint8_t bBWI, uint16_t wLevelParameter,
uint8_t SC_Secure(uint32_t dwLength, uint8_t bBWI, uint16_t wLevelParameter,
uint8_t* pbuf, uint32_t* returnLen ) {
UNUSED(bBWI);
UNUSED(wLevelParameter);
@ -550,7 +549,7 @@ uint8_t SC_Secure(uint32_t dwLength, uint8_t bBWI, uint16_t wLevelParameter,
break;
// 0 and 4-0xFF
default:
off = 18;
off = 18;
break;
}
//ret_len = dwLength - off;
@ -563,7 +562,7 @@ uint8_t SC_Secure(uint32_t dwLength, uint8_t bBWI, uint16_t wLevelParameter,
return SLOTERROR_CMD_NOT_SUPPORTED;
}
pbuf += off;
pbuf[0] = 0xEF;
pbuf[0] = 0xEF;
return SC_XferBlock(pbuf, ret_len, &ret_len);
}
@ -575,12 +574,12 @@ uint8_t SC_XferBlock (uint8_t* ptrBlock, uint32_t blockLen, uint16_t* expectedLe
if (blockLen > IO_APDU_BUFFER_SIZE) {
return SLOTERROR_BAD_LENTGH;
}
// copy received apdu // if G_io_ccid_data_buffer is the buffer apdu, then the memmove will do nothing
os_memmove(G_io_apdu_buffer, ptrBlock, blockLen);
G_io_apdu_length = blockLen;
G_io_apdu_media = IO_APDU_MEDIA_USB_CCID; // for application code
G_io_apdu_state = APDU_USB_CCID; // for next call to io_exchange
G_io_app.apdu_length = blockLen;
G_io_app.apdu_media = IO_APDU_MEDIA_USB_CCID; // for application code
G_io_app.apdu_state = APDU_USB_CCID; // for next call to io_exchange
return SLOT_NO_ERROR;
}

View File

@ -1,3 +1,19 @@
/*******************************************************************************
* Ledger Nano S - Secure firmware
* (c) 2019 Ledger
*
* 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.
********************************************************************************/
#ifndef USBD_CCID_IMPL_H
#define USBD_CCID_IMPL_H

View File

@ -1,3 +1,19 @@
/*******************************************************************************
* Ledger Nano S - Secure firmware
* (c) 2019 Ledger
*
* 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.
********************************************************************************/
#ifndef USBD_HID_IMPL_H
#define USBD_HID_IMPL_H

File diff suppressed because it is too large Load Diff