Hi all,

I had a little play with the new Crypto functions to export DER. With my test the Private Key exported was easy to use outside but I had some trouble with the public key. Some experimentation revealed that this is a DER encoded RSA Public Key, not the default public key openssl rsa spits out. To make complete the confusion, the openssl version on OSX 10.8 seems to be unable to deal with this format. To ease the key exchange with 3rd parties, I wrote a little function to convert the DER to PEM which is more easy to understand. If anybody interested, here is the code:

[code]Protected Function PEMEncodePublicKey(publicKey As String) As String

//the integrated Crypto.DEREncodePublicKey function outputs an MemoryBlock filled with the binaray form of an DER

//encoded RSAPublicKey (not the usual PublicKey OpenSSL exports with -pubout!)

//this method reformat that to PEM which is human readable and makes the unusual format obvious

//this does the same as:

//openssl rsa -inform der -outform pem -RSAPublicKey_out < Crypto.DEREncodePrivateKey

//or more specifically:

//openssl rsa -inform der -RSAPublicKey_in -outform pem -RSAPublicKey_out < Crypto.DEREncodePublicKey

dim result as string

dim DER as MemoryBlock

if Crypto.RSAVerifyKey(publicKey) then

DER = Crypto.DEREncodePublicKey(publicKey)

```
result = "-----BEGIN RSA PUBLIC KEY-----" + EndOfLine
result = result + ReplaceLineEndings(EncodeBase64(DER, 64), EndOfLine) + EndOfLine
result = result + "-----END RSA PUBLIC KEY-----" + EndOfLine
```

end if

return result

End Function

[/code]

hope this saves someone a little trouble.

Tobias