Integrate the Malware Detection SDK

Prev Next

Android

For the SDK to function, you need to generate a malware list that can be used by the SDK, and link some libraries to your project.

Malware list

You can generate the required malware list and key file with the Malware List Encryption Tool that is provided with the SDK product package. Run the java -jar MalwareListEncryptionTool.jar command to view instructions on how to use this tool.

To generate a malware list

  • Provide a JSON file to the tool:

    java -jar MalwareListEncryptionTool.jar -f /path/to/list.json -o output
    [
      {
        "packageName": "ExamplePackage1",
        "md5Hash" : "valid-md5-hash",
        "sha1Hash": "valid-sha1-hash",
        "sha256Hash": "valid-sha256-hash"
      }
    ]

    The encryption tool also handles null or empty values:

    [
      {
        "packageName": null,
        "md5Hash" : "valid-md5-hash",
      }
    ]

This generates the required files:

  • signed_malware_list.json: encrypted malware list used by the SDK

  • app_keys.json: keys for using the malware list

  • client_keys.json: keys that can be used to regenerate malware lists without having to create the app_keys.json file again

Required dependencies and libraries

The following dependencies and libraries are required for the SDK to function:

// WorkManager dependencies  
implementation("androidx.work:work-runtime-ktx:2.10.0")  
   
// Kotlin serialization  
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.1")  
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")  
   
// Android Security Crypto  
implementation("androidx.security:security-crypto:1.1.0-alpha06")

Integration steps

To use the Malware Detection SDK in your Android project

  1. Locate the app/libs folder in your project, or create one if it does not exist

  2. Link Add MalwareDetectionSDK.aar from the OneSpan Mobile Security Suite package to the app/libs folder.

  3. Add implementation(files("libs/MalwareDetectionSDK.aar")) to the build.gradle file.

  4. Generate the malware list and keys file. See Malware list for more information.

  5. Add the generated malware list (signed_malware_list.json) and keys file (app_keys.json) to your application’s assets in app/src/main/assets.

  6. Initialize the Malware Detection SDK features, using the file names:

    • Malware detection:

      MalwareDetection.getInstance(context, "app_keys.json", "signed_malware_list.json")
    • RAT detection:

      RatDetection.getInstance(context)
    • Sideloading detection:

      SideLoadingDetection.getInstance(context)

iOS

To use the Malware Detection SDK in your iOS project

  1. Link MalwareDetectionSDK.xcframework from the OneSpan Mobile Security Suite or Project Cyber package to your Xcode project (linked framework and libraries).

You are now ready to use the Malware Detection SDK.