Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6852403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:21:59+00:00 2026-05-27T01:21:59+00:00

Have a (rather complex) app that works fine on iOS 4 but fails on

  • 0

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 determined that, when CCCryptorUpdate is given a buffer length of 1008 (1024 – 16) it only decrypts 992 bytes (as reported in the dataOutMoved parameter). This would be OK if CCCryptorFinal returned the remaining bytes, but it reports zero bytes moved. However, CCCryptorFinal is reporting a -4304 return code (which is an unhelpful kCCDecodeError).

Update 2

I’ve pretty nailed it as an out-and-out bug. I’ve compared byte-for-byte the output from encryption and the input to decryption, and compared the keys. Identical. But if buffer length is 1008 then decryption always fails, even when the decryptor is given a larger output buffer (it says it needs 1024 in that case). I assume it works fine for 1024, though I haven’t gotten past the first oddball sized buffer to tell.

Etc

Well, it appears that nothing decrypts. This is using the "all in one" CCCrypt() interface that removes any chance of an error with the sequencing of CCCryptorCreate/Update/Final. I wonder if it’s a problem with AES128?

A curious thing is that when page 1 of the DB is encrypted the encryption always reports back 16 bytes more moved than what I tell it — if I tell it 1008 it reports 1024, if I tell it 1024 it reports 1040. No other page does that, and I don’t see how the CCCrypt could know what page it’s processing. Like I said, curious.

Found it (I think)

The old code was specifying kCCOptionPKCS7Padding, which, as I understand it, should only be used for encrypting where the buffer length is not a multiple of the block length (and where additional output buffer space is provided). This caused virtually all decrypt operations to fail with -4304. But in iOS 4 the operations would still move the data they had decrypted (which was essentially all of it), while iOS 5 changed such that all data movement was suppressed if the operation failed (and the last block would almost always fail).

Turning off the padding option makes the code work without posting any errors.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:22:00+00:00Added an answer on May 27, 2026 at 1:22 am

    As described above, there was a change from iOS 4 to iOS 5 in that data is no longer copied to the target buffer if there is an error. So in iOS 4 one could be ignoring errors and still get good results, while that doesn’t work in iOS 5. (I didn’t write the original code — I never would have ignored the errors.)

    The errors were due to having kCCOptionPKCS7Padding specified while doing fixed-length block-multiple operations. (Not entirely sure how one arranges the buffers when doing padding, but it’s not something I need to do.) Removing that option causes the operations to be error-free.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following the Heroku tutorial but I have already created a rather complex Django app
I have a window that contains several rather complex views. Right now, I'm using
I have a number rather large, complex xml documents that I need to loop
I have a PHP class that stores a complex multidimensional array, and rather than
I have what I think is a rather complex problem. I have a C#
I have a legacy class that is rather complex to maintain: class OldClass {
I have a rather complex legacy ASP.Net application that is under continuous development, and
I have a complex database conversion console app that reads from an old database,
I have a medium-complex Rails app. The main controller (the one that does what
I have this rather complex query that grabs data from three tables, and now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.