Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Verifying certificate signature using Bouncycastle (J2ME)

Thread view: 
nx - 03 May 2006 12:44 GMT
Good day. I have a problem again. I want to verify signature using this
code:

       // there is Base64.decoded byte array in tmp (represents
certificate)
       ASN1InputStream a = new ASN1InputStream(tmp);
       DERObject obj = a.readObject();
       ASN1Sequence seq = (ASN1Sequence)obj;
       a.close();

       X509CertificateStructure cert = new
X509CertificateStructure(seq);

       // Getting the signature. It's correct
       byte[] signature = cert.getSignature().getBytes();

       // Getting pub key. It's correct too
       SubjectPublicKeyInfo spki = cert.getSubjectPublicKeyInfo();
       RSAPublicKeyStructure rsapub = new
RSAPublicKeyStructure((ASN1Sequence)spki.getPublicKey());
       RSAKeyParameters pub = new RSAKeyParameters(false,
rsapub.getModulus(), rsapub.getPublicExponent());

       // Getting "to be signed" structure
       TBSCertificateStructure tbs = cert.getTBSCertificate();

       // !!!!!
       // Maybe TBS structure NOT correctly encoded??
       byte[] obg = tbs.getEncoded();

       RSAEngine engine = new RSAEngine();
       MD5Digest digest = new MD5Digest();

       PSSSigner signer = new PSSSigner(engine, digest, 0);
       signer.init(false, pub);

       signer.update(obg, 0, obg.length);
       boolean istrue = signer.verifySignature(signature);

Signatures doesn't match. i've got istrue = FALSE as result... What's
wrong? Help please...
I also tried to sign TBS using the private key but signatures didn't
match anyway.
nx - 03 May 2006 16:07 GMT
Nobody knows? :'(
Please help! :)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.