external storage of SFTP public-key authentication - WeOnlyDo Discussion board

external storage of SFTP public-key authentication (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Dennis Griesser, Friday, February 04, 2005, 03:11 (7231 days ago)

We have used your SFTP component with good results for a couple of years. Our product is written in PowerBuilder. Now we are trying to add public-key authentication. This question concerns use of the WeOnlyDo.Keys object. I'm not up to an actual SFTP yet.

I can instantiate the WeOnlyDo.Keys object in PowerBuilder. I can get it to Generate() keys. I can use Save() to export the keys.

But I want to do my own key storage by accessing the PrivateKey(KeyType) property.

Question #1 - The PublicKey property is read-only. If I assign a value to PrivateKey, will the corresponding PublicKey be generated? If not, how are we supposed to persist keys across sessions (without writing to a file)?

Question #2 - I am unable to get meaningful data from PrivateKey. If I Generate(DSA) and examine PrivateKey(RSA), I get an exception (good; that particular key type has no value). If I Generate(DSA) and examine PrivateKey(DSA), I get back a string (good) that has zero-length (bad).

[The environment is PowerBuilder 8.0.2, using your latest trial download of wodSFTP.exe, 2.2.1.]

Re: external storage of SFTP public-key authentica

by Dennis Griesser, Friday, February 04, 2005, 19:30 (7231 days ago) @ Dennis Griesser

I might have part of the answer to my own questions.

PowerBuilder may be storing strings in memory with null termination. If so, the first time it hits a zero, it thinks the string is over. And the (binary) key is likely to have a zero sooner or later, making string manipulation useless.

I have tried the PrivateKeyData(KeyType) property, and it returns a blob with nonzero length.

If you agree, this leaves only a modified form of Question #1 - If I assign a value to PrivateKeyData, will the corresponding PublicKey be generated? If not, how are we supposed to persist keys across sessions (without writing to a file)?

Re: external storage of SFTP public-key authentica

by wodSupport, Saturday, February 05, 2005, 11:08 (7230 days ago) @ Dennis Griesser

Dennis,

hi. Forget about public key - you need it only to paste to a server (to a corresponding file), and you don't need to keep it locally. Anyway, you can always derive it from the private key.

As for storing private key, yes, you're right, result of PrivateKey property returns raw data that may cause problems in some environments. But, latest version of wodKeys does allow you to specify PEM format of the key (base64 encoded) instead od raw data. So, if you need to keep it somehow in your app, you could Save it once, and then pass saved value (this will be base64 data, easy to keep in your app) to Load method.