All examples in the <root_directory>/kos/examples
directory share the same code that calculates the SHA256 hash for the message
Test Message Hello World
, and the source code is located in the <root_directory>/kos/examples/common
directory.
(root_directory
is the root directory containing the project's source files.)
This example shows how to use BoringSSL when it is a git submodule for a project.
The example uses the static variant of the BoringSSL library (the initialize_platform
command with the FORCE_STATIC
parameter).
For additional details regarding this command, please refer to the
platform library.
Hasher
is a program that calculates the SHA256 hash for the message Test Message Hello World
.
The ./einit/src/init.yaml.in
template is used to automatically generate part of the solution initialization
description file init.yaml
. For more information about the init.yaml.in
template file, see the
KasperskyOS Community Edition Online Help.
The ./einit/src/security.psl.in
template is used to automatically generate part
of the security.psl
file using CMake tools. The security.psl
file contains part of a solution security policy description.
For more information about the security.psl
file, see
Describing a security policy for a KasperskyOS-based solution.
To install KasperskyOS Community Edition SDK and run examples on QEMU or the Raspberry Pi hardware platform, make sure you meet all the System requirements listed in the KasperskyOS Community Edition Developer's Guide.
The example is built using the CMake build system, which is provided in the KasperskyOS Community Edition SDK.
There are environment variables that affect the build of the example:
SDK_PREFIX
specifies the path to the installed version of the KasperskyOS Community Edition SDK. The value of this environment variable must be set.TARGET
specifies the target platform. (Currently only theaarch64-kos
platform is supported.)
Run the following command:
$ SDK_PREFIX=/opt/KasperskyOS-Community-Edition-<version> [TARGET="aarch64-kos"] ./cross-build.sh
,
where version
—latest version number of the KasperskyOS Community Edition SDK.
For example, review the following command:
$ SDK_PREFIX=/opt/KasperskyOS-Community-Edition-<version> ./cross-build.sh
The command builds the example and runs the KasperskyOS-based solution image on QEMU. The solution
image is based on the SDK found in the /opt/KasperskyOS-Community-Edition-<version>
path, where version
is the latest version number of the KasperskyOS Community Edition SDK.
Running cross-build.sh
creates a KasperskyOS-based solution image that includes the example. The kos-qemu-image
solution image is located in the ./build/einit
directory.
The cross-build.sh
script both builds the example on QEMU and runs it.
Running cross-build.sh
creates a KasperskyOS-based solution image that includes the example and a bootable SD card image for Raspberry Pi 4 B. The kos-image
solution image is located in the ./build/einit
directory. The rpi4kos.img
bootable SD card image is located in the ./build
directory.
-
To copy the bootable SD card image to the SD card, connect the SD card to the computer and run the following command:
$ sudo dd bs=64k if=build/rpi4kos.img of=/dev/sd[X] conv=fsync
,where
[X]
is the final character in the name of the SD card block device. -
Connect the bootable SD card to the Raspberry Pi 4 B.
-
Supply power to the Raspberry Pi 4 B and wait for the example to run.
You can also use an alternative option to prepare and run the example:
- Prepare Raspberry Pi 4 B and a bootable SD card to run the example by following the instructions in the KasperskyOS Community Edition Online Help.
- Run the example by following the instructions in the KasperskyOS Community Edition Online Help
./cmake/BoringSSL.cmake—CMake commands for including the BoringSSL library in the project.
./hasher/CMakeLists.txt—CMake commands for building the Hasher
program.
./einit/CMakeLists.txt—CMake commands for building the Einit
program and the solution image.
./third_party/boringssl/CMakeLists.txt—CMake commands for building the BoringSSL library.
(The ./third_party
directory is generated when the example is built.)
./CMakeLists.txt—CMake commands for building the solution.
After running the example, the details about the message digest (or any errors) returned by the Hasher
should be displayed in the standard output:
Message parts: [Test][Message][Hello][World]
Message digest obtain with sha256 algorithm is: cb8f0c11401b96209ba9151f6eec442712502067287774ca2e61437b3feef2eb
© 2024 AO Kaspersky Lab