|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dotnet 2.0 PCKS CheckSignature ErrorI am extracting a pkcs7-signature part from a s/mime message. When I verifiy the signature I get a CryptographicException "The hash value is not correct" . I am using CheckSignature(true), therefore it should verify signature only and not worry about the certificates. This message was generated from webmethods by our customer. Any idea where the problem could be. I have checked the following. The decoded object has 3 certificates in the chain. It has 1 signerinfo object However the SignedCms.ContetInfo has a content of zero bytes. I am leaning to this as the issue. But what could cause the content to be zero. The sender of this message has successfully sent this type of messages to others. I am assuming the input s/mime data to be correct. Could there be any issues decoding WebMethods generated PCKS #7 object in dot net 2.0? Any inputs will be greatly appreciated. - Vijay Any chance you could post an example message that doesn't work? The ASCII
s/mime body part would be the easiest to put on the newsgroup. Joe K. -- Show quoteHide quoteJoe Kaplan-MS MVP Directory Services Programming Co-author of "The .NET Developer's Guide to Directory Services Programming" http://www.directoryprogramming.net -- <vij***@entcomm.com> wrote in message news:1153784668.338580.133400@i42g2000cwa.googlegroups.com... > Hello, > > I am extracting a pkcs7-signature part from a s/mime message. When I > verifiy the signature I get a CryptographicException "The hash value is > not correct" . > > I am using CheckSignature(true), therefore it should verify signature > only and not worry about the certificates. > > This message was generated from webmethods by our customer. > Any idea where the problem could be. > > I have checked the following. > The decoded object has 3 certificates in the chain. > It has 1 signerinfo object > However the SignedCms.ContetInfo has a content of zero bytes. > > I am leaning to this as the issue. But what could cause the content to > be zero. The sender of this message has successfully sent this type of > messages to others. I am assuming the input s/mime data to be correct. > > Could there be any issues decoding WebMethods generated PCKS #7 object > in dot net 2.0? > > Any inputs will be greatly appreciated. > > - Vijay > I am not able to post the mime data in this group. I am getting the
error We were unable to post your message Binary posts not allowed in non-binary groups. If you believe this is an error, please mail groups-supp***@google.com. I will try to post from outtook express news reader. - Vijay Joe Kaplan (MVP - ADSI) wrote: Show quoteHide quote > Any chance you could post an example message that doesn't work? The ASCII > s/mime body part would be the easiest to put on the newsgroup. > > Joe K. > > -- > Joe Kaplan-MS MVP Directory Services Programming > Co-author of "The .NET Developer's Guide to Directory Services Programming" > http://www.directoryprogramming.net > -- > <vij***@entcomm.com> wrote in message > news:1153784668.338580.133400@i42g2000cwa.googlegroups.com... > > Hello, > > > > I am extracting a pkcs7-signature part from a s/mime message. When I > > verifiy the signature I get a CryptographicException "The hash value is > > not correct" . > > > > I am using CheckSignature(true), therefore it should verify signature > > only and not worry about the certificates. > > > > This message was generated from webmethods by our customer. > > Any idea where the problem could be. > > > > I have checked the following. > > The decoded object has 3 certificates in the chain. > > It has 1 signerinfo object > > However the SignedCms.ContetInfo has a content of zero bytes. > > > > I am leaning to this as the issue. But what could cause the content to > > be zero. The sender of this message has successfully sent this type of > > messages to others. I am assuming the input s/mime data to be correct. > > > > Could there be any issues decoding WebMethods generated PCKS #7 object > > in dot net 2.0? > > > > Any inputs will be greatly appreciated. > > > > - Vijay > > I have tried several methods to post, but failed. Here is the link to
download the file http://www.entcomm.com/internal/~vijay/pkcs7.txt I have continued my debugging and have found the following info: Since SignedCms.contentInfo has a length of zero bytes, the sender of the message has not included the digtest into this message. We have to compute it from the mime message and pass to the SignedCms object instance. Something like: Oid dataOid = new Oid("1.2.840.113549.1.7.1"); ContentInfo contentInfo = new ContentInfo(dataOid, testHashData); SignedCms verifyCms = new SignedCms(contentInfo, true); However this failed with the same error. But the computed digest is in the right place in SignedCms object and its contentInfo shows the correct length. Secondly, Just to test, I navigated into the SignedCms.SignerInfos, Got the message digest ("1.2.840.113549.1.9.4" Pkcs9MessageDigestData) from signedattribtues collection and tried passing the digestdata toSignedCms object instance. byte[] testHashData = {112, 47, 42, 138, 253, 109, 28, 29, 6, 67, 203, 126, 126, 11, 165, 35, 191, 180, 127, 69 }; Oid dataOid = new Oid("1.2.840.113549.1.7.1"); ContentInfo contentInfo = new ContentInfo(dataOid, testHashData); SignedCms verifyCms = new SignedCms(contentInfo, true); This also failed with the same error "The hash value is not correct". I'm getting the same results as you are. There is no content data in the
message and the signature validation fails with the same message you are getting. Interestingly, the CheckHash method succeeds, but I'm not sure what that implies. I was under the impression that if you have a signed CMS message and the signature isn't detached, the data was supposed to be in the content. Signed messages with 0 length content data are sometimes used for providing a certificate with chain and crypto capabilities to a remote party. The signature on the message is usually valid though. I'm not sure what to tell you. It would be nice if there was a way to see the computed hash value that is being generated. The signed attributes seem to contain the expected value. Maybe someone else knows what's going on. Joe K. -- Show quoteHide quoteJoe Kaplan-MS MVP Directory Services Programming Co-author of "The .NET Developer's Guide to Directory Services Programming" http://www.directoryprogramming.net -- <vij***@entcomm.com> wrote in message news:1153794781.971542.70490@m79g2000cwm.googlegroups.com... >I have tried several methods to post, but failed. Here is the link to > download the file > http://www.entcomm.com/internal/~vijay/pkcs7.txt > > I have continued my debugging and have found the following info: > Since SignedCms.contentInfo has a length of zero bytes, the sender of > the message has not included the digtest into this message. We have to > compute it from the mime message and pass to the SignedCms object > instance. > > Something like: > Oid dataOid = new Oid("1.2.840.113549.1.7.1"); > ContentInfo contentInfo = new ContentInfo(dataOid, > testHashData); > SignedCms verifyCms = new SignedCms(contentInfo, > true); > > However this failed with the same error. But the computed digest is in > the right place in SignedCms object and its contentInfo shows the > correct length. > > Secondly, Just to test, I navigated into the SignedCms.SignerInfos, Got > the message digest ("1.2.840.113549.1.9.4" Pkcs9MessageDigestData) from > signedattribtues collection and tried passing the digestdata > toSignedCms object instance. > > byte[] testHashData = {112, 47, 42, 138, 253, 109, > 28, 29, 6, 67, 203, 126, 126, 11, 165, 35, 191, 180, 127, 69 }; > Oid dataOid = new Oid("1.2.840.113549.1.7.1"); > ContentInfo contentInfo = new ContentInfo(dataOid, > testHashData); > SignedCms verifyCms = new SignedCms(contentInfo, > true); > > This also failed with the same error "The hash value is not correct". > I have solved the problem with microsoft support.
Since PKCS#7/CMS messages from web methods are always detached. Upon receipt of the smime mesage, we have to create a ContentInfo with the data part of the message. Pass the signature part of the message (after base64 decoding; to get ASN.1 encoded PKCS#7 object) to Decode function as shown below: ContentInfo contentInfo = new ContentInfo(<data part of messate>); SignedCms verifyCms = new SignedCms(contentInfo, true); verifyCms.Decode(<base64 decoded signature part of message>); try { verifyCms.CheckSignature(true); } catch(CryptographicException cex) { // signatue check failed. message has to be discarded } The mistake i was doing was not selecting the carriage-return and linefeed (CRLF) characters after the mime boundary. Apparently those bytes were used to compute digital signature by WebMethods. Here are the answers for some of my questions from microsoft developer support person who was helping me ------------- The signed message contains the original hash value. When you verify the signature it will check the hash of the content that you supplied against the original. If that fails it will return "Hash value is not correct". If the hash values match, the signature is then checked. If the verification fails then "Invalid Signature" is returned. This step will most likely succeed unless the signature has been corrupted. "Has value is not correct" is what you will see most of the time when dealing with PKCS#7/CMS signed messages. --------------- Thanks for all Who helped me with this issue. Very interesting. Thanks for following up. I'm glad MS support was able to
resolve this. Joe K. -- Show quoteHide quoteJoe Kaplan-MS MVP Directory Services Programming Co-author of "The .NET Developer's Guide to Directory Services Programming" http://www.directoryprogramming.net -- <vij***@entcomm.com> wrote in message news:1153950671.422677.287660@i3g2000cwc.googlegroups.com... >I have solved the problem with microsoft support. > > Since PKCS#7/CMS messages from web methods are always detached. Upon > receipt of the smime mesage, we have to create a ContentInfo with the > data part of the message. Pass the signature part of the message (after > base64 decoding; to get ASN.1 encoded PKCS#7 object) to Decode function > as shown below: > > ContentInfo contentInfo = new ContentInfo(<data part of > messate>); > SignedCms verifyCms = new SignedCms(contentInfo, true); > verifyCms.Decode(<base64 decoded signature part of > message>); > > try > { > verifyCms.CheckSignature(true); > } > catch(CryptographicException cex) > { > // signatue check failed. message has to be > discarded > } > > The mistake i was doing was not selecting the carriage-return and > linefeed (CRLF) characters after the mime boundary. Apparently those > bytes were used to compute digital signature by WebMethods. > > Here are the answers for some of my questions from microsoft developer > support person who was helping me > > ------------- > The signed message contains the original hash value. When you verify > the signature it will check the hash of the content that you supplied > against the original. If that fails it will return "Hash value is not > correct". > > If the hash values match, the signature is then checked. If the > verification fails then "Invalid Signature" is returned. This step > will > most likely succeed unless the signature has been corrupted. > > "Has value is not correct" is what you will see most of the time when > dealing with PKCS#7/CMS signed messages. > --------------- > > Thanks for all Who helped me with this issue. > Here is the base64 encoded smime data
- Vijay Content-Type: application/pkcs7-signature; name=smime.p7s Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIKbTCCBJ8w ggQIoAMCAQICECwMlwD/x+GuQkMkWw37DLAwDQYJKoZIhvcNAQEFBQAwgboxHzAdBgNVBAoTFlZl cmlTaWduIFRydXN0IE5ldHdvcmsxFzAVBgNVBAsTDlZlcmlTaWduLCBJbmMuMTMwMQYDVQQLEypW ZXJpU2lnbiBJbnRlcm5hdGlvbmFsIFNlcnZlciBDQSAtIENsYXNzIDMxSTBHBgNVBAsTQHd3dy52 ZXJpc2lnbi5jb20vQ1BTIEluY29ycC5ieSBSZWYuIExJQUJJTElUWSBMVEQuKGMpOTcgVmVyaVNp Z24wHhcNMDYwNDA1MDAwMDAwWhcNMDkwNDI4MjM1OTU5WjCBsDELMAkGA1UEBhMCVVMxDjAMBgNV BAgTBVRleGFzMRAwDgYDVQQHFAdIb3VzdG9uMRUwEwYDVQQKFAxCYWtlciBIdWdoZXMxDjAMBgNV BAsUBUJIQlNTMTMwMQYDVQQLFCpUZXJtcyBvZiB1c2UgYXQgd3d3LnZlcmlzaWduLmNvbS9ycGEg KGMpMDUxIzAhBgNVBAMUGmJoaWIyYnRlc3QuYmFrZXJodWdoZXMuY29tMIGfMA0GCSqGSIb3DQEB AQUAA4GNADCBiQKBgQCrEf5XtfteNeZq7TVsFcBW/PvgUJOLhX4fb2c8wEQSs/9zh1Zuj7iQqjF0 Hb32EbUuIDekfAwbxpcveaqXAOl/D8q3DQUF9IUz29hxDjR57KDxaUAZ3q5UZZ6VWI2e6I0DYiI8 C4+6RrXsYQdloO4QWmTDqkJjTB2cGvJAXQ4VOQIDAQABo4IBrDCCAagwCQYDVR0TBAIwADALBgNV HQ8EB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MA4GCCqGSIb3DQMCAgIAgDANBggqhkiG9w0DAgIBQDANBggqhkiG9w0DAgIBKDAHBgUrDgMCBzAN BgkqhkiG9w0BAQEFAASBgBrpUJw6RltOEWVYd8hHTlq5UZnBi1hhyWfz1aMcyjD1HNDOVEyups3P IUREmKgua5abjSgOZ1kcrQqsqmqc0NRpnCwhNmaoJdk38z0BEcu4eZpGQKMb3z9trvG0KZMPyOx/ 5rxcjDbTPaeJZ+aNAn1zwPmDy8cVCbNg4Y15hajDAAAAAAAA Show quoteHide quote "Joe Kaplan (MVP - ADSI)" <joseph.e.kap***@removethis.accenture.com> wrote in message news:OBGL9z3rGHA.4856@TK2MSFTNGP03.phx.gbl... > Any chance you could post an example message that doesn't work? The ASCII > s/mime body part would be the easiest to put on the newsgroup. > > Joe K. > > -- > Joe Kaplan-MS MVP Directory Services Programming > Co-author of "The .NET Developer's Guide to Directory Services > Programming" > http://www.directoryprogramming.net > -- > <vij***@entcomm.com> wrote in message > news:1153784668.338580.133400@i42g2000cwa.googlegroups.com... >> Hello, >> >> I am extracting a pkcs7-signature part from a s/mime message. When I >> verifiy the signature I get a CryptographicException "The hash value is >> not correct" . >> >> I am using CheckSignature(true), therefore it should verify signature >> only and not worry about the certificates. >> >> This message was generated from webmethods by our customer. >> Any idea where the problem could be. >> >> I have checked the following. >> The decoded object has 3 certificates in the chain. >> It has 1 signerinfo object >> However the SignedCms.ContetInfo has a content of zero bytes. >> >> I am leaning to this as the issue. But what could cause the content to >> be zero. The sender of this message has successfully sent this type of >> messages to others. I am assuming the input s/mime data to be correct. >> >> Could there be any issues decoding WebMethods generated PCKS #7 object >> in dot net 2.0? >> >> Any inputs will be greatly appreciated. >> >> - Vijay >> > >
What permission do I need to add a user to a group? (C#)
Prevent others from using my class libraries Decryptionfailed to bring original text back.... Simple Keyed hash question What's wrong with my encryption function? Newbie Question - Thanks in Advance... random passwords Keyed hash vs Digital signature ???? Security Exception and Windows Vista Form authentication and files that shouldn'y be authenticated |
|||||||||||||||||||||||