In the end I achieved the needed result using the Bouncy Castle library for c# because .Net Framework does not have an easy way to do it. https://github.com/bcgit/bc-csharp/discussions/592