From nobody Sun Sep 29 15:25:16 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 4XGp186hj6z5XpB3; Sun, 29 Sep 2024 15:25:16 +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 4XGp185DmJz4krs; Sun, 29 Sep 2024 15:25:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727623516; 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=x/9uA4bmZSCOaYkn/gFf7y20mENH5N5J0162FmkvpMM=; b=lZApWUoEJHpdiA6IAeIimpPmQJC53imQF1PG6D54YnU8yfZY3gIijOOulH5U1Tm/43i2g3 +sU7tttBtHGgsX63nmPt9ByzXV0lorJUraQNgCHEfmq+lso8V4T4IM5m4Bn25+IcK0KIXs SRq/kI3bjlYNLwfUmxX8Rpg/yd7JvDmB9vfn/2giD8GrKMsnGbsvGFNn2ujfBrQiTYTVji Sz6mt50BCrQTamnJqQ2IzhRKxbEx/6pRaNHNf3rhTC8iSPMvvlV4Z8gj6mjNm/onA2I4kT LeNT8sJ82c/aecKOjGyBCCAWPtChM4QWEp3DDsHGPrFXIfhzE4LU378FdocZ3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727623516; 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=x/9uA4bmZSCOaYkn/gFf7y20mENH5N5J0162FmkvpMM=; b=ZGvfiOvnkeJ4ZtmtoLZridA4jk5ohr0Cmrvu+Tzc8MpFpN4IpMpE7mlfF0yeAfvZnNp+Cm UIF43u93gu65uHttq4Nj/w0vNQviTAx26Kjuz3nthPvpp5+E9o1CxSAz1Prby3wOa3Rajb h0wL/0DfRbCjIVe2Zsa02PNIsSo0fnuhIkMIWAG/taQIWQYr9PdKQnOjdKIkmCeYSQv1Cr uL6STodhfep9c/0lKdbDRg5gr0AyVv5/ubc1Qjq4lyTg0vOArxdNOoXWb311cyYl8eiXFO BrYxWP2AIyRueeFIVhqdVJ4Z64iQ9Nmk3P399Y5ZNg7pNQIIxwBu982hw3EzcQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727623516; a=rsa-sha256; cv=none; b=WQ1xnDKcN0ICreZd63GT1Hir6ExnvK3VI4dHOPj0R8bT69cqxqo5JH+C7HOlbUt2StAN7F VtsliJPoh71o9kN8wRQPeFdhzaSf9aHDoVoFCZolxH/O/RLBH/5tg0fzWIX079plppZWCx gtFW36fsd35HtoaHgdvZx5YiULFW0lWFzb86CRNQuor6rZ6qYAO5xrR9uXHhpjEm7ng72P t9XDUTpUhxrWWz3g8ApeBTfK7UV42bINfBMyuEM8ZFu1KPOYOi6Q/19keq+FhUGiGXwFWw n5tSVCgc1/xLkC0A8QUIUbpKicGiMy0F9BBZ3OdzchAOeVczFWZUrmEKI8VCQA== 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 4XGp184gjLzFGj; Sun, 29 Sep 2024 15:25:16 +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 48TFPGjR030462; Sun, 29 Sep 2024 15:25:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48TFPGEC030459; Sun, 29 Sep 2024 15:25:16 GMT (envelope-from git) Date: Sun, 29 Sep 2024 15:25:16 GMT Message-Id: <202409291525.48TFPGEC030459@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Colin Percival Subject: git: 8d2d49bdb5ce - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 8d2d49bdb5ce070a5e954baa59ad6a7d0e3514cd Auto-Submitted: auto-generated The branch stable/14 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=8d2d49bdb5ce070a5e954baa59ad6a7d0e3514cd commit 8d2d49bdb5ce070a5e954baa59ad6a7d0e3514cd Author: Colin Percival AuthorDate: 2024-09-18 11:02:05 +0000 Commit: Colin Percival CommitDate: 2024-09-29 15:24:52 +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 (cherry picked from commit 8ce291a335bc751e7a89691eebfb9f9da65b82ac) --- 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 ea3be36865b0..4ea5ea12634a 100644 --- a/sys/geom/eli/pkcs5v2.c +++ b/sys/geom/eli/pkcs5v2.c @@ -52,13 +52,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