I have implementation of a custom STS. After being authenticated and redirected but before the page was loaded I would receive this error:
[CryptographicException: Digest verification failed for Reference '#_8e0aea1a-713d-4536-8fac-a768073395e9'.]
The reference number would change every time I tried.
I eventually found out that the claims, I had loaded from the database, had carriage return line feeds. Once I replaced those I had no more issues.