Permalink
Browse files

Replacing custom hmac_sha1 implementation with standard CommonCrypto …

…code.
  • Loading branch information...
roustem authored and Juan Pablo Ortiz Aréchiga committed Apr 20, 2010
1 parent 4b97c8f commit e1c7918d57ace900a7a3cbf85672a2a75464f7f7
Showing with 10 additions and 4 deletions.
  1. +10 −4 OAHMAC_SHA1SignatureProvider.m
@@ -26,9 +26,12 @@
#import "OAHMAC_SHA1SignatureProvider.h"
-#include "hmac.h"
+// #include "hmac.h"
#include "Base64Transcoder.h"
+#import <CommonCrypto/CommonDigest.h>
+#import <CommonCrypto/CommonHMAC.h>
+
@implementation OAHMAC_SHA1SignatureProvider
- (NSString *)name {
@@ -38,9 +41,12 @@ - (NSString *)name {
- (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret {
NSData *secretData = [secret dataUsingEncoding:NSUTF8StringEncoding];
NSData *clearTextData = [text dataUsingEncoding:NSUTF8StringEncoding];
- unsigned char result[20];
- hmac_sha1((unsigned char *)[clearTextData bytes], [clearTextData length], (unsigned char *)[secretData bytes], [secretData length], result);
-
+ unsigned char result[CC_SHA1_DIGEST_LENGTH];
+
+// hmac_sha1((unsigned char *)[clearTextData bytes], [clearTextData length], (unsigned char *)[secretData bytes], [secretData length], result);
+
+ CCHmac(kCCHmacAlgSHA1, (const void *)[secretData bytes], [secretData length], (const void *)[clearTextData bytes], [clearTextData length], result);
+
//Base64 Encoding
char base64Result[32];

0 comments on commit e1c7918

Please sign in to comment.