ios - bad practices in Apple’s sample code for the doCipher:key:context:padding method -


according article http://blog.gdssecurity.com/labs/2013/3/5/retrieving-crypto-keys-via-ios-runtime-hooking.html

there "bad practices in apple’s sample code docipher:key:context:padding method http://developer.apple.com/library/ios/#samplecode/cryptoexercise/listings/classes_seckeywrapper_m.html. following code snippet shows use static iv of 16 bytes of 0x0’s.

 // initialization vector; dummy in case 0’s.  uint8_t iv[kchosencipherblocksize];  memset((void *) iv, 0x0, (size_t) sizeof(iv)); 

why bad in layman's term , how fix ?

what understand is possible hook code intercept symetric key. don't understand why , how prevent this.

the code outlined in post insecure because not follow rule initialization vectors being random values. notice engineer wrote commented:

//... dummy in case 0’s. 

true initialization vectors of fixed size (or ivs, blog calls them) never allocate buffer passed crypto function same value on , over, instead randomize data contained buffer each time location not inferred looking @ sample code provided -as author did. cut out call memset(), , block of memory filled "junk" runtime. if want technical, write own version of memset() generates pseudo-random data overwrite memory of local.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -