(C) DSA Public Key PEM to DER Conversion
Converts a DSA public key from PEM format to DER.
#include <C_CkDsa.h>
void ChilkatSample(void)
{
HCkDsa dsa;
const char *pemPublicKey;
BOOL success;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
dsa = CkDsa_Create();
// Load a PEM public key.
pemPublicKey = CkDsa_loadText(dsa,"dsa_pub.pem");
// Import the public key PEM into the DSA object.
success = CkDsa_FromPublicPem(dsa,pemPublicKey);
if (success != TRUE) {
printf("%s\n",CkDsa_lastErrorText(dsa));
CkDsa_Dispose(dsa);
return;
}
// Write it out as a DER file:
success = CkDsa_ToPublicDerFile(dsa,"dsa_pub.der");
if (success != TRUE) {
printf("%s\n",CkDsa_lastErrorText(dsa));
CkDsa_Dispose(dsa);
return;
}
printf("Finished!\n");
CkDsa_Dispose(dsa);
}
|