|
| 1 | +###### |
| 2 | +Crypto |
| 3 | +###### |
| 4 | + |
| 5 | +************ |
| 6 | +Introduction |
| 7 | +************ |
| 8 | + |
| 9 | +The Crypto API Driver is a set of Linux drivers that provide access to |
| 10 | +the hardware cryptographic accelerators available on AM62L devices. |
| 11 | +These drivers are available built-in in the kernel in the current SDK release. |
| 12 | + |
| 13 | +Following are the Hardware accelerators supported on the following |
| 14 | +devices: |
| 15 | + |
| 16 | +.. code-block:: text |
| 17 | +
|
| 18 | + * AM62LX : AES-ECB, AES-CBC, MD5, SHA224, SHA256, SHA384, SHA512 |
| 19 | +
|
| 20 | +******************** |
| 21 | +Building the Drivers |
| 22 | +******************** |
| 23 | + |
| 24 | +For devices with available cryptographic hardware accelerators, a Linux |
| 25 | +driver and additionally a Cryptodev kernel module (for OpenSSL) is used |
| 26 | +to access them. Other devices use the pure software implementation of these |
| 27 | +cryptographic operations. |
| 28 | + |
| 29 | +|__PART_FAMILY_DEVICE_NAMES__| SoC supports a hardware accelerator called |
| 30 | +DATA TRANSFORM AND HASHING ENGINE (DTHE) v2 for crypto operations. |
| 31 | + |
| 32 | +The kernel configuration has already been set up in the SDK and no further |
| 33 | +configuration is needed for the drivers to be built-in to the kernel. |
| 34 | + |
| 35 | +For reference, the configuration details are shown below. The |
| 36 | +configuration of the cryptographic drivers is done under the |
| 37 | +Hardware crypto devices sub-menu of the Cryptographic API menu in the |
| 38 | +kernel configuration. |
| 39 | + |
| 40 | +.. code-block:: text |
| 41 | +
|
| 42 | + Symbol: CRYPTO_DEV_TI_DTHEV2 [=m] |
| 43 | + | Type : tristate |
| 44 | + | Prompt: Support for TI security accelerator |
| 45 | + | Location: |
| 46 | + | -> Cryptographic API (CRYPTO [=y]) |
| 47 | + | (1) -> Hardware crypto devices (CRYPTO_HW [=y]) |
| 48 | +
|
| 49 | +To check if DTHEv2 module is properly installed, |
| 50 | +run the below command from the Linux command prompt: |
| 51 | + |
| 52 | +.. code-block:: console |
| 53 | +
|
| 54 | + lsmod | grep dthev2 |
| 55 | +
|
| 56 | +Output should show something similar to below: |
| 57 | + |
| 58 | +.. code-block:: text |
| 59 | +
|
| 60 | + dthev2 262144 0 |
| 61 | +
|
| 62 | +.. rubric:: Build the Cryptodev kernel module using SDK |
| 63 | + :name: build-the-cryptodev-kernel-module-using-sdk |
| 64 | + |
| 65 | +For using OpenSSL to access the Crypto Hardware Accelerator Drivers |
| 66 | +above, the Cryptodev is required (can be built as module). The framework |
| 67 | +is not officially in the kernel and was ported to Linux under the name |
| 68 | +"cryptodev". It is built as part of the SDK and no further configuration is needed. |
| 69 | + |
| 70 | +****************************************************** |
| 71 | +Using Cryptographic Hardware Accelerators from OpenSSL |
| 72 | +****************************************************** |
| 73 | + |
| 74 | +In order to use these drivers from OpenSSL, a |
| 75 | +special driver is available which abstracts the access to these |
| 76 | +accelerators through Cryprodev module. |
| 77 | + |
| 78 | +Cryptodev is itself a special device driver which provides a general |
| 79 | +interface for higher level applications such as OpenSSL to access |
| 80 | +hardware accelerators. |
| 81 | + |
| 82 | +The filesystem which comes with the SDK comes built with the Cryptodev |
| 83 | +kernel modules and the TI driver which directly accesses the hardware |
| 84 | +accelerators is built into the kernel. |
| 85 | + |
| 86 | +The following shows the command used to query the system for the state of |
| 87 | +the cryptodev module. |
| 88 | + |
| 89 | +.. code-block:: console |
| 90 | +
|
| 91 | + root@evm:~# lsmod | grep cryptodev |
| 92 | + cryptodev 11962 0 |
| 93 | +
|
| 94 | +The following example demonstrates the OpenSSL built-in speed |
| 95 | +test to demonstrate performance. The addition of the parameter **-engine |
| 96 | +devcrypto** tells OpenSSL to use the Cryptodev driver if it exists. |
| 97 | + |
| 98 | +.. code-block:: console |
| 99 | +
|
| 100 | + root@evm:~# openssl speed -evp aes-128-cbc -engine devcrypto |
| 101 | + Engine "devcrypto" set. |
| 102 | + Doing AES-128-CBC ops for 3s on 16 size blocks: 37316 AES-128-CBC ops in 0.00s |
| 103 | + Doing AES-128-CBC ops for 3s on 64 size blocks: 37305 AES-128-CBC ops in 0.00s |
| 104 | + Doing AES-128-CBC ops for 3s on 256 size blocks: 37503 AES-128-CBC ops in 0.00s |
| 105 | + Doing AES-128-CBC ops for 3s on 1024 size blocks: 37504 AES-128-CBC ops in 0.00s |
| 106 | + Doing AES-128-CBC ops for 3s on 8192 size blocks: 18784 AES-128-CBC ops in 0.00s |
| 107 | + Doing AES-128-CBC ops for 3s on 16384 size blocks: 18701 AES-128-CBC ops in 0.00s |
| 108 | + version: 3.2.3 |
| 109 | + built on: Tue Sep 3 12:52:35 2024 UTC |
| 110 | + options: bn(64,64) |
| 111 | + compiler: aarch64-oe-linux-gcc -mbranch-protection=standard --sysroot=recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fcanon-prefix-map -fmacro-prefix-map= -fdebug-prefix-map= -fmacro-prefix-mapG |
| 112 | + CPUINFO: OPENSSL_armcap=0xbd |
| 113 | + The 'numbers' are in 1000s of bytes per second processed. |
| 114 | + type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes |
| 115 | + AES-128-CBC infk infk infk infk infk infk |
| 116 | +
|
| 117 | +Using the Linux time -v function gives more information about CPU usage |
| 118 | +during the test. |
| 119 | + |
| 120 | +.. code-block:: console |
| 121 | +
|
| 122 | + root@evm:~# time -v openssl speed -evp aes-128-cbc -engine devcrypto |
| 123 | + Engine "devcrypto" set. |
| 124 | + Doing AES-128-CBC ops for 3s on 16 size blocks: 37194 AES-128-CBC ops in 0.00s |
| 125 | + Doing AES-128-CBC ops for 3s on 64 size blocks: 37406 AES-128-CBC ops in 0.00s |
| 126 | + Doing AES-128-CBC ops for 3s on 256 size blocks: 37455 AES-128-CBC ops in 0.00s |
| 127 | + Doing AES-128-CBC ops for 3s on 1024 size blocks: 37503 AES-128-CBC ops in 0.00s |
| 128 | + Doing AES-128-CBC ops for 3s on 8192 size blocks: 18744 AES-128-CBC ops in 0.01s |
| 129 | + Doing AES-128-CBC ops for 3s on 16384 size blocks: 18727 AES-128-CBC ops in 0.01s |
| 130 | + version: 3.2.3 |
| 131 | + built on: Tue Sep 3 12:52:35 2024 UTC |
| 132 | + options: bn(64,64) |
| 133 | + compiler: aarch64-oe-linux-gcc -mbranch-protection=standard --sysroot=recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fcanon-prefix-map -fmacro-prefix-map= -fdebug-prefix-map= -fmacro-prefix-mapG |
| 134 | + CPUINFO: OPENSSL_armcap=0xbd |
| 135 | + The 'numbers' are in 1000s of bytes per second processed. |
| 136 | + type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes |
| 137 | + AES-128-CBC infk infk infk infk 15355084.80k 30682316.80k |
| 138 | + Command being timed: "openssl speed -evp aes-128-cbc -engine devcrypto" |
| 139 | + User time (seconds): 0.02 |
| 140 | + System time (seconds): 11.40 |
| 141 | + Percent of CPU this job got: 62% |
| 142 | + Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 18.42s |
| 143 | + Average shared text size (kbytes): 0 |
| 144 | + Average unshared data size (kbytes): 0 |
| 145 | + Average stack size (kbytes): 0 |
| 146 | + Average total size (kbytes): 0 |
| 147 | + Maximum resident set size (kbytes): 23760 |
| 148 | + Average resident set size (kbytes): 0 |
| 149 | + Major (requiring I/O) page faults: 0 |
| 150 | + Minor (reclaiming a frame) page faults: 329 |
| 151 | + Voluntary context switches: 187095 |
| 152 | + Involuntary context switches: 95 |
| 153 | + Swaps: 0 |
| 154 | + File system inputs: 0 |
| 155 | + File system outputs: 0 |
| 156 | + Socket messages sent: 0 |
| 157 | + Socket messages received: 0 |
| 158 | + Signals delivered: 0 |
| 159 | + Page size (bytes): 4096 |
| 160 | + Exit status: 0 |
| 161 | +
|
| 162 | +
|
| 163 | +When the cryptodev driver is removed, OpenSSL reverts to the software |
| 164 | +implementation of the crypto algorithm. The performance using the |
| 165 | +software only implementation can be compared to the previous test. |
| 166 | + |
| 167 | +.. code-block:: console |
| 168 | +
|
| 169 | + root@evm:~# modprobe -r cryptodev |
| 170 | + root@evm:~# time -v openssl speed -evp aes-128-cbc |
| 171 | + Doing AES-128-CBC ops for 3s on 16 size blocks: 18675602 AES-128-CBC ops in 2.99s |
| 172 | + Doing AES-128-CBC ops for 3s on 64 size blocks: 14189260 AES-128-CBC ops in 2.99s |
| 173 | + Doing AES-128-CBC ops for 3s on 256 size blocks: 7121339 AES-128-CBC ops in 2.98s |
| 174 | + Doing AES-128-CBC ops for 3s on 1024 size blocks: 2437075 AES-128-CBC ops in 2.99s |
| 175 | + Doing AES-128-CBC ops for 3s on 8192 size blocks: 340806 AES-128-CBC ops in 2.98s |
| 176 | + Doing AES-128-CBC ops for 3s on 16384 size blocks: 171986 AES-128-CBC ops in 2.98s |
| 177 | + version: 3.2.3 |
| 178 | + built on: Tue Sep 3 12:52:35 2024 UTC |
| 179 | + options: bn(64,64) |
| 180 | + compiler: aarch64-oe-linux-gcc -mbranch-protection=standard --sysroot=recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fcanon-prefix-map -fmacro-prefix-map= -fdebug-prefix-map= -fmacro-prefix-mapG |
| 181 | + CPUINFO: OPENSSL_armcap=0xbd |
| 182 | + The 'numbers' are in 1000s of bytes per second processed. |
| 183 | + type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes |
| 184 | + AES-128-CBC 99936.33k 303716.60k 611766.03k 834637.06k 936873.41k 945576.72k |
| 185 | + Command being timed: "openssl speed -evp aes-128-cbc" |
| 186 | + User time (seconds): 17.91 |
| 187 | + System time (seconds): 0.04 |
| 188 | + Percent of CPU this job got: 99% |
| 189 | + Elapsed (wall clock) time (h:mm:ss or m:ss): 0m 18.02s |
| 190 | + Average shared text size (kbytes): 0 |
| 191 | + Average unshared data size (kbytes): 0 |
| 192 | + Average stack size (kbytes): 0 |
| 193 | + Average total size (kbytes): 0 |
| 194 | + Maximum resident set size (kbytes): 24304 |
| 195 | + Average resident set size (kbytes): 0 |
| 196 | + Major (requiring I/O) page faults: 0 |
| 197 | + Minor (reclaiming a frame) page faults: 324 |
| 198 | + Voluntary context switches: 1 |
| 199 | + Involuntary context switches: 24 |
| 200 | + Swaps: 0 |
| 201 | + File system inputs: 0 |
| 202 | + File system outputs: 0 |
| 203 | + Socket messages sent: 0 |
| 204 | + Socket messages received: 0 |
| 205 | + Signals delivered: 0 |
| 206 | + Page size (bytes): 4096 |
| 207 | + Exit status: 0 |
0 commit comments