You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by mi...@apache.org on 2008/04/02 06:14:27 UTC

svn commit: r643729 - in /webservices/rampart/scratch/c/pkcs/c: include/ src/omxmlsec/ src/util/

Author: milinda
Date: Tue Apr  1 21:14:25 2008
New Revision: 643729

URL: http://svn.apache.org/viewvc?rev=643729&view=rev
Log:
modifiying the key management logic.

Modified:
    webservices/rampart/scratch/c/pkcs/c/include/oxs_asym_ctx.h
    webservices/rampart/scratch/c/pkcs/c/include/oxs_key_mgr.h
    webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h
    webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/asym_ctx.c
    webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/key_mgr.c
    webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/utility.c
    webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c
    webservices/rampart/scratch/c/pkcs/c/src/util/rampart_sec_header_processor.c

Modified: webservices/rampart/scratch/c/pkcs/c/include/oxs_asym_ctx.h
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/include/oxs_asym_ctx.h?rev=643729&r1=643728&r2=643729&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/include/oxs_asym_ctx.h (original)
+++ webservices/rampart/scratch/c/pkcs/c/include/oxs_asym_ctx.h Tue Apr  1 21:14:25 2008
@@ -78,35 +78,6 @@
                       const axutil_env_t *env);
 
     /**
-    *Returns the filename. This is usually the filename of the certificate or the PKCS12 file
-    *@ctx pointer to the OMXMLSec asymmetric context struct
-    *@env pointer to environment struct
-    *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE	
-    */
-    AXIS2_EXTERN axis2_char_t* AXIS2_CALL
-    oxs_asym_ctx_get_file_name(const oxs_asym_ctx_t *ctx,
-                               const axutil_env_t *env);
-
-    /**
-    *@ctx pointer to the OMXMLSec asymmetric context struct
-    *@env pointer to environment struct
-    *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE	
-    */
-    AXIS2_EXTERN axis2_char_t* AXIS2_CALL
-    oxs_asym_ctx_get_pem_buf(const oxs_asym_ctx_t *ctx,
-                             const axutil_env_t *env);
-    /**
-    *Returns the password. Usually the password for the keystore. But alternatively may kepe the
-    *password for the private key in a PEM file.
-    *@ctx pointer to the OMXMLSec asymmetric context struct
-    *@env pointer to environment struct
-    *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE	
-    */
-    AXIS2_EXTERN axis2_char_t* AXIS2_CALL
-    oxs_asym_ctx_get_password(const oxs_asym_ctx_t *ctx,
-                              const axutil_env_t *env);
-
-    /**
     *Get the format. Can be either PEM or PKCS12
     *@ctx pointer to the OMXMLSec asymmetric context struct
     *@env pointer to environment struct
@@ -166,38 +137,6 @@
     oxs_asym_ctx_get_certificate(const oxs_asym_ctx_t *ctx,
                                  const axutil_env_t *env);
 
-    /**
-    * Set the file name. May be a PKCS12 file or a X509 certificate in PEM format.
-    *@ctx pointer to the OMXMLSec asymmetric context struct
-    *@env pointer to environment struct
-    *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE	
-    */
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    oxs_asym_ctx_set_file_name(oxs_asym_ctx_t *ctx,
-                               const axutil_env_t *env,
-                               axis2_char_t *file_name);
-    /**
-    *Set the base46 encoded certificate/key.
-    *@ctx pointer to the OMXMLSec asymmetric context struct
-    *@env pointer to environment struct
-    *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE	
-    */
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    oxs_asym_ctx_set_pem_buf(oxs_asym_ctx_t *ctx,
-                             const axutil_env_t *env,
-                             axis2_char_t *pem_buf);
-    /**
-    * Set the password. Usually the password for the keystore. But alternatively may kepe the
-    *password for the private key in a PEM file.
-    *@ctx pointer to the OMXMLSec asymmetric context struct
-    *@env pointer to environment struct
-    *@password the password
-    *@return AXIS2_SUCCESS on success, else AXIS2_FAILURE	
-    */
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    oxs_asym_ctx_set_password(oxs_asym_ctx_t *ctx,
-                              const axutil_env_t *env,
-                              axis2_char_t *password);
     /**
     * Sets the format. Can be either PEM or PKCS12
     *@ctx pointer to the OMXMLSec asymmetric context struct

Modified: webservices/rampart/scratch/c/pkcs/c/include/oxs_key_mgr.h
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/include/oxs_key_mgr.h?rev=643729&r1=643728&r2=643729&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/include/oxs_key_mgr.h (original)
+++ webservices/rampart/scratch/c/pkcs/c/include/oxs_key_mgr.h Tue Apr  1 21:14:25 2008
@@ -48,6 +48,14 @@
 #endif
 
 	typedef struct oxs_key_mgr_t oxs_key_mgr_t;
+	
+	typedef enum  {
+	        OXS_KEY_MGR_FORMAT_UNKNOWN=0,
+	        OXS_KEY_MGR_FORMAT_PEM,
+	        OXS_KEY_MGR_FORMAT_PKCS12
+	}oxs_key_mgr_format_t;
+	
+	    
     /**
      * Loads keys/certificates from a keystore or a PEm file depending on information available in the @ctx
      * @ctx pointer to the OMXMLSec asymmetric encryption context struct
@@ -242,6 +250,29 @@
 		oxs_key_mgr_t *key_mgr,
 		const axutil_env_t *env,
 		axis2_key_type_t type);
+	
+	AXIS2_EXTERN oxs_key_mgr_format_t AXIS2_CALL
+	oxs_key_mgr_get_format(
+		oxs_key_mgr_t *key_mgr,
+		const axutil_env_t *env);
+
+	AXIS2_EXTERN axis2_status_t AXIS2_CALL
+	oxs_key_mgr_set_format(
+		oxs_key_mgr_t *key_mgr,
+		const axutil_env_t *env,
+		oxs_key_mgr_format_t format);
+
+	AXIS2_EXTERN void * AXIS2_CALL
+	oxs_key_mgr_get_pem_buf(
+		oxs_key_mgr_t *key_mgr,
+		const axutil_env_t *env);
+
+	AXIS2_EXTERN axis2_status_t AXIS2_CALL
+	oxs_key_mgr_set_pem_buf(
+		oxs_key_mgr_t *key_mgr,
+		const axutil_env_t *env,
+		void *pem_buf);
+	
     /** @} */
 #ifdef __cplusplus
 }

