cryptoauthlib: update to 30/7/2019 pkcs11 release

This version is based on the 20190517 master release, with the addition of
pkcs11 provisioning support.

The source code now has cmake files, so we don't need as many code
customizations as we used to. Revamp the recipe and its patches.

https://jira.digi.com/browse/DEL-6826
https://jira.digi.com/browse/DEL-6835

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
Gabriel Valcazar 2019-11-07 16:52:06 +01:00
parent 73352a83a2
commit 3fc4ae7218
9 changed files with 272 additions and 14382 deletions

View File

@ -1,404 +0,0 @@
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
Date: Wed, 14 Feb 2018 17:30:49 +0100
Subject: [PATCH 1/2] Port changes from the cryptoauth engine repo to the
library repo
Incorporate makefiles to be able to build cryptoauthlib as well as the changes
Digi has done in the atmel-cryptoauth-openssl-engine repo (except for
our modifications in the HAL section, which are not needed anymore). Update
package configuration version to 1.3, remove OpenSSL engine dependencies and
fix an infinite recursion that happened when cleaning the project.
https://jira.digi.com/browse/DEL-5591
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
---
Makefile | 32 +++++++++++++++++
Makefile.generic | 22 ++++++++++++
ecc-test-main.c | 71 +++++++++++++++++++++++++++++++++++++
lib/Makefile | 46 ++++++++++++++++++++++++
lib/atca_cfgs.c | 16 +++++++--
lib/atcacert/Makefile | 1 +
lib/basic/Makefile | 1 +
lib/crypto/Makefile | 1 +
lib/crypto/hashes/Makefile | 1 +
lib/cryptoauthlib.pc | 11 ++++++
lib/hal/Makefile | 1 +
lib/host/Makefile | 1 +
lib/jwt/Makefile | 1 +
lib/tls/Makefile | 1 +
test/Makefile | 15 ++++++++
test/atcacert/Makefile | 1 +
test/jwt/Makefile | 1 +
test/sha-byte-test-vectors/Makefile | 1 +
test/tls/Makefile | 1 +
19 files changed, 222 insertions(+), 3 deletions(-)
create mode 100644 Makefile
create mode 100644 Makefile.generic
create mode 100644 ecc-test-main.c
create mode 100644 lib/Makefile
create mode 100644 lib/atcacert/Makefile
create mode 100644 lib/basic/Makefile
create mode 100644 lib/crypto/Makefile
create mode 100644 lib/crypto/hashes/Makefile
create mode 100644 lib/cryptoauthlib.pc
create mode 100644 lib/hal/Makefile
create mode 100644 lib/host/Makefile
create mode 100644 lib/jwt/Makefile
create mode 100644 lib/tls/Makefile
create mode 100644 test/Makefile
create mode 100644 test/atcacert/Makefile
create mode 100644 test/jwt/Makefile
create mode 100644 test/sha-byte-test-vectors/Makefile
create mode 100644 test/tls/Makefile
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000000..a471428ad12c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,32 @@
+CWD:= $(shell pwd)
+CFLAGS+= -I. -I../.. -fPIC -g -O0
+SRC:= $(wildcard *.c)
+export CFLAGS
+
+SUBDIRS= lib test
+
+.PHONY: tgt_lib tgt_test clean
+
+all: tgt_lib tgt_test ecc-test
+
+%.o: %.c
+ $(CC) $(CFLAGS) -o $@ -c $<
+
+tgt_lib:
+ make -w -C lib
+
+tgt_test:
+ make -w -C test
+
+ecc-test: tgt_lib tgt_test
+ $(CC) -c ecc-test-main.c $(CFLAGS) $(LDFLAGS) -I ./lib/ -I ./test/
+ $(CC) -o ecc-test-main ecc-test-main.o $(LDFLAGS) test/tls/atcatls_tests.o -L lib -L test -lm -lc -lrt -lcryptoauth -lunity
+
+install:
+ for a in $(SUBDIRS); do $(MAKE) -C $$a $@; done
+ install -d $(DESTDIR)/usr/bin
+ install -m 0755 ecc-test-main $(DESTDIR)/usr/bin/
+
+clean:
+ rm -f *.o *.a ecc-test-main
+ $(foreach subdir,$(basename $(SUBDIRS)),$(MAKE) -w -C $(subdir) clean;)
diff --git a/Makefile.generic b/Makefile.generic
new file mode 100644
index 000000000000..f6a0d67c708c
--- /dev/null
+++ b/Makefile.generic
@@ -0,0 +1,22 @@
+CWD:= $(shell pwd)
+CFLAGS+= -I. -I.. -I../.. -I../../.. -I../../../.. -I../../lib -I../lib -fPIC -g -O0 -DATCA_HAL_I2C -DATCAPRINTF
+SRC:= $(wildcard *.c)
+export CFLAGS
+
+DIRECTORIES= $(shell find . -maxdepth 1 ! -path . -type d)
+SUBDIRS= $(DIRECTORIES)
+
+.PHONY: clean tgt_local
+
+MODULES= $(patsubst %.c,%.o,$(SRC))
+
+all: $(MODULES) tgt_local
+ $(foreach subdir,$(basename $(SUBDIRS)),$(MAKE) -w -C $(subdir);)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -o $@ -c $<
+
+clean:
+ rm -f *.o *.a
+ $(foreach subdir,$(basename $(SUBDIRS)),$(MAKE) -w -C $(subdir) clean;)
+
diff --git a/ecc-test-main.c b/ecc-test-main.c
new file mode 100644
index 000000000000..032bc4bc2b5a
--- /dev/null
+++ b/ecc-test-main.c
@@ -0,0 +1,71 @@
+/** \file ecc-test-main.c
+ * \brief Used to launch CryptoAuthLib tests for TLS
+ *
+ * Copyright (c) 2015 Atmel Corporation. All rights reserved.
+ *
+ * \atmel_crypto_device_library_license_start
+ *
+ * \page License
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Atmel nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior written permission.
+ *
+ * 4. This software may only be redistributed and used in connection with an
+ * Atmel integrated circuit.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+//#include "ssl.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <cryptoauthlib.h>
+#include <tls/atcatls_tests.h>
+
+#define ATCA_HAL_I2C
+
+// Get a pointer to the default configuration based on the compiler switch
+#ifdef ATCA_HAL_KIT_CDC
+ATCAIfaceCfg* pCfg = &cfg_ecc508_kitcdc_default;
+#elif defined(ATCA_HAL_KIT_HID)
+ATCAIfaceCfg* pCfg = &cfg_ecc508_kithid_default;
+#elif defined(ATCA_HAL_I2C)
+ATCAIfaceCfg* pCfg = &cfg_ateccx08a_i2c_default;
+#endif
+
+
+/** \brief Main function for running ATECC508 tests.
+ * Use this test program to ensure that the Engine can communicate to your ATECC508
+ *
+ * \return For success return 0
+ */
+int main()
+{
+ uint8_t runTests = true;
+
+ if (runTests)
+ {
+ atcatls_test_runner(pCfg);
+ }
+ return 0;
+}
diff --git a/lib/Makefile b/lib/Makefile
new file mode 100644
index 000000000000..e8c89380a43c
--- /dev/null
+++ b/lib/Makefile
@@ -0,0 +1,46 @@
+CWD:=$(shell pwd)
+SRC:=$(wildcard *.c)
+
+DIRECTORIES=$(shell find . -maxdepth 1 ! -path . -type d)
+SUBDIRS=$(DIRECTORIES)
+
+.PHONY: clean
+
+MODULES=$(patsubst %.c,%.o,$(SRC))
+#O_FILES=$(shell find . -name \*.o)
+O_FILES=$(wildcard **/**/*.o)
+O_FILES+=$(wildcard **/*.o)
+LIBNAME=libcryptoauth
+
+INCLUDE_PATH = "$(DESTDIR)/usr/include/cryptoauthlib"
+
+all: $(MODULES)
+ - $(foreach subdir,$(basename $(SUBDIRS)),$(shell make -w -C $(subdir)))
+ @echo "OFILES: $(O_FILES)"
+ $(AR) -r $(LIBNAME).a $(MODULES) $(O_FILES)
+ $(RANLIB) $(LIBNAME).a
+
+.PHONY: install
+install: $(LIBNAME).a
+ install -d $(DESTDIR)/usr/lib/pkgconfig
+ install -m 0644 $(LIBNAME).a $(DESTDIR)/usr/lib/
+ install -m 0644 cryptoauthlib.pc $(DESTDIR)/usr/lib/pkgconfig/
+
+ install -d $(INCLUDE_PATH)/atcacert $(INCLUDE_PATH)/basic $(INCLUDE_PATH)/hal $(INCLUDE_PATH)/tls
+ install -m 0644 atcacert/*.h $(INCLUDE_PATH)/atcacert
+ install -m 0644 basic/*.h $(INCLUDE_PATH)/basic
+ install -m 0644 hal/*.h $(INCLUDE_PATH)/hal
+ install -m 0644 tls/*.h $(INCLUDE_PATH)/tls
+ install -m 0644 *.h $(INCLUDE_PATH)
+
+ install -d $(INCLUDE_PATH)/crypto/hashes
+ install -m 0644 crypto/*.h $(INCLUDE_PATH)/crypto
+ install -m 0644 crypto/hashes/*.h $(INCLUDE_PATH)/crypto/hashes
+
+%.o: %.c
+ $(CC) $(CFLAGS) -o $@ -c $<
+
+clean:
+ rm -f *.o *.a
+ $(foreach subdir,$(basename $(SUBDIRS)),$(MAKE) -w -C $(subdir) clean;)
+
diff --git a/lib/atca_cfgs.c b/lib/atca_cfgs.c
index b8de8e8ede7f..4cbd305724d4 100644
--- a/lib/atca_cfgs.c
+++ b/lib/atca_cfgs.c
@@ -40,14 +40,24 @@
/* if the number of these configurations grows large, we can #ifdef them based on required device support */
+/* Default I2C configuration */
+#ifndef ATCA_HAL_I2C_BUS
+#define ATCA_HAL_I2C_BUS 0
+#warning "Using default value for ATCA_HAL_I2C_BUS: 0"
+#endif
+
+#ifndef ATCA_HAL_I2C_SPEED
+#define ATCA_HAL_I2C_SPEED 400000
+#warning "Using default value for ATCA_HAL_I2C_SPEED: 400000"
+#endif
+
/** \brief default configuration for an ECCx08A device */
ATCAIfaceCfg cfg_ateccx08a_i2c_default = {
.iface_type = ATCA_I2C_IFACE,
.devtype = ATECC508A,
.atcai2c.slave_address = 0xC0,
- .atcai2c.bus = 2,
- .atcai2c.baud = 400000,
- //.atcai2c.baud = 100000,
+ .atcai2c.bus = ATCA_HAL_I2C_BUS,
+ .atcai2c.baud = ATCA_HAL_I2C_SPEED,
.wake_delay = 1500,
.rx_retries = 20
};
diff --git a/lib/atcacert/Makefile b/lib/atcacert/Makefile
new file mode 100644
index 000000000000..aa3e01644e15
--- /dev/null
+++ b/lib/atcacert/Makefile
@@ -0,0 +1 @@
+include ../../Makefile.generic
diff --git a/lib/basic/Makefile b/lib/basic/Makefile
new file mode 100644
index 000000000000..aa3e01644e15
--- /dev/null
+++ b/lib/basic/Makefile
@@ -0,0 +1 @@
+include ../../Makefile.generic
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
new file mode 100644
index 000000000000..aa3e01644e15
--- /dev/null
+++ b/lib/crypto/Makefile
@@ -0,0 +1 @@
+include ../../Makefile.generic
diff --git a/lib/crypto/hashes/Makefile b/lib/crypto/hashes/Makefile
new file mode 100644
index 000000000000..0356cb8c0cd5
--- /dev/null
+++ b/lib/crypto/hashes/Makefile
@@ -0,0 +1 @@
+include ../../../Makefile.generic
diff --git a/lib/cryptoauthlib.pc b/lib/cryptoauthlib.pc
new file mode 100644
index 000000000000..001a02c1c341
--- /dev/null
+++ b/lib/cryptoauthlib.pc
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: cryptoauthlib
+Description: Atmel Cryptochip library for ATECC508A
+Version:1.3
+
+Libs: -L${libdir} -lcryptoauth
+Cflags: -I${includedir} -I${includedir}/cryptoauthlib -I${includedir}/cryptoauthlib/tls
diff --git a/lib/hal/Makefile b/lib/hal/Makefile
new file mode 100644
index 000000000000..aa3e01644e15
--- /dev/null
+++ b/lib/hal/Makefile
@@ -0,0 +1 @@
+include ../../Makefile.generic
diff --git a/lib/host/Makefile b/lib/host/Makefile
new file mode 100644
index 000000000000..aa3e01644e15
--- /dev/null
+++ b/lib/host/Makefile
@@ -0,0 +1 @@
+include ../../Makefile.generic
diff --git a/lib/jwt/Makefile b/lib/jwt/Makefile
new file mode 100644
index 000000000000..aa3e01644e15
--- /dev/null
+++ b/lib/jwt/Makefile
@@ -0,0 +1 @@
+include ../../Makefile.generic
diff --git a/lib/tls/Makefile b/lib/tls/Makefile
new file mode 100644
index 000000000000..aa3e01644e15
--- /dev/null
+++ b/lib/tls/Makefile
@@ -0,0 +1 @@
+include ../../Makefile.generic
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 000000000000..5de9ef42a46b
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,15 @@
+LIBNAME= libunity
+LIB= $(LIBNAME).a
+AR+= r
+
+include ../Makefile.generic
+
+tgt_local:
+ $(CC) -o unity.o -c unity.c
+ $(AR) $(LIB) unity.o
+
+ecc-test: tgt_local
+ $(CC) -c ecc-test-main.c $(CFLAGS) -I. -I..
+ $(CC) -o ecc-test-main ecc-test-main.o ../test/tls/atcatls_tests.o -Lcryptoauthlib/lib -lcryptoauth -Lcryptoauthlib/test -lunity -lm -lc -lrt
+
+install: ;
diff --git a/test/atcacert/Makefile b/test/atcacert/Makefile
new file mode 100644
index 000000000000..aa3e01644e15
--- /dev/null
+++ b/test/atcacert/Makefile
@@ -0,0 +1 @@
+include ../../Makefile.generic
diff --git a/test/jwt/Makefile b/test/jwt/Makefile
new file mode 100644
index 000000000000..aa3e01644e15
--- /dev/null
+++ b/test/jwt/Makefile
@@ -0,0 +1 @@
+include ../../Makefile.generic
diff --git a/test/sha-byte-test-vectors/Makefile b/test/sha-byte-test-vectors/Makefile
new file mode 100644
index 000000000000..78d24559879f
--- /dev/null
+++ b/test/sha-byte-test-vectors/Makefile
@@ -0,0 +1 @@
+empty_target: ;
diff --git a/test/tls/Makefile b/test/tls/Makefile
new file mode 100644
index 000000000000..aa3e01644e15
--- /dev/null
+++ b/test/tls/Makefile
@@ -0,0 +1 @@
+include ../../Makefile.generic

View File

@ -0,0 +1,63 @@
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
Date: Thu, 31 Oct 2019 11:49:06 +0100
Subject: [PATCH 1/6] lib: add parameters to be able to modify default I2C bus
index and speed
https://jira.digi.com/browse/DEL-6826
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
---
lib/CMakeLists.txt | 8 ++++++++
lib/atca_cfgs.c | 15 +++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 9816ed1..b198d1f 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -66,6 +66,14 @@ add_definitions(-DATCA_HAL_I2C)
set(CRYPTOAUTH_SRC ${CRYPTOAUTH_SRC} ${TWI_SRC})
endif(LINUX AND ATCA_HAL_I2C)
+if(ATCA_HAL_I2C_BUS)
+add_definitions(-DATCA_HAL_I2C_BUS=${ATCA_HAL_I2C_BUS})
+endif(ATCA_HAL_I2C_BUS)
+
+if(ATCA_HAL_I2C_SPEED)
+add_definitions(-DATCA_HAL_I2C_SPEED=${ATCA_HAL_I2C_SPEED})
+endif(ATCA_HAL_I2C_SPEED)
+
if(ATCA_HAL_CUSTOM)
add_definitions(-DATCA_HAL_CUSTOM)
endif()
diff --git a/lib/atca_cfgs.c b/lib/atca_cfgs.c
index a79e02b..60727f7 100644
--- a/lib/atca_cfgs.c
+++ b/lib/atca_cfgs.c
@@ -37,13 +37,24 @@
/* if the number of these configurations grows large, we can #ifdef them based on required device support */
+/* Default I2C configuration */
+#ifndef ATCA_HAL_I2C_BUS
+#define ATCA_HAL_I2C_BUS 0
+#warning "Using default value for ATCA_HAL_I2C_BUS: 0"
+#endif
+
+#ifndef ATCA_HAL_I2C_SPEED
+#define ATCA_HAL_I2C_SPEED 400000
+#warning "Using default value for ATCA_HAL_I2C_SPEED: 400000"
+#endif
+
/** \brief default configuration for an ECCx08A device */
ATCAIfaceCfg cfg_ateccx08a_i2c_default = {
.iface_type = ATCA_I2C_IFACE,
.devtype = ATECC608A,
.atcai2c.slave_address = 0xC0,
- .atcai2c.bus = 1,
- .atcai2c.baud = 400000,
+ .atcai2c.bus = ATCA_HAL_I2C_BUS,
+ .atcai2c.baud = ATCA_HAL_I2C_SPEED,
//.atcai2c.baud = 100000,
.wake_delay = 1500,
.rx_retries = 20

View File

@ -0,0 +1,30 @@
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
Date: Mon, 4 Nov 2019 16:11:48 +0100
Subject: [PATCH 2/6] lib: apply library version number to CMake VERSION
property
This way, CMake will generate a shared library with the version number and an
additional symlink without it. This avoids bitbake errors that appear when
creating *-dev packages, as Yocto development packages should only include
the soname symlinks instead of the actual library file.
https://jira.digi.com/browse/DEL-6826
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
---
lib/CMakeLists.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index b198d1f..88533f1 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -93,6 +93,8 @@ endif()
add_library(cryptoauth ${CRYPTOAUTH_SRC} ${ATCACERT_DEF_SRC})
+set_property(TARGET cryptoauth PROPERTY VERSION "${VERSION}")
+
set_property(TARGET cryptoauth PROPERTY C_STANDARD 99)
if(ATCA_PRINTF)

View File

@ -1,50 +0,0 @@
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
Date: Mon, 26 Feb 2018 11:42:50 +0100
Subject: [PATCH 1/2] Build cryptochip-cmd-processor application along with the
library
This new test application is more complete than ecc-test-main. It includes a
command line with different test runs for the chip's basic functionality,
helper functions, certificate functions and allows the configuration to be
read, among other things.
Hardcode the app to use the ATECC508A and remove all code that is specific for
other chips.
https://jira.digi.com/browse/DEL-5763
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
---
Makefile | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index a471428..c57b1bf 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ SUBDIRS= lib test
.PHONY: tgt_lib tgt_test clean
-all: tgt_lib tgt_test ecc-test
+all: tgt_lib tgt_test ecc-test cmd-processor
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
@@ -22,11 +22,15 @@ ecc-test: tgt_lib tgt_test
$(CC) -c ecc-test-main.c $(CFLAGS) $(LDFLAGS) -I ./lib/ -I ./test/
$(CC) -o ecc-test-main ecc-test-main.o $(LDFLAGS) test/tls/atcatls_tests.o -L lib -L test -lm -lc -lrt -lcryptoauth -lunity
+cmd-processor: tgt_lib tgt_test
+ $(CC) -o cryptochip-cmd-processor test/*.o $(LDFLAGS) test/*/*.o -L lib -L test -lcryptoauth
+
install:
for a in $(SUBDIRS); do $(MAKE) -C $$a $@; done
install -d $(DESTDIR)/usr/bin
install -m 0755 ecc-test-main $(DESTDIR)/usr/bin/
+ install -m 0755 cryptochip-cmd-processor $(DESTDIR)/usr/bin
clean:
- rm -f *.o *.a ecc-test-main
+ rm -f *.o *.a ecc-test-main cryptochip-cmd-processor
$(foreach subdir,$(basename $(SUBDIRS)),$(MAKE) -w -C $(subdir) clean;)

View File

@ -0,0 +1,84 @@
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
Date: Thu, 7 Nov 2019 13:43:53 +0100
Subject: [PATCH 3/6] pkcs11: rename template configuration file to its
intended name
Otherwise, users will need to manually rename the file in the rootfs to use
the pkcs11 feature.
https://jira.digi.com/browse/DEL-6835
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
---
CMakeLists.txt | 4 ++--
app/pkcs11/0.conf | 19 +++++++++++++++++++
app/pkcs11/slot.conf.tmpl | 19 -------------------
3 files changed, 21 insertions(+), 21 deletions(-)
create mode 100644 app/pkcs11/0.conf
delete mode 100644 app/pkcs11/slot.conf.tmpl
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9326fd1..00214d3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -80,8 +80,8 @@ install(CODE "
install(DIRECTORY DESTINATION ${DEFAULT_STORE_PATH})
install(CODE "execute_process(COMMAND chmod 1777 ${DEFAULT_STORE_PATH})")
install(CODE "
- if(NOT EXISTS ${DEFAULT_STORE_PATH}/slot.conf.tmpl)
- file(INSTALL ${PROJECT_SOURCE_DIR}/app/pkcs11/slot.conf.tmpl
+ if(NOT EXISTS ${DEFAULT_STORE_PATH}/0.conf)
+ file(INSTALL ${PROJECT_SOURCE_DIR}/app/pkcs11/0.conf
DESTINATION ${DEFAULT_STORE_PATH})
endif()
")
diff --git a/app/pkcs11/0.conf b/app/pkcs11/0.conf
new file mode 100644
index 0000000..b637abd
--- /dev/null
+++ b/app/pkcs11/0.conf
@@ -0,0 +1,19 @@
+# Reserved Configuration for a device
+# The objects in this file will be created and marked as undeletable
+# These are processed in order. Configuration parameters must be comma
+# delimited and may not contain spaces
+
+interface = i2c,0xB0
+freeslots = 1,2,3
+
+# Slot 0 is the primary private key
+object = private,device,0
+
+# Slot 10 is the certificate data for the device's public key
+#object = certificate,device,10
+
+# Slot 12 is the intermedate/signer certificate data
+#object = certificate,signer,12
+
+# Slot 15 is a public key
+object = public,root,15
diff --git a/app/pkcs11/slot.conf.tmpl b/app/pkcs11/slot.conf.tmpl
deleted file mode 100644
index b637abd..0000000
--- a/app/pkcs11/slot.conf.tmpl
+++ /dev/null
@@ -1,19 +0,0 @@
-# Reserved Configuration for a device
-# The objects in this file will be created and marked as undeletable
-# These are processed in order. Configuration parameters must be comma
-# delimited and may not contain spaces
-
-interface = i2c,0xB0
-freeslots = 1,2,3
-
-# Slot 0 is the primary private key
-object = private,device,0
-
-# Slot 10 is the certificate data for the device's public key
-#object = certificate,device,10
-
-# Slot 12 is the intermedate/signer certificate data
-#object = certificate,signer,12
-
-# Slot 15 is a public key
-object = public,root,15

View File

@ -1,454 +0,0 @@
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
Date: Fri, 23 Feb 2018 13:50:29 +0100
Subject: [PATCH 2/2] Remove unnecessary code from cryptochip-cmd-processor
Some test commands apply to chips other than the ATECC508A, and can cause
errors when used incorrectly. Remove all code that doesn't apply to our
platforms.
https://jira.digi.com/browse/DEL-5763
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
---
test/cmd-processor.c | 348 ++-------------------------------------------------
1 file changed, 13 insertions(+), 335 deletions(-)
diff --git a/test/cmd-processor.c b/test/cmd-processor.c
index c8c60e0..592157e 100644
--- a/test/cmd-processor.c
+++ b/test/cmd-processor.c
@@ -92,10 +92,6 @@ static void sernum(void);
static void discover(void);
static void select_device(ATCADeviceType device_type);
static int run_test(void* fptest);
-static void select_204(void);
-static void select_108(void);
-static void select_508(void);
-static void select_608(void);
static void run_basic_tests(void);
static void run_unit_tests(void);
static void run_otpzero_tests(void);
@@ -103,20 +99,11 @@ static void run_helper_tests(void);
static void help(void);
static int parse_cmd(const char *command);
static void run_all_tests(void);
-static ATCA_STATUS set_chip_mode(uint8_t i2c_user_extra_add, uint8_t ttl_enable, uint8_t watchdog, uint8_t clock_divider);
-static void set_clock_divider_m0(void);
-static void set_clock_divider_m1(void);
-static void set_clock_divider_m2(void);
static const char* argv[] = { "manual", "-v" };
static t_menu_info mas_menu_info[] =
{
{ "help", "Display Menu", help },
- { "discover", "Discover Buses and Devices", discover },
- { "204", "Set Target Device to ATECC204A", select_204 },
- { "108", "Set Target Device to ATECC108A", select_108 },
- { "508", "Set Target Device to ATECC508A", select_508 },
- { "608", "Set Target Device to ATECC608A", select_608 },
{ "info", "Get the Chip Revision", info },
{ "sernum", "Get the Chip Serial Number", sernum },
{ "basic", "Run Basic Test on Selected Device", run_basic_tests },
@@ -135,12 +122,9 @@ static t_menu_info mas_menu_info[] =
{ "cio", "Run Unit Test on Cert I/O", (fp_menu_handler)certio_unit_tests },
#endif
#ifdef TEST_SW_CRYPTO
- { "crypto", "Run Unit Tests for Software Crypto Functions", atca_crypto_sw_tests },
+ { "crypto", "Run Unit Tests for Software Crypto Functions", (fp_menu_handler)atca_crypto_sw_tests },
#endif
{ "all", "Run all unit tests, locking as needed.", run_all_tests },
- { "clkdivm0", "Set ATECC608A to ClockDivider M0(0x00)", set_clock_divider_m0},
- { "clkdivm1", "Set ATECC608A to ClockDivider M1(0x05)", set_clock_divider_m1},
- { "clkdivm2", "Set ATECC608A to ClockDivider M2(0x0D)", set_clock_divider_m2},
{ NULL, NULL, NULL },
};
@@ -160,6 +144,8 @@ int main(int argc, char* argv[])
return 1;
}
+ select_device(ATECC508A);
+
while (true)
{
printf("$ ");
@@ -230,96 +216,13 @@ static void help(void)
}
}
-static void select_204(void)
-{
- select_device(ATSHA204A);
-}
-static void select_108(void)
-{
- select_device(ATECC108A);
-}
-static void select_508(void)
-{
- select_device(ATECC508A);
-}
-static void select_608(void)
-{
- select_device(ATECC608A);
-}
-
-static void update_chip_mode(uint8_t* chip_mode, uint8_t i2c_user_extra_add, uint8_t ttl_enable, uint8_t watchdog, uint8_t clock_divider)
-{
- if (i2c_user_extra_add != 0xFF)
- {
- *chip_mode &= ~ATCA_CHIPMODE_I2C_ADDRESS_FLAG;
- *chip_mode |= i2c_user_extra_add & ATCA_CHIPMODE_I2C_ADDRESS_FLAG;
- }
- if (ttl_enable != 0xFF)
- {
- *chip_mode &= ~ATCA_CHIPMODE_TTL_ENABLE_FLAG;
- *chip_mode |= ttl_enable & ATCA_CHIPMODE_TTL_ENABLE_FLAG;
- }
- if (watchdog != 0xFF)
- {
- *chip_mode &= ~ATCA_CHIPMODE_WATCHDOG_MASK;
- *chip_mode |= watchdog & ATCA_CHIPMODE_WATCHDOG_MASK;
- }
- if (clock_divider != 0xFF)
- {
- *chip_mode &= ~ATCA_CHIPMODE_CLOCK_DIV_MASK;
- *chip_mode |= clock_divider & ATCA_CHIPMODE_CLOCK_DIV_MASK;
- }
-}
-
-static ATCA_STATUS check_clock_divider(void)
-{
- ATCA_STATUS status;
- uint8_t chip_mode = 0;
-
- if (gCfg->devtype != ATECC608A)
- {
- printf("Current device doesn't support clock divider settings (only ATECC608A)\r\n");
- return ATCA_GEN_FAIL;
- }
-
- // Update the actual ATECC608A chip mode so it takes effect immediately
- status = atcab_init(gCfg);
- if (status != ATCA_SUCCESS)
- {
- printf("atcab_init() failed with ret=0x%08X\r\n", status);
- return status;
- }
-
- do
- {
- // Read current config values
- status = atcab_read_bytes_zone(ATCA_ZONE_CONFIG, 0, ATCA_CHIPMODE_OFFSET, &chip_mode, 1);
- if (status != ATCA_SUCCESS)
- {
- printf("atcab_read_bytes_zone() failed with ret=0x%08X\r\n", status);
- break;
- }
-
- // Update the ATECC608A test config data so all the unit tests will run with the new chip mode
- update_chip_mode(&test_ecc608_configdata[ATCA_CHIPMODE_OFFSET], 0xFF, 0xFF, chip_mode & ATCA_CHIPMODE_WATCHDOG_MASK, chip_mode & ATCA_CHIPMODE_CLOCK_DIV_MASK);
-
- } while (0);
-
- atcab_release();
- return status;
-}
-
static void run_basic_tests(void)
{
- if (gCfg->devtype == ATECC608A)
- check_clock_divider();
run_test(RunAllBasicTests);
}
static void run_unit_tests(void)
{
- if (gCfg->devtype == ATECC608A)
- check_clock_divider();
run_test(RunAllFeatureTests);
}
static void run_otpzero_tests(void)
@@ -453,37 +356,6 @@ static ATCA_STATUS do_randoms(void)
return status;
}
-static void discover(void)
-{
- ATCAIfaceCfg ifaceCfgs[10];
- int i;
- const char *devname[] = { "ATSHA204A", "ATECC108A", "ATECC508A", "ATECC608A" }; // indexed by ATCADeviceType
-
- for (i = 0; i < (int)(sizeof(ifaceCfgs) / sizeof(ATCAIfaceCfg)); i++)
- {
- ifaceCfgs[i].devtype = ATCA_DEV_UNKNOWN;
- ifaceCfgs[i].iface_type = ATCA_UNKNOWN_IFACE;
- }
-
- printf("Searching...");
- atcab_cfg_discover(ifaceCfgs, sizeof(ifaceCfgs) / sizeof(ATCAIfaceCfg));
- for (i = 0; i < (int)(sizeof(ifaceCfgs) / sizeof(ATCAIfaceCfg)); i++)
- {
- if (ifaceCfgs[i].devtype != ATCA_DEV_UNKNOWN)
- {
- printf("Found %s ", devname[ifaceCfgs[i].devtype]);
- if (ifaceCfgs[i].iface_type == ATCA_I2C_IFACE)
- {
- printf("@ bus %d addr %02x", ifaceCfgs[i].atcai2c.bus, ifaceCfgs[i].atcai2c.slave_address);
- }
- if (ifaceCfgs[i].iface_type == ATCA_SWI_IFACE)
- {
- printf("@ bus %d", ifaceCfgs[i].atcaswi.bus);
- }
- printf("\r\n");
- }
- }
-}
static void info(void)
{
ATCA_STATUS status;
@@ -636,18 +508,7 @@ static ATCA_STATUS get_serial_no(uint8_t *sernum)
static void select_device(ATCADeviceType device_type)
{
- ATCA_STATUS status;
-
- status = set_test_config(device_type);
-
- if (status == ATCA_SUCCESS)
- {
- printf("Device Selected.\r\n");
- }
- else
- {
- printf("IFace Cfg are NOT available\r\n");
- }
+ set_test_config(device_type);
}
static int run_test(void* fptest)
@@ -670,9 +531,6 @@ static void run_all_tests(void)
bool is_data_locked = false;
int fails = 0;
- if (gCfg->devtype == ATECC608A)
- check_clock_divider();
-
status = is_device_locked(LOCK_ZONE_CONFIG, &is_config_locked);
if (status != ATCA_SUCCESS)
{
@@ -814,204 +672,24 @@ static ATCA_STATUS set_test_config(ATCADeviceType deviceType)
gCfg->devtype = ATCA_DEV_UNKNOWN;
gCfg->iface_type = ATCA_UNKNOWN_IFACE;
- switch (deviceType)
- {
- case ATSHA204A:
-#if defined(ATCA_HAL_I2C)
- *gCfg = cfg_atsha204a_i2c_default;
-#elif defined(ATCA_HAL_SWI)
- *gCfg = cfg_atsha204a_swi_default;
-#elif defined(ATCA_HAL_KIT_HID)
- *gCfg = cfg_atsha204a_kithid_default;
-#elif defined(ATCA_HAL_KIT_CDC)
- *gCfg = cfg_atsha204a_kitcdc_default;
-#elif defined(ATCA_HAL_CUSTOM)
- *gCfg = g_cfg_atsha204a_custom;
-#else
-#error "HAL interface is not selected";
-#endif
- break;
-
- case ATECC108A:
-#if defined(ATCA_HAL_I2C)
- *gCfg = cfg_ateccx08a_i2c_default;
- gCfg->devtype = deviceType;
-#elif defined(ATCA_HAL_SWI)
- *gCfg = cfg_ateccx08a_swi_default;
- gCfg->devtype = deviceType;
-#elif defined(ATCA_HAL_KIT_HID)
- *gCfg = cfg_ateccx08a_kithid_default;
- gCfg->devtype = deviceType;
-#elif defined(ATCA_HAL_KIT_CDC)
- *gCfg = cfg_ateccx08a_kitcdc_default;
- gCfg->devtype = deviceType;
-#elif defined(ATCA_HAL_CUSTOM)
- *gCfg = g_cfg_atecc108a_custom;
-#else
-#error "HAL interface is not selected";
-#endif
- break;
-
- case ATECC508A:
-#if defined(ATCA_HAL_I2C)
- *gCfg = cfg_ateccx08a_i2c_default;
- gCfg->devtype = deviceType;
-#elif defined(ATCA_HAL_SWI)
- *gCfg = cfg_ateccx08a_swi_default;
- gCfg->devtype = deviceType;
-#elif defined(ATCA_HAL_KIT_HID)
- *gCfg = cfg_ateccx08a_kithid_default;
- gCfg->devtype = deviceType;
-#elif defined(ATCA_HAL_KIT_CDC)
- *gCfg = cfg_ateccx08a_kitcdc_default;
- gCfg->devtype = deviceType;
-#elif defined(ATCA_HAL_CUSTOM)
- *gCfg = g_cfg_atecc508a_custom;
-#else
-#error "HAL interface is not selected";
-#endif
- break;
-
- case ATECC608A:
#if defined(ATCA_HAL_I2C)
- *gCfg = cfg_ateccx08a_i2c_default;
- gCfg->devtype = deviceType;
+ *gCfg = cfg_ateccx08a_i2c_default;
+ gCfg->devtype = deviceType;
#elif defined(ATCA_HAL_SWI)
- *gCfg = cfg_ateccx08a_swi_default;
- gCfg->devtype = deviceType;
+ *gCfg = cfg_ateccx08a_swi_default;
+ gCfg->devtype = deviceType;
#elif defined(ATCA_HAL_KIT_HID)
- *gCfg = cfg_ateccx08a_kithid_default;
- gCfg->devtype = deviceType;
+ *gCfg = cfg_ateccx08a_kithid_default;
+ gCfg->devtype = deviceType;
#elif defined(ATCA_HAL_KIT_CDC)
- *gCfg = cfg_ateccx08a_kitcdc_default;
- gCfg->devtype = deviceType;
+ *gCfg = cfg_ateccx08a_kitcdc_default;
+ gCfg->devtype = deviceType;
#elif defined(ATCA_HAL_CUSTOM)
- *gCfg = g_cfg_atecc608a_custom;
+ *gCfg = g_cfg_atecc508a_custom;
#else
#error "HAL interface is not selected";
#endif
- break;
-
- default:
- //device type wasn't found, return with error
- return ATCA_GEN_FAIL;
- }
-
- #ifdef ATCA_RASPBERRY_PI_3
- gCfg->atcai2c.bus = 1;
- #endif
return ATCA_SUCCESS;
}
-static ATCA_STATUS set_chip_mode(uint8_t i2c_user_extra_add, uint8_t ttl_enable, uint8_t watchdog, uint8_t clock_divider)
-{
- ATCA_STATUS status;
- uint8_t config_word[ATCA_WORD_SIZE];
- bool is_config_locked = false;
-
- if (gCfg->devtype != ATECC608A)
- {
- printf("Current device doesn't support clock divider settings (only ATECC608A)\r\n");
- return ATCA_GEN_FAIL;
- }
-
- status = is_device_locked(LOCK_ZONE_CONFIG, &is_config_locked);
- if (status != ATCA_SUCCESS)
- {
- printf("is_device_locked() failed with ret=0x%08X\r\n", status);
- return status;
- }
-
- if (is_config_locked)
- {
- printf("Current device is config locked. Can't change clock divider. ");
- }
-
- // Update the actual ATECC608A chip mode so it takes effect immediately
- status = atcab_init(gCfg);
- if (status != ATCA_SUCCESS)
- {
- printf("atcab_init() failed with ret=0x%08X\r\n", status);
- return status;
- }
-
- do
- {
- // Read current config values
- status = atcab_read_bytes_zone(ATCA_ZONE_CONFIG, 0, 16, config_word, 4);
- if (status != ATCA_SUCCESS)
- {
- printf("atcab_read_bytes_zone() failed with ret=0x%08X\r\n", status);
- break;
- }
-
- if (is_config_locked)
- {
- printf("Currently set to 0x%02X.\r\n", (int)(config_word[3] >> 3));
- status = ATCA_GEN_FAIL;
- break;
- }
-
- // Update ChipMode
- update_chip_mode(&config_word[3], i2c_user_extra_add, ttl_enable, watchdog, clock_divider);
-
- // Write config values back to chip
- status = atcab_write_bytes_zone(ATCA_ZONE_CONFIG, 0, 16, config_word, 4);
- if (status != ATCA_SUCCESS)
- {
- printf("atcab_write_bytes_zone() failed with ret=0x%08X\r\n", status);
- break;
- }
-
- // Put to sleep so new values take effect
- status = atcab_wakeup();
- if (status != ATCA_SUCCESS)
- {
- printf("atcab_wakeup() failed with ret=0x%08X\r\n", status);
- break;
- }
- status = atcab_sleep();
- if (status != ATCA_SUCCESS)
- {
- printf("atcab_sleep() failed with ret=0x%08X\r\n", status);
- break;
- }
-
- // Update the ATECC608A test config data so all the unit tests will run with the new chip mode
- update_chip_mode(&test_ecc608_configdata[ATCA_CHIPMODE_OFFSET], i2c_user_extra_add, ttl_enable, watchdog, clock_divider);
-
- } while (0);
-
- atcab_release();
- return status;
-}
-
-static void set_clock_divider_m0(void)
-{
- ATCA_STATUS status = set_chip_mode(0xFF, 0xFF, ATCA_CHIPMODE_WATCHDOG_SHORT, ATCA_CHIPMODE_CLOCK_DIV_M0);
- if (status == ATCA_SUCCESS)
- {
- printf("Set device to clock divider M0 (0x%02X) and watchdog to 1.3s nominal.\r\n", ATCA_CHIPMODE_CLOCK_DIV_M0 >> 3);
- }
-}
-
-static void set_clock_divider_m1(void)
-{
- ATCA_STATUS status = set_chip_mode(0xFF, 0xFF, ATCA_CHIPMODE_WATCHDOG_SHORT, ATCA_CHIPMODE_CLOCK_DIV_M1);
- if (status == ATCA_SUCCESS)
- {
- printf("Set device to clock divider M1 (0x%02X) and watchdog to 1.3s nominal.\r\n", ATCA_CHIPMODE_CLOCK_DIV_M1 >> 3);
- }
-}
-
-static void set_clock_divider_m2(void)
-{
- // Additionally set watchdog to long settings (~13s) as some commands
- // can't complete in time on the faster watchdog setting.
- ATCA_STATUS status = set_chip_mode(0xFF, 0xFF, ATCA_CHIPMODE_WATCHDOG_LONG, ATCA_CHIPMODE_CLOCK_DIV_M2);
- if (status == ATCA_SUCCESS)
- {
- printf("Set device to clock divider M2 (0x%02X) and watchdog to 13s nominal.\r\n", ATCA_CHIPMODE_CLOCK_DIV_M2 >> 3);
- }
-}
\ No newline at end of file

View File

@ -0,0 +1,82 @@
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
Date: Thu, 7 Nov 2019 14:16:53 +0100
Subject: [PATCH 4/6] lib: install pkg-config file and header files
These are needed to be able to develop using cryptoauthlib.
https://jira.digi.com/browse/DEL-6826
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
---
CMakeLists.txt | 15 +++++++++++++++
lib/CMakeLists.txt | 4 ++++
lib/cryptoauthlib.pc.in | 11 +++++++++++
3 files changed, 30 insertions(+)
create mode 100644 lib/cryptoauthlib.pc.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 00214d3..f95736d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,10 @@ set(DEFAULT_CONF_PATH "${CMAKE_INSTALL_FULL_SYSCONFDIR}/${PROJECT_NAME}" CACHE
STRING "The default location of ${PROJECT_NAME}.conf")
set(DEFAULT_STORE_PATH "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/${PROJECT_NAME}" CACHE
STRING "The default location of the filestore directory")
+set(DEFAULT_PKGCONFIG_PATH "${DEFAULT_LIB_PATH}/pkgconfig" CACHE
+ STRING "The default location of the library's pkg-config file")
+set(DEFAULT_INCLUDE_PATH "${CMAKE_INSTALL_FULL_INCLUDEDIR}" CACHE
+ STRING "The default location of the library's header files")
endif()
set(DEFAULT_CONF_FILE_NAME "${PROJECT_NAME}.conf" CACHE
@@ -49,6 +53,9 @@ endif()
# Set up a default configuration file to install
configure_file(${PROJECT_SOURCE_DIR}/app/pkcs11/cryptoauthlib.conf.in ${PROJECT_BINARY_DIR}/${DEFAULT_CONF_FILE_NAME})
+# Set up the pkg-config file
+configure_file(${PROJECT_SOURCE_DIR}/lib/${PROJECT_NAME}.pc.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY)
+
message(STATUS "Building Configuration: ${CMAKE_BUILD_TYPE}")
# Packaging
@@ -86,3 +93,11 @@ install(CODE "
endif()
")
+install(DIRECTORY DESTINATION ${DEFAULT_PKGCONFIG_PATH})
+install(CODE "
+ if(NOT EXISTS ${DEFAULT_PKGCONFIG_PATH}/${PROJECT_NAME}.pc)
+ file(INSTALL ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc
+ DESTINATION ${DEFAULT_PKGCONFIG_PATH})
+ endif()
+ ")
+
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 88533f1..d4749ec 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -128,3 +128,7 @@ endif()
if(DEFAULT_LIB_PATH)
install(TARGETS ${PROJECT_NAME} DESTINATION ${DEFAULT_LIB_PATH})
endif()
+
+if(DEFAULT_INCLUDE_PATH)
+install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" DESTINATION "${DEFAULT_INCLUDE_PATH}" FILES_MATCHING PATTERN "*.h")
+endif()
diff --git a/lib/cryptoauthlib.pc.in b/lib/cryptoauthlib.pc.in
new file mode 100644
index 0000000..e682913
--- /dev/null
+++ b/lib/cryptoauthlib.pc.in
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+
+Name: @PROJECT_NAME@
+Description: Atmel Cryptochip library for ATECC508A
+Version: @VERSION@
+
+Libs: -L${libdir} -lcryptoauth
+Cflags: -I${includedir} -I${includedir}/@PROJECT_NAME@

View File

@ -1,21 +1,20 @@
# Copyright (C) 2017, 2018 Digi International Inc. # Copyright (C) 2017-2019 Digi International Inc.
SUMMARY = "Microchip CryptoAuthentication Library" SUMMARY = "Microchip CryptoAuthentication Library"
SECTION = "libs" SECTION = "libs"
LICENSE = "MICROCHIP_CRYPTOAUTHLIB_LICENSE" LICENSE = "MICROCHIP_CRYPTOAUTHLIB_LICENSE"
LIC_FILES_CHKSUM = "file://license.txt;endline=19;md5=5bcd26c644867b127c2cce82960fae7b" LIC_FILES_CHKSUM = "file://license.txt;md5=84f2905dc39d2f8cdffb00af6f9e6d4e"
SRCBRANCH = "master" SRCREV = "a0007d2f6c42fddab5dca1575e0f404788829ddc"
SRCREV = "c6da3358a102c10d954372598c6efef8ad84c9ee"
GIT_URI ?= "git://github.com/MicrochipTech/cryptoauthlib.git;protocol=https" GIT_URI ?= "git://github.com/MicrochipTech/cryptoauthlib.git;protocol=https"
SRC_URI = " \ SRC_URI = " \
${GIT_URI};nobranch=1 \ ${GIT_URI};nobranch=1 \
file://0001-Port-changes-from-the-cryptoauth-engine-repo-to-the-.patch \ file://0001-lib-add-parameters-to-be-able-to-modify-default-I2C-.patch \
file://0002-Remove-unused-HAL-implementations.patch \ file://0002-lib-apply-library-version-number-to-CMake-VERSION-pr.patch \
file://0003-Build-cryptochip-cmd-processor-application-along-wit.patch \ file://0003-pkcs11-rename-template-configuration-file-to-its-int.patch \
file://0004-Remove-unnecessary-code-from-cryptochip-cmd-processo.patch \ file://0004-lib-install-pkg-config-file-and-header-files.patch \
" "
S = "${WORKDIR}/git" S = "${WORKDIR}/git"
@ -27,17 +26,16 @@ I2C_BUS_ccimx8x = "0"
I2C_SPEED ?= "100000" I2C_SPEED ?= "100000"
CFLAGS += "-DATCA_HAL_I2C_BUS=${I2C_BUS} -DATCA_HAL_I2C_SPEED=${I2C_SPEED}" EXTRA_OECMAKE += "-DATCA_HAL_I2C_BUS=${I2C_BUS} -DATCA_HAL_I2C_SPEED=${I2C_SPEED}"
do_patch[prefuncs] = "change_line_endings" inherit cmake
change_line_endings() { do_install_append() {
find ${S} -type f -name '*.[ch]' -print0 | xargs -0 sed -i -e 's/\r//g' # Rename the folder containing the header files to be more package-specific
mv ${D}${includedir}/lib ${D}${includedir}/cryptoauthlib
} }
do_install() { RDEPENDS_${PN} = "libp11"
oe_runmake DESTDIR=${D} install
}
PACKAGE_ARCH = "${MACHINE_ARCH}" PACKAGE_ARCH = "${MACHINE_ARCH}"
COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x)" COMPATIBLE_MACHINE = "(ccimx6qpsbc|ccimx6ul|ccimx8x)"