From patchwork Fri May 10 02:11:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 731 X-Patchwork-Delegate: davids@openvpn.net Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id aKZIDSFv1VywZgAAIUCqbw for ; Fri, 10 May 2019 08:31:29 -0400 Received: from proxy9.mail.iad3b.rsapps.net ([172.31.255.6]) by director12.mail.ord1d.rsapps.net with LMTP id UHIKCyFv1VwtPwAAIasKDg ; Fri, 10 May 2019 08:31:29 -0400 Received: from smtp26.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy9.mail.iad3b.rsapps.net with LMTP id 4PyQBSFv1VwXBAAAC4PSzw ; Fri, 10 May 2019 08:31:29 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp26.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 887f5160-731f-11e9-b216-5254001088d3-1-1 Received: from [216.105.38.7] ([216.105.38.7:49376] helo=lists.sourceforge.net) by smtp26.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 15/E7-03413-02F65DC5; Fri, 10 May 2019 08:31:28 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1hP4fl-0005ve-FL; Fri, 10 May 2019 12:30:45 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hP4fk-0005vS-E9 for openvpn-devel@lists.sourceforge.net; Fri, 10 May 2019 12:30:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=/cz309KnGFUYxUdKGg/ZfI16g7o0BqlOFHdlRbmJtWA=; b=lu6FCcpZx+Hrm6TnxxQwj4Vf3G J0ps91pwfNGbsYnutBKM9Et95AjzYNu4A3Tj8th6q9uxz9QjnIjYzjiDcIOl/gtgz0MNpR5rP6EW0 9GjAUkx202WXpwNLoLzXEbwyBQiIessLxj/sGlDciApGH0Tymy9pm74FIgAe7Lt4USxU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/cz309KnGFUYxUdKGg/ZfI16g7o0BqlOFHdlRbmJtWA=; b=ebCjMRy4GpJE/PSsKW8ETStEyv 19gvLyn3KgTRTAWSDvTRDCq1UTHvE19x5fE7a4ATwdSJBHUnk/PQIYlHBW87z2mpDB/DdPDEPfmYy PUS3ZXN51juI+HkGvNvCT6gO3N471IqACCe0pojK9WhlNrIw3RXxlTSpzjKuG+nlVx68=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hP4fi-00FeDX-W3 for openvpn-devel@lists.sourceforge.net; Fri, 10 May 2019 12:30:44 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.91 (FreeBSD)) (envelope-from ) id 1hP4Mt-000B4j-1Y for openvpn-devel@lists.sourceforge.net; Fri, 10 May 2019 14:11:15 +0200 Received: (nullmailer pid 30516 invoked by uid 10006); Fri, 10 May 2019 12:11:14 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Fri, 10 May 2019 14:11:08 +0200 Message-Id: <20190510121114.30468-2-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510121114.30468-1-arne@rfc2549.org> References: <20190510121114.30468-1-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.1 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.2 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1hP4fi-00FeDX-W3 Subject: [Openvpn-devel] [PATCH v3 1/7] Write key to stdout if filename is not given X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This change is preperation for changing the way --genkey works. Acked-By: David Sommerseth --- src/openvpn/crypto.c | 13 +++++++++++-- src/openvpn/tls_crypt.c | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index ff9dbfdc..eb56421b 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -1465,8 +1465,13 @@ write_key_file(const int nkeys, const char *filename) buf_printf(&out, "%s\n", static_key_foot); + /* write key file to stdout if no filename given */ + if (!filename || strcmp(filename, "")==0) + { + printf("%s\n", BPTR(&out)); + } /* write key file, now formatted in out, to file */ - if (!buffer_write_file(filename, &out)) + else if (!buffer_write_file(filename, &out)) { nbits = -1; } @@ -1870,7 +1875,11 @@ write_pem_key_file(const char *filename, const char *pem_name) goto cleanup; } - if (!buffer_write_file(filename, &server_key_pem)) + if (!filename || strcmp(filename, "")==0) + { + printf("%s\n", BPTR(&server_key_pem)); + } + else if (!buffer_write_file(filename, &server_key_pem)) { msg(M_ERR, "ERROR: could not write key file"); goto cleanup; diff --git a/src/openvpn/tls_crypt.c b/src/openvpn/tls_crypt.c index d6a82252..e8889e93 100644 --- a/src/openvpn/tls_crypt.c +++ b/src/openvpn/tls_crypt.c @@ -697,7 +697,16 @@ tls_crypt_v2_write_client_key_file(const char *filename, goto cleanup; } - if (!buffer_write_file(filename, &client_key_pem)) + const char *client_filename = filename; + const char *client_inline = NULL; + + if (!filename || streq(filename, "")) + { + printf("%s\n", BPTR(&client_key_pem)); + client_filename = INLINE_FILE_TAG; + client_inline = (const char *)BPTR(&client_key_pem); + } + else if (!buffer_write_file(filename, &client_key_pem)) { msg(M_FATAL, "ERROR: could not write client key file"); goto cleanup; @@ -708,7 +717,7 @@ tls_crypt_v2_write_client_key_file(const char *filename, struct buffer test_wrapped_client_key; msg(D_GENKEY, "Testing client-side key loading..."); tls_crypt_v2_init_client_key(&test_client_key, &test_wrapped_client_key, - filename, NULL); + client_filename, client_inline); free_key_ctx_bi(&test_client_key); /* Sanity check: unwrap and load client key (as "server") */