Skip to content

Commit

Permalink
[Core] Remove call to setKeySize while generating key-pair for KeyPro…
Browse files Browse the repository at this point in the history
…vider18
  • Loading branch information
Karthikeyan Vasuki Balasubramaniam committed May 20, 2019
1 parent 1c52eea commit 235bfb6
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@
import com.amazonaws.logging.LogFactory;
import com.amazonaws.util.Base64;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.math.BigInteger;
import java.security.Key;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Calendar;

import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
Expand All @@ -31,7 +26,8 @@
* It generates a AES 256-bit symmetric key which is
* used to encrypt the data. It also generates a master
* key using RSA provided by AndroidKeyStore and uses
* the RSA key to encrypt the AES key.
* the RSA key to encrypt the AES key. The size of the
* RSA key is 2048 bits by default.
*
* Once the AES key is encrypted with the RSA key, the
* encrypted AES key is stored in SharedPreferences.
Expand All @@ -52,7 +48,6 @@ public class KeyProvider18 implements KeyProvider {
static final String KEY_ALGORITHM_RSA = "RSA";
static final String CIPHER_RSA_MODE = "RSA/ECB/PKCS1Padding";
static final String CIPHER_PROVIDER_NAME_FOR_RSA = "AndroidOpenSSL";
static final int RSA_KEY_SIZE = 2048;

static final String ENCRYPTED_AES_KEY = "AesGcmNoPadding18-encrypted-encryption-key";

Expand Down Expand Up @@ -151,7 +146,6 @@ private void initializeRSAKeyFromKeyStore(Context context,
.setSerialNumber(BigInteger.TEN)
.setStartDate(start.getTime())
.setEndDate(end.getTime())
.setKeySize(RSA_KEY_SIZE)
.build();
KeyPairGenerator kpg = KeyPairGenerator.getInstance(
KEY_ALGORITHM_RSA,
Expand Down

0 comments on commit 235bfb6

Please sign in to comment.