Password Callback
The password callback is invoked when an attempt is made to construct a key from encrypted data. The password callback supplies the password with which the key was encrypted. The signature of the callback function is:
 
extern “C” int passwordCallback(char *buffer, int bufLen, int flag);
The following table describes the parameters and their definitions.
Parameter
Definition
char *buffer
The buffer into which the null terminated password string must be copied.
int bufLen
The maximum length of buffer. The length of the password plus the null terminator must be less than or equal to this number.
int flag
The flag parameter can be safely ignored, but it must be specified in the signature of the callback.The password callback is also called by the cryptographic library when the cryptographic library tries to write a key. In this case, the flag parameter is 1. The Secure Sockets package does not support writing keys, so this parameter is not needed.
The password callback function must return the length of the password.
If the password copied into buffer is incorrect, the exception RWUnableToReadPrivateKeyError is thrown.
For more information, see the example in examples\secsock\manual\InlineEncryptedKeyServer.cpp.