locked
PDF signature , web asp.net RRS feed

  • Question

  • User1286969098 posted
    This code signing sha1  I need to sign me in sha256 , try to change , 
    SHA1CryptoService by SHA256CryptoService . But I was unable to install.

    Does anyone know how to do it. Thank you,Laughing Visual Studio 2013 C #


    objSA.SignDate = DateTime.Now;
    objSA.SetCrypto(null, objChain, null, null);
    objSA.Reason = Reason;
    objSA.Location = Location;
    objSA.Acro6Layers = true;
    objSA.Render = PdfSignatureAppearance.SignatureRender.NameAndDescription;
    PdfSignature objSignature = new PdfSignature(PdfName.ADOBE_PPKMS, PdfName.ADBE_PKCS7_SHA1);
    objSignature.Date = new PdfDate(objSA.SignDate);
    objSignature.Name = PdfPKCS7.GetSubjectFields(objChain[0]).GetField("CN");
    if (objSA.Reason != null)
    objSignature.Reason = objSA.Reason;
    if (objSA.Location != null)
    objSignature.Location = objSA.Location;
    objSA.CryptoDictionary = objSignature;
    int intCSize = 4000;
    Hashtable objTable = new Hashtable();
    objTable[PdfName.CONTENTS] = intCSize * 2 + 2;
    objSA.PreClose(objTable);

    HashAlgorithm objSHA256 = new SHA1CryptoServiceProvider();

    Stream objStream = objSA.RangeStream;
    int intRead = 0;
    byte[] bytBuffer = new byte[8192];
    while ((intRead = objStream.Read(bytBuffer, 0, 8192)) > 0)
    objSHA256.TransformBlock(bytBuffer, 0, intRead, bytBuffer, 0);
    objSHA256.TransformFinalBlock(bytBuffer, 0, 0);

    byte[] bytPK = SignMsg(objSHA256.Hash, Certificate, false);
    byte[] bytOut = new byte[intCSize];

     
    Monday, September 12, 2016 3:53 PM

All replies

  • User753101303 posted

    Hi,

    I was unable to install

    Instead always tell what happens. According to the doc it requires .NET 3.5. Could it be that you have a compile time error because your app is targeting .NET 2.0 ? (knowing the error message would help to confirm or not this first idea or would have shown directly that this class is not available from your code for some reason).

    Tuesday, September 13, 2016 7:40 AM