Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I was wondering if there is a smart way for a user to only encrypt a subset of a plaintext.

I'll try to be more specific. Let's suppose the user U wants to use a special cipher such that given a plaintext P and some additional information, it only encrypts the subset requested by the user, the rest of the plaintext is not modified.

Does it exist such a cipher? If so, where can I find it and how does it work? If not, how would you do design such a cipher?

Thanks

EDIT: I've read about selective encryption but it looks like it's mainly meant for images and video streams

share|improve this question
    
What do you mean with "subset of P"? You can use any cipher. What data you put through and what not is completely your choice and of no relevance for the cipher. –  marstato Aug 5 at 14:04
    
In practice, you probably want an AEAD scheme. It is almost always the case that your encrypted data should also be authenticated, and with AEAD your non-encrypted data will also be authenticated. –  otus Aug 5 at 14:07
    
@marstato "subset of P" means a subset of the bytes of P. What I'm wondering whether exists or not is a cipher that given a plaintext + some data it only encrypts the bytes the user asked to encrypt. –  pAkY88 Aug 5 at 14:12
    
@otus thank you for the advice! I'll have a look at it. Why don't you write an answer? I might accept it. –  pAkY88 Aug 5 at 14:13
    
Is there one continuous subset or many disjointed subsets? Do you require that the output (of plaintext and ciphertext) be the same length as the input plaintext? Do you want the ciphertext to be in-line with the plaintext? –  mikeazo Aug 5 at 15:49

1 Answer 1

up vote 4 down vote accepted

You can get what you want programmatically. No special ciphers or modes needed.

You say there is a single, continuous subset that needs to be encrypted. Thus, you could have a function where the programmer specifies the start of the portion of the plaintext that needs to be encrypted and the number of bytes to encrypt. The function could pull that part out, encrypt it (using a good block cipher and mode) into a buffer. Then write out the part preceding it, the ciphtertext, then the part following the portion that needs to be encrypted.

If you require integrity checks too, a simple HMAC of the plain-part-one + ciphertext + plain-part-two using a different key would do.

share|improve this answer

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.