socsvn commit: r284998 - soc2013/def/crashdump-head/sbin/cryptcore
def at FreeBSD.org
def at FreeBSD.org
Mon May 4 17:38:40 UTC 2015
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);
More information about the svn-soc-all
mailing list