Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8263687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:11:34+00:00 2026-06-08T04:11:34+00:00

I am writing a secure file sharing application in Java. The general architecture looks

  • 0

I am writing a secure file sharing application in Java. The general architecture looks like this:

  1. User wishes to encrypt a file for secure sharing between multiple users.
  2. The application generates a random UUID on the client and uses this as the AES 256 password, and encrypts the data with the UUID.
  3. The UUID is then RSA encrypted with each person’s public key. Once per shared user.
  4. Each encrypted UUID packet is stored as part of the file in a custom file header.
  5. The file is then uploaded to a server where others can access it.
  6. The user’s can each use their private key to read the AES encryption key and decrypt the file.

Here is the catch. The user’s private key must be encrypted and stored on our servers in our database so that the files can be accessed from multiple locations. The private key will be encrypted with a user selected password on the client prior to being uploaded to the server.

I would like to do this using AES 256 bit encryption. And I would like to do the entire thing without relying on BouncyCastle libraries or any 3rd party libraries. It needs to use the standard Java 5 libraries, which is why I have chosen to use AES 256 encryption and RSA rather than something like PGP.

Can anyone find anything inherently insecure with this approach, or think of a more efficient way to do this?

Edit:

OK, I’m updating the question because all of the answers I am getting are suggesting that I not transmit the private key to the server. The reason I need the private key on the server is because the user’s need to be able to access their data from multiple clients and multiple locations (ie: their iphone, their ipad, their work laptop, their home pc). They do not want to have to manage and copy their keys from device to device, which is even more insecure than storing their keys on our server because they would just end up emailing them to themselves at that point.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:11:35+00:00Added an answer on June 8, 2026 at 4:11 am

    The scheme you outline is equivalent to CMS (the standard underlying S/MIME) and PGP; fundamentally, it is secure. In CMS, this mode is called “key transport”. You could also use multi-party “key agreement,” with an algorithm like DH or ECDH.

    The only problem is that you are using poorly chosen keys for AES.

    I can’t think of any reason to use a random UUID, which contains non-random bits. Just use the normal key generation mechanism of the Java Cryptography Architecture. Keys, plaintext, and ciphertext should all be represented as byte sequences, unless you need to accommodate some external storage or transport that only accommodates text.

    Iterable<Certificate> recipients = null;
    KeyGenerator gen = KeyGenerator.getInstance("AES");
    gen.init(256);
    SecretKey contentEncryptionKey = gen.generateKey();
    

    Initialize the AES cipher and let the provider choose an IV.

    Cipher contentCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    contentCipher.init(Cipher.ENCRYPT_MODE, contentEncryptionKey);
    AlgorithmParameters params = contentCipher.getParameters();
    byte[] iv = params.getParameterSpec(IvParameterSpec.class).getIV();
    

    For each recipient, initialize the RSA cipher and encrypt the AES key.

    Cipher keyEncryptionCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
    for (Certificate recipient : recipients) {
      keyEncryptionCipher.init(Cipher.WRAP_MODE, recipient);
      byte[] encryptedKey = keyEncryptionCipher.wrap(contentEncryptionKey);
      /* Store the encryptedKey with an identifier for the recipient... */
    }
    /* Store the IV... */ 
    /* Encrypt the file... */
    

    Having users select and remember passwords that give 256 bits of effective strength is unreasonable. To get that strength, you’d have to randomly choose passwords, encode them as text, and have users write them down on a card. If you really need that much strength, you could check out a smart-card–based solution for storing the users’ RSA keys.

    I’d highly recommend using a CMS library to store your files. It will increase your chances that the protocol you’re using is safe, the code you are using has had more review, and that other tools, libraries, and systems can inter-operate with the encrypted messages. BouncyCastle’s API is a little obscure, but it might be worth learning it.

    (I can’t remember if Java 5 supports “RSA/ECB/OAEPWithSHA-512AndMGF1Padding”; if it does, you should use that instead of PKCS1Padding.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On this winform application I am writing, I want to secure one menu item
I am writing a web application that has secure images uploaded by users. These
I'm writing a GUI application that will have a user log in feature. Each
I'm simply trying to create a secure user file that will save basic login
I am writing an application that heavily uses cryptology. Like most networked applications, mine
I'm writing a secure WCF REST webservice using C#. My code is something like
I am writing an Android application which aims to encrypt and decrypt files using
Writing a python program, and I came up with this error while using the
Writing a .NET DLL how do I find Application.ProductName ? EDIT: Obviously, importing Windows.Forms
Writing my first C# application...never touched the language before and not much of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.