Modified: webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h?rev=643729&r1=643728&r2=643729&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h (original)
+++ webservices/rampart/scratch/c/pkcs/c/include/rampart_context.h Tue Apr  1 21:14:25 2008
@@ -701,6 +701,13 @@
     rampart_context_get_algorithmsuite(
         rampart_context_t *rampart_context,
         const axutil_env_t *env);
+    
+    AXIS2_EXTERN oxs_key_mgr_t * AXIS2_CALL
+    rampart_context_get_key_mgr(
+    	rampart_context_t *rampart_context,
+    	const axutil_env_t *env);
+    
+
 
 #ifdef __cplusplus
 }

Modified: webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/asym_ctx.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/asym_ctx.c?rev=643729&r1=643728&r2=643729&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/asym_ctx.c (original)
+++ webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/asym_ctx.c Tue Apr  1 21:14:25 2008
@@ -23,53 +23,76 @@
 
 struct oxs_asym_ctx_t
 {
-    axis2_char_t *file_name;
-    axis2_char_t *pem_buf;
-    axis2_char_t *password;
     axis2_char_t *algorithm;
     axis2_char_t *st_ref_pattern;
     oxs_asym_ctx_operation_t operation;
     oxs_asym_ctx_format_t format;
     oxs_x509_cert_t *certificate;
     openssl_pkey_t *private_key;
-
 };
 
 
 /*Public functions*/
 
 AXIS2_EXTERN
