Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

Is it possible using encryption keys to encrypt a file so for example some one will full access can read it all but some one with little access can only read say the top paragraph

share|improve this question
    
Do you want to find out whether that is possible in principle (of course it is) or whether there are stable implementations (I have no idea)? –  mkl Dec 6 '12 at 12:51
    
Please provide more details so we can understand the use case. –  Steel City Hacker Dec 6 '12 at 15:42

3 Answers 3

The quick answer is no, there isn't anything out there that does that with a single key, that's not how encryption works, at least with current software.

You could accomplish this using two keys though. One key (inner key) would encrypt the most sensitive data, which could then be put into another document as ciphertext and then encrypted with a second key (outer key). Those with the outer key would be able to see the less sensitive data while those with both keys could read all the data.

That is a clunky way to do it though. What would make more sense would be to authenticate users based on public/private keypairs and then give them access to data based on their privilege level. There's many ways to accomplish that.

share|improve this answer
    
how would i go about authenticating users based on public / private keypairs, what is the principle behind this –  test1245 Dec 6 '12 at 13:06
5  
This is a huge subject @test1245, and I'm not going to attempt to explain the whole thing as there's entire libraries of books on the subject. I suggest you start learning the basics by searching on public key cryptography, and public key infrastructure. –  GdD Dec 6 '12 at 13:17

It seems like you are confusing encryption with access control. Either you can decrypt the entire file or you can't.

With access control and certain pieces of software you can restrict files in the manner which you are talking about. For instance you can allow someone preview only, and someone else preview and read-only.

In order to make a more precise suggestion, however, we need more details about the intended use case where this solution will be provided.

share|improve this answer

Encryption is based on authorized persons knowing a secret (a key); anyone knowing that secret can decrypt any message that is encrypted with that key. If Alice is authorized to decrypt the whole file and Bob is only allowed to decrypt the first paragraph, then Alice must know a secret that Bob doesn't know.

So one way to proceed is to encrypt the first paragraph and the rest of the document with two different keys. Give Alice both keys, and give Bob only the key for the first paragraph.

A variant is to encrypt the whole document except the first paragraph with a key KA, then encrypt the first paragraph and the encrypted document-except-first-paragraph with another key KB. Again, give Alice both keys, and give Bob only KB.

Another variant is to separately encrypt the whole document with a key KA, and the first paragraph with another key KB. Give Alice KA and Bob KB.

The last of these three is the simplest approach. It's easy to implement with any encryption infrastructure, since the distribution is fully separate from the cryptography. Do this unless you have a really good reason to do otherwise.

A different approach is to encrypt the whole document with a key, but not to give that key to anyone (or at least not to Bob, Alice may have it in this scenario). Instead of giving Bob a decryption key, give him some other means to decrypt only the part that he is authorized to decrypt.

Relying on access control to restrict access to data is called digital rights management. If Bob obtains the encrypted content and the means of decryption separately, this is difficult to achieve, because the means of decryption must contain the decryption key inside, yet Bob must not be able to exctract it. The means of decryption (DRM software) must also be able to authenticate Bob: if Bob can bypass or mislay the authentication step, he might be able to pass off as Alice.

An easier approach to access control is to make it online. Leave the content on a server (encryption is optional). Provide Alice and Bob with authentication methods on the server (passwords or otherwise). Configure the server to serve only the first paragraph to Alice, and the whole document to Bob.

If Alice willingly transmits the whole document to Bob, that's a completely different problem, and unsolvable outside of very specific situations. The best you can hope (for some kinds of documents) is to be able to know later that Bob obtained the document through Alice.

share|improve this answer
    
wow thank you very much for this ! this has made things very clear in what i am trying to achieve, thank you very much for this !, would it be possible using keys to write to a document and not see it ? –  test1245 Dec 6 '12 at 18:37
    
@test1245 You mean that for example some could append to a document, but not read what's already there? Kind of. With asymmetric cryptography, someone who has the public key but not the private key can encrypt data but not read it back. Asymmetric cryptography is very slow, so it's mostly only used to encrypt symmetric keys that are generated for each item to be encrypted (file, network session, …). In practice, what would happen is that you'd write separate documents. Further reading: security.stackexchange.com/q/22824, security.stackexchange.com/q/6218 –  Gilles Dec 6 '12 at 18:55
    
thats exactly what i mean ! thank you very much for the information, looks like what i shall be reading tonight ! –  test1245 Dec 6 '12 at 19:01
    
this is a great site, very helpful people ! –  test1245 Dec 6 '12 at 19:06
    
Would it be possible for a user say the boss of the company, to be able to read the data from a user below him but not edit it in any way –  test1245 Dec 8 '12 at 21:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.