iOS integration
  • 26 Dec 2024
  • 2 Minutes à lire
  • Sombre
    Lumière
  • PDF

iOS integration

  • Sombre
    Lumière
  • PDF

The content is currently unavailable in French. You are viewing the default English version.
Résumé de l’article

The special SAROM folder is sarom. This folder should be placed at the root of the app, i.e., directly inside the app folder. In Xcode, adding sarom as a folder to the project should achieve the required result.

The key is the file path relative to sarom. For example, if you have a file sarom/path/to/secret, its key is path/to/secret.

No other string or variations of this string, like Path/To/Secret or /path/to/secret or path//to/secret, will work!.

The value is the content of the file.

To use this feature

  • Import Shield.h into your application.

  • Add the data you want to store in SAROM into the sarom folder in the ipa.

Adding files to an app can be challenging. For example, in Xcode it does not work to add individual files to the app. If you add the file sarom/secret to your project, Xcode will only add the file secret to the ipa without putting it in a sarom folder. However, if you add the sarom folder itself, all the files inside that folder will also be added automatically to the ipa.

Using Secure App ROM without shielding

The SAROM interfaces also work before shielding. But in this case, the data will not be encrypted or the files will not be renamed.

One caveat here is that if the name of your files contain non-ASCII characters, there may be issues. Issues have arisen with both codesign getting things wrong, and the system not being able to parse the ipa files correctly.

These problems only apply to the name of the files, the content can be anything.

Non-ASCII characters in the file names are only a problem before shielding. During shielding the files will be renamed to hide their names, and the new file names do not have these problems.

Secure App ROM Objective-C API

To access the SAROM data from the app, use the following API:

@interface NSData (SAROM)
+ (nullable instancetype)dataFromSecureAppROMItem:(NSString *)name NS_SWIFT_NAME(init(secureAppROMItem:));
@end

[NSData dataFromSecureAppROMItem:]

This is a class method on the NSData class.

This method will return the data associated with the key given by name in the SAROM storage, as an NSData object. If there are any errors, this method returns the nil object. For example, if the item name is not found in the SAROM storage, or the data is corrupt.

Example using the Secure App ROM API

After building the ipa, with a sarom folder that contains the file secret (i.e., in sarom/secret), you can retrieve the original data by:

#import <Shield.h>
...
- (NSData *)getSecret
{  
  return [NSData dataFromSecureAppROMItem:@"secret"];
}
...

Example using the Secure App ROM API from Swift

class SomeClass {
  ...
  func getSecret() -> NSData? {
    return NSData(secureAppROMItem: "secret")
  }
  ...
}


Cet article vous a-t-il été utile ?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Ozzy, facilitant la découverte de connaissances grâce à l’intelligence conversationnelle