Is there an algorithm which on input "$(a,p)$" (where $0\leq a<p$ are integers) takes time polynomial in $\log p$ and outputs "NOT PRIME" if $p$ is not prime and otherwise outputs the Legendre symbol $(a/p)$?
By the AKS primality test, it suffices to assume $p$ is prime. I know of two tricks to compute the Legendre symbol: quadratic reciprocity and Euler's criterion. The difficulty with naive application of quadratic reciprocity is that, in the worst case, I am led to factor, but I don't know how to do this efficiently. On the other hand, Euler's criterion naturally leads to an attractive repeated squaring algorithm, but the final multiplications are between integers of length at least $O(p)$.
Here's a related question. The accepted answer indicates that quadratic reciprocity should solve my problem, but perhaps that answer implicitly uses a factoring oracle. If not, I would love a reference that shows "the complexity of the usual computation with the laws of quadratic reciprocity is logarithmic in $p$."