Creating pkcs7 signature with SHA256 RRS feed

  • Question

  • I am trying to compute a signature this way:

    System.Security.Cryptography.Pkcs.ContentInfo contentInfo = new System.Security.Cryptography.Pkcs.ContentInfo(inputBytes);
    SignedCms signedCms = new SignedCms(contentInfo);
    CmsSigner cmsSigner = new CmsSigner(cert);
    cmsSigner.DigestAlgorithm = new Oid("");
    signedCms.ComputeSignature(cmsSigner, false);
    byte[] enc = signedCms.Encode();

    This works fine, because the Oid is for SHA1, but if I replace it with OID for SHA256:


    it will wail with "Invalid algorithm specified".

    Any ideas? 

    I am using windows xp sp3 .NET 3.5 sp1


    • Moved by SamAgain Wednesday, September 29, 2010 3:20 AM not CLR specific (From:Common Language Runtime)
    Monday, September 27, 2010 2:15 PM