Search code examples
delphilockbox-3

How to generate RSA keypair with LockBox


I would like to generate RSA keyPair using delphi and LockBox3 library , actually I know how to do it using either a TSignatory or TCodec , but the pairing device that I comunicate with accept only X509 Spec where the generated key by lockbox is assumed as an Invalid key Format , so how can I do it with lockBox are there is another way to achieve that !! thanks in advance


Solution

  • TP-Lockbox3 TSignatory component uses the OpenSSL library to generate keys (Lockbox also has a native RSA component that doesnt rely on OpenSSL, but that is a different story). The OpenSSL library is named libeay32.dll or libeay64.dll according to platform.

    TSignatory calls the Open SSL function RSA_generate_key_ex() to generate a PKCS#1 Key in PEM format. This is also referred to as "SSLeay format" or "traditional format". Also refer.

    The contents of this key will end in either:

    '-----END RSA PRIVATE KEY-----'
    

    or...

    '-----END RSA PUBLIC KEY-----'
    

    X509 is a broad umbrella. So the question arises, What encoding formats does your device accept?

    If you need the more modern PKCS#8, then you could try conversion.