From well as, openssl_private_decrypt() function used inside RSA_decrypt($data) function

From this value to the private key we deduce how strong the private key which composed of 904 byte ? 2048 bits as shown. The algorithm will encrypt the user’s passwords by the public key, while the private key will be used for decryption purpose using the following code for encryption:

   public function RSA_encrypt($data)

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

    {

        if (openssl_public_encrypt($data, $encrypted, $this->pubkey))

            $data = base64_encode($encrypted);

        else

            throw new Exception(‘Unable to encrypt data. Perhaps it is bigger than the key size?’);

        return $data;

    }

In other hand, the following codes used for decryption:

public function RSA_decrypt($data)

    {

        if (openssl_private_decrypt(base64_decode($data), $decrypted, $this->privkey))

            $data = $decrypted;

        else

            $data = ”;

 

        return $data;

    }

Where, openssl_public_encrypt() function is used inside RSA_encrypt($data) function to encrypt data with public key and stores the result into encrypted variable. As well as, openssl_private_decrypt() function used inside RSA_decrypt($data) function to decrypt data with private key and stores the result into decrypted variable. First, after the creation of both public and private key and prepare them using setkey($val) function. This is followed by compression of the data to be sent in encrypted form, which in our case are the passwords for users using the following piece of codes:

$plaintext = gzcompress($plaintext);

 Then, a created system get the public key of the recipient using a command $publicKey = openssl_pkey_get_public(‘public.key’); Generate the public key for the private key using a command:

 $a_key = openssl_pkey_get_details($publicKey);

The previous operations are completed by segmenting the data (user password) into small chunks to be encrypted and then combine to send it using the following piece of code:

while ($plaintext)

        {

            $chunk = substr($plaintext, 0, $chunkSize);

            $plaintext = substr($plaintext, $chunkSize);

            $encrypted = ”;

 

            if (!openssl_public_encrypt($chunk, $encrypted, $_SESSION’pubKey’))

            {

                die(‘Failed to encrypt data’);

            }

            $output .= $encrypted;

        }

              $encrypted = $output;

        return $encrypted;

 

Where, encrypted variable contains the final encrypted data to be sent to the recipient in our case the recipient is SQL database. In other hand, the data is decrypted by using the following code steps:

        if (openssl_private_decrypt(base64_decode($data), $decrypted, $this->privkey))

            $data = $decrypted;

        else

            $data = ”;

 

        return $data;

   

Where, data variable contains the final decrypted data to be sent to the recipient in our case the recipient is the data owner who request viewing the stored file in the created cloud system.  

1)      Modulus (ie. n) is a variable defined by var $modulus; command.

2)      RSA private exponent represented as d and RSA public exponent  represented by e so, e and d are defined by    var $exponent; command.

3)      Primes used for the famous theorem called Chinese Remainder Theorem (p and q) is a variable of type array defined by var $primes; command.

Where, createKey function creates both public and private pairs during returning variable of type array with the following three attributes:

·         Privatekey variable represent the RSA private key.

·         Publickey variable represent the  RSA public key.

·         partialkey: A partially processed key used in case if the execution time exceeded the specified time by variable named timeout, a partial key passed back to createKey function as one of the parameter for additional processing.

In fact, RSA algorithm was chosen to be a secure gate that protects user passwords become famous as One-Way Trapdoor function. This is due to the difficulty of encryption and decryption without knowing the value of e. Here we come to the question of why we find it difficult to find n, the answer is the prime factorization. For example, it’s easy to find the product of two large prime numbers but, it’s hard to take a very large product result and factor it to find the 2 primes that compose it such follow:

Of course the challenge would be greater if the public key is:

‘2d 2d 2d 2d 2d 42 45 47 49 4e 20 50 55 42 4c 49 43 20 4b 45 59 2d 2d 2d 2d 2d 0d 0a 4d 49 47 66 4d 41 30 47 43 53 71 47 53 49 62 33 44 51 45 42 41 51 55 41 41 34 47 4e 41 44 43 42 69 51 4b 42 67 51 43 71 47 4b 75 6b 4f 31 44 65 37 7a 68 5a 6a 36 2b 48 30 71 74 6a 54 6b 56 78 77 54 43 70 76 4b 65 6e 6f 6f 6e 65 0d 0a 46 50 71 72 69 30 63 62 32 4a 5a 66 58 4a 2f 44 67 59 53 46 36 76 55 70 77 6d 4a 47 38 77 56 51 5a 4b 6a 65 47 63 6a 44 4f 4c 35 55 6c 73 75 75 73 46 6e 63 43 7a 57 42 51 37 52 4b 4e 55 53 65 73 6d 51 52 4d 53 47 6d 6f 6f 6e 2f 0d 0a 33 6a 2b 73 6b 5a 36 55 74 57 2b 35 75 30 39 6c 48 4e 73 6a 36 74 51 35 31 73 31 53 50 72 43 42 6b 65 64 62 4e 66 30 54 70 30 47 62 4d 4a 44 79 52 34 65 39 54 30 34 5a 5a 77 49 44 41 51 43 44 0d 0a 2d 2d 2d 2d 2d 45 4e 44 20 50 55 42 4c 49 43 20 4b 45 59 2d 2d 2d 2d 2d 0d 0a’

Is big challenge when we trying to analyze the two numbers composed the previous public key! Finally, the RSA has the disadvantage that it slower than symmetric crypto algorithms such as AES. But what supports our policy to choose this slow algorithm is the high level of security and the slow can be forgiven because the user log and encrypt the user data will be mostly once. However, compression of encrypted files will relatively eliminate the problem of slow performance in this high-security algorithm named RSA.

x

Hi!
I'm Mack!

Would you like to get a custom essay? How about receiving a customized one?

Check it out