-axis2_char_t *AXIS2_CALL
-oxs_asym_ctx_get_file_name(
-    const oxs_asym_ctx_t *asym_ctx,
-    const axutil_env_t *env)
+oxs_asym_ctx_t *AXIS2_CALL
+oxs_asym_ctx_create(const axutil_env_t *env)
 {
-    return asym_ctx->file_name;
-}
+    oxs_asym_ctx_t *asym_ctx = NULL;
 
-AXIS2_EXTERN
-axis2_char_t *AXIS2_CALL
-oxs_asym_ctx_get_pem_buf(
-    const oxs_asym_ctx_t *asym_ctx,
-    const axutil_env_t *env)
-{
-    return asym_ctx->pem_buf;
-}
-AXIS2_EXTERN
-axis2_char_t *AXIS2_CALL
-oxs_asym_ctx_get_password(
-    const oxs_asym_ctx_t *asym_ctx,
-    const axutil_env_t *env)
-{
-    return asym_ctx->password;
+    AXIS2_ENV_CHECK(env, NULL);
+
+    asym_ctx = AXIS2_MALLOC(env->allocator, sizeof(oxs_asym_ctx_t));
+    if (!asym_ctx)
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+
+    asym_ctx->algorithm = NULL;
+    asym_ctx->st_ref_pattern = NULL;
+    asym_ctx->operation = -1;
+    asym_ctx->certificate = NULL;
+    asym_ctx->private_key = NULL;
+
+    return asym_ctx;
 }
+
+
 AXIS2_EXTERN
-oxs_asym_ctx_format_t AXIS2_CALL
-oxs_asym_ctx_get_format(
-    const oxs_asym_ctx_t *asym_ctx,
-    const axutil_env_t *env)
+axis2_status_t AXIS2_CALL
+oxs_asym_ctx_free(oxs_asym_ctx_t *asym_ctx,
+                  const axutil_env_t *env)
 {
-    return asym_ctx->format;
+
+    if (asym_ctx->algorithm)
+    {
+        AXIS2_FREE(env->allocator, asym_ctx->algorithm);
+        asym_ctx->algorithm = NULL;
+    }
+
+    if (asym_ctx->st_ref_pattern)
+    {
+        AXIS2_FREE(env->allocator, asym_ctx->st_ref_pattern);
+        asym_ctx->st_ref_pattern = NULL;
+    }
+
+    if (asym_ctx->certificate)
+    {
+        oxs_x509_cert_free(asym_ctx->certificate, env);
+        asym_ctx->certificate = NULL;
+    }
+
+    if (asym_ctx->private_key)
+    {
+        openssl_pkey_free(asym_ctx->private_key, env);
+        asym_ctx->private_key = NULL;
+    }
+
+    AXIS2_FREE(env->allocator,  asym_ctx);
+    asym_ctx = NULL;
+
+    return AXIS2_SUCCESS;
 }
 
 AXIS2_EXTERN
@@ -121,69 +144,6 @@
 
 AXIS2_EXTERN
 axis2_status_t AXIS2_CALL
