summaryrefslogtreecommitdiff
path: root/contrib/keychain-mcd/crypto_osx.c
diff options
context:
space:
mode:
authorAlberto Gonzalez Iniesta <agi@inittab.org>2016-12-27 18:25:47 +0100
committerAlberto Gonzalez Iniesta <agi@inittab.org>2016-12-27 18:25:47 +0100
commit79f3537f69e125f19f59c36aa090120a63186a54 (patch)
tree2089a3b7dac990841dbc2e4d9b2f535b82dbb0af /contrib/keychain-mcd/crypto_osx.c
parentf2137fedb30cb87448eb03b2f288920df6187571 (diff)
parent3a2bbdb05ca6a6996e424c9fb225cb0d53804125 (diff)
Merge tag 'upstream/2.4.0'
Upstream version 2.4.0
Diffstat (limited to 'contrib/keychain-mcd/crypto_osx.c')
-rw-r--r--contrib/keychain-mcd/crypto_osx.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/contrib/keychain-mcd/crypto_osx.c b/contrib/keychain-mcd/crypto_osx.c
index 87ba09b..092e64f 100644
--- a/contrib/keychain-mcd/crypto_osx.c
+++ b/contrib/keychain-mcd/crypto_osx.c
@@ -31,45 +31,50 @@
#include "crypto_osx.h"
#include <err.h>
-void printErrorMsg(const char *func, CFErrorRef error)
+void
+printErrorMsg(const char *func, CFErrorRef error)
{
- CFStringRef desc = CFErrorCopyDescription(error);
- warnx("%s failed: %s", func, CFStringGetCStringPtr(desc, kCFStringEncodingUTF8));
- CFRelease(desc);
+ CFStringRef desc = CFErrorCopyDescription(error);
+ warnx("%s failed: %s", func, CFStringGetCStringPtr(desc, kCFStringEncodingUTF8));
+ CFRelease(desc);
}
-void printErrorStatusMsg(const char *func, OSStatus status)
+void
+printErrorStatusMsg(const char *func, OSStatus status)
{
- CFStringRef error;
- error = SecCopyErrorMessageString(status, NULL);
- if (error)
+ CFStringRef error;
+ error = SecCopyErrorMessageString(status, NULL);
+ if (error)
{
- warnx("%s failed: %s", func, CFStringGetCStringPtr(error, kCFStringEncodingUTF8));
- CFRelease(error);
+ warnx("%s failed: %s", func, CFStringGetCStringPtr(error, kCFStringEncodingUTF8));
+ CFRelease(error);
+ }
+ else
+ {
+ warnx("%s failed: %X", func, (int)status);
}
- else
- warnx("%s failed: %X", func, (int)status);
}
-void signData(SecIdentityRef identity, const uint8_t *from, int flen, uint8_t *to, size_t *tlen)
+void
+signData(SecIdentityRef identity, const uint8_t *from, int flen, uint8_t *to, size_t *tlen)
{
- SecKeyRef privateKey = NULL;
- OSStatus status;
+ SecKeyRef privateKey = NULL;
+ OSStatus status;
- status = SecIdentityCopyPrivateKey(identity, &privateKey);
- if (status != noErr)
+ status = SecIdentityCopyPrivateKey(identity, &privateKey);
+ if (status != noErr)
{
- printErrorStatusMsg("signData: SecIdentityCopyPrivateKey", status);
- *tlen = 0;
- return;
+ printErrorStatusMsg("signData: SecIdentityCopyPrivateKey", status);
+ *tlen = 0;
+ return;
}
- status = SecKeyRawSign(privateKey, kSecPaddingPKCS1, from, flen, to, tlen);
- CFRelease(privateKey);
- if (status != noErr)
+ status = SecKeyRawSign(privateKey, kSecPaddingPKCS1, from, flen, to, tlen);
+ CFRelease(privateKey);
+ if (status != noErr)
{
- printErrorStatusMsg("signData: SecKeyRawSign", status);
- *tlen = 0;
- return;
+ printErrorStatusMsg("signData: SecKeyRawSign", status);
+ *tlen = 0;
+ return;
}
}