{
glb_ctx *cc = (glb_ctx*) ctx;
creds *crd = (creds*) cred;
- int ret = 0;
mech_glb_ctx *m_ctx = (mech_glb_ctx *)cc->mech_ctx;
if (!ctx)
}
}
- if (crd->c_key) {
- if ((ret = pkey_dup(&m_ctx->cert_key->key, crd->c_key))) {
- return ret;
- }
- }
+ if (crd->c_key)
+ pkey_dup(&m_ctx->cert_key->key, crd->c_key);
if (crd->c_cert)
m_ctx->cert_key->cert = X509_dup(crd->c_cert);
return 0;
}
-int pkey_dup(EVP_PKEY **to, EVP_PKEY *from)
+void pkey_dup(EVP_PKEY **to, EVP_PKEY *from)
{
CRYPTO_add(&from->references,1,CRYPTO_LOCK_EVP_PKEY);
*to = from;
- return 0;
}
canl_err_code CANL_CALLCONV
}
canl_err_code CANL_CALLCONV
+canl_cred_save_priv_key(canl_ctx ctx, canl_cred cred, EVP_PKEY **pkey)
+{
+ glb_ctx *cc = (glb_ctx*) ctx;
+ creds *crd = (creds*) cred;
+ int ret = 0;
+
+ if (!ctx)
+ return EINVAL;
+
+ if (!cred)
+ return set_error(cc, EINVAL, POSIX_ERROR, "Cred. handler"
+ " not initialized" );
+ if (!pkey)
+ return set_error(cc, EINVAL, POSIX_ERROR, "Invalid private key"
+ " parameter");
+ pkey_dup(pkey, crd->c_key);
+
+ return ret;
+}
+
+canl_err_code CANL_CALLCONV
canl_cred_load_chain(canl_ctx ctx, canl_cred cred, STACK_OF(X509) *cert_stack)
{
glb_ctx *cc = (glb_ctx*) ctx;
canl_err_code CANL_CALLCONV
canl_cred_load_priv_key_file(canl_ctx, canl_cred, const char *,
canl_password_callback, void *);
+canl_err_code CANL_CALLCONV
+canl_cred_save_priv_key(canl_ctx, canl_cred, EVP_PKEY **);
canl_err_code CANL_CALLCONV
canl_cred_load_priv_key_pkcs11(canl_ctx, canl_cred, const char *,
int set_key_file(glb_ctx *cc, EVP_PKEY **to, const char *key);
int set_cert_file(glb_ctx *cc, X509 **to, const char *cert);
int set_cert_chain_file(glb_ctx *cc, STACK_OF(X509) **to, const char *cert);
-int pkey_dup(EVP_PKEY **to, EVP_PKEY *from);
+void pkey_dup(EVP_PKEY **to, EVP_PKEY *from);
#endif