Reading — step 1 of 5
Read
~1 min readSigning & Verification
RS256: RSA Asymmetric Signing
RS256 = RSA-Signature with SHA-256 (PKCS#1 v1.5).
Asymmetric:
- Private key signs.
- Public key verifies.
The verifier doesn't need to know the secret. This is critical for:
- OIDC / OAuth providers: Google's public key is public; anyone can verify Google-signed JWTs without being able to forge them.
- Microservices: a central auth service signs; many downstream services verify with public keys.
Algorithm:
hash = SHA-256(signing_input)
padded = PKCS#1_v1_5_pad(hash) # add ASN.1 prefix + 0xFF padding
signature = padded ^ private_key_d (mod n) # RSA encrypt with private key
Verifier:
recovered = signature ^ public_key_e (mod n)
expected = PKCS#1_v1_5_pad(SHA-256(signing_input))
return recovered == expected
Key sizes: 2048-bit minimum (256 bytes), 4096-bit recommended for new keys. Generated keys come as PEM files; runtime parses to (n, e, d) integers.
For this lesson we model the signing input + comparison; full RSA implementation (Miller-Rabin primes, modular exponentiation) would be a course on its own.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…