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.

Is there any possible way to filter a key space in a crypto-system to get a set of keys that decrypts out a valid text (text that is in same language or readable)?

I tried a random approach and got certain set of keys but its not that appreciative to actually required text size

code

from Crypto.Cipher import ARC4
import base64, string, time, random
key = ''.join(random.choice(string.ascii_letters + string.digits ) for i in       range(8))
obj1 = ARC4.new(key)
obj2 = ARC4.new(key)
text = 'abcdefgh'
cipher_text = base64.b64encode(obj1.encrypt(text))

decoded_text= obj2.decrypt(base64.b64decode(cipher_text))

Dict={}
count=0
valid = set(string.ascii_letters + string.digits )
def test(s):
    return set(s).issubset(valid)

print; print 'plain text: ', text
print; print 'Actual key: ', key 
print; print 'Cipher text: ', cipher_text

timeout=time.time()+60
while time.time()< timeout:
   count+=1
   key = ''.join(random.choice(string.ascii_letters + string.digits ) for i in range(8))
   obj2 = ARC4.new(key)
   decoded= obj2.decrypt(base64.b64decode(cipher_text))
   if test(decoded):
       Dict.update({'key: '+key : 'Valid Decrypted Text: '+decoded})
import pprint
print; print 'Analysis: '
pprint.pprint(Dict)
print;print 'Number of valid Decrypted Text: ', len(Dict)
print;print 'Total number of decryption performed: ', count

Output:

plain text:  abcdefgh

Actual key:  go6oMkCG

Cipher text:  JB1a3osG+es=

Analysis: 
{'key: 0UUvjzLw': 'Valid Decrypted Text: mzptBVo4',

 'key: 2beOXKN1': 'Valid Decrypted Text: Yhz3jIL8',

 'key: 3Eq7MKwu': 'Valid Decrypted Text: GA9BTdzy',

 'key: 3jUQPXs8': 'Valid Decrypted Text: 3gCa3KBG',

.

.

Number of valid Decrypted Text:  36

Total number of decryption performed:  2275140

Is there any better to sort out such keys. Such keys may be valuable to strengthen cryptography by introducing confusion

share|improve this question

closed as unclear what you're asking by Gilles, DrLecter, AFS, archie, poncho Apr 30 at 21:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
I'm not sure I understand the question. Are you looking for keys that would map a given plaintext to some ciphertext containing only printing characters? Or for keys that would map any plaintext consisting only of printing characters to a ciphertext consisting of only printing characters? What do you mean by “spurious keys” (are you sure you're using the right English word here?)? Are you using “confusion” in the technical sense, and if not what do you mean? Where does key derivation come in? –  Gilles Apr 23 at 9:37
    
By spurious keys i mean incorrect keys and among incorrect keys i am searching for those incorrect keys that maps a cipher text to decrypted text that looks like a proper text(lets say english text map to english text) so that deciding whether that key is incorrect will be a confusing job to cryptanalyst.... –  ceasif Apr 23 at 10:10
1  
Perhaps you are looking for something like this technologyreview.com/news/523746/… –  mikeazo Apr 23 at 12:54
    
Indeed, sounds like you want the work of Tom Ristenpart on 'honey encryption' or 'format transforming encryption' depending on the exact meaning of your question –  figlesquidge Apr 24 at 7:54
1  
@ceasif: Do you want the ciphertext to look like English, or incorrect decryptions to look like English? –  figlesquidge Apr 24 at 8:33
show 1 more comment

1 Answer 1

up vote 2 down vote accepted

Here is the problem. For a specific ciphertext, sure you could try a bunch of keys and output the couple that result in the type of plaintext you want. But what does this really get you? For a different ciphertext, likely these same keys will not result in the same type of plaintext you desire.

Recent work on honey encryption might be what you are really looking for. It is still very new, so it should not be used in a production system without understanding all the intricacies. The authors of the paper also provide some nice theoretical foundation for the area.

share|improve this answer
    
Thank you very much for your advice. Actually, I am doing research in this field and I am just trying to figure out the measure of such confusing factor in modern cryptosystems. But I am not getting perfect weapon to do that. I will go through your suggestions and will be grateful to have further more suggestions to this topic :) –  ceasif Apr 23 at 19:15
    
@ceasif good luck with your research. I hope you find this site useful in your research. –  mikeazo Apr 23 at 19:27
add comment

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