-oxs_asym_ctx_set_file_name(
-    oxs_asym_ctx_t *asym_ctx,
-    const axutil_env_t *env,
-    axis2_char_t *file_name)
-{
-
-    if (asym_ctx->file_name)
-    {
-        AXIS2_FREE(env->allocator, asym_ctx->file_name);
-        asym_ctx->file_name = NULL;
-    }
-    asym_ctx->file_name = axutil_strdup(env, file_name);
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL
-oxs_asym_ctx_set_pem_buf(
-    oxs_asym_ctx_t *asym_ctx,
-    const axutil_env_t *env,
-    axis2_char_t *pem_buf)
-{
-
-    if (asym_ctx->pem_buf)
-    {
-        AXIS2_FREE(env->allocator, asym_ctx->pem_buf);
-        asym_ctx->pem_buf = NULL;
-    }
-    asym_ctx->pem_buf = axutil_strdup(env, pem_buf);
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL
-oxs_asym_ctx_set_password(
-    oxs_asym_ctx_t *asym_ctx,
-    const axutil_env_t *env,
-    axis2_char_t *password)
-{
-
-    if (asym_ctx->password)
-    {
-        AXIS2_FREE(env->allocator, asym_ctx->password);
-        asym_ctx->password = NULL;
-    }
-    asym_ctx->password = axutil_strdup(env, password);
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL
-oxs_asym_ctx_set_format(
-    oxs_asym_ctx_t *asym_ctx,
-    const axutil_env_t *env,
-    oxs_asym_ctx_format_t format)
-{
-
-    asym_ctx->format = format;
-    return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL
 oxs_asym_ctx_set_algorithm(
     oxs_asym_ctx_t *asym_ctx,
     const axutil_env_t *env,
@@ -259,92 +219,6 @@
         asym_ctx->private_key = NULL;
     }
     asym_ctx->private_key = private_key;
-    return AXIS2_SUCCESS;
-}
-
-
-AXIS2_EXTERN
-oxs_asym_ctx_t *AXIS2_CALL
-oxs_asym_ctx_create(const axutil_env_t *env)
-{
-    oxs_asym_ctx_t *asym_ctx = NULL;
-
-    AXIS2_ENV_CHECK(env, NULL);
-
-    asym_ctx = AXIS2_MALLOC(env->allocator, sizeof(oxs_asym_ctx_t));
-    if (!asym_ctx)
-    {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
-
-    asym_ctx->file_name= NULL;
-    asym_ctx->pem_buf= NULL;
-    asym_ctx->password= NULL;
-    asym_ctx->format= -1;
-    asym_ctx->algorithm = NULL;
-    asym_ctx->st_ref_pattern = NULL;
-    asym_ctx->operation = -1;
-    asym_ctx->certificate = NULL;
-    asym_ctx->private_key = NULL;
-
-    return asym_ctx;
-}
-
-
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL
-oxs_asym_ctx_free(oxs_asym_ctx_t *asym_ctx,
-                  const axutil_env_t *env)
-{
-
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
-    if (asym_ctx->file_name)
-    {
-        AXIS2_FREE(env->allocator, asym_ctx->file_name);
-        asym_ctx->file_name = NULL;
-    }
-
-    if (asym_ctx->pem_buf)
-    {
-        AXIS2_FREE(env->allocator, asym_ctx->pem_buf);
-        asym_ctx->pem_buf = NULL;
-    }
-
-    if (asym_ctx->password)
-    {
-        AXIS2_FREE(env->allocator, asym_ctx->password);
-        asym_ctx->password = NULL;
-    }
-
-    if (asym_ctx->algorithm)
-    {
-        AXIS2_FREE(env->allocator, asym_ctx->algorithm);
-        asym_ctx->algorithm = NULL;
-    }
-
-    if (asym_ctx->st_ref_pattern)
-    {
-        AXIS2_FREE(env->allocator, asym_ctx->st_ref_pattern);
-        asym_ctx->st_ref_pattern = NULL;
-    }
-
-    if (asym_ctx->certificate)
-    {
-        oxs_x509_cert_free(asym_ctx->certificate, env);
-        asym_ctx->certificate = NULL;
-    }
-
-    if (asym_ctx->private_key)
-    {
-        openssl_pkey_free(asym_ctx->private_key, env);
-        asym_ctx->private_key = NULL;
-    }
-
-    AXIS2_FREE(env->allocator,  asym_ctx);
-    asym_ctx = NULL;
-
     return AXIS2_SUCCESS;
 }
 

Modified: webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/key_mgr.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/key_mgr.c?rev=643729&r1=643728&r2=643729&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/key_mgr.c (original)
+++ webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/key_mgr.c Tue Apr  1 21:14:25 2008
@@ -23,19 +23,44 @@
 
 struct oxs_key_mgr_t 
 {
+	/* Location of the private key file */
     axis2_char_t *private_key_file;
+    
+    /*Pasword of the private key */
+    axis2_char_t *prv_key_password;
+    
+    /*Location of the cert file of the private key owner */
     axis2_char_t *certificate_file;
+    
+    /*Location of the cert file of the user at the other end */
     axis2_char_t *reciever_certificate_file;
-    axis2_char_t *prv_key_password;
-
+    
+    /* Priate key */
     void *prv_key;
+    
+    /*Type of the private key */
     axis2_key_type_t prv_key_type;
+    
+    /*Owner certificate */
     void *certificate;
+    
+    /* type of the certificate */
     axis2_key_type_t certificate_type;
+    
+    /*Certificate of the enityt at the other end*/
     void *receiver_certificate;
+    
+    /*Type of Certificate at the other end*/
     axis2_key_type_t receiver_certificate_type;
 
+    /* PKCS12 Key store */
 	pkcs12_keystore_t *key_store;
+	
+	/* Buffer holding keys and certs */
+	void *pem_buf;
+	
+	/* Format of the current key */
+	oxs_key_mgr_format_t format;
 }; 
 
 AXIS2_EXTERN oxs_key_mgr_t * AXIS2_CALL
@@ -56,6 +81,8 @@
 		key_mgr->receiver_certificate = NULL;
 		key_mgr->receiver_certificate_type = AXIS2_KEY_TYPE_UNKNOWN;
 		key_mgr->key_store = NULL;
+		key_mgr->pem_buf = NULL;
+		key_mgr->format = -1;
 	}
 	return key_mgr; 
 }
@@ -257,6 +284,42 @@
 	return AXIS2_SUCCESS;
 }
 
+AXIS2_EXTERN oxs_key_mgr_format_t AXIS2_CALL
+oxs_key_mgr_get_format(
+	oxs_key_mgr_t *key_mgr,
+	const axutil_env_t *env)
+{
+	return key_mgr->format;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_format(
+	oxs_key_mgr_t *key_mgr,
+	const axutil_env_t *env,
+	oxs_key_mgr_format_t format)
+{
+	key_mgr->format = format;
+	return AXIS2_SUCCESS;
+}
+
+
+AXIS2_EXTERN void * AXIS2_CALL
+oxs_key_mgr_get_pem_buf(
+	oxs_key_mgr_t *key_mgr,
+	const axutil_env_t *env)
+{
+	return key_mgr->pem_buf;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_key_mgr_set_pem_buf(
+	oxs_key_mgr_t *key_mgr,
+	const axutil_env_t *env,
+	void *pem_buf)
+{
+	key_mgr->pem_buf = pem_buf;
+	return AXIS2_SUCCESS;
+}
 /**
  * Loads the key
  * 1. If the key buffer is specified, Take that as the source.

Modified: webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/utility.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/utility.c?rev=643729&r1=643728&r2=643729&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/utility.c (original)
+++ webservices/rampart/scratch/c/pkcs/c/src/omxmlsec/utility.c Tue Apr  1 21:14:25 2008
@@ -66,26 +66,26 @@
 
 }
 
-AXIS2_EXTERN oxs_asym_ctx_format_t AXIS2_CALL
+AXIS2_EXTERN oxs_key_mgr_format_t AXIS2_CALL
 oxs_util_get_format_by_file_extension(const axutil_env_t *env,
                                       axis2_char_t *file_name)
 {
     axis2_char_t *extension = NULL;
     if(!file_name){
-        return OXS_ASYM_CTX_FORMAT_UNKNOWN;
+        return OXS_KEY_MGR_FORMAT_UNKNOWN;
     }
     extension = axutil_rindex(file_name, '.');
     if(!extension){
         /*No extension*/
         /*Its safe to assume that PEM can be without extension*/
-        return OXS_ASYM_CTX_FORMAT_PEM;
+        return OXS_KEY_MGR_FORMAT_PEM;
     }
 
     if((strcmp(extension, ".pfx") == 0) ){
-        return OXS_ASYM_CTX_FORMAT_PKCS12;
+        return OXS_KEY_MGR_FORMAT_PKCS12;
     }else{
         /*Its safe to assume that PEM can be in any extensions. e.g. .cert, .cer, .pem*/
-        return OXS_ASYM_CTX_FORMAT_PEM;
+        return OXS_KEY_MGR_FORMAT_PEM;
     }
 
 }

Modified: webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c?rev=643729&r1=643728&r2=643729&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c (original)
+++ webservices/rampart/scratch/c/pkcs/c/src/util/rampart_context.c Tue Apr  1 21:14:25 2008
@@ -2990,3 +2990,12 @@
     }
     return NULL;
 }
