amitaymolko / react-native-rsa-native

A native implementation of RSA key generation and encryption/decryption.
MIT License
234 stars 115 forks source link

[question] What encryption type is used? #88

Open davidcallanan opened 4 years ago

davidcallanan commented 4 years ago

What encryption type is used by this library? I would like to use RSA-PSS to match my webcrypto code:

await crypto.subtle.generateKey(
    {
      name: "RSA-PSS",
      hash: "SHA-256",
      modulusLength: 4096,
      publicExponent: new Uint8Array([1, 0, 1]),
    },
    true,
    ["sign", "verify"],
  );
Saiid2001 commented 1 year ago

After digging in the Android and IOS code, it uses the RSA_PKCS1 according to RFC 3447 - section 7.2.

To change them, you must go into RSA.java and update the Algorithm in lines 132 and 154.

final Cipher cipher = Cipher.getInstance("RSA/NONE/PKCS1Padding");

A similar analysis can be done for IOS.