Solution

ID: past-exam-of-the-computer-science-course-of-the-university-of-oxford/2015/computer-security/1/d/i/solution

Avoid constructing the huge integers explicitly. Maintain and , computing after each step.
In case (1), the nontrivial greatest common divisor is one of the prime factors . Divide by it, compute with the extended Euclidean algorithm, and return .
In case (2), . The preceding value satisfies . Cubing is a bijection on the residue classes modulo , so there is only one such cube root, namely the original plaintext . Therefore
For , the preceding value is ; a fixed point is its own plaintext. Keeping the previous iterate makes the recovery immediate once the RSA cycling attack succeeds.

New to topics? Read the docs here!