Skip to content

Commit

Permalink
Release v3.3.0 (20210126)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-hunt committed Jan 27, 2021
1 parent 8c29897 commit 51fa842
Show file tree
Hide file tree
Showing 115 changed files with 5,900 additions and 4,008 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 2.6.4)
project (cryptoauthlib C)

# Set the current release version
set(VERSION "3.2.5")
set(VERSION "3.3.0")
set(VERSION_MAJOR 3)
set(VERSION_MINOR 2)
set(VERSION_PATCH 5)
set(VERSION_MINOR 3)
set(VERSION_PATCH 0)

# Build Options
option(BUILD_TESTS "Create Test Application with library" OFF)
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ configuration is well tested, then you can commit it to a CryptoAuth Xplained
Pro Extension, for example. Keep in mind that once you lock a device, it will
not be changeable.

Licensing
---------------------------

The CryptoAuthLib license can be found in the accompaning [license.txt](https://github.com/MicrochipTech/cryptoauthlib/blob/main/license.txt)
file.

Cryptoauthlib also includes optional third party software subject to their own licensing terms. If you are using one of these optional components please
verify the terms of those licenses as well in the third_party/<module> directories.


Examples
-----------
Expand Down
3 changes: 1 addition & 2 deletions app/api_206a/api_206a.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ extern "C" {
#endif

#include "atca_status.h"
#include "atca_command.h"

#define ATCA_SHA206A_ZONE_WRITE_LOCK 0x20
#define ATCA_SHA206A_DKEY_CONSUMPTION_MASK 0x01
Expand Down Expand Up @@ -68,4 +67,4 @@ ATCA_STATUS sha206a_get_data_store_lock_status(uint8_t slot, uint8_t* is_locked)
}
#endif

#endif
#endif
Binary file modified cryptoauthlib-manual.pdf
Binary file not shown.
89 changes: 85 additions & 4 deletions harmony/config/cryptoauthlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,22 @@ def updateHalTracker(id, inc):
calHalTracker[id] = cnt
elif cnt > 0:
cnt -= 1

symbol = Database.getComponentByID('cryptoauthlib').getSymbolByID('CAL_FILE_SRC_HAL_' + id.upper())

print('updateHalTracker', id)

symbol = Database.getComponentByID('cryptoauthlib').getSymbolByID('CAL_FILE_SRC_HAL_' + id)
symbol.setEnabled(cnt > 0)

calHalList = Database.getComponentByID('cryptoauthlib').getSymbolByID('CAL_HAL_LIST_ENTRIES')

if cnt == 0:
del_value_from_list(calHalList, id)
else:
add_value_to_list(calHalList, id)


def updatePlibTracker(id, inc):
# id is of the form: <plib>_<hal>_<mode>
global calPlibTracker
cnt = calPlibTracker.pop(id, 0)
if inc:
Expand All @@ -75,7 +85,12 @@ def updatePlibTracker(id, inc):
elif cnt > 0:
cnt -= 1

updateHalTracker(id.split('_')[1], inc)
hal_ids = id.upper().split('_')[1:]
if len(hal_ids) > 1:
updateHalTracker('_'.join(hal_ids), inc)
updateHalTracker(hal_ids[1], inc)
else:
updateHalTracker(hal_ids[0], inc)

calPlibList = Database.getComponentByID('cryptoauthlib').getSymbolByID('CAL_PLIB_LIST_ENTRIES')

Expand Down Expand Up @@ -134,6 +149,15 @@ def updateFileEnable(component, pattern, enable):
srcFile.setEnabled(enable)


def check_if_file_exists(component, pattern):
global numFileCntr
for x in range(numFileCntr):
srcFile = component.getSymbolByID(fileSymbolName + str(x))
if srcFile is not None:
if pattern.replace('/*','') in srcFile.getOutputName():
return True
return False


def onAttachmentConnected(source, target):
global _ca_dev_cnt
Expand All @@ -150,6 +174,9 @@ def onAttachmentConnected(source, target):
if 'TA100' in targetComponentID:
_ta_dev_cnt += 1
updateFileEnable(srcComponent, _TA_PATHS, True)
if check_if_file_exists(srcComponent, 'talib_fce'):
calTaEnableFce = srcComponent.getSymbolByID('CAL_ENABLE_TA100_FCE')
calTaEnableFce.setValue(True)
else:
_ca_dev_cnt += 1
updateFileEnable(srcComponent, _CA_PATHS, True)
Expand All @@ -167,7 +194,9 @@ def onAttachmentConnected(source, target):

WolfCrypto = srcComponent.getSymbolByID('CAL_FILE_SRC_WOLFSSL_WRAPPER')
WolfCrypto.setEnabled(True)
print('connected lib_wolfcrypt')

calTaEnableAesAuth = srcComponent.getSymbolByID('CAL_ENABLE_TA100_AES_AUTH')
calTaEnableAesAuth.setValue(True)


def onAttachmentDisconnected(source, target):
Expand All @@ -185,6 +214,10 @@ def onAttachmentDisconnected(source, target):
_ta_dev_cnt -= 1
if 0 == _ta_dev_cnt:
updateFileEnable(srcComponent, _TA_PATHS, False)
calTaEnableFce = srcComponent.getSymbolByID('CAL_ENABLE_TA100_FCE')
calTaEnableFce.setValue(False)
calTaEnableAesAuth = srcComponent.getSymbolByID('CAL_ENABLE_TA100_AES_AUTH')
calTaEnableAesAuth.setValue(False)
else:
_ca_dev_cnt -= 1
if 0 == _ca_dev_cnt:
Expand All @@ -204,6 +237,9 @@ def onAttachmentDisconnected(source, target):

WolfCrypto = srcComponent.getSymbolByID('CAL_FILE_SRC_WOLFSSL_WRAPPER')
WolfCrypto.setEnabled(False)

calTaEnableAesAuth = srcComponent.getSymbolByID('CAL_ENABLE_TA100_AES_AUTH')
calTaEnableAesAuth.setValue(False)

print('disconnected lib_wolfcrypt')

Expand Down Expand Up @@ -307,6 +343,38 @@ def instantiateComponent(calComponent):
calLibI2cHalSrcFile.setProjectPath("config/" + configName + "/library/cryptoauthlib/hal/")
calLibI2cHalSrcFile.setType('SOURCE')
calLibI2cHalSrcFile.setEnabled(False)

calLibUartHalSrcFile = calComponent.createFileSymbol("CAL_FILE_SRC_HAL_UART", None)
calLibUartHalSrcFile.setSourcePath("lib/hal/hal_uart_harmony.c")
calLibUartHalSrcFile.setOutputName("hal_uart_harmony.c")
calLibUartHalSrcFile.setDestPath("library/cryptoauthlib/hal")
calLibUartHalSrcFile.setProjectPath("config/" + configName + "/library/cryptoauthlib/hal/")
calLibUartHalSrcFile.setType('SOURCE')
calLibUartHalSrcFile.setEnabled(False)

calLibSwiUartHalSrcFile = calComponent.createFileSymbol("CAL_FILE_SRC_HAL_SWI_UART", None)
calLibSwiUartHalSrcFile.setSourcePath("lib/hal/hal_swi_uart.c")
calLibSwiUartHalSrcFile.setOutputName("hal_swi_uart.c")
calLibSwiUartHalSrcFile.setDestPath("library/cryptoauthlib/hal")
calLibSwiUartHalSrcFile.setProjectPath("config/" + configName + "/library/cryptoauthlib/hal/")
calLibSwiUartHalSrcFile.setType('SOURCE')
calLibSwiUartHalSrcFile.setEnabled(False)

calLibSwiBBHalSrcFile = calComponent.createFileSymbol("CAL_FILE_SRC_HAL_BB", None)
calLibSwiBBHalSrcFile.setSourcePath("lib/hal/hal_gpio_harmony.c")
calLibSwiBBHalSrcFile.setOutputName("hal_gpio_harmony.c")
calLibSwiBBHalSrcFile.setDestPath("library/cryptoauthlib/hal")
calLibSwiBBHalSrcFile.setProjectPath("config/" + configName + "/library/cryptoauthlib/hal/")
calLibSwiBBHalSrcFile.setType('SOURCE')
calLibSwiBBHalSrcFile.setEnabled(False)

calLibSwiBBHalSrcFile = calComponent.createFileSymbol("CAL_FILE_SRC_HAL_SWI_BB", None)
calLibSwiBBHalSrcFile.setSourcePath("lib/hal/hal_swi_bitbang_harmony.c")
calLibSwiBBHalSrcFile.setOutputName("hal_swi_bitbang_harmony.c")
calLibSwiBBHalSrcFile.setDestPath("library/cryptoauthlib/hal")
calLibSwiBBHalSrcFile.setProjectPath("config/" + configName + "/library/cryptoauthlib/hal/")
calLibSwiBBHalSrcFile.setType('SOURCE')
calLibSwiBBHalSrcFile.setEnabled(False)

calLibSpiHalSrcFile = calComponent.createFileSymbol("CAL_FILE_SRC_HAL_SPI", None)
calLibSpiHalSrcFile.setSourcePath("lib/hal/hal_spi_harmony.c")
Expand All @@ -317,6 +385,10 @@ def instantiateComponent(calComponent):
calLibSpiHalSrcFile.setEnabled(False)

# List of HALs that will be included based on device connections
calHalList = calComponent.createListSymbol('CAL_HAL_LIST', None)
calHalList = calComponent.createListEntrySymbol('CAL_HAL_LIST_ENTRIES', None)
calHalList.setTarget('cryptoauthlib.CAL_HAL_LIST')

calPlibList = calComponent.createListSymbol('CAL_PLIB_LIST', None)
calPlibList = calComponent.createListEntrySymbol('CAL_PLIB_LIST_ENTRIES', None)
calPlibList.setTarget('cryptoauthlib.CAL_PLIB_LIST')
Expand All @@ -325,6 +397,15 @@ def instantiateComponent(calComponent):
calDeviceList = calComponent.createListSymbol('CAL_DEVICE_LIST', None)
calDeviceList = calComponent.createListEntrySymbol('CAL_DEVICE_LIST_ENTRIES', None)
calDeviceList.setTarget('cryptoauthlib.CAL_DEVICE_LIST')

# Add device specific options
calTaEnableAesAuth = calComponent.createBooleanSymbol('CAL_ENABLE_TA100_AES_AUTH', None)
calTaEnableAesAuth.setValue(False)
calTaEnableAesAuth.setVisible(True)

calTaEnableFce = calComponent.createBooleanSymbol('CAL_ENABLE_TA100_FCE', None)
calTaEnableFce.setValue(False)
calTaEnableFce.setVisible(True)


################# Templated files to be included #######################
Expand Down
116 changes: 90 additions & 26 deletions harmony/config/device_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*****************************************************************************"""

_DEFAULT_I2C_ADDRESS = {'ecc': 0xC0, 'sha': 0xC8, 'ta100': 0x2e}
_SWI_DEVICES = ['ATSHA204A', 'ATSHA206A', 'ATECC108A', 'ATECC508A', 'ATECC608']
_I2C_DEVICES = ['ATSHA204A', 'ATECC108A', 'ATECC508A', 'ATECC608', 'TA100']
_SWI_DEVICES = ['ATSHA204A', 'ATSHA206A', 'ATECC108A', 'ATECC508A', 'ATECC608', 'ECC204']
_I2C_DEVICES = ['ATSHA204A', 'ATECC108A', 'ATECC508A', 'ATECC608', 'TA100', 'ECC204']
_SPI_DEVICES = ['TA100']


Expand All @@ -36,29 +36,56 @@ def updateTngCapability(id, src):
Database.sendMessage('cryptoauthlib_tng', 'UPDATE_TNG_TYPE', {'id': id, 'src': src})


def updateSwiBbInterfaceSettings(symbol, swi_bb_iface):
if swi_bb_iface:
symbol.getComponent().getSymbolByID('HAL_INTERFACE').setValue("GPIO")
updateSercomPlibList("GPIO_SWI_BB", swi_bb_iface)
else:
if symbol.getComponent().getSymbolByID('INTERFACE').getReadOnly():
pass
else:
try:
symbol.getComponent().getSymbolByID('HAL_INTERFACE').clearValue()
except AttributeError:
pass
updateSercomPlibList("GPIO_SWI_BB", swi_bb_iface)


def updatePartInterfaceSettings(symbol, event):
symObj = event['symbol']
updateId = event['id'].upper()
selected_key = symObj.getSelectedKey()
SWI_BB_IFACE = False

if updateId == 'INTERFACE':
if selected_key == 'ATCA_SPI_IFACE':
symbol.setVisible('SPI' in symbol.getID())
symbol.getComponent().getSymbolByID('I2C_ADDR').setVisible(False)
elif selected_key == 'ATCA_I2C_IFACE':
symbol.setVisible('I2C' in symbol.getID())
elif selected_key == 'ATCA_SWI_IFACE':
symbol.setVisible('SWI_UART' in symbol.getID())
symbol.getComponent().getSymbolByID('I2C_ADDR').setVisible(False)
elif selected_key == 'ATCA_SWI_BB_IFACE':
SWI_BB_IFACE = True
symbol.setVisible('SWIBB' in symbol.getID())
symbol.getComponent().getSymbolByID('I2C_ADDR').setVisible(False)

updateSwiBbInterfaceSettings(symbol, SWI_BB_IFACE)
elif updateId == 'PART_TYPE':
if selected_key == "TNGTLS":
Database.activateComponents(['cryptoauthlib_tng'])
symbol.setValue(0x6A)
i2c_addr = 0x6A
elif selected_key == "TFLEX":
Database.activateComponents(['cryptoauthlib_tng'])
symbol.setValue(0x6C)
i2c_addr = 0x6C
elif selected_key == "TNGLORA":
Database.activateComponents(['cryptoauthlib_tng'])
symbol.setValue(0xB2)
i2c_addr = 0xB2
else:
symbol.setValue(0xC0)
i2c_addr = 0xC0

symbol.getComponent().getSymbolByID('I2C_ADDR').setValue(i2c_addr)
updateTngCapability(selected_key, event['namespace'])


Expand All @@ -84,10 +111,11 @@ def instantiateComponent(deviceComponent, index):
interfaceType.setLabel('Interface Type')
if deviceType in _I2C_DEVICES:
interfaceType.addKey("ATCA_I2C_IFACE", "0", "I2C")
# if deviceType in _SWI_DEVICES:
# interfaceType.addKey("ATCA_SWI_IFACE", "1", "SWI")
if deviceType in _SWI_DEVICES:
interfaceType.addKey("ATCA_SWI_IFACE", "1", "SWI")
interfaceType.addKey("ATCA_SWI_BB_IFACE", "2", "SWI_BB")
if deviceType in _SPI_DEVICES:
interfaceType.addKey("ATCA_SPI_IFACE", "2", "SPI")
interfaceType.addKey("ATCA_SPI_IFACE", "3", "SPI")
interfaceType.setDefaultValue(0)
interfaceType.setOutputMode("Key")
interfaceType.setDisplayMode("Description")
Expand All @@ -102,22 +130,25 @@ def instantiateComponent(deviceComponent, index):
devicePartType.setDefaultValue(0)
devicePartType.setOutputMode("Key")
devicePartType.setDisplayMode("Description")

deviceAddress = deviceComponent.createHexSymbol("I2C_ADDR", devicePartType)
deviceAddress.setLabel("I2C Address")
deviceAddress.setDefaultValue(0xC0)
else:
deviceAddress = deviceComponent.createHexSymbol("I2C_ADDR", interfaceType)
deviceAddress.setLabel("I2C Address")

if 'ECC' in deviceID:
deviceAddress.setDefaultValue(_DEFAULT_I2C_ADDRESS['ecc'])
elif 'SHA' in deviceID:
deviceAddress.setDefaultValue(_DEFAULT_I2C_ADDRESS['sha'])
elif 'TA' in deviceID:
deviceAddress.setDefaultValue(_DEFAULT_I2C_ADDRESS['ta100'])

deviceAddress.setDependencies(updatePartInterfaceSettings, ["PART_TYPE"])
devicePartType.setDependencies(updatePartInterfaceSettings, ["PART_TYPE"])

deviceAddress = deviceComponent.createHexSymbol("I2C_ADDR", interfaceType)
deviceAddress.setLabel("I2C Address")

if 'ECC' in deviceID:
deviceAddress.setDefaultValue(_DEFAULT_I2C_ADDRESS['ecc'])
elif 'SHA' in deviceID:
deviceAddress.setDefaultValue(_DEFAULT_I2C_ADDRESS['sha'])
elif 'TA' in deviceID:
deviceAddress.setDefaultValue(_DEFAULT_I2C_ADDRESS['ta100'])

deviceAddress.setDependencies(updatePartInterfaceSettings, ["INTERFACE"])
deviceAddress.setVisible(True)

swiUartComment = deviceComponent.createCommentSymbol("SWI_UART_COMMENT", interfaceType)
swiUartComment.setLabel("!!! Select UART Ring buffer mode in UART configuration.!!! ")
swiUartComment.setDependencies(updatePartInterfaceSettings, ["INTERFACE"])
swiUartComment.setVisible(False)

spiCsComment = deviceComponent.createCommentSymbol("SPI_CS_PINS_COMMENT", interfaceType)
spiCsComment.setLabel("!!! Configure the Chip Select pin as GPIO OUTPUT in Pin Settings.!!! ")
Expand All @@ -132,6 +163,20 @@ def instantiateComponent(deviceComponent, index):
spiChipSelectPin.setDependencies(updatePartInterfaceSettings, ["INTERFACE"])
spiChipSelectPin.setVisible(False)

swibbPinComment = deviceComponent.createCommentSymbol("SWIBB_PIN_COMMENT", interfaceType)
swibbPinComment.setLabel("!!! Configure the SWI Crypto pin as GPIO INPUT.!!! ")
swibbPinComment.setDependencies(updatePartInterfaceSettings, ["INTERFACE"])
swibbPinComment.setVisible(False)

# Gpio pin configuration for swi bitbang
swibbCryptoPin = deviceComponent.createKeyValueSetSymbol("SWIBB_CRYPTO_PIN", interfaceType)
swibbCryptoPin.setLabel("SWIBB Crypto Pin")
swibbCryptoPin.setDefaultValue(0)
swibbCryptoPin.setOutputMode("Key")
swibbCryptoPin.setDisplayMode("Description")
swibbCryptoPin.setDependencies(updatePartInterfaceSettings, ["INTERFACE"])
swibbCryptoPin.setVisible(False)

availablePinDictionary = {}
availablePinDictionary = Database.sendMessage("core", "PIN_LIST", availablePinDictionary)

Expand All @@ -140,6 +185,7 @@ def instantiateComponent(deviceComponent, index):
value = list(availablePinDictionary.keys())[list(availablePinDictionary.values()).index(pad)]
description = pad
spiChipSelectPin.addKey(key, value, description)
swibbCryptoPin.addKey(key, value, description)

wakeupDelay = deviceComponent.createIntegerSymbol("WAKEUP_DELAY", None)
wakeupDelay.setLabel("Wakeup Delay (us)")
Expand Down Expand Up @@ -179,7 +225,14 @@ def onAttachmentConnected(source, target):
elif 'SPI' in sourceID:
source['component'].getSymbolByID('HAL_INTERFACE').setValue(targetID)
source['component'].getSymbolByID('INTERFACE').setReadOnly(True)
source['component'].getSymbolByID('INTERFACE').setSelectedKey('ATCA_SPI_IFACE', 1)
source['component'].getSymbolByID('INTERFACE').setSelectedKey('ATCA_SPI_IFACE', 3)
updateSercomPlibList(target['id'], True)
elif 'SWI' in sourceID:
source['component'].getSymbolByID('HAL_INTERFACE').setValue(targetID)
source['component'].getSymbolByID('INTERFACE').setReadOnly(True)
source['component'].getSymbolByID('INTERFACE').setSelectedKey('ATCA_SWI_IFACE', 1)
if "uart" in target['id'].lower():
target['id'] = target['id'].replace("UART", "SWI_UART")
updateSercomPlibList(target['id'], True)


Expand All @@ -205,5 +258,16 @@ def onAttachmentDisconnected(source, target):
# Happens when the instance is deleted while attached
pass
updateSercomPlibList(target['id'], False)
elif 'SWI' in sourceID:
try:
source['component'].getSymbolByID('HAL_INTERFACE').clearValue()
source['component'].getSymbolByID('INTERFACE').clearValue()
source['component'].getSymbolByID('INTERFACE').setReadOnly(False)
except AttributeError:
# Happens when the instance is deleted while attached
pass
if "uart" in target['id'].lower():
target['id'] = target['id'].replace("UART", "SWI_UART")
updateSercomPlibList(target['id'], False)


Loading

0 comments on commit 51fa842

Please sign in to comment.