public byte[] PssSign(byte[] m, TpmAlgId hashAlg) { // The TPM uses the maximum salt length int defaultPssSaltLength = 0; // KeySize - CryptoLib.DigestSize(hashAlg) - 1 - 1; // Encode byte[] em = CryptoEncoders.PssEncode(m, hashAlg, defaultPssSaltLength, NumBits - 1); BigInteger message = FromBigEndian(em); // Sign BigInteger sig = BigInteger.ModPow(message, D, N); byte[] signature = ToBigEndian(sig, KeySize); return(signature); }