Reputation: 13121
There is a service that stores user data on a remote file share. The user data needs to be encrypted so the remote file store such that anyone accessing it directly cannot access it. The front-end machines that do the storage and retrieval do need the private key to encrypt and decrypt.
Does it make sense to use a self-signed X509Certificate, stored in the cert store on each front-machine, to hold the private key?
I thought this made sense but, looking at the APIs for AesCryptoServiceProvider, I don't see an easy way to load the X509Certificate2 private-key into the AES as the private key.
Upvotes: 1
Views: 3943
Reputation: 102296
Does it make sense to use a self-signed X509Certificate, stored in the cert store on each front-machine, to hold the private key?
Not really. Don't use an X509 certificate; rather use PKCS #12.
An X509 certificate binds an entity (user, org, etc) to a public key. Its the wrong tool for the job. PKCS #12 is Personal Information Exchange Syntax Standard. It defines a file format used to store private keys with public key certificates, protected with a password.
So the user gets the PKCS #12 file to decrypt his/her data. The front-end server gets the X509 certificate from the PFX file to encrypt the user's data.
I don't see an easy way to load the
X509Certificate2
private-key into the AES as the private key
That's a different problem. But its kind of out of scope since the AES key won't be stored in the X509 certificate. You'll make other gyrations for it later.
Upvotes: 0
Reputation: 8877
I thought this made sense but, looking at the APIs for AesCryptoServiceProvider, I don't see an easy way to load the X509Certificate2 private-key into the AES as the private key.
X509Certificate2 represents asymetric cryptography. AES represents symetric cryptography.
When encrypting large data asymetric cryptography is not a good option (performance reasons). However use of asymetric cryptography (i.e. certificates) is good for authenticating users and authorizing operations like encrypt and decrypt for this user. Designing encryption and decryption of user data can be done in multiplne ways.
Upvotes: 1