0

Any success in implementing SHA1withDSA signature with PHP? A failure reported here.

PKCS8EncodedKeySpec prvSpec = new PKCS8EncodedKeySpec(prvKeyBytes);
KeyFactory keyFactory = KeyFactory.getInstance("DSA");
PrivateKey prvKey = keyFactory.generatePrivate(prvSpec);
Signature sig = Signature.getInstance("SHA1withDSA");
sig.initSign(prvKey);
sig.update(text);
byte[] result = sig.sign();
Mohsen
  • 3,512
  • 3
  • 38
  • 66

1 Answers1

1

You are after the PHP OpenSSL extension.

Specifically, load the private key with openssl_pkey_get_private() and create the signature with openssl_sign(), passing OPENSSL_ALGO_DSS1 as $signature_alg.

caf
  • 233,326
  • 40
  • 323
  • 462
  • I cannot verify at the moment that this works or not. I accept this, as it seems reasonable. Thank you caf! – Mohsen Aug 30 '10 at 19:03