• caglararli@hotmail.com
  • 05386281520

Secure Transmission of Secret Keys Between Mobile App and API Server

Çağlar Arlı      -    8 Views

Secure Transmission of Secret Keys Between Mobile App and API Server

I need to establish a secure method for transmitting shared secret keys between a mobile app and an API server to ensure the integrity of the data.

When initially exchanging shared secret keys, I'am employ X25519. However, if a previously established shared secret key exists for a user on the server, It must retrieve and use the shared secret key that is already stored for that user. Because altering the shared secret key by generating a new one would render it incompatible with other logged-in devices.

The threat model is for users to spoof the API by discovering their shared secret key.

To prevent this, I came up with three approaches.

First Approach:

  1. The server possesses an RSA or ECIES key pair. Server's public key is hardcoded into the client.
  2. The client generates a random AES key, encrypts it using the server's public key, and transmits it to the server.
  3. The server decrypts the received encrypted AES key with its own private key, encrypts the message with that key, and sends the value to the client, including signing it with the private key.
  4. The client decrypts the received encrypted message with the AES key and verifies the signature with the server's public key.

Second Approach:

  1. The client has an RSA or ECIES key pair.
  2. The client sends its public key to the server.
  3. The server encrypts the message using the public key received from the client and transmits it.
  4. The client decrypts the encrypted message received from the server with its own private key.

Third Approach:

  1. Both client and server have RSA key pairs.
  2. The client sends its public key to the server.
  3. The server encrypts the message with the client's public key and generates a signature with its own private key. It sends the encrypted message, its signature, and its own public key to the client.
  4. The client verifies the integrity of the signature by verifying it with the server’s public key and decrypts the encrypted message with its own private key.

Which of the three approaches above best suits my situation? Or if you have any other insights or solutions, I'd sincerely appreciate your input.