From patchwork Thu Sep 19 13:39:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe REYNES X-Patchwork-Id: 1164638 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=softathome.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Yygp3rzvz9s4Y for ; Thu, 19 Sep 2019 23:41:58 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1F3A2C21E16; Thu, 19 Sep 2019 13:40:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 349DBC21E07; Thu, 19 Sep 2019 13:40:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 36107C21BE5; Thu, 19 Sep 2019 13:39:58 +0000 (UTC) Received: from vrout30.yaziba.net (vrout30.yaziba.net [185.56.204.33]) by lists.denx.de (Postfix) with ESMTPS id 04A17C21C38 for ; Thu, 19 Sep 2019 13:39:58 +0000 (UTC) Received: from mtaout20.int.yaziba.net (mtaout20.int.yaziba.net [10.4.20.37]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout30.yaziba.net (mx10.yaziba.net) with ESMTPS id 192E85208D; Thu, 19 Sep 2019 15:39:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mtaout20.int.yaziba.net (Postfix) with ESMTP id 34AE516022B; Thu, 19 Sep 2019 15:39:57 +0200 (CEST) Received: from mtaout20.int.yaziba.net ([127.0.0.1]) by localhost (mtaout20.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id t9tqSrOZ5gAq; Thu, 19 Sep 2019 15:39:57 +0200 (CEST) Received: from sahnlpt0333.softathome.com (unknown [149.6.166.170]) by mtaout20.int.yaziba.net (Postfix) with ESMTPSA id 033F5160231; Thu, 19 Sep 2019 15:39:57 +0200 (CEST) From: Philippe Reynes To: sjg@chromium.org, mario.six@gdsys.cc, joe.hershberger@ni.com Date: Thu, 19 Sep 2019 15:39:45 +0200 Message-Id: <1568900385-21957-5-git-send-email-philippe.reynes@softathome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1568900385-21957-1-git-send-email-philippe.reynes@softathome.com> References: <1568900385-21957-1-git-send-email-philippe.reynes@softathome.com> X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: 0 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrvddtgdeikecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhestddtredtredttdenucfhrhhomheprfhhihhlihhpphgvucftvgihnhgvshcuoehphhhilhhiphhpvgdrrhgvhihnvghssehsohhfthgrthhhohhmvgdrtghomheqnecukfhppedugeelrdeirdduieeirddujedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhht X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 4/4] pytest: add a new test for aes X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This commit add a simple test to check that a text may be ciphered and unciphered. Each step are checked with the known result. Signed-off-by: Philippe Reynes --- test/py/tests/test_aes.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 test/py/tests/test_aes.py diff --git a/test/py/tests/test_aes.py b/test/py/tests/test_aes.py new file mode 100644 index 0000000..408bd77 --- /dev/null +++ b/test/py/tests/test_aes.py @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019, Softathome + +# Test U-Boot's "aes" command. + +import pytest + +def test_aes(u_boot_console): + """ + Test the aes command, and validate that it can + cipher and uncipher a simple text + """ + + cons = u_boot_console + tmpdir = cons.config.result_dir + '/' + datadir = cons.config.source_dir + '/test/py/tests/aes/' + + # Check that the option cmd_aes is enabled in the config + if cons.config.buildconfig.get('config_cmd_aes', 'n') != 'y': + pytest.skip('aes command not supported') + + # Send a command with no argument ... + output = cons.run_command('aes') + assert('AES 128 CBC encryption' in ''.join(output)) + + # Load file from host + output = cons.run_command('host load hostfs - 1000 %skey128.bin' % datadir) + assert('16 bytes read' in ''.join(output)) + output = cons.run_command('host load hostfs - 2000 %siv128.bin' % datadir) + assert('16 bytes read' in ''.join(output)) + output = cons.run_command('host load hostfs - 3000 %splaintext.bin' % datadir) + assert('32 bytes read' in ''.join(output)) + + output = cons.run_command('md.b 3000 0x20') + + output = cons.run_command('aes enc 1000 2000 3000 4000 0x20') + + output = cons.run_command('cmp.b 3000 4000 0x20') + assert('Total of 0 byte(s) were the same' in ''.join(output)) + + output = cons.run_command('md.b 4000 0x20') + + output = cons.run_command('aes dec 1000 2000 4000 5000 0x20') + + output = cons.run_command('md.b 5000 0x20') + + output = cons.run_command('cmp.b 3000 5000 0x20') + assert('Total of 32 byte(s) were the same' in ''.join(output))