From patchwork Sun Mar 25 13:04:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Geier X-Patchwork-Id: 890634 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4010:c07::238; helo=mail-lf0-x238.google.com; envelope-from=swupdate+bncbdf5n4x5qufbbtf433kqkgqe6qe3q4i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=streamunlimited.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="KXe2zaaH"; dkim-atps=neutral Received: from mail-lf0-x238.google.com (mail-lf0-x238.google.com [IPv6:2a00:1450:4010:c07::238]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 408HXx43Cpz9s08 for ; Mon, 26 Mar 2018 00:04:16 +1100 (AEDT) Received: by mail-lf0-x238.google.com with SMTP id u18-v6sf2551848lfc.5 for ; Sun, 25 Mar 2018 06:04:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1521983053; cv=pass; d=google.com; s=arc-20160816; b=Vd3SkD1evzM20BCRKhwVsb7zr0d9AYfvLZka5+hNpDlWbl5SJF84RrITv9wS1SN73v TftjsXWooCvRfgPtYHOsWo2FLVjr4FaCn0HD8cp9ejMn0X8YdDrPB1qbb2Iphvfkua5X wxMdMg8X/p4oindoCiOidBo2EbMMfZVVRzWjMG0rIC0ASAKZTOkS3wl6dQF4krMVaKVf b+4fZAYmrzb+kspHKEKqoDRIDAFFOx4fR0aZ9beq7gMYhbDLzBnU5Uyy4qEBDR7waMFF tCr3/+nbqFqmGVq6ZxYzDaAgQJRV3R2xLotCn9oX4BnRfBC9Dv97/43BfVMlYW4pHeVr yIPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:content-language:mime-version :user-agent:date:message-id:subject:from:to :arc-authentication-results:arc-message-signature:sender :dkim-signature:arc-authentication-results; bh=U3VXfogHSgndbkpCkwqYB3NvmHMUDkcEvAQwD4kfAt4=; b=akty16wosW/6nG/AS/AvHKnCqVGWDBPTMOSOTa3rLjja77oq9zQxRXotaF7q7ybRoL S/aEuevzhxl/BQgo/GYFlyPQ0WPrf5N+JIECYem2NjGH0JdA2rkJsKq0uaVXZEAOuQzW aH5lQtt4BpNf4HorU+TwsMqdkcm3/rFBbSIyvQjLUnCZ5yBLTACT1r268YLbEewW5sM9 ZJl2zKMp7I9Pc3RIq1ysjl3mWWTdaP0j+3FFn/uZp88pLHEnJhpU2GiNw7Dfgtn0Qlz3 eBdSKh5iZSgh/2oD74HJ444BrOFE4HYfx5Z7mVa+MWfgUSUdmVYEgWctqCBMyw1saoL0 voYg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 213.33.87.17 is neither permitted nor denied by best guess record for domain of martin.geier@streamunlimited.com) smtp.mailfrom=martin.geier@streamunlimited.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=U3VXfogHSgndbkpCkwqYB3NvmHMUDkcEvAQwD4kfAt4=; b=KXe2zaaHccOFb+nsKjCzqS5u7tSc+QQvzrcs2QpXwgIqdtwk3dRy8/QYzbJW5dfdDy IaNrDdrSZp3LphlUJpoHJk58Y2mgQKNcR8Rl6glEZTrSOwtRvuV6IAGG2hIWQw25M+/j fnqdlWl11Zvjv6LcvN2nKBRQOlphiA3of/IDNW3l/ac54qUpEXONdlo2thnwuU2tpY9o vbySJA4OAZfz6VE6o4igaRYSYKnd91rLqJOancLAjwSGUSrg9V/22MVzeJWWjv0/sNWx LY08GUZeaXF9a1EBDX3l4Qml08wNV8XoAV+mqVom8/9UQwnTK7QsRdOB8EB9jVdlYHAx /5OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:to:from:subject:message-id:date :user-agent:mime-version:content-language:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=U3VXfogHSgndbkpCkwqYB3NvmHMUDkcEvAQwD4kfAt4=; b=EBDfwpFmknT3qRVA2f54WYpQpXPBn8JlkW2jt8dx1zRGLcxNk5wBBU5eM7ssmrhtT8 ph5PfP3Jt9hlKsnnX6DvIMdeqYjAw/h64Ln2DvFOH9dU3nCanAub+E+m+e1GDREyn8P+ hUw1TKnlu09dtOgL6fIZgUu/LwxPy0d0Ql9HBYBz6JLmF+t+oChgPeOiaWLC3NIW1qG1 Y1QUa3cm2Gw/T3lz7KMKpRloGxBDx8L7qWyk8+kk1ni64HBEHZIv/m9y1injLpMp9ohc H6878J4qv+MsFXDx26qPHlNT/E67B7LydHTjZ0/Ib8nDI+lWfpmgr4U/wif7aQ4kiGf0 pAiA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AElRT7HNq30N6C16qIgYAEYplR9VSs1V8svOS+49q6uijLhFBSQCIqYG /GpaImD39eXlVL4/8CtsuTU= X-Google-Smtp-Source: AG47ELvYgKd/ek7UY2B9NptqPOHIqC4BVgznDd0OlC3qEHbV2FRzJDMUGM/eFzBGnSMuSUPFgRR8sg== X-Received: by 2002:a19:d286:: with SMTP id j128-v6mr106377lfg.1.1521983053302; Sun, 25 Mar 2018 06:04:13 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:c10d:: with SMTP id r13-v6ls560391lff.12.gmail; Sun, 25 Mar 2018 06:04:12 -0700 (PDT) X-Received: by 2002:a19:cd90:: with SMTP id d138-v6mr1426723lfg.25.1521983052330; Sun, 25 Mar 2018 06:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521983052; cv=none; d=google.com; s=arc-20160816; b=b6H2ED1io1oxB3SoPFtOER3JfByODlpHLLCF35wFkMf/ww2WpQ97BFx9OtVG2d2ZIk BRomwos1ANwuUbPQxVTUcEkwOpO9S4yQ/tbtT19JgwX7B0IK3t79zL0eWJ9QuYFTQ4MG 5kZqTjsGn4AjiLl4XTrIpOAxTKajQy4hpeFAgFRWoVuXgD7ObVJcT/VgWSvKpqmkz9Wu 1qonNE4K0bJNB2L7PwdLy7pLttMnj72ZmxY90ERouEybuygpPOAr/+qinZOLtFiLFwpL lAXXsvMVpgGkbmcHqtWnlzfGVFmLPZgl9AW9W1mMTaKCneeF4lDavYhUNKqSjeqr8vLI 3PUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-language:content-transfer-encoding:mime-version:user-agent :date:message-id:subject:from:to:arc-authentication-results; bh=XumiFM7i8fnfQDdUquTJQZkA8mhRTaTigCau66UXoO0=; b=tsYjZMuM3uRF6Q54io+WTZwhBl+SHxtbMdjN5d0LRcO4IWBpJ8IHhEefAepDKMJmeC zkPdK5db7BZNzQunBEAD5aIrLV3crAdpJN45Oo+GZ+X4RF+1VTZymrIEYvC17Ntjwmvv w/BDrZ0JX08AAALGCYDAypFYc+SXDoY+0wx5ukS2OhW9GsmfMsZgsin3K3kFcQJO7JRa wCF3OADpYIP6QL8trKGQEDfPA3AW6br2gZn9/x+IWkkU/hvnJEUyAlDLgdJRVy3m0lph viFrdDZ5Gy/4u0YXfylt3ptG13txP1ZviKM9hnkkh2OyYJ9HArGzPbxq8h8kOd54uRx9 czfA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 213.33.87.17 is neither permitted nor denied by best guess record for domain of martin.geier@streamunlimited.com) smtp.mailfrom=martin.geier@streamunlimited.com Received: from bsmtp3.bon.at (bsmtp3.bon.at. [213.33.87.17]) by gmr-mx.google.com with ESMTPS id m18-v6si485063lfj.0.2018.03.25.06.04.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Mar 2018 06:04:12 -0700 (PDT) Received-SPF: neutral (google.com: 213.33.87.17 is neither permitted nor denied by best guess record for domain of martin.geier@streamunlimited.com) client-ip=213.33.87.17; Received: from [192.168.3.6] (bband-dyn46.95-103-209.t-com.sk [95.103.209.46]) by bsmtp3.bon.at (Postfix) with ESMTPSA id 408HXq2Jkyz5tlB for ; Sun, 25 Mar 2018 15:04:11 +0200 (CEST) To: swupdate@googlegroups.com From: Martin Geier Subject: [swupdate] [V2] corelib: print both error code and reason string for decrypt functions Message-ID: <84e18739-deee-1501-81a0-b7150270ae14@streamunlimited.com> Date: Sun, 25 Mar 2018 15:04:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Language: en-US X-Original-Sender: martin.geier@streamunlimited.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 213.33.87.17 is neither permitted nor denied by best guess record for domain of martin.geier@streamunlimited.com) smtp.mailfrom=martin.geier@streamunlimited.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , From 05f0b52dbdb4973b51e0fd2694f7e966b7f7f6a3 Mon Sep 17 00:00:00 2001 From: Martin Geier Date: Sun, 25 Mar 2018 15:00:22 +0200 Subject: [V2] corelib: print both error code and reason string for decrypt functions To register reason strings for error codes ERR_load_crypto_strings has to be called for openssl version < 1.1.0 Signed-off-by: Martin Geier --- corelib/swupdate_decrypt.c | 13 +++++++++---- include/sslapi.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/corelib/swupdate_decrypt.c b/corelib/swupdate_decrypt.c index 3238cce..1360aec 100644 --- a/corelib/swupdate_decrypt.c +++ b/corelib/swupdate_decrypt.c @@ -70,7 +70,9 @@ struct swupdate_digest *swupdate_DECRYPT_init(unsigned char *key, unsigned char */ ret = EVP_DecryptInit_ex(SSL_GET_CTXDEC(dgst), cipher, NULL, key, iv); if (ret != 1) { - ERROR("Decrypt Engine not initialized, error 0x%lx\n", ERR_get_error()); + const char *reason = ERR_reason_error_string(ERR_peek_error()); + ERROR("Decrypt Engine not initialized, error 0x%lx, reason: %s\n", ERR_get_error(), + reason != NULL ? reason : "unknown"); free(dgst); return NULL; } @@ -82,7 +84,9 @@ int swupdate_DECRYPT_update(struct swupdate_digest *dgst, unsigned char *buf, int *outlen, unsigned char *cryptbuf, int inlen) { if (EVP_DecryptUpdate(SSL_GET_CTXDEC(dgst), buf, outlen, cryptbuf, inlen) != 1) { - ERROR("Update: Decryption error 0x%lx\n", ERR_get_error()); + const char *reason = ERR_reason_error_string(ERR_peek_error()); + ERROR("Update: Decryption error 0x%lx, reason: %s\n", ERR_get_error(), + reason != NULL ? reason : "unknown"); return -EFAULT; } @@ -96,8 +100,9 @@ int swupdate_DECRYPT_final(struct swupdate_digest *dgst, unsigned char *buf, return -EINVAL; if (EVP_DecryptFinal_ex(SSL_GET_CTXDEC(dgst), buf, outlen) != 1) { - ERROR("Decryption error 0x%s\n", - ERR_reason_error_string(ERR_get_error())); + const char *reason = ERR_reason_error_string(ERR_peek_error()); + ERROR("Final: Decryption error 0x%lx, reason: %s\n", ERR_get_error(), + reason != NULL ? reason : "unknown"); return -EFAULT; } diff --git a/include/sslapi.h b/include/sslapi.h index 213478e..1d24dfb 100644 --- a/include/sslapi.h +++ b/include/sslapi.h @@ -63,6 +63,7 @@ struct swupdate_digest { do { \ CRYPTO_malloc_init(); \ OpenSSL_add_all_algorithms(); \ + ERR_load_crypto_strings(); \ } while (0); \ } #else