35
$\begingroup$

My problem:

  • I want to block sites on my router.
  • I want to generate new password for my router after blocking sites.
  • This new password I want to encrypt.
  • But to decrypt it, I want it to take 2 to 8 hour to decrypt.

Is there any solution that could solve my problem?

The reason to do that is I want to lock myself out. By generating a random password that I can't memorize and doing the encryption, I can be sure that it's impossible for me to login. As Joseph Sible-Reinstate Monica commented:

I think the actual goal here is that the OP is trying to focus on something important for a while, and so block access to distracting sites, and needs to lock themselves out so they don't just unblock them when they want to look at them.

Related: How to hide a code from myself until a specified time? on Super User.

$\endgroup$
  • 24
    $\begingroup$ Does that even make sense? What exactly are you trying to achieve? The router should hopefully not reveal the password, and the encryption should hopefully guarantee that someone who doesn't have the key (i.e. everybody except yourself) cannot feasibly decrypt the password. So... you are only hindering yourself from accessing the password which you already know legitimately anyway and for which you have the key. On the other hand, you might very well block a site during those 8 hours, which sucks if you can't do it... $\endgroup$ – Damon Apr 19 at 14:44
  • 2
    $\begingroup$ Are you deliberately trying to use something that can be decrypted in 2 to 8 hours, or just something that will last at least that long? $\endgroup$ – ikrase Apr 19 at 17:01
  • 15
    $\begingroup$ I think the actual goal here is that the OP is trying to focus on something important for a while, and so block access to distracting sites, and needs to lock themselves out so they don't just unblock them when they want to look at them. $\endgroup$ – Joseph Sible-Reinstate Monica Apr 19 at 19:16
  • 8
    $\begingroup$ You really should update the question to explain your goals (i.e. the last two comments). It's very hard to understand what you mean the way it is currently written (IMO). $\endgroup$ – JBentley Apr 20 at 0:45
  • 17
    $\begingroup$ It does seem like this is an X-Y problem... If your goal is just to keep yourself out for a set (or random) period of time, there are far easier ways to accomplish that than having to devote a server to constantly running at full load. $\endgroup$ – Josh Eller Apr 20 at 12:38

10 Answers 10

39
$\begingroup$

Time-lock puzzles appear to be what you want (see for example this). A basic construction is via "Repeated Squaring in the RSA group".

Let $p,q$ be large primes, and let $N = pq$. The goal is, for fixed $t>0$, to compute $2^{2^t}\bmod N$. There are two "obvious" ways to do this, depending on whether you know the factorization of $N$ or don't.

If you do know the factorization of $N$, you can first compute $2^t\bmod \varphi(N) = 2^t\bmod (p-1)(q-1)$, and then compute $2^{2^t\bmod \varphi(N)}$ via Repeated Squaring. The complexity of this is at most $O(\log N)$ multiplications within $(\mathbb{Z}/N\mathbb{Z})$.

If you don't know the factorization of $N$, then there are some conjectures [1] that computing $2^{2^t}\bmod N$ must be done "directly" (and that it cannot really be parallelized). One can do this by repeated squaring to give a complexity of $2t$ multiplications within $(\mathbb{Z}/N\mathbb{Z})$. Here $t\in\mathbb{N}$ is an arbitrarily large number, allowing you to make this as "difficult" as you want.

