Apple's cryptography framework. Contains functions for generating commonly-used hashes and cryptographic functions.
Questions tagged [commoncrypto]
209 questions
4
votes
2 answers
Interoperability of AES CTR mode?
I use AES128 crypto in CTR mode for encryption, implemented for different clients (Android/Java and iOS/ObjC). The 16 byte IV used when encrypting a packet is formated like this:
<11 byte nonce> | <4 byte packet counter> | 0
The packet counter…

Markus R
- 73
- 1
- 8
4
votes
1 answer
AES-256 encryption on iOS not producing same result as openssl
I have been looking and looking at this for hours. I am desperately trying to get iOS to encrypt a short piece of text using AES-256 encryption that can then be decrypted by openssl.
Straight forward? Nope.
The code I've found for iOS is not…

padajo
- 65
- 2
- 8
3
votes
1 answer
kSecRandomDefault not found?
I am using CommonCrypto for encryption on Mac OS 10.7. Isn't this framework built in? When I am generating random data:
+ (NSData *)randomDataOfLength:(size_t)length {
NSMutableData *data = [NSMutableData dataWithLength:length];
int result =…
user762034
3
votes
1 answer
PyCrypto compatibility with CommonCrypto in CFB mode?
I'm trying to get somepython code to decrypt data that was encrypted using the OS X CommonCrypto APIs. There is little to no documentation on the exact options that CommonCrypto uses, so I'm needing some help figuring out what options to set in…

Loki
- 6,205
- 4
- 24
- 36
3
votes
2 answers
Anyone else having trouble with iOS 5 encryption?
Have a (rather complex) app that works fine on iOS 4 but fails on iOS 5 with a decryption problem. It's decrypting a SQLite DB page, and the last 16 bytes do not appear to be properly decrypted.
Does this ring a bell with anyone?
Update
I've…

Hot Licks
- 47,103
- 17
- 93
- 151
3
votes
1 answer
Does CommonCrypto reliably know when my key is invalid when I decrypt a ciphertext?
When I try to decrypt a cipher text using the wrong key, CCCrypt returns kCCDecodeError.
Question is, does it do so reliably (eg. am I guaranteed that if it returns success, my input key was the key used to encrypt the plain text, and am I also…

lhunath
- 120,288
- 16
- 68
- 77
3
votes
1 answer
Swift 5 + kCCDecrypt (CommonCrypto): Failing to decrypt
Trying to write my own encrypt/decrypt functions in Swift 5, based on tons of other similar questions -- and failing miserably.
I'm using CommonCrypto + CCCrypt to encrypt/decrypt (AES, 256 key, random iv).
I'm favouring NSData.bytes over…

backslash-f
- 7,923
- 7
- 52
- 80
3
votes
1 answer
Getting error "Include of non-modular header inside framework module"
I have a private pod written on top of CommonCrypto which explicitly relies on CommonCrypto. Headers have types declared by CommonCrypto like:
#include
typedef CC_SHA256_CTX qwer_digest_evp;
Since CC_SHA256_CTX is…

Ayush Goel
- 3,134
- 27
- 36
3
votes
2 answers
AES128 CTR encryption with iv
I want to implement AES128 CTR with iv and key. I'm looking for any advice how to do that in best way and not reinvent wheel.
I found good lib for this RNCryptor, but looks like this aes is not supported there.
Also I test this approach, but looks…

hbk
- 10,908
- 11
- 91
- 124
3
votes
1 answer
CommonCrypto XCode 9.0 unable to create key from data
The following code fails with OSStatus -50 (secParam) both in my manual code and in other libraries (SwiftyRSA, Heimdall) on XCode 9.0, ios 10+. Any ideas as to why or any way to obtain more info?
let keyDict: [CFString: Any] = [
…

RedPoppy
- 573
- 4
- 11
3
votes
1 answer
Swift 3 import CommonCrypto
How to import the Obj-C CommonCrypto library to an existing Swift Xcode Project (Swift 3, Xcode 8.3.3)?
I tried to create my own Objective-C bridging file and it wasn't working.

Alec
- 666
- 8
- 23
3
votes
1 answer
Swift AES encryption using CommonCrypto
I am working on an iOS app on XCode 7.1 with Swift 2.1 and I am trying to do simple encryption with AES 128 bit and PKCS7 padding using CommonCrypto library.
The code works but every time I try to cast the NSData object to NSString then to String I…

Waxren
- 2,002
- 4
- 30
- 43
3
votes
2 answers
implementing AES256 encryption into IOS
This is my java code. Now I want to implement same functionality in Objective-C.
Cipher encryptCipher;
IvParameterSpec iv = new IvParameterSpec(key);
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
encryptCipher =…

Askarc Ali
- 318
- 4
- 21
3
votes
2 answers
iOS Core Data encryption using NSValueTransformer
I'm experimenting with encrypting data with Core Data and CommonCrypto. I am trying to use a NSValueTransformer to lazily encrypt and decrypt.
However when I'm now trying save the encrypted data to the persistent store coordinator, it fails. Every…

Orion
- 1,258
- 2
- 14
- 32
3
votes
3 answers
Is there a way to use Common Crypto in a Swift playground?
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…

zoul
- 102,279
- 44
- 260
- 354