common: SCP03 control (enable and provision of keys)
Subsystems (2)
PATCH 1/3 common: SCP03 control (enable and provision of keys)
This Trusted Application allows enabling and provisioning SCP03 keys on TEE controlled secure element (ie, NXP SE050)
For information on SCP03, check the Global Platform HomePage[1]
[1] globalplatform.org
--- common/Kconfig | 8 ++++++ common/Makefile | 1 + common/scp03.c | 52 ++++++++++++++++++++++++++++++++++++ include/scp03.h | 19 +++++++++++++ include/tee/optee_ta_scp03.h | 21 +++++++++++++++ 5 files changed, 101 insertions(+) create mode 100644 common/scp03.c create mode 100644 include/scp03.h create mode 100644 include/tee/optee_ta_scp03.h
common/Kconfig +8 -0
@@ -588,6 +588,14 @@ config AVB_BUF_SIZE endif # AVB_VERIFY +config SCP03 + bool "Build SCP03 - Secure Channel Protocol O3 - controls" + depends on OPTEE || SANDBOX + depends on TEE + help + This option allows U-Boot to enable and or provision SCP03 on an OPTEE + controlled Secured Element. + config SPL_HASH bool # "Support hashing API (SHA1, SHA256, etc.)" help
common/Makefile +1 -0
@@ -137,3 +137,4 @@ obj-$(CONFIG_CMD_LOADB) += xyzModem.o obj-$(CONFIG_$(SPL_TPL_)YMODEM_SUPPORT) += xyzModem.o obj-$(CONFIG_AVB_VERIFY) += avb_verify.o +obj-$(CONFIG_SCP03) += scp03.o
common/scp03.c new file +52 -0
52 lines not on this page · raw message
include/scp03.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* (C) Copyright 2021, Foundries.IO +* +*/ + +#ifndef _SCP03_H +#define _SCP03_H + +/* +* Requests to OPTEE to enable or provision the Secure Channel Protocol on its +* Secure Element +* +* If key provisioning is requested, OPTEE shall generate new SCP03 keys and +* write them to the Secure Element. +*/ +int tee_enable_scp03 (void ); +int tee_provision_scp03 (void ); +#endif /* _SCP03_H */
include/tee/optee_ta_scp03.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* +* (C) Copyright 2021, Foundries.IO +* +*/ +#ifndef __TA_SCP03_H +#define __TA_SCP03_H + +#define PTA_SCP03_UUID { 0xbe0e5821, 0xe718, 0x4f77, \ + { 0xab, 0x3e, 0x8e, 0x6c, 0x73, 0xa9, 0xc7, 0x35 } } + +/* +* Enable Secure Channel Protocol functionality (SCP03) on the Secure Element. +* Setting the operation value to something different than NULL will trigger +* the SCP03 provisioning request. +* +* in params[0].a = operation +*/ +#define PTA_CMD_ENABLE_SCP03 0 + +#endif /*__TA_SCP03_H*/
Signature · 1 line
2.30.0
PATCH 1/1 drivers: tee: sandbox: secure channel protocol control
Adds support for SCP03 emulation.
--- drivers/tee/optee/Kconfig | 6 ++++ drivers/tee/sandbox.c | 59 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 2 deletions(-)
drivers/tee/optee/Kconfig +6 -0
@@ -22,6 +22,12 @@ config OPTEE_TA_AVB The TA can support the "avb" subcommands "read_rb", "write"rb" and "is_unlocked". +config OPTEE_TA_SCP03 + bool "Support SCP03 TA" + default y + help + Enables support for the SCP03 Trusted Application (TA) in OP-TEE. + endmenu endif
drivers/tee/sandbox.c +57 -2
89 lines not on this page · raw message
Signature · 1 line
2.30.0
PATCH 2/3 cmd: SCP03: enable and provision command
In reply to Jorge Ramirez-OrtizEnable and provision the SCP03 keys on a TEE controlled secured elemt from the U-Boot shell.
--- cmd/Kconfig | 9 ++++++++ cmd/Makefile | 3 +++ cmd/scp03.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 cmd/scp03.c
cmd/Kconfig +9 -0
@@ -2021,6 +2021,15 @@ config HASH_VERIFY help Add -v option to verify data against a hash. +config CMD_SCP03 + bool "scp03 - SCP03 enable and rotate/provision operations" + depends on SCP03 + help + Enables the SCP03 commands to activate I2C channel encryption and + provision the SCP03 keys. + scp03 enable + scp03 provision + config CMD_TPM_V1 bool
cmd/Makefile +3 -0
@@ -193,6 +193,9 @@ obj-$(CONFIG_CMD_BLOB) += blob.o # Android Verified Boot 2.0 obj-$(CONFIG_CMD_AVB) += avb.o +# Foundries.IO SCP03 +obj-$(CONFIG_CMD_SCP03) += scp03.o + obj-$(CONFIG_ARM) += arm/ obj-$(CONFIG_RISCV) += riscv/ obj-$(CONFIG_SANDBOX) += sandbox/
cmd/scp03.c new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.30.0
PATCH 2/3 cmd: SCP03: enable and provision command
Hi Jorge,
Quoted 11 lines · Jorge Ramirez-Ortiz
Enable and provision the SCP03 keys on a TEE controlled secured elemt from the U-Boot shell.
Signed-off-by Jorge Ramirez-Ortiz <[email protected]>--- cmd/Kconfig | 9 ++++++++ cmd/Makefile | 3 +++ cmd/scp03.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 cmd/scp03.c
Can we have a test for this please? See mem_search.c for an example.
Quoted 6 lines
cmd/Kconfig +0
-0
cmd/Kconfig config HASH_VERIFY · line 2028
Quoted 8 lines
cmd/Kconfig +5
-0@@ -2021,6 +2021,15 @@ config HASH_VERIFY help Add -v option to verify data against a hash. +config CMD_SCP03 + bool "scp03 - SCP03 enable and rotate/provision operations" + depends on SCP03 + help + Enables the SCP03 commands to activate I2C channel encryption and
I2C-channel ?
cmd/Kconfig config HASH_VERIFY · line 2031
Quoted 3 lines
cmd/Kconfig +3
-0+ provision the SCP03 keys. + scp03 enable + scp03 provision
Also add this to doc/usage (see 'make htmldocs')
Quoted 32 lines
cmd/Kconfig +1
-0+ config CMD_TPM_V1 boolcmd/Makefile +3
-0@@ -193,6 +193,9 @@ obj-$(CONFIG_CMD_BLOB) += blob.o # Android Verified Boot 2.0 obj-$(CONFIG_CMD_AVB) += avb.o +# Foundries.IO SCP03 +obj-$(CONFIG_CMD_SCP03) += scp03.o + obj-$(CONFIG_ARM) += arm/ obj-$(CONFIG_RISCV) += riscv/ obj-$(CONFIG_SANDBOX) += sandbox/cmd/scp03.c new file +8
-0@@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2021, Foundries.IO +* +*/ + +#include <common.h> +#include <command.h>
cmd/scp03.c line 18
Quoted 10 lines
cmd/scp03.c new file +10
-0+#include <env.h> +#include <scp03.h> + +int do_scp03_enable (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]) +{ +if (argc !=1 ) +return CMD_RET_USAGE ; + +if (tee_enable_scp03 ())
Do you want to report the failure with a message?
Quoted 14 lines
cmd/scp03.c new file +14
-0+return CMD_RET_FAILURE ; + +return CMD_RET_SUCCESS ; +} + +int do_scp03_provision (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]) +{ +if (argc !=1 ) +return CMD_RET_USAGE ; + +if (tee_provision_scp03 ()) +return CMD_RET_FAILURE ; +
cmd/scp03.c line 42
Quoted 10 lines
cmd/scp03.c new file +10
-0+return CMD_RET_SUCCESS ; +} + +static struct cmd_tbl cmd_scp03[] = { +U_BOOT_CMD_MKENT (enable,1 ,0 , do_scp03_enable,"" ,"" ), +U_BOOT_CMD_MKENT (provision,1 ,0 , do_scp03_provision,"" ,"" ), +}; + +static int do_scp03 (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[])
You could use U_BOOT_CMD_WITH_SUBCMDS() which might save some hassle here.
Quoted 23 lines
cmd/scp03.c new file +22
-1+{ +struct cmd_tbl *cp; + + cp =find_cmd_tbl (argv[1 ], cmd_scp03,ARRAY_SIZE (cmd_scp03)); + + argc--; + argv++; + +if (!cp || argc > cp->maxargs) +return CMD_RET_USAGE ; + +if (flag ==CMD_FLAG_REPEAT ) +return CMD_RET_FAILURE ; + +return cp->cmd (cmdtp, flag, argc, argv); +} + +U_BOOT_CMD (scp03,2 ,0 , do_scp03, +"Provides a command to enable SCP03 and provision the SCP03 keys\n" , +"\tenable - enable SCP03\n" +"\tprovision - provision SCP03\n" +); --
Quoted 2 lines
2.30.0
Regards,
Simon
Jorge Ramirez-Ortiz
PATCH 2/3 cmd: SCP03: enable and provision command
Quoted 15 lines · Simon Glass
Hi Jorge,
Quoted 11 lines · Jorge Ramirez-Ortiz
Enable and provision the SCP03 keys on a TEE controlled secured elemt from the U-Boot shell.
Signed-off-by Jorge Ramirez-Ortiz <[email protected]>--- cmd/Kconfig | 9 ++++++++ cmd/Makefile | 3 +++ cmd/scp03.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 cmd/scp03.c
Quoted 1 line
Can we have a test for this please? See
mem_search.cfor an example.
you mean other than what I posted already (the sandbox test using the TEE emulator)?
I am not really sure what else can it do: this command sends a request to a TEE and waits to a response (and both are emulated on the sandbox).
Quoted 10 lines
Quoted 10 lines
cmd/Kconfig +0
-0@@ -2021,6 +2021,15 @@ config HASH_VERIFY help Add -v option to verify data against a hash.
Quoted 7 lines
cmd/Kconfig config HASH_VERIFY · line 2028
Quoted 5 lines
cmd/Kconfig +5
-0+config CMD_SCP03 + bool "scp03 - SCP03 enable and rotate/provision operations" + depends on SCP03 + help + Enables the SCP03 commands to activate I2C channel encryption andI2C-channel ?
sure
Quoted 6 lines
cmd/Kconfig config HASH_VERIFY · line 2031
Quoted 4 lines
cmd/Kconfig +3
-0+ provision the SCP03 keys. + scp03 enable + scp03 provisionAlso add this to doc/usage (see 'make htmldocs')
ok
Quoted 37 lines
Quoted 37 lines
cmd/Kconfig +1
-0+ config CMD_TPM_V1 boolcmd/Makefile +3
-0@@ -193,6 +193,9 @@ obj-$(CONFIG_CMD_BLOB) += blob.o # Android Verified Boot 2.0 obj-$(CONFIG_CMD_AVB) += avb.o +# Foundries.IO SCP03 +obj-$(CONFIG_CMD_SCP03) += scp03.o + obj-$(CONFIG_ARM) += arm/ obj-$(CONFIG_RISCV) += riscv/ obj-$(CONFIG_SANDBOX) += sandbox/cmd/scp03.c new file +12
-0@@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2021, Foundries.IO +* +*/ + +#include <common.h> +#include <command.h> +#include <env.h> +#include <scp03.h> + +int do_scp03_enable(struct cmd_tbl *cmdtp, int flag, int argc,
Quoted 8 lines
cmd/scp03.c line 18
Quoted 6 lines
cmd/scp03.c new file +6
-0+ char *const argv[]) +{ +if (argc !=1 ) +return CMD_RET_USAGE ; + +if (tee_enable_scp03 ())Do you want to report the failure with a message?
ok
Quoted 20 lines
Quoted 20 lines
cmd/scp03.c new file +19
-0+return CMD_RET_FAILURE ; + +return CMD_RET_SUCCESS ; +} + +int do_scp03_provision (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]) +{ +if (argc !=1 ) +return CMD_RET_USAGE ; + +if (tee_provision_scp03 ()) +return CMD_RET_FAILURE ; + +return CMD_RET_SUCCESS ; +} + +static struct cmd_tbl cmd_scp03[] = { +U_BOOT_CMD_MKENT (enable,1 ,0 , do_scp03_enable,"" ,"" ),
Quoted 8 lines
cmd/scp03.c line 42
Quoted 5 lines
cmd/scp03.c new file +5
-0+ U_BOOT_CMD_MKENT(provision, 1, 0, do_scp03_provision, "", ""), +}; + +static int do_scp03 (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[])You could use
U_BOOT_CMD_WITH_SUBCMDS()which might save some hassle here.
yes, much nicer. thanks
Quoted 29 lines
Quoted 24 lines
cmd/scp03.c new file +22
-1+{ +struct cmd_tbl *cp; + + cp =find_cmd_tbl (argv[1 ], cmd_scp03,ARRAY_SIZE (cmd_scp03)); + + argc--; + argv++; + +if (!cp || argc > cp->maxargs) +return CMD_RET_USAGE ; + +if (flag ==CMD_FLAG_REPEAT ) +return CMD_RET_FAILURE ; + +return cp->cmd (cmdtp, flag, argc, argv); +} + +U_BOOT_CMD (scp03,2 ,0 , do_scp03, +"Provides a command to enable SCP03 and provision the SCP03 keys\n" , +"\tenable - enable SCP03\n" +"\tprovision - provision SCP03\n" +); --Quoted 2 lines
2.30.0
Regards,
Simon
PATCH 2/3 cmd: SCP03: enable and provision command
Hi Jorge,
Quoted 17 lines · Foundries
Quoted 15 lines · Simon Glass
Hi Jorge,
Quoted 11 lines · Jorge Ramirez-Ortiz
Enable and provision the SCP03 keys on a TEE controlled secured elemt from the U-Boot shell.
Signed-off-by Jorge Ramirez-Ortiz <[email protected]>--- cmd/Kconfig | 9 ++++++++ cmd/Makefile | 3 +++ cmd/scp03.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 cmd/scp03.c
Quoted 7 lines
Quoted 1 line
Can we have a test for this please? See
mem_search.cfor an example.you mean other than what I posted already (the sandbox test using the TEE emulator)?
I am not really sure what else can it do: this command sends a request to a TEE and waits to a response (and both are emulated on the sandbox).
It should just be a few lines of code to test the basics. E.g.:
Regards,
Simon
Jorge Ramirez-Ortiz
PATCH 2/3 cmd: SCP03: enable and provision command
Quoted 26 lines · Simon Glass
Hi Jorge,
Quoted 22 lines · Foundries
Quoted 15 lines · Simon Glass
Hi Jorge,
Quoted 11 lines · Jorge Ramirez-Ortiz
Enable and provision the SCP03 keys on a TEE controlled secured elemt from the U-Boot shell.
Signed-off-by Jorge Ramirez-Ortiz <[email protected]>--- cmd/Kconfig | 9 ++++++++ cmd/Makefile | 3 +++ cmd/scp03.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 cmd/scp03.cQuoted 1 line
Can we have a test for this please? See
mem_search.cfor an example.you mean other than what I posted already (the sandbox test using the TEE emulator)?
Quoted 6 lines
Quoted 2 lines
I am not really sure what else can it do: this command sends a request to a TEE and waits to a response (and both are emulated on the sandbox).
It should just be a few lines of code to test the basics. E.g.:
ah ok I see what you mean.
I'll have a look
Quoted 3 lines
Regards,
Simon
PATCH 3/3 drivers: tee: sandbox: secure channel protocol control
In reply to Jorge Ramirez-OrtizAdds support for SCP03 emulation.
--- drivers/tee/optee/Kconfig | 6 ++++ drivers/tee/sandbox.c | 60 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 2 deletions(-)
drivers/tee/optee/Kconfig +6 -0
@@ -22,6 +22,12 @@ config OPTEE_TA_AVB The TA can support the "avb" subcommands "read_rb", "write"rb" and "is_unlocked". +config OPTEE_TA_SCP03 + bool "Support SCP03 TA" + default y + help + Enables support for the SCP03 Trusted Application (TA) in OP-TEE. + endmenu endif
drivers/tee/sandbox.c +58 -2
90 lines not on this page · raw message
Signature · 1 line
2.30.0
PATCH 3/3 drivers: tee: sandbox: secure channel protocol control
Hi Jorge,
Quoted 9 lines · Jorge Ramirez-Ortiz
Adds support for SCP03 emulation.
Signed-off-by Jorge Ramirez-Ortiz <[email protected]>--- drivers/tee/optee/Kconfig | 6 ++++ drivers/tee/sandbox.c | 60 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 2 deletions(-)
drivers/tee/optee/Kconfig config OPTEE_TA_AVB · line 29
Quoted 13 lines
drivers/tee/optee/Kconfig +5
-0@@ -22,6 +22,12 @@ config OPTEE_TA_AVB The TA can support the "avb" subcommands "read_rb", "write"rb" and "is_unlocked". +config OPTEE_TA_SCP03 + bool "Support SCP03 TA" + default y + help + Enables support for the SCP03 Trusted Application (TA) in OP-TEE.
What is SCP03? Can you add a link and write it out in full if it is an abbreviation?
Quoted 4 lines
drivers/tee/optee/Kconfig +1
-0+ endmenu endif
[..]