Safe Computing: Authentication, Encryption and Attacks
AP Computer Science Principles · Unit 5 — Impact of Computing
Proving who you are
Authentication measures protect devices and information from unauthorized access. A strong password is easy for the user to remember but hard for someone else to guess. Its strength comes from the size of the key space: with an alphabet of $a$ symbols and length $n$ there are $a^n$ possible passwords, so a brute-force attacker making $r$ guesses per second needs up to $a^n/r$ seconds. Length matters most, because it is the exponent.
Multifactor authentication (MFA) requires at least two of three different kinds of evidence: something you know (password, PIN, security question), something you have (phone receiving a code, hardware key), something you are (fingerprint, face). Two pieces of the same kind, such as a password plus a security question, are not multifactor. MFA means a stolen password alone is not enough to log in.
MFA is not invulnerable. A fake login page can ask for both the password and the current one-time code and pass them to the real site within seconds, before the code expires. Hardware keys that check the website's real address resist this; codes typed by the user do not.
Encryption and common attacks
Encryption is the process of encoding data to prevent unauthorized access; decryption reverses it. In symmetric encryption one key both encrypts and decrypts, as in a shift (Caesar) cipher where every letter moves forward $k$ places and decrypting moves back $k$. Its problem is distribution: the two parties must already share the secret key. Public key encryption pairs a key that is published for everyone with a private key held only by the recipient. Anyone can encrypt a message with Bob's public key; only Bob's private key decrypts it. Certificate authorities issue digital certificates that vouch that a public key really belongs to a particular website, which is how a browser knows it is talking to the real bank.
Common attacks: malware is software intended to damage a system or gain unauthorized access; a computer virus attaches itself to legitimate programs and spreads; keylogging records keystrokes to capture passwords. Phishing tricks a user into giving personal information, often through a look-alike email or website. A rogue access point is a wireless network set up without authorization, often named like a legitimate one, that lets its owner intercept unencrypted traffic. Defenses include keeping software updated, checking a site's address and certificate before entering credentials, using encrypted connections (HTTPS), and MFA.
Worked example: độ dài hay bảng ký tự
Kẻ tấn công thử $10^9$ mật khẩu mỗi giây. So sánh thời gian vét cạn tối đa của: (1) mật khẩu 8 ký tự chỉ gồm chữ thường; (2) mật khẩu 8 ký tự gồm chữ thường, chữ hoa và chữ số. Rồi cho biết thêm 2 ký tự chữ thường vào mật khẩu (1) có tác dụng ra sao.
Solution
(1) Bảng 26 ký tự: $26^8\approx 2{.}09\times 10^{11}$ mật khẩu. Thời gian $\dfrac{2{.}09\times 10^{11}}{10^9}\approx 209$ giây, chưa tới 4 phút.
(2) Bảng $26+26+10=62$ ký tự: $62^8\approx 2{.}18\times 10^{14}$. Thời gian $\approx 2{.}18\times 10^{5}$ giây, khoảng $2{.}5$ ngày — gấp khoảng $\left(62/26\right)^8\approx 1045$ lần.
Thêm 2 chữ thường vào (1): $26^{10}\approx 1{.}41\times 10^{14}$, khoảng $1{.}6$ ngày — gấp $26^2=676$ lần chỉ nhờ thêm hai ký tự dễ nhớ. Độ dài nằm ở số mũ nên tăng độ dài thường là cách rẻ nhất để làm mật khẩu khó dò. Dù vậy, không độ dài nào cứu được mật khẩu đã bị keylogger ghi lại hay bị gõ vào trang phishing — đó là việc của MFA.