|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sign hash with public keyI´ve developed a page to do a Asymmetric Cryptography with Digital Certificate, but something doesn´t work. I have a URL like that : "FIELD1=000000000000001&FIELD2=0000&FIELD3=AAAAA&SIGN=5705236f1f462afe65f6704d24c8e1359fead41e42c460d........" When I receive it, I have to get the Digital Signature of all field and after compare with the SIGN field. But I can´t cryptography the field using "SIGNHASH", because my Certificate File (CER) haven´t the Private Key, and the same time, I can´t use the VERIFYHASH, because I don´t know how convert the SIGN value to a array of bytes. The code : 'TextBox1.text = ClearText 'TextBox2.text = SIGN Dim ClearTextBytes As Byte() = Encoding.UTF8.GetBytes(TextBox1.Text) Dim AlgHash As HashAlgorithm = HashAlgorithm.Create("SHA1") Dim hash As Byte() = AlgHash.ComputeHash(ClearTextBytes) Dim Cert As X509Certificate = X509Certificate.CreateCertFromFile("C:\CertificateFile.cer") Dim sign As New RSACryptoServiceProvider sign.ImportParameters(Cert.PublicKey.ExportParameters(False)) Dim b As Byte Dim resultHexString As String MsgBox(sign.VerifyHash(hash, CryptoConfig.MapNameToOID("SHA1"), "????I have to convert, but I don´t know how ????")) Thank you !! Daniel Godoy You can encrypt with public key and decrypt with private.
You can sign with private key and verify with public. Tha'ts one of the reasons it was called ASYMMETRIC cryptography. -Valery. http://www.harper.no/valery Daniel Godoy wrote: Show quoteHide quote > Hello all ! > > I´ve developed a page to do a Asymmetric Cryptography with Digital > Certificate, but something doesn´t work. > > I have a URL like that : > "FIELD1=000000000000001&FIELD2=0000&FIELD3=AAAAA&SIGN=5705236f1f462afe65f6704d24c8e1359fead41e42c460d........" > > When I receive it, I have to get the Digital Signature of all field and > after compare with the SIGN field. But I can´t cryptography the field using > "SIGNHASH", because my Certificate File (CER) haven´t the Private Key, and > the same time, I can´t use the VERIFYHASH, because I don´t know how convert > the SIGN value to a array of bytes. > > The code : > 'TextBox1.text = ClearText > > 'TextBox2.text = SIGN > > Dim ClearTextBytes As Byte() = Encoding.UTF8.GetBytes(TextBox1.Text) > > Dim AlgHash As HashAlgorithm = HashAlgorithm.Create("SHA1") > > Dim hash As Byte() = AlgHash.ComputeHash(ClearTextBytes) > > Dim Cert As X509Certificate = > X509Certificate.CreateCertFromFile("C:\CertificateFile.cer") > > Dim sign As New RSACryptoServiceProvider > > sign.ImportParameters(Cert.PublicKey.ExportParameters(False)) > > Dim b As Byte > > Dim resultHexString As String > > MsgBox(sign.VerifyHash(hash, CryptoConfig.MapNameToOID("SHA1"), "????I have > to convert, but I don´t know how ????")) > > > > Thank you !! > > > > Daniel Godoy
GET the real content of a .p7m file with CAPICOM
Registry Permission Attributes .NET 2.0: SetAccessControl wipe out inherited ACEs deserialize and "medium trust" Active Directory User Creation Issues PKI in .net Program EnvironmentPermission ASN1 unexpected end of data Runtime Security Policy Question Events over remoting and security problem, related/not related, I don't know |
|||||||||||||||||||||||