commoncrypto

Determine if key is incorrect with CCCrypt kCCOptionPKCS7Padding-Objective C

一世执手 提交于 2019-12-13 08:56:55
问题 I am working on incorporating encryption for data stored in my application. I have gotten pretty far in that I am encrypting and decrypting data, my problem is that I cannot seem to force an obvious decryption error when the wrong key is used. My decrypt function: + (NSData *)decryptedDataForData:(NSData *)data password:(NSString *)password iv:(NSData *)iv salt:(NSData *)salt error:(NSError **)error { NSAssert(iv, @"IV must not be NULL"); NSAssert(salt, @"salt must not be NULL"); NSData *key

Why does my initWithData return nil indicating an error after converting NSData to NSString returning from encrypting via CommonCrypto?

霸气de小男生 提交于 2019-12-12 23:19:35
问题 Here is my code: -(IBAction)encryptText:(id)sender { key = self.tvKey.text; CCCryptorStatus status = kCCSuccess; algorithm = kCCAlgorithmAES128; CCOptions opts = kCCOptionPKCS7Padding; NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding]; NSString *plainString = [NSString stringWithFormat:@"%@", self.tvEntryText.text]; NSData *plainData = [plainString dataUsingEncoding:NSUTF8StringEncoding]; NSData *encryptedData = [plainData dataEncryptedUsingAlgorithm: algorithm key: keyData

Does the usage of CCCryptor warrant French import declaration certificate?

自闭症网瘾萝莉.ら 提交于 2019-12-11 23:33:04
问题 Would like to get some help from people who implemented encryption in their apps and already passed it to app store. Our app uses https/SSL and AES256 encryption provided by CCCryptor along with keychain . According to this message regarding encryption: Apps that meet the following criteria are required to comply with French Encryption Laws/Regulations if you intend to distribute your app in France. This requirement applies to apps that use, access, implement, or incorporate: (a) any

objective c aes 128 encryption for a c# web service

情到浓时终转凉″ 提交于 2019-12-11 10:15:37
问题 So I'm trying to figure out how to make an objective c version of this as it's part of a wcf service security that was implemented. My main issue here is Idk where to begin as some articles/tutorials would automatically pad 0 in the beginning (not sure if that's their IV) like so: (a couple of replies down) http://iphonedevsdk.com/forum/iphone-sdk-development/60926-aesencryption-in-objective-c-and-php.html compared to this which doesn't use any padding: Objective-C decrypt AES 128 cbc hex

How is CommonCrypto used in SWIFT3?

二次信任 提交于 2019-12-10 14:54:32
问题 The guidance is to to use #import "CommonCrypto/CommonCrypto.h" in the bridging header. This is from the question at: SHA256 in swift. However, when I use the answers given by Andi and Graham Xcode still complains about "use of unresolved identifier CC_SHA256_DIGEST_LENGTH..." I am thinking I've made one of two mistakes: Either (a) I am missing something in not having wired up the header and import correctly. i.e. I did not setup the bridging header correctly. I'd love clear steps on how to

Data signed on iOS can't be verified in Java

懵懂的女人 提交于 2019-12-10 02:48:48
问题 I have some data that I'm signing on iOS with SecKeyRawSign using Elliptic Curve private key. However, verifying that data in Java using Signature.verify() returns false The data is a random 64 bit integer, split into bytes like so uint64_t nonce = (some 64 bit integer) NSData *nonceData = [NSData dataWithBytes: &nonce length: sizeof(nonce)]; From that data I'm creating a SHA256 digest int digestLength = CC_SHA256_DIGEST_LENGTH; uint8_t *digest = malloc(digestLength); CC_SHA256(nonceData

Xcode 7.3 beta 1 vs. CommonCrypto in Swift

痞子三分冷 提交于 2019-12-08 17:14:36
问题 I'm using CommonCrypto in a Swift framework - and it's been working fine for over a year. I used solutions found here: Importing CommonCrypto in a Swift framework Specifically, to reference CommonCrypto from the Swift framework, I had to: Create a module.map file in a folder named CommonCrypto next to my framework's Xcode project. module.map contents: module CommonCrypto [system] { header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs

Decrypting DES with CommonCrypto in Swift 3

帅比萌擦擦* 提交于 2019-12-08 04:50:09
问题 I want to decrypt a DES encrypted String with CommonCrypto. I already imported CommonCrypto with a Bridging Header into my Project. By try and error I managed to call CCCrypt function and it even returns kCCSuccess. But after that my result is still empty. Here is my code: if let key = "12345678".data(using: .utf8), let data = "inMyOriginalCodeYouWouldSeeADESEncryptedStringHere/ahw==".data(using: .utf8) { var numBytesDecrypted: size_t = 0 var result = Data(capacity: data.count) let err =

AES128 truncated decrypted text on iOS 7, no problems on iOS 8

孤街醉人 提交于 2019-12-07 23:15:49
问题 Using ciphertext encrypted with AES128 using ECB mode (this is toy encryption) and PKCS7 padding, the following code block results in the complete plaintext being recovered under iOS 8. Running the same code block under iOS 7 results in the correct plaintext, but truncated. Why is this? #import "NSData+AESCrypt.h" // <-- a category with the below function #import <CommonCrypto/CommonCryptor.h> - (NSData *)AES128Operation:(CCOperation)operation key:(NSString *)key iv:(NSString *)iv { char

Is there a way to use Common Crypto in a Swift playground?

孤街醉人 提交于 2019-12-07 18:16:17
问题 I am toying with a REST API in an Xcode playground and I need to hash something with SHA1. All the solutions I have found depend on Common Crypto, and that doesn’t seem to be directly available in a Swift playground. Is there a way to SHA1 something in a Swift playground? 回答1: A quick and dirty solution: func SHA1HashString(string: String) -> String { let task = NSTask() task.launchPath = "/usr/bin/shasum" task.arguments = [] let inputPipe = NSPipe() inputPipe.fileHandleForWriting.writeData