Note that someone could always factor $N$ if they want to ignore this (so it's not "arbitrarily hard"), but if you make factoring $N$ appropriately hard it gives you fine-grained control over the difficulty of computing $2^{2^t}\bmod N$ (which is the "easier option" in comparison). One can then use $2^{2^t}\bmod N$ as the basis of any symmetric-key crypto scheme (or hash it into any suitable domain first). Your algorithm could then look as follows:

  1. To encrypt something, generate an RSA instance, compute $2^{2^t}\bmod N$, use this value (or its hash) to encrypt something, then only store $(N, t)$.
  2. To decrypt, start by recomputing $2^{2^t}\bmod N$, then decrypt using whatever "base scheme" you encrypted with.

This has the benefit of allowing you freedom to "tune" the parameter $t$ to take however long you want to decrypt.


[1] For more information I'd suggest looking into Verifiable Delay Functions, but I'm not too familiar with the area admittedly.

| improve this answer | |
$\endgroup$
  • 3
    $\begingroup$ So if you don’t reuse N then you just need to pick p and q large enough so that factoring N also takes 2 to 8 hours. Where normally you’d pick N that cannot be factored in a million years. $\endgroup$ – gnasher729 Apr 19 at 9:19
  • $\begingroup$ Thanks @Mark. I don't understand that much, but I have been able to figure it out with your reference to Time-lock puzzles. :D $\endgroup$ – Mateusz Rybin Apr 19 at 9:48
  • 4
    $\begingroup$ @gnasher729 You could do that, but the "downside" is that factorizing is highly parallelizable. So 2-8 core hours $\neq$ 2-8 wall clock hours. Depending on what you're optimizing for one choice is more appropriate than another. $\endgroup$ – Mark Apr 19 at 18:54
  • $\begingroup$ @gnasher729 You want at least 2 to 8 hours, so a million years is fine $\endgroup$ – Hagen von Eitzen Apr 20 at 18:42
30
$\begingroup$

Somewhat offtopic, but I think you're missing something: The 5$ wrench method.

It might take 2 - 8 hours to decrypt a password, but it takes 20seconds to reset a router (sorry if you didnt think of this shortcut, but you probably would've at some point).

  • Most routers have some form of parental controls. You could set them to specific hour so that during work-hours you can't access those sites.
  • Or you could just practise. I had a focus problem a while back, what worked for me was allowing myself 5 minutes at every whole hour mark (10:00am, 11:00am, etc)
  • You could just write a 20character password on a note, sticking that to the back of the router. All you're looking for is a threshold where it's too much effort to change the settings. If you have to type it manually, it's tedious.
  • Or let someone else enter a passphraze

Your current solution fights the symptom, not the problem :) And there are probably better methods and wasting so much energy by literally blasting the routers CPU to the max for 2-8 hours.

| improve this answer | |
$\endgroup$
  • $\begingroup$ When the router reboots, it'll still have the site blocked in its configuration, so your shortcut won't work. $\endgroup$ – Jeff Learman May 13 at 17:48
  • 7
    $\begingroup$ @JeffLearman Reset != reboot. Each router should have hardware button to reset completely all its settings. $\endgroup$ – Robyer May 13 at 23:15
  • 1
    $\begingroup$ Oops! Right! Doh! $\endgroup$ – Jeff Learman May 14 at 12:50
11
$\begingroup$

Instead of using a custom cryptographic algorithm and/or implementation, you could use standard ones to generate a random key, but store only part of the key, and discard the rest.

To recover the complete key, you would need to brute force the missing part of the key. By discarding more or fewer bits, you can tune how long the brute forcing will take.

So that you can use standard brute forcing tools (say Hashcat), you could store a hash of the key (or of only the missing parts) in a format which this tool understands, and use a mask to fill in the known parts of the key.

But to achieve the underlying goal of your question, you could skip the encryption altogether, and just discard part of the generated password, and brute force that instead.

So the procedure for setting a new password would become:

  1. generate a random password
  2. configure your router to use the new password
  3. hash the password
  4. store part of the password, and the hash

And to crack it:

  1. brute force the hash, using a mask to fill in the stored part of the password
| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ It's possible that you could get lucky and guess the password on the first try, which doesn't guarantee a minimum of 2 hours that the poster wanted. $\endgroup$ – b-jazz Apr 20 at 16:50
  • 3
    $\begingroup$ You are right. That said, it will always be possible to guess the password correctly on the first attempt when trying to log in into the modem, regardless of the algorithm used to encrypt it. It's just very unlikely, as it is with my scheme, assuming your hashing algorithm is fast enough so that you can have millions of attempts a second, and you tune the number of unknown bits accordingly. $\endgroup$ – SvdB Apr 20 at 17:16
  • 2
    $\begingroup$ If you want to delay by a max of 8 hours, you could require me to guess among 80 possibiliteis where checking a possibility is so hard that it takes 6 minutes, or 28800000 possibilities that cost a millisecond each. In all scenarios, the probability of winning in less than 2 hours is 25%. We could turn this into nested puzzles: You solve such a puzzle that takes up to 8 minutes. With the solution you can decrypt a message "Congrats! Next passwords begins with ...." and have your next puzzle. Nesting 60 such puzzles, the av. total time needed is 4 hours win in less than 2 hours is unlikely. $\endgroup$ – Hagen von Eitzen Apr 20 at 19:00
3
$\begingroup$

You could store the hash of your password, and then when you wish to recover it, hash every password combination until you find the right one.

The password length and hash function would have to be chosen such that it took the right amount of time to brute-force it. Too long a password or too slow a hash function and you could not process all the combinations in a reasonable amount of time.

| improve this answer | |
$\endgroup$
  • 2
    $\begingroup$ This strategy has a few downsides: (1) It results in a pretty uniform distribution of times to decrypt, where a brute-forcer may get lucky and solve it far quicker than they'd intended with significant likelihood. For example, if they want 2-to-8 hours, and so tune it to take up-to 8-hours, then a brute-forcer has a 25% chance of getting it in less than 2-hours, which is significant. (2) This is highly parallelizable, e.g. allowing someone to cut the time in half by getting a second worker. (3) Hash-collisions may yield false solutions, which isn't a desired property here. $\endgroup$ – Nat Apr 20 at 18:35
  • $\begingroup$ @Nat Could (3) be dealt with by using a cryptographic hash function like SHA256? Wikipedia says "it is infeasible to find two different messages with the same hash value" in that case. $\endgroup$ – 5ndG Apr 20 at 19:40
  • $\begingroup$ Yeah, for many standard cryptographic hash functions, collisions wouldn't be expected to be too common. The problem can be avoided entirely by using an algorithm that is guaranteed to avoid collisions over the password space. $\endgroup$ – Nat Apr 20 at 20:06
2
$\begingroup$

Given your reason for the required delay, might I suggest perhaps an easier analogue method?

  1. Purchase a timed kitchen lock (usually used to stop people from snacking on cookies or from smoking, etc.). Although most are outrageously expensive, you can find reasonably-priced ones if you look around.
  2. Generate and use a random password that's too long to remember — say, 20 characters.
  3. Print this password on a piece of paper, and fold the paper so that you can't read it.
  4. Delete any digital copy, including from your browser's password manager.
  5. Place the folded paper in the timed kitchen timer, and set it to 8 hours (or however long you want it).

This is easy, avoids complicated programming, lets you reuse the password each time you need it, and solves your problem!

There's a cheaper way if you're prepared to up the time to a full day. Place the paper in an envelope and post it to yourself! Post a couple of envelopes in case one goes missing (it can happen). This assumes that the postal service in your country works well.

| improve this answer | |
$\endgroup$
1
$\begingroup$

The easiest way is to find the preimage of hash which is partly known. For example you have a password of length $n$ symbols, $k$ of which you know, then you can adjust these parameters in such way, that bruteforcing the password would lie in your time limits.

Below is python example code. For the sake of simplicity the password consists only of digit symbols. Adding/removing a symbol changes bruteforce time in roughly 10 times.

import hashlib
import itertools

plaintext = "0209485034786395866562345"
init =      "0209485034786395866" #the initial part which is known

s = hashlib.sha256()
s.update(bytes(plaintext,'utf-8'))
ciphertext = s.digest()

number_of_symbols = len(plaintext) - len(init)

res = ''
tail = ''
for x in itertools.product(map(str, range(10)), repeat = number_of_symbols):
    tail = ''.join(x)
    m = hashlib.sha256()
    m.update(bytes(init+tail,'utf-8'))
    res = m.digest()
    if res == ciphertext:
        print(init+tail)
        break

This method is motivated by bitcoin.

| improve this answer | |
$\endgroup$
1
$\begingroup$

You can use a password-storing program like Keepass.

When you create the database of stored password you can specify the number of iterations of the algorithm used to encrypt the database. For example, Keepass can auto-calculate the numbers needed for a 1 second delay every time you open or save the database on your pc. You can multiply those numbers by 10.000 to create a password database that will take nearly 3 hours to open (and also to save it, if you modify the password).

| improve this answer | |
$\endgroup$
0
$\begingroup$

Seems to me that the easiest way is probably just to nest your encryption - it should be perfectly possible to set up a script that encrypts your password, then again and again a million times, or a trillion, or whatever it takes. Variations of this repetition is already used in some 'commercial' encryption, but does potentially reduce the strength of a few specific cyphers, but that doesn't appear to be an issue here - you could use anything more sophisticated than Rot13 for the same effect.

| improve this answer | |
$\endgroup$
0
$\begingroup$

Take a large random password and hash it in parts. This is better than hashing the whole thing together because it leads to more consistent cracking effort. I we tune a single password for 4 hours on average we have a significant chance of doing it in less time. If we break it up to several similar problems it becomes quickly unlikely we will get lucky in all of them.

p.s It will probably take you only a few minutes to reset your router and reconfigure it without decrypting a password.

| improve this answer | |
$\endgroup$
0
$\begingroup$

If your problem is actually that “you want to focus on something important for a while,” then I think you should reconsider whether an encryption scheme is really the next logical step to solving your original problem. Elaborately tying yourself in straightjackets may just distract you further from that “important thing” you initially cared about.

XKCD 1319: Automation

(In this above XKCD comic, replace “write a program” with “devise and implement an elaborate cryptographic strategy.”)

The ideal would be to obey a self-declaration of mind over matter: “you won’t be distracted!” But that’s easier said than done.

Then there’s logic: “compulsively checking information feeds and my inbox is actually making me less happy.”

Fear is a good motivator, too. “If I don’t focus on this important thing, then I’ll dishonor myself and/or lose my job and/or disappoint my significant other… ultimately, making me unhappy.”

Supervision is another: “I’d goof off, but this other person is in the room, and will bear witness to my transgression.” Go into the office, or create/find a shared workspace. To save on automobile-related costs while still controlling myself, I like to imagine there is an invisible camera observing me at all times, and to behave accordingly (and smile for it).

Alternatively, there’s acceptance: you realize you really would be happier by throwing everything else away; the “important thing” really wasn’t important, with your soul’s protests as evidence. You do that thing now — even if, in the worst case, you are judged by others, and you lose your home and wife. However, that distraction—now not a distraction, rather your priority—makes you happier than those things/people anyway.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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