libcamera: Add IPA module signing infrastructure

Add infrastructure to generate an RSA private key and sign IPA modules.
The signatures are stored in separate files with a .sign suffix.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
Laurent Pinchart
2020-03-29 04:48:59 +03:00
parent e62bc9db73
commit ec92318891
6 changed files with 59 additions and 9 deletions

11
src/ipa/gen-ipa-priv-key.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020, Google Inc.
#
# Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
#
# gen-ipa-priv-key.sh - Generate an RSA private key to sign IPA modules
key="$1"
openssl genpkey -algorithm RSA -out "${key}" -pkeyopt rsa_keygen_bits:2048

13
src/ipa/ipa-sign.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020, Google Inc.
#
# Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
#
# ipa-sign.sh - Generate a signature for an IPA module
key="$1"
input="$2"
output="$3"
openssl dgst -sha256 -sign "${key}" -out "${output}" "${input}"

View File

@@ -10,6 +10,8 @@ config_h.set('IPA_MODULE_DIR',
subdir('libipa')
ipa_sign = find_program('ipa-sign.sh')
ipas = ['rkisp1', 'vimc']
foreach pipeline : get_option('pipelines')

View File

@@ -1,8 +1,17 @@
rkisp1_ipa = shared_module('ipa_rkisp1',
'rkisp1.cpp',
name_prefix : '',
include_directories : [ipa_includes, libipa_includes],
dependencies : libcamera_dep,
link_with : libipa,
install : true,
install_dir : ipa_install_dir)
ipa_name = 'ipa_rkisp1'
mod = shared_module(ipa_name,
'rkisp1.cpp',
name_prefix : '',
include_directories : [ipa_includes, libipa_includes],
dependencies : libcamera_dep,
link_with : libipa,
install : true,
install_dir : ipa_install_dir)
custom_target(ipa_name + '.so.sign',
input : mod,
output : ipa_name + '.so.sign',
command : [ ipa_sign, ipa_priv_key, '@INPUT@', '@OUTPUT@' ],
install : true,
install_dir : ipa_install_dir)

View File

@@ -1,4 +1,7 @@
ipa = shared_module('ipa_vimc', 'vimc.cpp',
ipa_name = 'ipa_vimc'
mod = shared_module(ipa_name,
'vimc.cpp',
name_prefix : '',
include_directories : [ipa_includes, libipa_includes],
dependencies : libcamera_dep,
@@ -6,3 +9,10 @@ ipa = shared_module('ipa_vimc', 'vimc.cpp',
install : true,
install_dir : ipa_install_dir,
cpp_args : '-DLICENSE="LGPL-2.1-or-later"')
custom_target(ipa_name + '.so.sign',
input : mod,
output : ipa_name + '.so.sign',
command : [ ipa_sign, ipa_priv_key, '@INPUT@', '@OUTPUT@' ],
install : true,
install_dir : ipa_install_dir)

View File

@@ -2,6 +2,11 @@ if get_option('android')
subdir('android')
endif
ipa_gen_priv_key = find_program('ipa/gen-ipa-priv-key.sh')
ipa_priv_key = custom_target('ipa-priv-key',
output : [ 'ipa-priv-key.pem' ],
command : [ ipa_gen_priv_key, '@OUTPUT@' ])
subdir('libcamera')
subdir('ipa')
subdir('cam')