RSA
Source: std/rsa.mw.
Signature verification only (PKCS#1 v1.5 and PSS), with a public exponent and modulus passed as big-endian bytes.
RSA signature verification: PKCS#1 v1.5 (RFC 8017 §8.2) and PSS (§8.1). n and e are big-endian magnitudes. mhash is the already computed digest of the message, produced with hash algorithm alg (see hash.mw).
Functions
Section titled “Functions”rsa_public_op
Section titled “rsa_public_op”fn rsa_public_op(n: *u8, nlen: i64, e: *u8, elen: i64, sig: *u8, siglen: i64, em: *u8) -> boolComputes sig^e mod n into em (exactly k = byte length of n).
rsa_modulus_len
Section titled “rsa_modulus_len”fn rsa_modulus_len(n: *u8, nlen: i64) -> i64rsa_verify_pkcs1
Section titled “rsa_verify_pkcs1”fn rsa_verify_pkcs1(n: *u8, nlen: i64, e: *u8, elen: i64, alg: i64, mhash: *u8, sig: *u8, siglen: i64) -> boolrsa_verify_pss
Section titled “rsa_verify_pss”fn rsa_verify_pss(n: *u8, nlen: i64, e: *u8, elen: i64, alg: i64, mhash: *u8, saltlen: i64, sig: *u8, siglen: i64) -> boolRSASSA-PSS with MGF1 using the same hash, salt length saltlen (TLS 1.3 uses saltlen = hash length).