Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Certificate signature verification using Bouncycastle (J2ME)
Good day. I have a problem again. I want to verify signature using this
code:

// there is Base64.decoded byte array in tmp..
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 decoded??
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 plz.
I also tried to sign TBS using the private key but signatures didn't
match anyway.


Report this thread to moderator Post Follow-up to this message
Old Post
nx
05-03-06 03:03 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Security archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:11 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.