From owner-svn-soc-all@FreeBSD.ORG Mon May 4 17:38:40 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DE34E973 for ; Mon, 4 May 2015 17:38:39 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BF62A1C8E for ; Mon, 4 May 2015 17:38:39 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t44HcdfA071792 for ; Mon, 4 May 2015 17:38:39 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t44Hcd9L071789 for svn-soc-all@FreeBSD.org; Mon, 4 May 2015 17:38:39 GMT (envelope-from def@FreeBSD.org) Date: Mon, 4 May 2015 17:38:39 GMT Message-Id: <201505041738.t44Hcd9L071789@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r284998 - soc2013/def/crashdump-head/sbin/cryptcore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2015 17:38:40 -0000 Author: def Date: Mon May 4 17:38:38 2015 New Revision: 284998 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=284998 Log: EVP_DecryptUpdate(3), PEM_read_RSA_PUBKEY(3), PEM_read_RSAPrivateKey(3), RSA_new(3), RSA_private_decrypt(3) and RSA_public_encrypt(3) don't set errno. Modified: soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c Modified: soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c Mon May 4 17:19:42 2015 (r284997) +++ soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c Mon May 4 17:38:38 2015 (r284998) @@ -34,24 +34,21 @@ uint8_t ciphertext[KERNELDUMP_CIPHERTEXT_SIZE]; FILE *fp; RSA *pubkey; - int err, pubkeysize; + int pubkeysize; PJDLOG_ASSERT(pubkeyfile != NULL); pubkey = RSA_new(); if (pubkey == NULL) - pjdlog_exit(1, "Unable to allocate an RSA structure"); + pjdlog_exitx(1, "Unable to allocate an RSA structure."); fp = fopen(pubkeyfile, "r"); if (fp == NULL) pjdlog_exit(1, "Unable to open %s", pubkeyfile); pubkey = PEM_read_RSA_PUBKEY(fp, &pubkey, NULL, NULL); - err = errno; fclose(fp); - if (pubkey == NULL) { - errno = err; - pjdlog_exit(1, "Unable to read data from %s", pubkeyfile); - } + if (pubkey == NULL) + pjdlog_exitx(1, "Unable to read data from %s.", pubkeyfile); pubkeysize = RSA_size(pubkey); if (RSA_size(pubkey) > 8 * KERNELDUMP_CIPHERTEXT_SIZE) { pjdlog_exitx(1, "The maximum RSA modulus size is %db.", @@ -61,7 +58,7 @@ arc4random_buf(buf, sizeof(buf)); if (RSA_public_encrypt(KERNELDUMP_KEY_SIZE + KERNELDUMP_IV_SIZE, buf, ciphertext, pubkey, RSA_PKCS1_PADDING) != pubkeysize) { - pjdlog_exit(1, "Unable to encrypt the one-time key"); + pjdlog_exitx(1, "Unable to encrypt the one-time key."); } /* @@ -112,7 +109,7 @@ privkey = RSA_new(); if (privkey == NULL) - pjdlog_exit(1, "Unable to allocate an RSA structure"); + pjdlog_exitx(1, "Unable to allocate an RSA structure."); EVP_CIPHER_CTX_init(&ctx); fd = open(keyfile, O_RDONLY); @@ -130,12 +127,9 @@ if (fp == NULL) pjdlog_exit(1, "Unable to open %s", privkeyfile); privkey = PEM_read_RSAPrivateKey(fp, &privkey, NULL, NULL); - err = errno; fclose(fp); - if (privkey == NULL) { - errno = err; - pjdlog_exit(1, "Unable to read data from %s", privkeyfile); - } + if (privkey == NULL) + pjdlog_exitx(1, "Unable to read data from %s.", privkeyfile); /* * From this moment on keys have to be erased before exit. */ @@ -149,7 +143,7 @@ if (RSA_private_decrypt(KERNELDUMP_CIPHERTEXT_SIZE, ciphertext, buf, privkey, RSA_PKCS1_PADDING) != KERNELDUMP_KEY_SIZE + KERNELDUMP_IV_SIZE) { - pjdlog_errno(LOG_ERR, "Unable to decrypt key and IV"); + pjdlog_error("Unable to decrypt key and IV."); goto failed; } @@ -178,7 +172,7 @@ if (EVP_DecryptUpdate(&ctx, buf, &size, buf, KERNELDUMP_BUFFER_SIZE) == 0) { - pjdlog_errno(LOG_ERR, "Unable to decrypt core."); + pjdlog_error("Unable to decrypt core."); goto failed; } PJDLOG_ASSERT(size == KERNELDUMP_BUFFER_SIZE);