+
+AXIS2_EXTERN oxs_key_mgr_t * AXIS2_CALL
+rampart_context_get_key_mgr(
+	rampart_context_t *rampart_context,
+	const axutil_env_t *env)
+{
+	return rampart_context->key_mgr;
+}
+

Modified: webservices/rampart/scratch/c/pkcs/c/src/util/rampart_sec_header_processor.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/pkcs/c/src/util/rampart_sec_header_processor.c?rev=643729&r1=643728&r2=643729&view=diff
==============================================================================
--- webservices/rampart/scratch/c/pkcs/c/src/util/rampart_sec_header_processor.c (original)
+++ webservices/rampart/scratch/c/pkcs/c/src/util/rampart_sec_header_processor.c Tue Apr  1 21:14:25 2008
@@ -586,6 +586,7 @@
     axis2_status_t status = AXIS2_FAILURE;
     oxs_asym_ctx_t *asym_ctx = NULL;
     oxs_key_t *decrypted_sym_key = NULL;
+    oxs_key_mgr_t *key_mgr = NULL;
     axis2_char_t *enc_asym_algo_in_pol = NULL;
     axis2_char_t *enc_sym_algo_in_pol = NULL;
     password_callback_fn password_function = NULL;
@@ -625,6 +626,7 @@
         return AXIS2_FAILURE;
     }
     
