-
Mike Shantz
- PowerBuilder
- Wednesday, 21 May 2025 04:35 PM UTC
After a bunch of experimentation I see that CrypterObject.AsymmetricSign
Uses a SHA1 hash algorithm and PKCS1 padding.
SHA1 is considered a "compromised algorithm" (see hashicorp vault's documentation), and PSS is the considered the preferred padding option.
Is there any way to at least use a secure hash algorithm?
I see that many more hash algorithms are available on CrypterObject
(eg SHA), and SymmetricEncrypt
supports a padding option, so it seems like this kind of thing should be available, or perhaps be coming in a future version. We're on 2022, and my team just started looking into an upgrade to 2025. I'm really hoping there's just some undocumented feature someone can point me at! (Maybe the runtime matters? we're stuck back on 22.2.0.3391 for the moment)
For reference, I've generated an private key externally, and loaded it as described in this question: AsymmetricSign with external RSA key PB17
If I do the following in PowerBuilder:
Blob lblb_ppk, lblb_testdata, lblb_sig
String ls_ppk, ls_sig
CrypterObject lnv_crypter
CoderObject lnv_coder
lnv_crypter = create CrypterObject
lnv_coder = create CoderObject
ls_ppk = "..." // external generated PKCS#8 format key
lblb_ppk = lnv_coder.Base64Decode(ls_ppk)
lblb_testdata = Blob("Test Rsa", EncodingUTF8!)
lblb_sig = lnv_crypter.asymmetricsign(RSA!, lblb_testdata, lblb_ppk)
ls_sig = lnv_coder.base64encode(lblb_sig)
then the result in ls_sig
matches the output if I do this via openssl
(testrsa.pem contains the original key)
echo -n "Test Rsa" > testrsa.txt
openssl dgst -sha1 -sigopt rsa_padding_mode:pkcs1 -sign testrsa.pem testrsa.txt | base64
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.