utzig commented on a change in pull request #2174: Updates to crypto_test app; 
STM32 crypto HW driver; CBC/CTR speed
URL: https://github.com/apache/mynewt-core/pull/2174#discussion_r387698511
 
 

 ##########
 File path: apps/crypto_test/src/main.c
 ##########
 @@ -282,6 +286,66 @@ run_benchmark(char *name, block_encrypt_func_t encfn, 
void *data, uint8_t iter)
     }
     printf("done in %lu ticks\n", os_time_get() - t);
 }
+
+static void
+run_cbc_bench(struct crypto_dev *crypto, uint8_t iter)
+{
+    int i, j;
+    uint8_t iv[AES_BLOCK_LEN];
+    uint8_t output[AES_BLOCK_LEN];
+    uint16_t blkidx;
+    os_time_t t;
+
+    printf("AES-128-CBC - running %d iterations of 4096 block encrypt... ", 
iter);
+    t = os_time_get();
+    for (i = 0; i < iter; i++) {
+        memcpy(iv, aes_128_cbc_iv, AES_BLOCK_LEN);
+        for (blkidx = 0; blkidx < 4096; blkidx += AES_BLOCK_LEN) {
+            (void)crypto_encrypt_aes_cbc(crypto, aes_128_key, 128, iv,
+                    &aes_128_input[blkidx], output, AES_BLOCK_LEN);
+            if (memcmp(output, &aes_128_cbc_expected[blkidx],
+                        AES_BLOCK_LEN)) {
+                printf("fail... blkidx=%u\n", blkidx);
+                for (j = 0; j < AES_BLOCK_LEN; j++) {
+                    printf("[%02x]<%02x> ", output[j],
+                            aes_128_cbc_expected[blkidx + j]);
+                }
+                return;
+            }
+        }
+    }
+    printf("done in %lu ticks\n", os_time_get() - t);
 
 Review comment:
   Comparing to different boards is not relevant IMO, what is being done here 
is to compare the HW acceleration speed to SW implementations using 
tinycrypt/mbedTLS.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to