+    key_mgr = rampart_context_get_key_mgr(rampart_context, env);
     asym_ctx = oxs_asym_ctx_create(env);
     oxs_asym_ctx_set_algorithm(asym_ctx, env, enc_asym_algo);
 
@@ -635,8 +637,8 @@
         type = rampart_context_get_prv_key_type(rampart_context, env);
         if(type == AXIS2_KEY_TYPE_PEM)
         {
-            oxs_asym_ctx_set_pem_buf(asym_ctx, env, (axis2_char_t *)key_buf);
-            oxs_asym_ctx_set_format(asym_ctx, env, OXS_ASYM_CTX_FORMAT_PEM);
+            oxs_key_mgr_set_format(key_mgr, env, OXS_KEY_MGR_FORMAT_PEM);
+            oxs_key_mgr_set_pem_buf(key_mgr, env, key_buf);
         }
     }
     else
@@ -650,9 +652,9 @@
                             "[rampart][shp] Private Key is not specified.");
             return AXIS2_FAILURE;
         }
-        oxs_asym_ctx_set_file_name(asym_ctx, env, prv_key_file);
-        oxs_asym_ctx_set_format(asym_ctx, env,
-                                oxs_util_get_format_by_file_extension(env, prv_key_file));
+        oxs_key_mgr_set_private_key_file(key_mgr, env, prv_key_file);
+        oxs_key_mgr_set_format(key_mgr, env, oxs_util_get_format_by_file_extension(env, prv_key_file));
+        
 
         /*Get the password to retrieve the key from key store*/
         /*  password = rampart_callback_encuser_password(env, actions, msg_ctx);*/
@@ -692,7 +694,7 @@
                 }
             }
         }
-        oxs_asym_ctx_set_password(asym_ctx, env, password);
+        oxs_key_mgr_set_prv_key_password(key_mgr, env, password);
     }
     oxs_asym_ctx_set_operation(asym_ctx, env, OXS_ASYM_CTX_OPERATION_PRV_DECRYPT);