From nobody Thu Oct 06 14:52:50 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MjvYt28Cqz4dmHy; Thu, 6 Oct 2022 14:52:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MjvYt1cV7z3M9J; Thu, 6 Oct 2022 14:52:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665067970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/+73gAtRjZmn/e0O+CSjTWoYYsF9pnXCOUDCigwL+Ak=; b=hTHuW4ZGIpip+J+FoCuWVctLC1BgCsThXHV8bpLKx2dcuPjvAspZyDIJh2rC2WNf0qfVls BtdZ8trfF2gEIt5UYB7FzuDCEtg936gQlBCwPdotCPMl9Ye1+pO+L5k5gUQz/Lv62QjUKW WigFCPlsk82O43bZCNKYYJLdr5kH63LCla4oPG0FtuDHUMnKE1eFgzgjIm7dvBheiI48B+ gyra7bL5XTRTLqHPaqT6tD77U0O+gDK8FHZUSSlXbRQ31WuwxMq3hU4R8r8jQpShj85dhm 0nKl+NIthn8He9qqqCQDLwVzrBxuiPAiJC8XoBANWA/oanS9o5qqm+AsB04ROQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MjvYt0dDwzHBR; Thu, 6 Oct 2022 14:52:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 296EqoD7016986; Thu, 6 Oct 2022 14:52:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 296EqoXf016985; Thu, 6 Oct 2022 14:52:50 GMT (envelope-from git) Date: Thu, 6 Oct 2022 14:52:50 GMT Message-Id: <202210061452.296EqoXf016985@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Kornel=20Dul=C4=99ba?= Subject: git: fdbd0ba75d99 - main - test/sys/opencrypto: Fix NIST KAT parser iterator List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fdbd0ba75d99f1909b13a9f9ece5e8c576bd8977 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665067970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/+73gAtRjZmn/e0O+CSjTWoYYsF9pnXCOUDCigwL+Ak=; b=DG+HLokf5WyUuXnHy1HvH0MGH3lxgBtaeKGI0uJmUiMiJV8RH08DPPJ0Xtys5YEpzPGcZE dbpqZsnW+44KoAYNk3htbAJ+StM9e6/vR3vXMwM2QBIq9RYrortskrwjXJVvVif0NXzyoS W6xxUI/sG30ZPEzE35RR5XXM8d7r1I8srrz9ID9gvlDuqDmnwRv69QuuFPsCwAlBH7VsWY aZlWKgAUCsVWhX9YucGnyvwUAd8d+4BowdWBWa5l6sPvCvI7IrUYk0dNByLJ5x0/0771aQ V5wG8j+LVxS9mzoG+JB0OEKD5D8gsMGqTHVTnuZo+7u2Qz8lJBiBpknzDnNrGQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665067970; a=rsa-sha256; cv=none; b=eXpDrHtMObc6PsDC6RfCwS+hZAlrrKrhJmkFPcwUotECdU8CfKVhd7D9sYwDe/ioEi0lrP 3Z6b8SKd/oemMQw3Dvw9l5mbbovuyEAbUgsCGs39lVbF4ijnRs797uYzFogjfuBKR4W3Ur hRQNpxpNH3ZRnpw539diPw761cp2djMyBXJ/LQDd2faW18E6LPoGxhUUhaN9anMLpzQsuW InZfr6o0lE0ut50U+2b2+pia0Ub4AMlQ8f4Q2g1D66j6qqjzbfFIO7PsZfRwm5AdUUrpwv FCMiiPNqZbgB7upGpHvMWwOR8SsN/41HZ8GTwmuJpwGKUDA3sp83r3xWgE8fqQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kd: URL: https://cgit.FreeBSD.org/src/commit/?id=fdbd0ba75d99f1909b13a9f9ece5e8c576bd8977 commit fdbd0ba75d99f1909b13a9f9ece5e8c576bd8977 Author: Kornel Dulęba AuthorDate: 2022-10-06 14:20:58 +0000 Commit: Kornel Dulęba CommitDate: 2022-10-06 14:42:31 +0000 test/sys/opencrypto: Fix NIST KAT parser iterator When yield a.k.a "generator" iterator is used we need to return all data using "yield", before returning from the function. Because of that only encryption tests were run for AES-CBC, other modes were affected as well. Add one more loop to the iterator "next" routine to fix that. This unveiled a problem in the GCM AEAD parser logic, which didn't correctly handle tests cases with empty plaintext, i.e. AAD only. Include the fix in this patch as it's a rather trivial one. Obtained from: Semihalf Differential Revision: https://reviews.freebsd.org/D36861 --- tests/sys/opencrypto/cryptodev.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/sys/opencrypto/cryptodev.py b/tests/sys/opencrypto/cryptodev.py index d97a731d37ba..7e9b1f6a9fbb 100644 --- a/tests/sys/opencrypto/cryptodev.py +++ b/tests/sys/opencrypto/cryptodev.py @@ -38,6 +38,7 @@ from fcntl import ioctl import os import platform import random +import re import signal from struct import pack as _pack import sys @@ -258,7 +259,7 @@ class Crypto: caead.op = op caead.flags = CRD_F_IV_EXPLICIT caead.flags = 0 - if src is not None and len(src) != 0: + if src: src = str_to_ascii(src) caead.len = len(src) s = array.array('B', src) @@ -287,7 +288,7 @@ class Crypto: ioctl(_cryptodev, CIOCCRYPTAEAD, bytes(caead)) - if src is not None: + if src: s = array_tobytes(s) else: s = empty_bytes() @@ -358,6 +359,7 @@ class KATParser: self._pending = None self.fname = fname self.fp = None + self.field_re = re.compile(r"\[(?P[^]]+)\]") def __enter__(self): self.fp = open(self.fname) @@ -372,24 +374,22 @@ class KATParser: def __next__(self): while True: - didread = False - if self._pending is not None: - i = self._pending - self._pending = None - else: - i = self.fp.readline() - didread = True - - if didread and not i: - return - - if not i.startswith('#') and i.strip(): - break + while True: + if self._pending is not None: + i = self._pending + self._pending = None + else: + i = self.fp.readline() + if not i: + return + + if not i.startswith('#') and i.strip(): + break - if i[0] == '[': - yield i[1:].split(']', 1)[0], self.fielditer() - else: - raise ValueError('unknown line: %r' % repr(i)) + matches = self.field_re.match(i) + if matches is None: + raise ValueError("Unknown line: %r" % (i)) + yield matches.group("field"), self.fielditer() def eatblanks(self): while True: