As many of us know, there's been a recent situation with Apple where hackers are able to get any In-App Purchase for free. Apple recently released this document describing how to patch it, but I'm a bit confused on step #4 and would appreciate any help.
The first steps are to download their patch .h and .m, include it in your project, and link it against the Security framework. Okay, good, got it. Then Apple says:
4. Provide a base64 encoder, a base64 decoder, and the action to perform when validation succeeds.
What exactly does the part about the encoders mean I should do? (The action to perform when validation succeeds is clear to me.) I see the functions named base64_encode
and base64_decode
in the class, certainly. But what is it asking for? Is this like a special PIN number that only I know, to prevent hacking? I'm not sure what to do here. I get the overall concepts of encoding and decoding, of course, but not the programmatic specifics of how to generate one properly in this situation.
The code as Apple writes it, if this helps any:
- (NSString *)encodeBase64:(const uint8_t *)input length:(NSInteger)length
{
#warning Replace this method.
return nil;
}
- (NSString *)decodeBase64:(NSString *)input length:(NSInteger *)length
{
#warning Replace this method.
return nil;
}
#warning Implement this function.
char* base64_encode(const void* buf, size_t size)
{ return NULL; }
#warning Implement this function.
void * base64_decode(const char* s, size_t * data_len)
{ return NULL; }
I'm also perplexed that there are 2 encode and 2 decode functions. I get that there's a pair that returns NSString*
s, but why does the second pair return a char*
and a void*
? What are these functions expected to return? I really don't get it.
Please have a look at a solution presented: here, posted by unknown author.
which contains the following code, which I tested and works for me:
Sounds like they want a general-purpose base64 encoder. Try some of the code here:
http://cocoadev.com/wiki/BaseSixtyFour
(disclaimer: I have not tested any of this)
Here's a second one that's rather easier to read: http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html