iOS library to Encrypt AES128 CFB no padding
I'd suggest pushing OpenSSL into your project, if possible. A quick search for "ios openssl" returns a first hit for Easy inclusion of OpenSSL into iOS projects. See also AES interoperability between .Net and iPhone?
Beware that without padding, you'll need to feed the cipher blocks of the correct size.
Objective C Encryption CFB Mode
CBC can be built using ECB, conceptually it's:
Key K;
InitializationVector IV;
OutputDataStream OS;
Block X;
set X = IV;
for each Block B of data D:
Block E = ECB(K, B ^ X);
set X = E
write E to OS
Objective C AES CBC Encryption with Zero Padding
The Method in CommonCrypto.m
- (NSData *) dataEncryptedUsingAlgorithm: (CCAlgorithm) algorithm
key: (id) key
initializationVector: (id) iv
options: (CCOptions) options
error: (CCCryptorStatus *) error
iv parameter declaration
@param iv Initialization vector, optional. Used for
Cipher Block Chaining (CBC) mode. If present,
must be the same length as the selected
algorithm's block size. If CBC mode is
selected (by the absence of any mode bits in
the options flags) and no IV is present, a
NULL (all zeroes) IV will be used. This is
ignored if ECB mode is used or if a stream
cipher algorithm is selected.
so , you could pass nil
value to iv
parameter
How can I make my AES encryption identical between Java and Objective-C (iPhone)?
Since the CCCrypt takes an IV, does it not use a chaining block cipher method (such as CBC)? This would be consistant with what you see: the first block is identical, but in the second block the Java version applies the original key to encrypt, but the OSX version seems to use something else.
EDIT:
From here I saw an example. Seems like you need to pass the kCCOptionECBMode to CCCrypt:
ccStatus = CCCrypt(encryptOrDecrypt,
kCCAlgorithm3DES,
kCCOptionECBMode, <-- this could help
vkey, //"123456789012345678901234", //key
kCCKeySize3DES,
nil, //"init Vec", //iv,
vplainText, //"Your Name", //plainText,
plainTextBufferSize,
(void *)bufferPtr,
bufferPtrSize,
&movedBytes);
EDIT 2:
I played around with some command line to see which one was right. I thought I could contribute it:
$ echo "Now then and what is this nonsense all about. Do you know?" | openssl enc -aes-128-ecb -K $(echo 1234567890123456 | xxd -p) -iv 0 | xxd
0000000: 7a68 ea36 8288 c73d f7c4 5d8d 2243 2577 zh.6...=..]."C%w
0000010: e66b 32f9 772b 6679 d7c0 cb69 037b 8740 .k2.w+fy...i.{.@
0000020: 883f 8211 7482 29f4 7239 84be b50b 5aea .?..t.).r9....Z.
0000030: eaa7 519b 65e8 fa26 a1bb de52 083b 478f ..Q.e..&...R.;G.
Related Topics
Invalid Signature - Code Object Is Not Signed at All
Core Data Does Not React on Changed Predicate
Iphone: Can a Dev Other Than Team Agent Build an App for Distribution
Change Bundle Identifier in Xcode When Submitting My First App in iOS
Programmatically Linking Uipagecontrol to Uiscrollview
How to Add Constraint Between a View and the Top Layout Guide in a Xib File
Uiscrollview Adjusts Contentoffset When Contentsize Changes
How to Set-Up in App Purchase Free Trial Period in iOS App
How to Cache Using Nsurlsession and Nsurlcache. Not Working
How to Integrate Linphone into an Existing Project (Sip in iOS)
Change Table to Edit Mode and Delete Rows Inside a Normal Viewcontroller
Swift Array Append Overwriting Other Array Values
How to Pretty Print Swift Dictionaries to the Console
Uitableview Disable Swipe to Delete, But Still Have Delete in Edit Mode
How to Lock Portrait Orientation for Only Main View Using Swift
How to Write Init Methods of a Uiviewcontroller in Swift
How to Convert .Dae to .Scn Files in Scenekit
iOS 9 Searchbar Disappears from Table Header View When Uisearchcontroller Is Active