From nobody Sun Sep 22 07:36:43 2024 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 4XBHxm31SLz5XYBv; Sun, 22 Sep 2024 07:36:44 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XBHxl70w8z44Qq; Sun, 22 Sep 2024 07:36:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726990604; 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=nlY42FYZ9Pe7ASvcs/5r6vlgtUrPnKb8j7HnA5kHyWE=; b=n2D4XMqYHMB/o4UT6bYwn8Ys1WiNIgWNtXveQJolSbCnX+0mj92qz02zeXgW24SfwaJdqu calUHBL9xhdAZZCJJyCFfkvacT1JHU7gSv7sXveJe5noH75Cz/rOZB/aTSQ3//dpAyRPtQ AuOLejDii71fgwAoJfOJomPdBZjB+sd1uMQmTtXLporvvn8eU+9IANvB64audQZ4iv7rVM yw79CarkDxDH0zErUsb/AGc4F9D+URXKIQZRaTiCZEN8XfZefijxhzhTcqo8F2eWN4MThc B4fF0qWA1VcFGwyTzk5WaHNwiOJJQnQmQAj2mFG58tE8vdMsj/87oLsdOJnT4g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726990604; a=rsa-sha256; cv=none; b=C3h591JDu7YaJNNrX5ZwyhD/HVqYxaFDE0OjCnn+v5iYMPKrFtQt4YmfsZjyaV5art5NlC Krrszf11IzEte02QjD9apkbsfFou2YUb2P8SIV/6dfgXWpz1Dq3Ap3yJwQs8BSHeHtYTX6 vNK4AC2ORMmNLHLbbm46mHLxVTTxfQ7TgV55BVR7mDz2cUVmxmvrK6mK74NevWp0gr40Co aV+6DPwMiwpYz/CmFgOBUsG26FDXLdc0FE3TpfRbMTTc+GsN9WF4VPwFkWESJ1+jieWK0q vHBPoUhX5dhb5NtY6bV6liXHrwrraah1v26ylFkNCH8XP9oQc+XY2zSevKprmw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726990604; 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=nlY42FYZ9Pe7ASvcs/5r6vlgtUrPnKb8j7HnA5kHyWE=; b=i8lX8BZ6dpibCSxOXYxMe3ij3+Jcnb/qqm0yUlJAgdEa0utNfgYWZwzB5FZcPcvTpY6D8A HOWhqEYyI43fJedDmg1PgTVFZ3Y+x9HvkjPjBz6GQq7Hb7/dRLsSk4p5HFSGTnAeiaiA/P GoycO6bPPp0ZExcvQy7xjaZe3gZQdRyG/DvCworoR+CnQI6GS/ByMuon/L8XtHkqLunL6Z OLW59vz/X+60mXdjiiUJBy8QOEM4yHJ+vvaggMOADLwUUu2yRQhRIFAQSdeZXilSuWAUEM TTwTCjTkVFIEVDP0KoWpPotxQgM0uwhFe65FCgbn4JS/nRKUqSRt7TLgwL2+nw== 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 4XBHxl6bwdz16qY; Sun, 22 Sep 2024 07:36:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48M7ahJ7097179; Sun, 22 Sep 2024 07:36:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48M7ahk2097176; Sun, 22 Sep 2024 07:36:43 GMT (envelope-from git) Date: Sun, 22 Sep 2024 07:36:43 GMT Message-Id: <202409220736.48M7ahk2097176@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 8ce291a335bc - main - pkcs5v2: Add pkcs5v2_genkey_raw function 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8ce291a335bc751e7a89691eebfb9f9da65b82ac Auto-Submitted: auto-generated The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=8ce291a335bc751e7a89691eebfb9f9da65b82ac commit 8ce291a335bc751e7a89691eebfb9f9da65b82ac Author: Colin Percival AuthorDate: 2024-09-18 11:02:05 +0000 Commit: Colin Percival CommitDate: 2024-09-22 07:35:47 +0000 pkcs5v2: Add pkcs5v2_genkey_raw function This is like pkcs5v2_genkey but takes a "passphrase" as a buffer and length rather than a NUL-terminated string. Reviwed by: pjd MFC after: 1 week Sponsored by: Amazon Differential Revision: https://reviews.freebsd.org/D46633 --- sys/geom/eli/pkcs5v2.c | 13 +++++++++++-- sys/geom/eli/pkcs5v2.h | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/geom/eli/pkcs5v2.c b/sys/geom/eli/pkcs5v2.c index 546f1d64af83..c4cecf4782ab 100644 --- a/sys/geom/eli/pkcs5v2.c +++ b/sys/geom/eli/pkcs5v2.c @@ -51,13 +51,22 @@ void pkcs5v2_genkey(uint8_t *key, unsigned keylen, const uint8_t *salt, size_t saltsize, const char *passphrase, u_int iterations) { + + pkcs5v2_genkey_raw(key, keylen, salt, saltsize, passphrase, + strlen(passphrase), iterations); +} + +void +pkcs5v2_genkey_raw(uint8_t *key, unsigned keylen, const uint8_t *salt, + size_t saltsize, const uint8_t *passphrase, size_t passlen, + u_int iterations) +{ uint8_t md[SHA512_MDLEN], saltcount[saltsize + sizeof(uint32_t)]; uint8_t *counter, *keyp; - u_int i, bsize, passlen; + u_int i, bsize; uint32_t count; struct hmac_ctx startpoint, ctx; - passlen = strlen(passphrase); bzero(key, keylen); bcopy(salt, saltcount, saltsize); counter = saltcount + saltsize; diff --git a/sys/geom/eli/pkcs5v2.h b/sys/geom/eli/pkcs5v2.h index f271f17a68c1..02e3fac02fe7 100644 --- a/sys/geom/eli/pkcs5v2.h +++ b/sys/geom/eli/pkcs5v2.h @@ -30,6 +30,9 @@ #define _PKCS5V2_H_ void pkcs5v2_genkey(uint8_t *key, unsigned keylen, const uint8_t *salt, size_t saltsize, const char *passphrase, u_int iterations); +void pkcs5v2_genkey_raw(uint8_t *key, unsigned keylen, const uint8_t *salt, + size_t saltsize, const uint8_t *passphrase, size_t passlen, + u_int iterations); #ifndef _KERNEL int pkcs5v2_calculate(int usecs); #endif