1. Roland Smith
  2. PowerBuilder
  3. Thursday, 1 August 2024 13:49 PM UTC

PB 2019 Build 2170

I'm trying to generate RSA public/private keys which are stored in the database. They are then used by our C# .Net web application.

The C# developer I am working with tells me the public key from the below code is X.509 formatted. He is unsure what the private key format is. He says that X.509 is not the usual format.

What is the format of the private key? Has anyone been able to do this using CryptoAPI or BCrypt Windows API functions?

CrypterObject lnv_CrypterObject
CoderObject lnv_CoderObject

Integer li_return
Blob lblb_privKey, lblb_pubKey

lnv_CrypterObject = Create CrypterObject
lnv_CoderObject = Create CoderObject

// Generate the keys
li_return = lnv_CrypterObject.AsymmetricGenerateKey(RSA!, 2048, lblb_privKey, lblb_pubKey)
If li_return = 1 Then
	// convert blobs to Base64 strings
	as_privKey = lnv_CoderObject.Base64Encode(lblb_privKey)
	as_pubKey  = lnv_CoderObject.Base64Encode(lblb_pubKey)
Else
	Return False
End If

Return True
Who is viewing this page
Mark Goldsmith Accepted Answer Pending Moderation
  1. Thursday, 1 August 2024 19:29 PM UTC
  2. PowerBuilder
  3. # 1

Hi Roland,

I generated a set of keys and plugged the private key into an online tool that is supposed to be able to determine the format, among other things. Not sure how accurate it is but it shows the private key formatted as PKCS#8 (and confirmed the public key as X.509).

I'm thinking Appeon engineering should be able to confirm this or provide the format that is actually being used.

HTH...regards,

Mark

Comment
  1. Roland Smith
  2. Thursday, 1 August 2024 20:55 PM UTC
They should add an option so we can choose the format.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 1 August 2024 15:18 PM UTC
  2. PowerBuilder
  3. # 2

Hi Roland;

  Typically RSA keys are typically 1024- or 2048-bits long. So I am not sure why you are trying to convert what normally be string within the blob to Base64 when the blob would be a "bit" array after the AsymmetricGenerateKey method call?

Regards .. Chris

Comment
  1. Roland Smith
  2. Thursday, 1 August 2024 17:04 PM UTC
Because the C# code developer wants it that way.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 1 August 2024 18:41 PM UTC
ROFLMAO .. yep, been there, had to do that. ;-)
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.