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
commit3a2bbdb05ca6a6996e424c9fb225cb0d53804125 (patch)
treef29063da5bec4caf3853d49a22a09c8619eebd21 /contrib/keychain-mcd/crypto_osx.c
parentd53dba59e78da865c4fe820386ff2f4f76925f3b (diff)
New upstream version 2.4.0upstream/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;
}
}