commoncrypto

aes 128 message decryption — Swift, iOS

℡╲_俬逩灬. 提交于 2019-12-02 18:19:09
问题 I'm trying to decrypt message with 128 key with following code. This is an extension for String: func aesDecrypt(key:String, iv:String, options:Int = kCCOptionPKCS7Padding) -> String? { if let keyData = key.dataUsingEncoding(NSUTF8StringEncoding), data = NSData(base64EncodedString: self, options: .IgnoreUnknownCharacters), cryptData = NSMutableData(length: Int((data.length)) + kCCBlockSizeAES128) { let keyLength = size_t(kCCKeySizeAES128) let operation: CCOperation = UInt32(kCCDecrypt) let

Support of AES 256 with GCM not possible in iOS? [duplicate]

ε祈祈猫儿з 提交于 2019-12-02 10:38:51
This question already has an answer here: Is it possible to use AES128 with GCM mode on iOS? 3 answers Currently the encryption mode supported with AES 256 is CBC . But I want to use AES 256 encryption with GCM mode along with PKCS5Padding / PKCS7Padding . Do let me know how it can be done ? zaph Common Crypto does not support GCM. But there is an implementation of AES GCM in the Security.framework, and you can add your own header file to use it. However associated data (AEAD) does not work. From SO Answer by soyer: CCCryptorStatus CCCryptorGCM( CCOperation op, // kCCEncrypt, kCCDecrypt

lib commonCrypto not available for iOS simulator?

心不动则不痛 提交于 2019-12-01 16:02:59
I've been adding libCommonCrypto.dylib to my project to do md5 hash verification. Works all proper on the iPhone (iOS 5.1), but when I try to run it on the simulator, I get this error: ld: library not found for -lcommonCrypto clang: error: linker command failed with exit code 1 (use -v to see invocation) I'm a bit clueless why this happens. I added the commonCrypto to the project target -> build phase -> link binary with libraries. Is there any additional step required to get it working also in the simulator? You don't have to add that dynamic library. It is available by default in iphoneOS >>

How can I use a PKCS8 RSA DER Private Key in iOS?

家住魔仙堡 提交于 2019-12-01 09:29:03
At run time, my iOS application receives a file with a public-private RSA key-pair, generated by someone else's Java: KeyPairGenerator keygenerator; keygenerator = KeyPairGenerator.getInstance("RSA"); keygenerator.initialize(4096); KeyPair keypair = keygenerator.generateKeyPair(); PrivateKey privateKey = keypair.getPrivate().getEncoded(); PublicKey publicKey = keypair.getPublic().getEncoded(); I have successfully read and used the public key, using this method , which strips some preamble from the key. I now want to use the private key. The same method doesn't work, I assumed the preamble is

cURL error 58: SSL: Can't load the certificate “…” and its private key: OSStatus -25299 on Mac

别等时光非礼了梦想. 提交于 2019-11-30 18:59:31
问题 The code is working fine on Ubuntu vagrant box, but on local MacOs it does not load sertificates saying cURL error 58: SSL: Can't load the certificate "..." and its private key: OSStatus -25299 I researched that Mac has a point of supporting the OS X native API instead of OpenSSL. And I need to convert a pem + cert to pkcs12 like that. openssl pkcs12 -export -in ./client.crt -inkey ./client.pem -out client.p12 But this is not working for me because my PHP server is on Ubuntu and I don't want

Signing and Verifying on iOS using RSA

☆樱花仙子☆ 提交于 2019-11-29 20:29:47
How to sign and verify some data on iOS with an RSA key (preferably using the system own libcommonCrypto )? Since there hasn't been nearly any knowledge about signing and verifying found on StackOverflow and the Apple docs, I had to manually browse around in the iOS header files and found SecKeyRawSign and SecKeyRawVerify . The following lines of code seem to work. Signing NSData (using SHA256 with RSA): NSData* PKCSSignBytesSHA256withRSA(NSData* plainData, SecKeyRef privateKey) { size_t signedHashBytesSize = SecKeyGetBlockSize(privateKey); uint8_t* signedHashBytes = malloc(signedHashBytesSize

Using CommonCrypto with an IV but always returning nil

为君一笑 提交于 2019-11-29 18:16:13
I am using the CommonCrypto CCCryptorCreate to decrypt a message. I am using a password and an IV but it always returns nil. If I use the CCCryptorCreate to decrypt, but don't use an IV on during encryption on the RUBY side and don't use the IV on the obj-c decrypt side then decryption works perfectly and I can see the message. But if I use an IV on the RUBY and IV on the obj-c side decryption ends with a nil message object. I am using this Encrypt in Objective-C / Decrypt in Ruby using anything OBJ-C method: - (NSData *) decryptedDataUsingAlgorithm: (CCAlgorithm) algorithm key: (id) key //

MD5 3DES encryption Swift

坚强是说给别人听的谎言 提交于 2019-11-29 12:07:01
I have an app that must send login credentials that have been encrypted first by MD5 and then by 3DES. I have managed to use CryptoSwift to encrypt the string by MD5. However I cannot find anything to encrypt by 3DES on Swift. I have tried CommonCrypto. As far as I can tell this is in C but could be imported into Objective C with a bridging header. I have found a few articles and tutorials that tell me how to import CommonCrypto into Swift, either by a bridging header(with the warning it will not work with frameworks) or by Model.map. However neither are working. Im not sure if this is a

Where can I get CommonCrypto / CommonCrypto file from?

北战南征 提交于 2019-11-29 11:40:27
I have a problem with importing CommonCrypto/CommonCrypto or CommonCrypto/CommonDigest . I need a SHA256 for my Swift code. I found CommonCrypto github site in Cocoapods. https://github.com/AlanQuatermain/aqtoolkit So I have downloaded the file from above. But I'm getting errors about ARC (I have added Bridging-Header like other tutorials do.) The header file's name is NSData+CommonCrypto.h and NSData+CommonCrypto.m . It's not a CommonCrypto/CommonCrypto or CommonCrypto/CommonDigest Where can I download and get the exact file CommonCrypto for SHA256? No additional files are required. You need

Swift Calculate MD5 Checksum for Large Files

帅比萌擦擦* 提交于 2019-11-29 02:17:22
I'm working on creating the MD5 Checksum for large video files. I'm currently using the code: extension NSData { func MD5() -> NSString { let digestLength = Int(CC_MD5_DIGEST_LENGTH) let md5Buffer = UnsafeMutablePointer<CUnsignedChar>.allocate(capacity: digestLength) CC_MD5(bytes, CC_LONG(length), md5Buffer) let output = NSMutableString(capacity: Int(CC_MD5_DIGEST_LENGTH * 2)) for i in 0..<digestLength { output.appendFormat("%02x", md5Buffer[i]) } return NSString(format: output) } } But that creates a memory buffer, and for large video files would not be ideal. Is there a way in Swift to