diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..19947e34c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,21 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..85bf078e2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,14 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/product-support.md b/.github/ISSUE_TEMPLATE/product-support.md new file mode 100644 index 000000000..308b59c4d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/product-support.md @@ -0,0 +1,9 @@ +--- +name: Product Support +about: Questions on product or library configuration and usage + +--- + +For product support please submit a request through the [mySupport portal](https://microchipsupport.force.com/s/) where Microchip's global team of FAEs can work on your use case and questions. + +For details on the mySupport Portal or how to use it please see the [instructions for using the mySupport portal](https://microchipsupport.force.com/s/article/How-to-submit-a-case) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..8ca4c6205 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,104 @@ +name: Build and deploy wheels to pypi + +on: + push: + tags: + - 20* + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: '3.7' + + - name: Describe Tag & Branch Name + id: build_names + shell: bash + run: | + echo ::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/} + + - name: Install cibuildwheel + run: | + python -m pip install cibuildwheel + + - name: Install Visual C++ for Python 2.7 + if: runner.os == 'Windows' + run: | + choco install vcpython27 -f -y + + - name: Build wheels + shell: bash + run: | + echo $TAG_NAME + cd python + echo $TAG_NAME >VERSION + cp -r ../lib . + cp -r ../third_party . + mkdir app + cp -r ../app/tng app + python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_BUILD_VERBOSITY: 3 + TAG_NAME: ${{ steps.build_names.outputs.TAG_NAME }} + + - uses: actions/upload-artifact@v2 + with: + path: python/wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: '3.7' + + - name: Describe Tag & Branch Name + id: build_names + run: | + echo ::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/} + + - name: Build sdist + run: | + echo $TAG_NAME + cd python + echo $TAG_NAME >VERSION + cp -r ../lib . + cp -r ../third_party . + mkdir app + cp -r ../app/tng app + python setup.py sdist + env: + TAG_NAME: ${{ steps.build_names.outputs.TAG_NAME }} + + - uses: actions/upload-artifact@v2 + with: + path: python/dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + + steps: + - uses: actions/download-artifact@v2 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@master + with: + user: ${{ secrets.pypi_username }} + password: ${{ secrets.pypi_password }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1a5d3c504..000000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: python - -matrix: - include: -# - sudo: required -# services: -# - docker -# env: -# - PIP=pip -# - PYTHON=python -# - CIBW_BEFORE_BUILD_LINUX='yum install cmake -y' - - os: osx - language: generic - compiler: gcc - env: - - PIP=pip2 - - PYTHON=python2 - -script: - - cd python - - git describe --exclude v* --tags --abbrev=0 >VERSION - - cp -r ../lib . - - cp -r ../third_party . - - cp ../test/atca_utils_sizes.c . - - mkdir app - - cp -r ../app/tng app - - $PIP install wheel - - $PYTHON setup.py sdist --dist-dir wheelhouse - - $PIP install cibuildwheel - - export CIBW_SKIP='cp34-*' - - export CIBW_BUILD_VERBOSITY=3 - - cibuildwheel --output-dir wheelhouse - - | - if [[ $TRAVIS_TAG =~ ^[0-9]+$ ]]; then - $PIP install twine - $PYTHON -m twine upload wheelhouse/* --skip-existing - fi diff --git a/app/tng/tnglora_cert_def_2_device.h b/app/tng/tnglora_cert_def_2_device.h index c52b0cff8..5210a6a84 100644 --- a/app/tng/tnglora_cert_def_2_device.h +++ b/app/tng/tnglora_cert_def_2_device.h @@ -38,7 +38,7 @@ extern "C" { * @{ */ -SHARED_LIB_IMPORT const atcacert_def_t g_tnglora_cert_def_2_device; +ATCA_DLL const atcacert_def_t g_tnglora_cert_def_2_device; /** @} */ diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index e9e974f25..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,53 +0,0 @@ -environment: - TWINE_USERNAME: - secure: TEiy+eHGeQQIy9jUEpUNMA== - TWINE_PASSWORD: - secure: nGYP/oqo/DSfCQduEhhKGg== - - matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_JOB_NAME: "python37-x64-vs2017" - TAG_SCENARIO: true - -stack: python 3.7 - -init: - - cmd: set PATH=C:\Python37;C:\Python37\Scripts;%PATH% - -install: - - python -m pip install --upgrade twine - - python -m pip install --upgrade cibuildwheel - - -before_build: - - cd python - - mkdir lib - - mkdir app\tng - - mkdir third_party - - xcopy /S ..\lib lib - - xcopy /S ..\third_party third_party - - xcopy /S ..\app\tng app\tng - - copy ..\test\atca_utils_sizes.c . - - cmd: "git describe --exclude v* --tags --abbrev=0 >VERSION" - -build_script: - - python -m cibuildwheel --output-dir wheelhouse - -artifacts: - - path: python\wheelhouse\*.whl - name: Wheels - -#on_success: -# You can use this step to upload your artifacts to a public website. -# See Appveyor's documentation for more details. Or you can simply -# access your wheels from the Appveyor "artifacts" tab for your build. -deploy_script: - - ps: if ($env:APPVEYOR_REPO_TAG -eq $TRUE -and $env:APPVEYOR_REPO_TAG_NAME -notlike "v*") { & python -m twine upload "wheelhouse\*.whl" --skip-existing } - -for: -- - matrix: - only: - - TAG_SCENARIO: true - - skip_non_tags: true \ No newline at end of file diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 39427b58f..d788ab57b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -266,6 +266,7 @@ endif() if(ATCA_BUILD_SHARED_LIBS) add_definitions(-DATCA_BUILD_SHARED_LIBS) +set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} atca_utils_sizes.c) endif(ATCA_BUILD_SHARED_LIBS) add_library(cryptoauth ${CRYPTOAUTH_SRC} ${ATCACERT_DEF_SRC}) diff --git a/lib/atca_compiler.h b/lib/atca_compiler.h index 7242d74db..bf7e5c61f 100644 --- a/lib/atca_compiler.h +++ b/lib/atca_compiler.h @@ -37,6 +37,8 @@ #define ATCA_UINT16_HOST_TO_LE(x) __builtin_bswap16(x) #define ATCA_UINT16_LE_TO_HOST(x) __builtin_bswap16(x) #define ATCA_UINT32_HOST_TO_LE(x) __builtin_bswap32(x) +#define ATCA_UINT16_HOST_TO_BE(x) (x) +#define ATCA_UINT16_BE_TO_HOST(x) (x) #define ATCA_UINT32_HOST_TO_BE(x) (x) #define ATCA_UINT32_BE_TO_HOST(x) (x) #define ATCA_UINT64_HOST_TO_BE(x) (x) @@ -45,6 +47,8 @@ #define ATCA_UINT16_HOST_TO_LE(x) (x) #define ATCA_UINT16_LE_TO_HOST(x) (x) #define ATCA_UINT32_HOST_TO_LE(x) (x) +#define ATCA_UINT16_HOST_TO_BE(x) __builtin_bswap16(x) +#define ATCA_UINT16_BE_TO_HOST(x) __builtin_bswap16(x) #define ATCA_UINT32_HOST_TO_BE(x) __builtin_bswap32(x) #define ATCA_UINT32_BE_TO_HOST(x) __builtin_bswap32(x) #define ATCA_UINT64_HOST_TO_BE(x) __builtin_bswap64(x) diff --git a/test/atca_utils_sizes.c b/lib/atca_utils_sizes.c similarity index 100% rename from test/atca_utils_sizes.c rename to lib/atca_utils_sizes.c diff --git a/lib/hal/hal_linux_spi_userspace.c b/lib/hal/hal_linux_spi_userspace.c index a646193f0..004591951 100644 --- a/lib/hal/hal_linux_spi_userspace.c +++ b/lib/hal/hal_linux_spi_userspace.c @@ -111,7 +111,7 @@ ATCA_STATUS hal_spi_init(void *hal, ATCAIfaceCfg *cfg) hal_data->ref_ct = 1; // buses are shared, this is the first instance (void)snprintf(hal_data->spi_file, sizeof(hal_data->spi_file) - 1, - "/dev/spidev%d.%d", cfg->atcaspi.bus, cfg->atcaspi.select_pin); + "/dev/spidev%d.%d", (uint8_t)cfg->atcaspi.bus, (uint8_t)cfg->atcaspi.select_pin); pHal->hal_data = hal_data; } @@ -263,13 +263,14 @@ ATCA_STATUS hal_spi_wake(ATCAIface iface) uint8_t csr_reg; int delay_timeout = (int)cfg->wake_delay; + do { - status = hal_spi_receive(iface, word_address, &csr_reg, &len); if (status == ATCA_SUCCESS) { +#ifdef ATCA_TA100_SUPPORT /*status bit check in CSR register*/ if ((len == 1) && (((csr_reg >> 1) & 0x03 ) != 0x03)) { @@ -282,6 +283,9 @@ ATCA_STATUS hal_spi_wake(ATCAIface iface) break; } +#else + break; +#endif } /*poll csr register for every 100us*/ diff --git a/lib/hal/hal_linux_spi_userspace.h b/lib/hal/hal_linux_spi_userspace.h index f5abba154..a5e275696 100644 --- a/lib/hal/hal_linux_spi_userspace.h +++ b/lib/hal/hal_linux_spi_userspace.h @@ -40,7 +40,7 @@ // A structure to hold I2C information typedef struct atcaSPImaster { - char spi_file[16]; + char spi_file[20]; int ref_ct; } ATCASPIMaster_t; diff --git a/python/MANIFEST.in b/python/MANIFEST.in index ffaf5939b..5044a4d0e 100644 --- a/python/MANIFEST.in +++ b/python/MANIFEST.in @@ -1,4 +1,4 @@ recursive-include lib *.c *.h atca_config.h.in CMakeLists.txt 90-cryptohid.rules recursive-include third_party *.c *.h recursive-include app *.c *.h -include MANIFEST.in setup.py setup.cfg README.md VERSION atca_utils_sizes.c +include MANIFEST.in setup.py setup.cfg README.md VERSION diff --git a/python/cryptoauthlib/atcab.py b/python/cryptoauthlib/atcab.py index 2a096e33d..fc1bae205 100644 --- a/python/cryptoauthlib/atcab.py +++ b/python/cryptoauthlib/atcab.py @@ -2983,6 +2983,6 @@ def atcab_write_config_counter(counter_id, counter_value): # Make module import * safe - keep at the end of the file -__all__ = ['atca_aes_cbc_ctx', 'atca_aes_cmac_ctx', 'atca_aes_ctr_ctx', - 'atca_aes_gcm_ctx', 'atca_sha256_ctx', 'atca_hmac_sha256_ctx'] +__all__ = ['atca_aes_cbc_ctx', 'atca_aes_cmac_ctx', 'atca_aes_ctr_ctx', 'atca_aes_cbcmac_ctx', + 'atca_aes_ccm_ctx', 'atca_aes_gcm_ctx', 'atca_sha256_ctx', 'atca_hmac_sha256_ctx'] __all__ += [x for x in dir() if x.startswith(__name__.split('.')[-1])] diff --git a/python/setup.py b/python/setup.py index 2b4f429d4..6813d3e00 100644 --- a/python/setup.py +++ b/python/setup.py @@ -54,6 +54,12 @@ else: _sdist_build = False +#python 2 compatibility +try: + FileNotFoundError +except NameError: + FileNotFoundError = IOError + # See if the library is already installed try: lib = cdll.LoadLibrary('libcryptoauth.so') @@ -158,8 +164,6 @@ def build_extension(self, ext): if sys.platform.startswith('linux'): cmake_args += ['-DATCA_HAL_I2C=ON', '-DATCA_HAL_SPI=ON'] - cmake_args += ['-DATCACERT_DEF_SRC={}atca_utils_sizes.c'.format(setupdir.replace('\\','/') if _sdist_build else '../test/')] - if not os.path.exists(self.build_temp): os.makedirs(self.build_temp)