We know that the biggest human rights violators in human history are capable of one trillion password guesses per second as of approximately January 2013.
Assume that the 1 trillion guesses per second is not a dictionary attack, but a brute force search of all possible permutations of the available characters in the password.
Assume this rate of password guessing is the same speed regardless of their computing equipment. Assume they have special equipment e.g. GPUs/ASICs capable of performing the industry standard Password Based Key Derivation Function (PBKDF2-SHA2 with large number of iterations) for each password guess and they can still guess 1 trillion password combinations per second. Therefore their actual hardware will not factor into the equation, just the 1 trillion guesses per second they can perform.
Discard the assumption of weak passwords and assume the password is very strong and made up of uniformly and randomly selected characters available on a standard US keyboard layout including special characters (95 possible characters total).
We also know from Moore's law that transistor count on an integrated circuit doubles every two years, which loosely translates to doubling of computing power every two years. So in January 2015 they will be able to guess 2 trillion passwords per second. In January 2017 they can guess 4 trillion per second and so on. Assume this trend will continue regardless of speculation that this law may come to an end and it needs to be factored into the formula.
To successfully guess a password, it often only requires 2^n-1 attempts. That needs to be factored into the equation. Please also factor this into the formula.
What I would like is a reusable formula which takes into account the known adversary power of 1 trillion guesses per second as of January 2013 and its future power with regards to Moore's law. I would like to dynamically enter in the total number of password characters and the current date. The formula will return a calculation of how many years this password will be secure from brute force search from that current date.
Apologies if this is the incorrect StackExchange forum, but I think it is in the right place as I am after a correct mathematical formula which I can then turn into a software function. Feel free to move it if that is more appropriate.
Let $t_0$ be the current time in years from January 2013, and $n$ be the number of bits in the password. If $y$ is the number of attempts since the NSA started trying to hack your password, then we have the equation
$$\frac{dy}{dt}=10^{12}\cdot60\cdot60\cdot24\cdot365\cdot 2^{t/2}=:k\,2^{t/2}.$$
The big number $k$ is for converting the $10^{12}$ attacks-per-second figure into years, and the derivative is because this is measuring the accumulation of attacks done.
Now, we want to find the number of attacks that occur between now and some future time $t_0+t$, which we obtain by integrating this:
$$y(t_0+t)=\int_{t_0}^{t_0+t}k\,2^{x/2}\,dx=\left.\frac{2k}{\log 2}2^{x/2}\right|_{t_0}^{t_0+t}=\frac{2k}{\log 2}2^{t_0/2}(2^{t/2}-1).$$
Now, we are interested in finding when this number of attacks exceeds the maximum that our password can tolerate, which is roughly $2^n$ (I'm ignoring the $-1$ because the difference is negligible compared to other approximations of the model):
$$y(t_0+t)=2^n\implies2^{t/2}+1=\frac{2^n\log 2}{2k\,2^{t_0/2}}\implies t=2\log_2\left[\frac{2^n\log 2}{2k\,2^{t_0/2}}-1\right].$$
And there is your formula, given inputs $t_0$ and $n$, and the constant $k$. (Edit: I notice I have not factored in the information about keyboard layouts into this analysis, since the "$2^n-1$ attempts" part is already enough to answer the question. If the passwords are not bit strings but instead strings of characters from an alphabet of $95$ symbols, replace $2^n$ with ${95}^n$; nothing else is affected.)
Discussion: Looking at the form of the formula, we can get a feel for the implications of Moore's law in action. The denominator involves factors $k$ and $t_0$ that you can't do much about (we can't choose the era we live in), but $n$ is of course under our control, so it helps to isolate that part. Note that we can rewrite the equation as $t=2\log_2(2^{n+a}-1)$, where $a=\log_2\frac{\log 2}{2k\,2^{t_0/2}}$ is a constant; thus the overall speed of computing can be offset simply by adding a constant amount to your password length.
For large $n$, the $-1$ factor becomes negligible, and we get $t\sim 2\log_2(2^{n+a})=2(n+a)$. Thus the time to break the password goes up by about 2 years for every extra bit in the password. If we are working from a $95$-symbol alphabet, this changes to $t\sim 2\log_2(95^{n+a'})\approx13.1(n+a')$, so that each extra US keyboard character adds 13 years to the password strength.