Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Verifying certificate signature using Bouncycastle (J2ME) (http://www.velocityreviews.com/forums/t237124-verifying-certificate-signature-using-bouncycastle-j2me.html)

nx 05-03-2006 11:44 AM

Verifying certificate signature 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 (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.getPublic Key());
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 05-03-2006 03:07 PM

Re: Verifying certificate signature using Bouncycastle (J2ME)
 
Nobody knows? :'(
Please help! :)



All times are GMT. The time now is 02:03 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57