Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Verify a signature (using Bouncycastle) that has been made with OpenSSL

843811Jun 11 2005 — edited Nov 24 2005
hi!

i got a problem with the signature...
first a signature is created with php (OpenSSL)

then it�s send to a java application...

i got the problem that i can�t decrypt the encrypted signature right
(but i know that iam using the right key)...

here is the php code:
$fp = fopen("sec\\key.pem", "r");
$priv_key = fread($fp, 8192);
fclose($fp);
$pkeyid = openssl_get_privatekey($priv_key, "test");

$msg = "2005-06-10T11:43:14.0Z181010";
openssl_sign($msg , $signature, $pkeyid);
and now the java code:
Security.addProvider(new BouncyCastleProvider());
Cipher encrypt = Cipher.getInstance("RSA/NONE/PKCS1PADDING", "BC");

encrypt.init(Cipher.DECRYPT_MODE, cert);
encrypt.update(signature);
byte[] signdecr = encrypt.doFinal();
iam getting 35 byte instead of 20 (SHA1 hashing)

i hope someone can tell me what iam doing wrong

iam thankfull for everyone that wants to help

have a nice day
Extol
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 22 2005
Added on Jun 11 2005
3 comments
1,190 views