Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMSCryptoUtilsSimpleEncryptData #13

Open
editdb opened this issue Jul 1, 2015 · 0 comments
Open

IMSCryptoUtilsSimpleEncryptData #13

editdb opened this issue Jul 1, 2015 · 0 comments

Comments

@editdb
Copy link

editdb commented Jul 1, 2015

The following string lengths do not encrypt: 15, 31, 47, 63, 79, 95, 111, 127, 143, 159, 175, 191, 207, 223, 239, 255, 271, 287, 303, 319, 335, 351, 367, 383, 399, 415, 431, 447, 463, 479, 495, 511, 527, 543, 559, 575, 591, 607, 623, 639, 655, 671, 687, 703, 719, 735, 751, 767, 783, 799, 815, 831, 847, 863, 879, 895, 911, 927, 943, 959, 975, 991, 1007, 1023, etc etc

The fix is as follows:
// create a buffer
size_t ciphertext_len = ([plaintext length] + kCCBlockSizeAES128 + [iv length]);

// Patch - the output length should be calculated using this iOS function.
// If this line is not included, then 1/16th of strings will fail encryption
// for an incorrect output buffer size kCCBufferTooSmall reported from CCCryptorFinal
ciphertext_len = CCCryptorGetOutputLength(cryptor, ciphertext_len, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant