Package 

Class CryptoUtil


  • 
    class CryptoUtil
    
                        

    Created by lbalmaceda on 8/24/17. Class to handle encryption/decryption cryptographic operations using AES and RSA algorithms in devices with API 19 or higher.

    • Method Summary

      Modifier and Type Method Description
      KeyStore.PrivateKeyEntry getRSAKeyEntry() Attempts to recover the existing RSA Private Key entry or generates a new one as secure asthis device and Android version allows it if none is found.
      Array<byte> RSADecrypt(Array<byte> encryptedInput) Decrypts the given input using a generated RSA Private Key.Used to decrypt the AES key for later usage.
      Array<byte> RSAEncrypt(Array<byte> decryptedInput) Encrypts the given input using a generated RSA Public Key.Used to encrypt the AES key for later storage.
      Array<byte> getAESKey() Attempts to recover the existing AES Key or generates a new one if none is found.
      Array<byte> decrypt(Array<byte> encryptedInput) Encrypts the given input bytes using a symmetric key (AES).The AES key is stored protected by an asymmetric key pair (RSA).
      Array<byte> encrypt(Array<byte> decryptedInput) Encrypts the given input bytes using a symmetric key (AES).The AES key is stored protected by an asymmetric key pair (RSA).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getRSAKeyEntry

         KeyStore.PrivateKeyEntry getRSAKeyEntry()

        Attempts to recover the existing RSA Private Key entry or generates a new one as secure asthis device and Android version allows it if none is found.

      • RSADecrypt

         Array<byte> RSADecrypt(Array<byte> encryptedInput)

        Decrypts the given input using a generated RSA Private Key.Used to decrypt the AES key for later usage.

        Parameters:
        encryptedInput - the input bytes to decrypt
      • RSAEncrypt

         Array<byte> RSAEncrypt(Array<byte> decryptedInput)

        Encrypts the given input using a generated RSA Public Key.Used to encrypt the AES key for later storage.

        Parameters:
        decryptedInput - the input bytes to encrypt
      • getAESKey

         Array<byte> getAESKey()

        Attempts to recover the existing AES Key or generates a new one if none is found.

      • decrypt

         Array<byte> decrypt(Array<byte> encryptedInput)

        Encrypts the given input bytes using a symmetric key (AES).The AES key is stored protected by an asymmetric key pair (RSA).

        Parameters:
        encryptedInput - the input bytes to decrypt.
      • encrypt

         Array<byte> encrypt(Array<byte> decryptedInput)

        Encrypts the given input bytes using a symmetric key (AES).The AES key is stored protected by an asymmetric key pair (RSA).

        Parameters:
        decryptedInput - the input bytes to encrypt.