@@ -85,7 +85,10 @@ There are 3 signing mechanisms supported by meta-swupdate at the moment:
* Set variable: `SWUPDATE_SIGNING = "CUSTOM"`
* Set variable `SWUPDATE_SIGN_TOOL' to custom string that needs to be
- executed in order to perform the signing
+ executed in order to perform the signing. The variables
+ `SWUPDATE_SIGN_INPUT` (the file to sign) and `SWUPDATE_SIGN_OUTPUT`
+ (where the signature must be written) are available for expansion
+ inside `SWUPDATE_SIGN_TOOL`.
sw-description is signed and the signature is written to sw-description.sig
which is included in the SWU file.
@@ -191,10 +191,12 @@ def prepare_sw_description(d):
signing = "RSA"
if signing:
- sw_desc_sig = os.path.join(workdir, 'sw-description.sig')
- sw_desc = os.path.join(workdir, 'sw-description.plain' if encrypt else 'sw-description')
+ swupdate_sign_input = os.path.join(workdir, 'sw-description.plain' if encrypt else 'sw-description')
+ swupdate_sign_output = os.path.join(workdir, 'sw-description.sig')
if signing == "CUSTOM":
+ d.setVar('SWUPDATE_SIGN_INPUT', swupdate_sign_input)
+ d.setVar('SWUPDATE_SIGN_OUTPUT', swupdate_sign_output)
signcmd = []
sign_tool = d.getVar('SWUPDATE_SIGN_TOOL')
signtool = sign_tool.split()
@@ -208,7 +210,7 @@ def prepare_sw_description(d):
bb.fatal("SWUPDATE_PRIVATE_KEY isn't set")
if not os.path.exists(privkey):
bb.fatal("SWUPDATE_PRIVATE_KEY %s doesn't exist" % (privkey))
- signcmd = ["openssl", "dgst", "-sha256", "-sign", privkey] + get_pwd_file_args(d, 'SWUPDATE_PASSWORD_FILE') + ["-out", sw_desc_sig, sw_desc]
+ signcmd = ["openssl", "dgst", "-sha256", "-sign", privkey] + get_pwd_file_args(d, 'SWUPDATE_PASSWORD_FILE') + ["-out", swupdate_sign_output, swupdate_sign_input]
elif signing == "RSA-PSS":
privkey = d.getVar('SWUPDATE_PRIVATE_KEY', True)
if not privkey:
@@ -216,7 +218,7 @@ def prepare_sw_description(d):
if not os.path.exists(privkey):
bb.fatal("SWUPDATE_PRIVATE_KEY %s doesn't exist" % (privkey))
signcmd = ["openssl", "dgst", "-sha256", "-sign", privkey] + get_pwd_file_args(d, 'SWUPDATE_PASSWORD_FILE') + \
- ["-sigopt", "rsa_padding_mode:pss", "-sigopt", "rsa_pss_saltlen:-2", "-out", sw_desc_sig, sw_desc]
+ ["-sigopt", "rsa_padding_mode:pss", "-sigopt", "rsa_pss_saltlen:-2", "-out", swupdate_sign_output, swupdate_sign_input]
elif signing == "CMS":
cms_certs = (d.getVar('SWUPDATE_CMS_CERT') or "").split()
if not cms_certs:
@@ -235,7 +237,7 @@ def prepare_sw_description(d):
signer_args += ["-signer", cms_cert, "-inkey", cms_key]
cms_md = d.getVar('SWUPDATE_CMS_MD')
md_args = ["-md", cms_md] if cms_md else []
- signcmd = ["openssl", "cms", "-sign", "-in", sw_desc, "-out", sw_desc_sig] + signer_args + \
+ signcmd = ["openssl", "cms", "-sign", "-in", swupdate_sign_input, "-out", swupdate_sign_output] + signer_args + \
["-outform", "DER", "-nosmimecap", "-binary"] + md_args + \
get_pwd_file_args(d, 'SWUPDATE_PASSWORD_FILE') + \
get_certfile_args(d)
Allows custom commands to use SWUPDATE_SIGN_INPUT and SWUPDATE_SIGN_OUTPUT variables within the custom command to reference the same inputs and outputs used by the built-in signing options. Signed-off-by: Colin Pinnell McAllister <colinmca242@gmail.com> --- README | 5 ++++- classes-recipe/swupdate-common.bbclass | 12 +++++++----- 2 files changed, 11 insertions(+), 6 deletions(-)